Hi,

i'd like to get the following simple patches to the MIPS/mipssim target adding
virtio-mmio devices to it. This makes the target a lot more usefull as microvm
for kernel developement. It currently lives in our qemu extensions patches and
we have a working kernel that supports all virtio devices for it.

Thoughts?

Reinoud Zandijk, NetBSD developer

$NetBSD$

--- hw/mips/Kconfig.orig        2020-08-11 19:17:15.000000000 +0000
+++ hw/mips/Kconfig
@@ -20,6 +20,7 @@ config MIPSSIM
     select ISA_BUS
     select SERIAL_ISA
     select MIPSNET
+    select VIRTIO_MMIO
 
 config JAZZ
     bool
$NetBSD$

--- hw/mips/mipssim.c.orig	2020-08-11 19:17:15.000000000 +0000
+++ hw/mips/mipssim.c
@@ -45,6 +45,7 @@
 #include "qemu/error-report.h"
 #include "sysemu/qtest.h"
 #include "sysemu/reset.h"
+#include "hw/virtio/virtio-mmio.h"
 
 static struct _loaderparams {
     int ram_size;
@@ -229,6 +230,16 @@ mips_mipssim_init(MachineState *machine)
     if (nd_table[0].used)
         /* MIPSnet uses the MIPS CPU INT0, which is interrupt 2. */
         mipsnet_init(0x4200, env->irq[2], &nd_table[0]);
+
+    /*
+     * virtio extention; register 32 virtio devices just after the ISA space
+     * at 0x1fd10000 with strave of 512 bytes as per i386s microvm target.
+     */
+    for (int i = 0; i < 32; i++) {
+        sysbus_create_simple("virtio-mmio",
+            0x1fd10000 + i * 512,
+            env->irq[3]);
+    }
 }
 
 static void mips_mipssim_machine_init(MachineClass *mc)

Reply via email to