When optionrom threading is enabled, allow hardware init to run in parallel with boot menu key press delay and with the smp detection.
Also, run qemu_cfg_port_probe() before ram_probe(). --- src/boot.c | 6 ++++- src/post.c | 64 ++++++++++++++++++++++++++++++++------------------------- src/stacks.c | 4 ++- src/util.c | 6 +++++ 4 files changed, 50 insertions(+), 30 deletions(-)
diff --git a/src/boot.c b/src/boot.c index 19e16f3..36450f0 100644 --- a/src/boot.c +++ b/src/boot.c @@ -236,6 +236,7 @@ interactive_bootmenu(void) ;
printf("Select boot device:\n\n"); + wait_threads();
int subcount[ARRAY_SIZE(IPL.bev)]; int menupos = 1; @@ -306,13 +307,16 @@ run_bcv(struct ipl_entry_s *ie) void boot_prep(void) { - if (! CONFIG_BOOT) + if (! CONFIG_BOOT) { + wait_threads(); return; + }
// XXX - show available drives?
// Allow user to modify BCV/IPL order. interactive_bootmenu(); + wait_threads();
// Setup floppy boot order int override = IPL.bev[0].subchoice; diff --git a/src/post.c b/src/post.c index c781aa4..638b0f7 100644 --- a/src/post.c +++ b/src/post.c @@ -172,6 +172,20 @@ 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(); +} + // Main setup code. static void post(void) @@ -180,6 +194,7 @@ post(void) init_ivt(); init_bda(); memmap_setup(); + qemu_cfg_port_probe(); ram_probe(); malloc_setup(); thread_setup(); @@ -189,16 +204,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 +232,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();
diff --git a/src/stacks.c b/src/stacks.c index 92d91a0..859de3f 100644 --- a/src/stacks.c +++ b/src/stacks.c @@ -193,6 +193,8 @@ __end_thread(struct thread_info *old) *old->pprev = old->next; free(old); dprintf(DEBUG_thread, "\%08x/ End thread\n", (u32)old); + if (MainThread.next == &MainThread) + dprintf(1, "All threads complete.\n"); }
// Create a new thread and start executing 'func' in it. @@ -299,7 +301,7 @@ finish_preempt(void) } CanPreempt = 0; releaseRTC(); - dprintf(1, "Done preempt - %d checks\n", PreemptCount); + dprintf(9, "Done preempt - %d checks\n", PreemptCount); yield(); }
diff --git a/src/util.c b/src/util.c index bbef995..e146c97 100644 --- a/src/util.c +++ b/src/util.c @@ -294,7 +294,9 @@ check_for_keystroke(void) memset(&br, 0, sizeof(br)); br.flags = F_IF; br.ah = 1; + start_preempt(); call16_int(0x16, &br); + finish_preempt(); return !(br.flags & F_ZF); }
@@ -305,7 +307,9 @@ get_raw_keystroke(void) struct bregs br; memset(&br, 0, sizeof(br)); br.flags = F_IF; + start_preempt(); call16_int(0x16, &br); + finish_preempt(); return br.ah; }
@@ -318,7 +322,9 @@ get_keystroke(int msec) return get_raw_keystroke(); if (msec <= 0) return -1; + start_preempt(); biosusleep(50*1000); + finish_preempt(); msec -= 50; } }