Support for booting from virtio disks
[seabios.git] / src / post.c
index c781aa44ea555c9f537b376d154876f579f8ccd8..25535e21f2949c046e2217104bdc4420f406e167 100644 (file)
@@ -23,6 +23,7 @@
 #include "smbios.h" // smbios_init
 #include "paravirt.h" // qemu_cfg_port_probe
 #include "ps2port.h" // ps2port_setup
+#include "virtio-blk.h" // virtio_blk_setup
 
 void
 __set_irq(int vector, void *loc)
@@ -172,6 +173,21 @@ init_bios_tables(void)
     acpi_bios_init();
 }
 
+// Initialize hardware devices
+static void
+init_hw(void)
+{
+    usb_setup();
+    ps2port_setup();
+    lpt_setup();
+    serial_setup();
+
+    floppy_setup();
+    ata_setup();
+    ramdisk_setup();
+    virtio_blk_setup();
+}
+
 // Main setup code.
 static void
 post(void)
@@ -180,6 +196,7 @@ post(void)
     init_ivt();
     init_bda();
     memmap_setup();
+    qemu_cfg_port_probe();
     ram_probe();
     malloc_setup();
     thread_setup();
@@ -189,16 +206,26 @@ post(void)
     timer_setup();
     mathcp_setup();
 
-    // Initialize smp
-    qemu_cfg_port_probe();
+    // Initialize mtrr
     smp_probe_setup();
     mtrr_setup();
-    smp_probe();
 
     // Initialize pci
     pci_setup();
     smm_init();
 
+    // Initialize internal tables
+    boot_setup();
+    drive_setup();
+    cdemu_setup();
+
+    // Start hardware initialization (if optionrom threading)
+    if (CONFIG_THREADS && CONFIG_THREAD_OPTIONROMS)
+        init_hw();
+
+    // Find and initialize other cpus
+    smp_probe();
+
     // Setup interfaces that option roms may need
     bios32_setup();
     pmm_setup();
@@ -207,35 +234,18 @@ post(void)
     mouse_setup();
     init_bios_tables();
 
-    // Run vga option rom (if running synchronously)
-    if (!CONFIG_THREADS || !CONFIG_THREAD_OPTIONROMS)
-        vga_setup();
-
-    // Initialize hardware devices
-    usb_setup();
-    ps2port_setup();
-    lpt_setup();
-    serial_setup();
+    // Run vga option rom
+    vga_setup();
 
-    boot_setup();
-    drive_setup();
-    cdemu_setup();
-    floppy_setup();
-    ata_setup();
-    ramdisk_setup();
-
-    // Run option roms
-    if (CONFIG_THREADS && CONFIG_THREAD_OPTIONROMS) {
-        // Run option roms while hw init still in progress.
-        vga_setup();
-        optionrom_setup();
+    // Do hardware initialization (if running synchronously)
+    if (!CONFIG_THREADS || !CONFIG_THREAD_OPTIONROMS) {
+        init_hw();
         wait_threads();
-    } else {
-        // Wait for hw init to finish and run non-vga option roms.
-        wait_threads();
-        optionrom_setup();
     }
 
+    // Run option roms
+    optionrom_setup();
+
     // Run BCVs and show optional boot menu
     boot_prep();