1
1
#include <assert.h>
2
2
#include <fcntl.h>
3
3
#include <getopt.h>
4
+ #include <signal.h>
4
5
#include <stdio.h>
5
6
#include <stdlib.h>
6
7
#include <string.h>
11
12
#include "device.h"
12
13
#include "riscv.h"
13
14
#include "riscv_private.h"
15
+ #include "window.h"
14
16
15
17
#define PRIV (x ) ((emu_state_t *) x->priv)
16
18
@@ -72,6 +74,18 @@ static void emu_update_vblk_interrupts(vm_t *vm)
72
74
}
73
75
#endif
74
76
77
+ #if SEMU_HAS (VIRTIOGPU )
78
+ static void emu_update_vgpu_interrupts (vm_t * vm )
79
+ {
80
+ emu_state_t * data = (emu_state_t * ) vm -> priv ;
81
+ if (data -> vgpu .InterruptStatus )
82
+ data -> plic .active |= IRQ_VGPU_BIT ;
83
+ else
84
+ data -> plic .active &= ~IRQ_VGPU_BIT ;
85
+ plic_update_interrupts (vm , & data -> plic );
86
+ }
87
+ #endif
88
+
75
89
static void mem_load (vm_t * vm , uint32_t addr , uint8_t width , uint32_t * value )
76
90
{
77
91
emu_state_t * data = PRIV (vm );
@@ -104,6 +118,12 @@ static void mem_load(vm_t *vm, uint32_t addr, uint8_t width, uint32_t *value)
104
118
virtio_blk_read (vm , & data -> vblk , addr & 0xFFFFF , width , value );
105
119
emu_update_vblk_interrupts (vm );
106
120
return ;
121
+ #endif
122
+ #if SEMU_HAS (VIRTIOGPU )
123
+ case 0x43 : /* virtio-gpu */
124
+ virtio_gpu_read (vm , & data -> vgpu , addr & 0xFFFFF , width , value );
125
+ emu_update_vgpu_interrupts (vm );
126
+ return ;
107
127
#endif
108
128
}
109
129
}
@@ -142,6 +162,12 @@ static void mem_store(vm_t *vm, uint32_t addr, uint8_t width, uint32_t value)
142
162
virtio_blk_write (vm , & data -> vblk , addr & 0xFFFFF , width , value );
143
163
emu_update_vblk_interrupts (vm );
144
164
return ;
165
+ #endif
166
+ #if SEMU_HAS (VIRTIOGPU )
167
+ case 0x43 : /* virtio-gpu */
168
+ virtio_gpu_write (vm , & data -> vgpu , addr & 0xFFFFF , width , value );
169
+ emu_update_vgpu_interrupts (vm );
170
+ return ;
145
171
#endif
146
172
}
147
173
}
@@ -423,6 +449,12 @@ static int semu_start(int argc, char **argv)
423
449
emu .vblk .ram = emu .ram ;
424
450
emu .disk = virtio_blk_init (& (emu .vblk ), disk_file );
425
451
#endif
452
+ #if SEMU_HAS (VIRTIOGPU )
453
+ emu .vgpu .ram = emu .ram ;
454
+ virtio_gpu_init (& (emu .vgpu ));
455
+ virtio_gpu_add_scanout (& (emu .vgpu ), 1024 , 768 );
456
+ display_window_init ();
457
+ #endif
426
458
427
459
/* Emulate */
428
460
uint32_t peripheral_update_ctr = 0 ;
@@ -444,6 +476,11 @@ static int semu_start(int argc, char **argv)
444
476
if (emu .vblk .InterruptStatus )
445
477
emu_update_vblk_interrupts (& vm );
446
478
#endif
479
+
480
+ #if SEMU_HAS (VIRTIOGPU )
481
+ if (emu .vgpu .InterruptStatus )
482
+ emu_update_vgpu_interrupts (& vm );
483
+ #endif
447
484
}
448
485
449
486
if (vm .insn_count > emu .timer )
0 commit comments