Enhance experimental option rom "threading" - enable preemption.
[seabios.git] / src / post.c
index 085fb91d81df772150e67a0fab50df26596c6aa6..42a27bcbd0471ba27d32c75f4c6a8dd318fadee6 100644 (file)
@@ -22,6 +22,7 @@
 #include "usb.h" // usb_setup
 #include "smbios.h" // smbios_init
 #include "paravirt.h" // qemu_cfg_port_probe
+#include "ps2port.h" // ps2port_setup
 
 void
 __set_irq(int vector, void *loc)
@@ -182,17 +183,22 @@ post()
     pci_setup();
     smm_init();
 
-    // Run vga option rom.
+    // Setup interfaces that option roms may need
     pmm_setup();
     pnp_setup();
-    vga_setup();
+    kbd_setup();
+    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();
-    kbd_setup();
+    ps2port_setup();
     lpt_setup();
     serial_setup();
-    mouse_setup();
 
     boot_setup();
     drive_setup();
@@ -201,10 +207,17 @@ post()
     ata_setup();
     ramdisk_setup();
 
-    // Run option roms (non vga)
-    init_bios_tables();
-    wait_threads();
-    optionrom_setup();
+    // Run option roms
+    if (CONFIG_THREADS && CONFIG_THREAD_OPTIONROMS) {
+        // Run option roms while hw init still in progress.
+        vga_setup();
+        optionrom_setup();
+        wait_threads();
+    } else {
+        // Wait for hw init to finish and run non-vga option roms.
+        wait_threads();
+        optionrom_setup();
+    }
 
     // Run BCVs and show optional boot menu
     boot_prep();