From 61f777c7c0afe5b0a37c2d3464499fa34deaf0f0 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Andreas=20F=C3=A4rber?= <andreas.faerber@web.de>
Date: Tue, 2 Feb 2010 20:45:14 +0100
Subject: [PATCH] Revert "Applied patch by "Grey":"
This reverts commit d72f520778e9a775194164b33a4c7a952be2143e.
---
src/system/boot/platform/bios_ia32/bios.S | 62 +----------------------
src/system/boot/platform/bios_ia32/bios.h | 5 --
src/system/boot/platform/bios_ia32/keyboard.cpp | 32 ++++++------
src/system/boot/platform/bios_ia32/start.c | 3 +
4 files changed, 19 insertions(+), 83 deletions(-)
diff --git a/src/system/boot/platform/bios_ia32/bios.S b/src/system/boot/platform/bios_ia32/bios.S
index 7842062..a1bd5fc 100644
a
|
b
|
|
22 | 22 | #define SAVED_EAX 0x10008 |
23 | 23 | #define SAVED_ES 0x1000c |
24 | 24 | #define SAVED_FLAGS 0x10010 |
25 | | #define SAVED_EBP 0x10014 |
26 | 25 | // we're overwriting the start of our boot loader to hold some |
27 | 26 | // temporary values - the first 1024 bytes of it are used at |
28 | 27 | // startup only, and we avoid some linking issues this way |
… |
… |
_no_paging:
|
75 | 74 | // setup protected stack frame again |
76 | 75 | movl SAVED_ESP, %eax |
77 | 76 | movl %eax, %esp |
78 | | movl SAVED_EBP, %ebp |
| 77 | movl %eax, %ebp |
79 | 78 | |
80 | 79 | // copy the return address to the current stack |
81 | 80 | movl REAL_MODE_STACK, %eax |
… |
… |
FUNCTION(switch_to_real_mode)
|
97 | 96 | movl %esp, %eax |
98 | 97 | movl %eax, SAVED_ESP |
99 | 98 | |
100 | | movl %ebp, SAVED_EBP |
101 | | |
102 | 99 | // put the return address on the real mode stack |
103 | 100 | movl (%esp), %eax |
104 | 101 | movl %eax, REAL_MODE_STACK |
… |
… |
int_number:
|
235 | 232 | |
236 | 233 | //-------------------------------------------------------------- |
237 | 234 | |
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 | | |
295 | 235 | .globl idt_descriptor |
296 | 236 | idt_descriptor: |
297 | 237 | .short 0x7ff // IDT at 0x0, default real mode location |
diff --git a/src/system/boot/platform/bios_ia32/bios.h b/src/system/boot/platform/bios_ia32/bios.h
index 4468551..f18d267 100644
a
|
b
|
extern
|
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(); |
49 | 44 | |
50 | 45 | #endif /* BIOS_H */ |
diff --git a/src/system/boot/platform/bios_ia32/keyboard.cpp b/src/system/boot/platform/bios_ia32/keyboard.cpp
index 80dfc79..ed0838c 100644
a
|
b
|
wait_for_key(void)
|
58 | 58 | extern "C" uint32 |
59 | 59 | check_for_boot_keys(void) |
60 | 60 | { |
61 | | bios_regs regs; |
| 61 | union key key; |
62 | 62 | uint32 options = 0; |
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 | | } |
| 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 | } |
79 | 77 | } |
80 | 78 | |
81 | 79 | dprintf("options = %ld\n", options); |
diff --git a/src/system/boot/platform/bios_ia32/start.c b/src/system/boot/platform/bios_ia32/start.c
index 5dc91bc..8877442 100644
a
|
b
|
_start(void)
|
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 key |
| 133 | spin(750000); |
| 134 | |
132 | 135 | // reading the keyboard doesn't seem to work in graphics mode |
133 | 136 | // (maybe a bochs problem) |
134 | 137 | sBootOptions = check_for_boot_keys(); |