On Fri, Apr 03, 2020 at 10:31:13AM +0200, Gerd Hoffmann wrote:
Add a new virtio-mmio.c source file, providing a function to register virtio-mmio devices.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com
Makefile | 2 +- src/hw/virtio-mmio.h | 6 ++++++ src/hw/virtio-mmio.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/hw/virtio-mmio.h create mode 100644 src/hw/virtio-mmio.c
diff --git a/Makefile b/Makefile index 5f7d5370198a..985ef591a13b 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ SRC32FLAT=$(SRCBOTH) post.c e820map.c malloc.c romfile.c x86.c optionroms.c \ fw/coreboot.c fw/lzmadecode.c fw/multiboot.c fw/csm.c fw/biostables.c \ fw/paravirt.c fw/shadow.c fw/pciinit.c fw/smm.c fw/smp.c fw/mtrr.c fw/xen.c \ fw/acpi.c fw/mptable.c fw/pirtable.c fw/smbios.c fw/romfile_loader.c \
- hw/virtio-ring.c hw/virtio-pci.c hw/virtio-blk.c hw/virtio-scsi.c \
- hw/virtio-ring.c hw/virtio-pci.c hw/virtio-mmio.c hw/virtio-blk.c hw/virtio-scsi.c \ hw/tpm_drivers.c hw/nvme.c
SRC32SEG=string.c output.c pcibios.c apm.c stacks.c hw/pci.c hw/serialio.c DIRS=src src/hw src/fw vgasrc diff --git a/src/hw/virtio-mmio.h b/src/hw/virtio-mmio.h new file mode 100644 index 000000000000..751984241f49 --- /dev/null +++ b/src/hw/virtio-mmio.h @@ -0,0 +1,6 @@ +#ifndef _VIRTIO_MMIO_H +#define _VIRTIO_MMIO_H
+void virtio_mmio_register(u64 mmio);
+#endif /* _VIRTIO_MMIO_H */ diff --git a/src/hw/virtio-mmio.c b/src/hw/virtio-mmio.c new file mode 100644 index 000000000000..6c969d787ec7 --- /dev/null +++ b/src/hw/virtio-mmio.c @@ -0,0 +1,30 @@ +#include "config.h" // CONFIG_DEBUG_LEVEL +#include "malloc.h" // free +#include "output.h" // dprintf +#include "virtio-pci.h" +#include "virtio-ring.h"
+/* qemu microvm supports 8 virtio-mmio devices */ +static u64 devs[8];
It would be preferable to avoid using global variables for temporary state. Because of all the weird linker rules and segment rules, the use of global variables is conceptually harder in SeaBIOS.
If I understand this patch series correctly, the ultimate result is an acpi parser that walks the dsdt and calls virtio_mmio_register(). Could that code directly launch the appropriate hardware registration directly?
-Kevin
+void virtio_mmio_register(u64 mmio) +{
- int i;
- for (i = 0; i < ARRAY_SIZE(devs); i++) {
if (devs[i] == mmio) {
/*
* This can happen in case we have multiple scsi devices
* attached to a single virtio-scsi controller
*/
dprintf(3, "virtio-mmio: duplicate device at 0x%llx, ignoring\n", mmio);
return;
}
if (devs[i] == 0) {
dprintf(3, "virtio-mmio: register device at 0x%llx\n", mmio);
devs[i] = mmio;
return;
}
- }
- dprintf(1, "virtio-mmio: device list full\n");
+}
2.18.2 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org