From 394a42ea834423d1f70fe2ba859789c709e2a3dc Mon Sep 17 00:00:00 2001
From: Andreas Faerber <andreas.faerber@web.de>
Date: Sun, 6 Jun 2010 00:39:19 +0200
Subject: [PATCH 8/8] Add keyboard options for menu and debug output
---
src/system/boot/platform/openfirmware/console.cpp | 11 +++++++++++
src/system/boot/platform/openfirmware/console.h | 1 +
src/system/boot/platform/openfirmware/start.c | 15 +++++++++++++--
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/src/system/boot/platform/openfirmware/console.cpp b/src/system/boot/platform/openfirmware/console.cpp
index 9a9b5ac..3af9d76 100644
a
|
b
|
console_wait_for_key(void)
|
327 | 327 | return buffer[0]; |
328 | 328 | } |
329 | 329 | |
| 330 | |
| 331 | int |
| 332 | console_check_for_key(void) |
| 333 | { |
| 334 | char buffer[3]; |
| 335 | ssize_t bytesRead = sInput.ReadAt(NULL, 0, buffer, 1); |
| 336 | if (bytesRead <= 0) |
| 337 | return 0; |
| 338 | |
| 339 | return buffer[0]; |
| 340 | } |
diff --git a/src/system/boot/platform/openfirmware/console.h b/src/system/boot/platform/openfirmware/console.h
index 487542c..c1a16dd 100644
a
|
b
|
extern "C" {
|
12 | 12 | #endif |
13 | 13 | |
14 | 14 | extern status_t console_init(void); |
| 15 | extern int console_check_for_key(void); |
15 | 16 | |
16 | 17 | #ifdef __cplusplus |
17 | 18 | } |
diff --git a/src/system/boot/platform/openfirmware/start.c b/src/system/boot/platform/openfirmware/start.c
index 7a8dc2e..eb9573e 100644
a
|
b
|
extern uint8 __bss_start;
|
31 | 31 | extern uint8 _end; |
32 | 32 | |
33 | 33 | uint32 gMachine; |
| 34 | static uint32 sBootOptions; |
34 | 35 | |
35 | 36 | |
36 | 37 | static void |
… |
… |
platform_exit(void)
|
110 | 111 | uint32 |
111 | 112 | platform_boot_options(void) |
112 | 113 | { |
113 | | // ToDo: implement me! |
114 | | return 0; |
| 114 | return sBootOptions; |
115 | 115 | } |
116 | 116 | |
117 | 117 | |
… |
… |
start(void *openFirmwareEntry)
|
162 | 162 | if (init_real_time_clock() != B_OK) |
163 | 163 | of_exit(); |
164 | 164 | |
| 165 | // we need to check for keys once, not for every options inquiry |
| 166 | sBootOptions = 0; |
| 167 | int key = console_check_for_key(); |
| 168 | if (key == 32) { |
| 169 | // space bar: option menu |
| 170 | sBootOptions |= BOOT_OPTION_MENU; |
| 171 | } else if (key == 27) { |
| 172 | // ESC: debug output |
| 173 | sBootOptions |= BOOT_OPTION_DEBUG_OUTPUT; |
| 174 | } |
| 175 | |
165 | 176 | gKernelArgs.platform_args.openfirmware_entry = openFirmwareEntry; |
166 | 177 | |
167 | 178 | main(&args); |