Ticket #5163: boot_keys3.patch
File boot_keys3.patch, 4.3 KB (added by , 14 years ago) |
---|
-
src/system/boot/platform/bios_ia32/bios.S
22 22 #define SAVED_EAX 0x10008 23 23 #define SAVED_ES 0x1000c 24 24 #define SAVED_FLAGS 0x10010 25 #define SAVED_EBP 0x10014 25 26 // we're overwriting the start of our boot loader to hold some 26 27 // temporary values - the first 1024 bytes of it are used at 27 28 // startup only, and we avoid some linking issues this way … … 74 75 // setup protected stack frame again 75 76 movl SAVED_ESP, %eax 76 77 movl %eax, %esp 77 movl %eax, %ebp78 movl SAVED_EBP, %ebp 78 79 79 80 // copy the return address to the current stack 80 81 movl REAL_MODE_STACK, %eax … … 96 97 movl %esp, %eax 97 98 movl %eax, SAVED_ESP 98 99 100 movl %ebp, SAVED_EBP 101 99 102 // put the return address on the real mode stack 100 103 movl (%esp), %eax 101 104 movl %eax, REAL_MODE_STACK … … 232 235 233 236 //-------------------------------------------------------------- 234 237 238 /** uint32 search_keyboard_buffer() 239 * Search in keyboard buffer keycodes for F8, F12 or Space 240 * if not found - search ESC keycode. 241 */ 242 243 FUNCTION(search_keyboard_buffer) 244 pushal 245 pushfl 246 247 // make sure the correct IDT is in place 248 lidt idt_descriptor 249 250 call switch_to_real_mode 251 .code16 252 253 cld 254 push %ds 255 xorl %eax, %eax 256 mov %ax, %ds 257 mov $0x41E, %si // BIOS kbd buffer 258 search_cycle1: 259 lodsw 260 cmp $0x4200, %ax // test F8 key 261 jz to_ret 262 cmp $0x8600, %ax // test F12 key 263 jz to_ret 264 cmp $0x3920, %ax // test Space key 265 jz to_ret 266 cmp $0x440, %si 267 jnz search_cycle1 268 269 movw $0x41E, %si // BIOS kbd buffer 270 search_cycle2: 271 lodsw 272 cmp $0x011B, %ax // test ESC key 273 jz to_ret 274 cmp $0x440, %si 275 jnz search_cycle2 276 to_ret: 277 pop %ds 278 279 // save %eax 280 movl %eax, (SAVED_EAX - 0x10000) 281 282 call switch_to_protected_mode 283 .code32 284 285 popfl 286 popal 287 288 // restore %eax 289 movl SAVED_EAX, %eax 290 291 ret 292 293 //-------------------------------------------------------------- 294 235 295 .globl idt_descriptor 236 296 idt_descriptor: 237 297 .short 0x7ff // IDT at 0x0, default real mode location -
src/system/boot/platform/bios_ia32/keyboard.cpp
58 58 extern "C" uint32 59 59 check_for_boot_keys(void) 60 60 { 61 union key key;61 bios_regs regs; 62 62 uint32 options = 0; 63 64 while ((key.ax = check_for_key()) != 0) { 65 switch (key.code.ascii) { 66 case ' ': 67 options |= BOOT_OPTION_MENU; 68 break; 69 case 0x1b: // escape 70 options |= BOOT_OPTION_DEBUG_OUTPUT; 71 break; 72 case 0: 73 // evaluate BIOS scan codes 74 // ... 75 break; 76 } 63 uint32 keycode = 0; 64 regs.eax = 0x0200; 65 call_bios(0x16, ®s); 66 // Read Keyboard flags. bit 0 LShift, bit 1 RShift 67 if ((regs.eax & 0x03) != 0) { 68 // LShift or RShift - option menu 69 options |= BOOT_OPTION_MENU; 70 } else { 71 keycode = search_keyboard_buffer(); 72 if (keycode == 0x4200 || keycode == 0x8600 || keycode == 0x3920) { 73 // F8 or F12 or Space - option menu 74 options |= BOOT_OPTION_MENU; 75 } else if (keycode == 0x011B) { 76 // ESC - debug output 77 options |= BOOT_OPTION_DEBUG_OUTPUT; 78 } 77 79 } 78 80 79 81 dprintf("options = %ld\n", options); -
src/system/boot/platform/bios_ia32/bios.h
41 41 "C" 42 42 #endif 43 43 void call_bios(uint8 num, struct bios_regs *regs); 44 extern 45 #ifdef __cplusplus 46 "C" 47 #endif 48 uint32 search_keyboard_buffer(); 44 49 45 50 #endif /* BIOS_H */ -
src/system/boot/platform/bios_ia32/start.c
129 129 mmu_init(); 130 130 parse_multiboot_commandline(&args); 131 131 132 // wait a bit to give the user the opportunity to press a key133 spin(750000);134 135 132 // reading the keyboard doesn't seem to work in graphics mode 136 133 // (maybe a bochs problem) 137 134 sBootOptions = check_for_boot_keys();