@@ -100,6 +100,18 @@ static void emu_update_swi_interrupt(hart_t *hart)
100
100
aclint_sswi_update_interrupts (hart , & data -> sswi );
101
101
}
102
102
103
+ #if SEMU_HAS (VIRTIOSND )
104
+ static void emu_update_vsnd_interrupts (vm_t * vm )
105
+ {
106
+ emu_state_t * data = PRIV (vm -> hart [0 ]);
107
+ if (data -> vsnd .InterruptStatus )
108
+ data -> plic .active |= IRQ_VSND_BIT ;
109
+ else
110
+ data -> plic .active &= ~IRQ_VSND_BIT ;
111
+ plic_update_interrupts (vm , & data -> plic );
112
+ }
113
+ #endif
114
+
103
115
static void mem_load (hart_t * hart ,
104
116
uint32_t addr ,
105
117
uint8_t width ,
@@ -155,6 +167,13 @@ static void mem_load(hart_t *hart,
155
167
emu_update_vrng_interrupts (hart -> vm );
156
168
return ;
157
169
#endif
170
+
171
+ #if SEMU_HAS (VIRTIOSND )
172
+ case 0x47 : /* virtio-snd */
173
+ virtio_snd_read (hart , & data -> vsnd , addr & 0xFFFFF , width , value );
174
+ emu_update_vsnd_interrupts (hart -> vm );
175
+ return ;
176
+ #endif
158
177
}
159
178
}
160
179
vm_set_exception (hart , RV_EXC_LOAD_FAULT , hart -> exc_val );
@@ -209,12 +228,20 @@ static void mem_store(hart_t *hart,
209
228
aclint_sswi_write (hart , & data -> sswi , addr & 0xFFFFF , width , value );
210
229
aclint_sswi_update_interrupts (hart , & data -> sswi );
211
230
return ;
231
+
212
232
#if SEMU_HAS (VIRTIORNG )
213
233
case 0x46 : /* virtio-rng */
214
234
virtio_rng_write (hart , & data -> vrng , addr & 0xFFFFF , width , value );
215
235
emu_update_vrng_interrupts (hart -> vm );
216
236
return ;
217
237
#endif
238
+
239
+ #if SEMU_HAS (VIRTIOSND )
240
+ case 0x47 : /* virtio-snd */
241
+ virtio_snd_write (hart , & data -> vsnd , addr & 0xFFFFF , width , value );
242
+ emu_update_vsnd_interrupts (hart -> vm );
243
+ return ;
244
+ #endif
218
245
}
219
246
}
220
247
vm_set_exception (hart , RV_EXC_STORE_FAULT , hart -> exc_val );
@@ -651,6 +678,11 @@ static int semu_start(int argc, char **argv)
651
678
emu .mtimer .mtimecmp = calloc (vm .n_hart , sizeof (uint64_t ));
652
679
emu .mswi .msip = calloc (vm .n_hart , sizeof (uint32_t ));
653
680
emu .sswi .ssip = calloc (vm .n_hart , sizeof (uint32_t ));
681
+ #if SEMU_HAS (VIRTIOSND )
682
+ if (!virtio_snd_init (& (emu .vsnd )))
683
+ fprintf (stderr , "No virtio-snd functioned\n" );
684
+ emu .vsnd .ram = emu .ram ;
685
+ #endif
654
686
655
687
/* Emulate */
656
688
uint32_t peripheral_update_ctr = 0 ;
@@ -676,6 +708,11 @@ static int semu_start(int argc, char **argv)
676
708
if (emu .vblk .InterruptStatus )
677
709
emu_update_vblk_interrupts (& vm );
678
710
#endif
711
+
712
+ #if SEMU_HAS (VIRTIOSND )
713
+ if (emu .vsnd .InterruptStatus )
714
+ emu_update_vsnd_interrupts (& vm );
715
+ #endif
679
716
}
680
717
681
718
emu_update_timer_interrupt (vm .hart [i ]);
0 commit comments