Author: stippi Date: 2010-01-13 16:02:55 +0100 (Wed, 13 Jan 2010) New Revision: 35050 Changeset: http://dev.haiku-os.org/changeset/35050/haiku Modified: haiku/trunk/docs/userguide/en/bootloader.html haiku/trunk/src/system/boot/platform/bios_ia32/bios.S haiku/trunk/src/system/boot/platform/bios_ia32/bios.h haiku/trunk/src/system/boot/platform/bios_ia32/keyboard.cpp haiku/trunk/src/system/boot/platform/bios_ia32/start.c Log: Applied patch by "Grey": Entering the boot loader menu has changed/simplified while reducing the boot time by .75 seconds. Now it is enough to hold one of shift/Esc/F8/F12/Space. Thanks! I've also updated the boot loader documentation to reflect the change, but I only mentioned holding shift. I know that changing the documention directly is not preferred anymore, but I wanted to make sure this patch is complete. Modified: haiku/trunk/docs/userguide/en/bootloader.html =================================================================== --- haiku/trunk/docs/userguide/en/bootloader.html 2010-01-13 14:33:35 UTC (rev 35049) +++ haiku/trunk/docs/userguide/en/bootloader.html 2010-01-13 15:02:55 UTC (rev 35050) @@ -40,7 +40,7 @@ <p>Haiku's Boot Loader can help when you experience hardware related problems or want to choose which Haiku installation to start, if you have more than one (maybe on an installation CD or USB stick).<br /> It's also handy after you installed a software component that acts up and prevents you from booting the system to remove it again. The <i>Disable user add-ons</i> option that's mentioned below, will start Haiku without loading user installed components, e.g. a driver.</p> -<p>To enter the Boot Loader options, you have to press the <span class="key">SPACE BAR</span> right at the beginning of the boot process. It's easy to miss so you best keep hitting the key until it shows up.</p> +<p>To enter the Boot Loader options, you have to press and keep holding the <span class="key">SHIFT</span> key before the beginning of Haiku's boot process. If you have a boot manager installed, you can start holding the <span class="key">SHIFT</span> key before invoking the boot entry for Haiku. If Haiku is the only operating system installed, you can start pressing <span class="key">SHIFT</span> while you still see boot messages from the BIOS.</p> <p><br /></p> <p>Once it's there, you're offered three menus:</p> <table summary="bootloader menus" border="0" cellspacing="0" cellpadding="2"> Modified: haiku/trunk/src/system/boot/platform/bios_ia32/bios.S =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/bios.S 2010-01-13 14:33:35 UTC (rev 35049) +++ haiku/trunk/src/system/boot/platform/bios_ia32/bios.S 2010-01-13 15:02:55 UTC (rev 35050) @@ -22,6 +22,7 @@ #define SAVED_EAX 0x10008 #define SAVED_ES 0x1000c #define SAVED_FLAGS 0x10010 +#define SAVED_EBP 0x10014 // we're overwriting the start of our boot loader to hold some // temporary values - the first 1024 bytes of it are used at // startup only, and we avoid some linking issues this way @@ -74,7 +75,7 @@ // setup protected stack frame again movl SAVED_ESP, %eax movl %eax, %esp - movl %eax, %ebp + movl SAVED_EBP, %ebp // copy the return address to the current stack movl REAL_MODE_STACK, %eax @@ -96,6 +97,8 @@ movl %esp, %eax movl %eax, SAVED_ESP + movl %ebp, SAVED_EBP + // put the return address on the real mode stack movl (%esp), %eax movl %eax, REAL_MODE_STACK @@ -232,6 +235,63 @@ //-------------------------------------------------------------- +/** uint32 search_keyboard_buffer() + * Search in keyboard buffer keycodes for F8, F12 or Space + * if not found - search ESC keycode. + */ + +FUNCTION(search_keyboard_buffer) + pushal + pushfl + + // make sure the correct IDT is in place + lidt idt_descriptor + + call switch_to_real_mode + .code16 + + cld + push %ds + xorl %eax, %eax + mov %ax, %ds + mov $0x41E, %si // BIOS kbd buffer +search_cycle1: + lodsw + cmp $0x4200, %ax // test F8 key + jz to_ret + cmp $0x8600, %ax // test F12 key + jz to_ret + cmp $0x3920, %ax // test Space key + jz to_ret + cmp $0x440, %si + jnz search_cycle1 + + movw $0x41E, %si // BIOS kbd buffer +search_cycle2: + lodsw + cmp $0x011B, %ax // test ESC key + jz to_ret + cmp $0x440, %si + jnz search_cycle2 +to_ret: + pop %ds + + // save %eax + movl %eax, (SAVED_EAX - 0x10000) + + call switch_to_protected_mode + .code32 + + popfl + popal + + // restore %eax + movl SAVED_EAX, %eax + + ret + +//-------------------------------------------------------------- + .globl idt_descriptor idt_descriptor: .short 0x7ff // IDT at 0x0, default real mode location Modified: haiku/trunk/src/system/boot/platform/bios_ia32/bios.h =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/bios.h 2010-01-13 14:33:35 UTC (rev 35049) +++ haiku/trunk/src/system/boot/platform/bios_ia32/bios.h 2010-01-13 15:02:55 UTC (rev 35050) @@ -41,5 +41,10 @@ "C" #endif void call_bios(uint8 num, struct bios_regs *regs); +extern +#ifdef __cplusplus +"C" +#endif +uint32 search_keyboard_buffer(); #endif /* BIOS_H */ Modified: haiku/trunk/src/system/boot/platform/bios_ia32/keyboard.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/keyboard.cpp 2010-01-13 14:33:35 UTC (rev 35049) +++ haiku/trunk/src/system/boot/platform/bios_ia32/keyboard.cpp 2010-01-13 15:02:55 UTC (rev 35050) @@ -58,22 +58,24 @@ extern "C" uint32 check_for_boot_keys(void) { - union key key; + bios_regs regs; uint32 options = 0; - - while ((key.ax = check_for_key()) != 0) { - switch (key.code.ascii) { - case ' ': - options |= BOOT_OPTION_MENU; - break; - case 0x1b: // escape - options |= BOOT_OPTION_DEBUG_OUTPUT; - break; - case 0: - // evaluate BIOS scan codes - // ... - break; - } + uint32 keycode = 0; + regs.eax = 0x0200; + call_bios(0x16, ®s); + // Read Keyboard flags. bit 0 LShift, bit 1 RShift + if ((regs.eax & 0x03) != 0) { + // LShift or RShift - option menu + options |= BOOT_OPTION_MENU; + } else { + keycode = search_keyboard_buffer(); + if (keycode == 0x4200 || keycode == 0x8600 || keycode == 0x3920) { + // F8 or F12 or Space - option menu + options |= BOOT_OPTION_MENU; + } else if (keycode == 0x011B) { + // ESC - debug output + options |= BOOT_OPTION_DEBUG_OUTPUT; + } } dprintf("options = %ld\n", options); Modified: haiku/trunk/src/system/boot/platform/bios_ia32/start.c =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/start.c 2010-01-13 14:33:35 UTC (rev 35049) +++ haiku/trunk/src/system/boot/platform/bios_ia32/start.c 2010-01-13 15:02:55 UTC (rev 35050) @@ -129,9 +129,6 @@ mmu_init(); parse_multiboot_commandline(&args); - // wait a bit to give the user the opportunity to press a key - spin(750000); - // reading the keyboard doesn't seem to work in graphics mode // (maybe a bochs problem) sBootOptions = check_for_boot_keys();