Seach for virtio-mmio devices in the DSDT table, register the devices found.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- src/hw/virtio-mmio.h | 1 + src/util.h | 1 + src/hw/virtio-mmio.c | 20 ++++++++++++++++++++ src/post.c | 2 ++ 4 files changed, 24 insertions(+)
diff --git a/src/hw/virtio-mmio.h b/src/hw/virtio-mmio.h index 5e24f692c1ae..349d744d9364 100644 --- a/src/hw/virtio-mmio.h +++ b/src/hw/virtio-mmio.h @@ -71,6 +71,7 @@ typedef struct virtio_mmio_cfg { } virtio_mmio_cfg;
void virtio_mmio_register(u64 mmio); +void virtio_mmio_acpi(void); void virtio_mmio_setup(void); void vp_init_mmio(struct vp_device *vp, void *mmio);
diff --git a/src/util.h b/src/util.h index 8ee0370492b8..76e1bfcd9897 100644 --- a/src/util.h +++ b/src/util.h @@ -100,6 +100,7 @@ struct acpi_device *acpi_dsdt_find_string(struct acpi_device *prev, const char * struct acpi_device *acpi_dsdt_find_eisaid(struct acpi_device *prev, u16 eisaid); char *acpi_dsdt_name(struct acpi_device *dev); int acpi_dsdt_present_eisaid(u16 eisaid); +void acpi_dsdt_virtio(void); int acpi_dsdt_find_io(struct acpi_device *dev, u64 *min, u64 *max); int acpi_dsdt_find_mem(struct acpi_device *dev, u64 *min, u64 *max); int acpi_dsdt_find_irq(struct acpi_device *dev, u64 *irq); diff --git a/src/hw/virtio-mmio.c b/src/hw/virtio-mmio.c index b205ec6ef6ae..78618ab49e44 100644 --- a/src/hw/virtio-mmio.c +++ b/src/hw/virtio-mmio.c @@ -3,6 +3,7 @@ #include "output.h" // dprintf #include "stacks.h" // run_thread #include "string.h" // memset +#include "util.h" // acpi_dsdt_* #include "virtio-pci.h" #include "virtio-blk.h" #include "virtio-scsi.h" @@ -34,6 +35,25 @@ void virtio_mmio_register(u64 mmio) dprintf(1, "virtio-mmio: device list full\n"); }
+void virtio_mmio_acpi(void) +{ + static const char *virtio_hid = "LNRO0005"; + struct acpi_device *dev; + u64 mem, irq, unused; + + for (dev = acpi_dsdt_find_string(NULL, virtio_hid); + dev != NULL; + dev = acpi_dsdt_find_string(dev, virtio_hid)) { + if (acpi_dsdt_find_mem(dev, &mem, &unused) < 0) + continue; + if (acpi_dsdt_find_irq(dev, &irq) < 0) + continue; + dprintf(1, "ACPI: virtio-mmio device %s at 0x%llx, irq %lld\n", + acpi_dsdt_name(dev), mem, irq); + virtio_mmio_register(mem); + } +} + void virtio_mmio_setup(void) { u32 magic, version, devid; diff --git a/src/post.c b/src/post.c index febdc0859764..c4ab5b814a00 100644 --- a/src/post.c +++ b/src/post.c @@ -17,6 +17,7 @@ #include "hw/rtc.h" // rtc_write #include "hw/serialio.h" // serial_debug_preinit #include "hw/usb.h" // usb_setup +#include "hw/virtio-mmio.h" // virtio_mmio_acpi #include "malloc.h" // malloc_init #include "memmap.h" // SYMBOL #include "output.h" // dprintf @@ -150,6 +151,7 @@ platform_hardware_setup(void) coreboot_platform_setup();
acpi_dsdt_parse(); + virtio_mmio_acpi();
// Setup timers and periodic clock interrupt timer_setup();