1 | /*␊ |
2 | * Copyright (c) 2009 Evan Lojewski. All rights reserved.␊ |
3 | *␊ |
4 | */␊ |
5 | ␊ |
6 | /*␊ |
7 | * cparm : cleaned␊ |
8 | */␊ |
9 | ␊ |
10 | ␊ |
11 | #include "libsaio.h"␊ |
12 | #include "options.h"␊ |
13 | #include "graphic_utils.h"␊ |
14 | #include "embedded.h"␊ |
15 | ␊ |
16 | #include "picopng.h"␊ |
17 | #include "gui.h"␊ |
18 | ␊ |
19 | #include "modules.h"␊ |
20 | ␊ |
21 | /* Kabyl: BooterLog */␊ |
22 | #define BOOTER_LOG_SIZE (128 * 1024)␊ |
23 | #define SAFE_LOG_SIZE 134␊ |
24 | ␊ |
25 | bool useGUI = true;␊ |
26 | ␊ |
27 | void GUI_Kernel_Start_hook(void* kernelEntry, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);␊ |
28 | void GUI_PreBoot_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);␊ |
29 | ␊ |
30 | int GUI_getBootOptions(bool firstRun);␊ |
31 | ␊ |
32 | static void GUI_updateBootArgs( int key );␊ |
33 | void GUI_clearBootArgs(void);␊ |
34 | static void GUI_showBootPrompt(int row, bool visible);␊ |
35 | static void GUI_showMenu( const MenuItem * items, int count, int selection, int row, int height );␊ |
36 | static int GUI_updateMenu( int key, void ** paramPtr );␊ |
37 | static void GUI_showHelp(void);␊ |
38 | static void GUI_showMessage(char *message);␊ |
39 | ␊ |
40 | int GUI_printf(const char * fmt, ...);␊ |
41 | int GUI_verbose(const char * fmt, ...);␊ |
42 | int GUI_error(const char * fmt, ...);␊ |
43 | void GUI_stop(const char * fmt, ...);␊ |
44 | ␊ |
45 | ␊ |
46 | /* console.c */␊ |
47 | struct putc_info {␊ |
48 | char * str;␊ |
49 | char * last_str;␊ |
50 | };␊ |
51 | void sputc(int c, struct putc_info * pi);␊ |
52 | extern char *msgbuf;␊ |
53 | extern char *cursor;␊ |
54 | ␊ |
55 | ␊ |
56 | ␊ |
57 | ␊ |
58 | char GUI_bootRescanPrompt[] =␊ |
59 | "Press Enter to start up Darwin/x86 with no options, or you can:\n"␊ |
60 | " Press F5 after you swapped the media. The drive will be rescanned.\n"␊ |
61 | " Type -v and press Enter to start up with diagnostic messages\n"␊ |
62 | " Type ? and press Enter to learn about advanced startup options\n\n"␊ |
63 | "boot: ";␊ |
64 | ␊ |
65 | ␊ |
66 | static bool KernelStart = false;␊ |
67 | /**␊ |
68 | ** The kernel is about to start, draw the boot graphics if we are not in␊ |
69 | ** verbose mode.␊ |
70 | **/␊ |
71 | void GUI_ExecKernel_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)␊ |
72 | {␊ |
73 | ␉if(!gVerboseMode)␊ |
74 | ␉{␊ |
75 | ␉␉// Note: shouldn't be needed, but just in case␊ |
76 | ␉␉drawBootGraphics();␊ |
77 | ␉}␊ |
78 | ␉else␊ |
79 | ␉{␊ |
80 | #if UNUSED␊ |
81 | ␉␉setVideoMode(GRAPHICS_MODE, 0);␊ |
82 | #else␊ |
83 | ␉␉setVideoMode(GRAPHICS_MODE);␊ |
84 | #endif␊ |
85 | ␉␉␊ |
86 | ␉}␊ |
87 | ␉KernelStart = true;␊ |
88 | }␊ |
89 | ␊ |
90 | /**␊ |
91 | ** A boot option has been selected, disable the graphical elements on screen.␊ |
92 | **/␊ |
93 | void GUI_PreBoot_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)␊ |
94 | {␉␉␊ |
95 | ␉// Turn off any GUI elements␊ |
96 | ␉if( bootArgs->Video.v_display == GRAPHICS_MODE )␊ |
97 | ␉{␊ |
98 | ␉␉gui.devicelist.draw = false;␊ |
99 | ␉␉gui.bootprompt.draw = false;␊ |
100 | ␉␉gui.menu.draw = false;␊ |
101 | ␉␉gui.infobox.draw = false;␊ |
102 | ␉␉gui.logo.draw = false;␊ |
103 | ␉␉drawBackground();␉␉␊ |
104 | ␉␉updateVRAM();␊ |
105 | ␊ |
106 | ␉␉if(!gVerboseMode)␊ |
107 | ␉␉{␊ |
108 | ␉␉␉// Disable outputs, they will still show in the boot log.␊ |
109 | ␉␉␉replace_function("_printf", &GUI_verbose);␊ |
110 | ␉␉␉//drawBootGraphics();␊ |
111 | ␉␉}␊ |
112 | ␉␉␊ |
113 | ␉}␉␊ |
114 | ␉ ␊ |
115 | }␊ |
116 | ␊ |
117 | void GUI_diplay_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)␊ |
118 | {␊ |
119 | ␉// Start and display the gui␊ |
120 | ␉msglog("* Attempting to Display GUI\n");␊ |
121 | ␉␊ |
122 | ␉if (initGUI())␊ |
123 | ␉{␊ |
124 | ␉␉␊ |
125 | ␉␉useGUI = false; // initGUI() returned with an error, disabling GUI.␉␉␊ |
126 | ␉␉msglog("* GUI failed to Display, or disabled by user (a.k.a you)\n");␊ |
127 | ␊ |
128 | ␉␉␊ |
129 | ␉}␊ |
130 | ␉else␊ |
131 | ␉{␊ |
132 | ␉␉replace_function("_initGraphicsMode", &GUI_initGraphicsMode);␊ |
133 | ␉␉replace_function("_getBootOptions", &GUI_getBootOptions);␊ |
134 | ␉␉replace_function("_clearBootArgs", &GUI_clearBootArgs);␊ |
135 | ␉␉replace_function("_showHelp", &GUI_showHelp);␊ |
136 | ␉␉␊ |
137 | ␉␉replace_function("_printf", &GUI_printf);␊ |
138 | ␉␉replace_function("_verbose", &GUI_verbose);␊ |
139 | ␉␉replace_function("_error", &GUI_error);␊ |
140 | ␉␉replace_function("_stop", &GUI_stop);␊ |
141 | ␉␉replace_function("_showMessage", &GUI_showMessage);␊ |
142 | ␉␉␊ |
143 | ␉␉␊ |
144 | ␉␉// Hoot for the boot screen ␉␊ |
145 | ␉␉register_hook_callback("GUI_ExecKernel", &GUI_ExecKernel_hook);␊ |
146 | ␉␉register_hook_callback("GUI_PreBoot", &GUI_PreBoot_hook);␊ |
147 | ␉␉␊ |
148 | ␉␉msglog("* GUI successfully Displayed\n");␊ |
149 | ␊ |
150 | ␉␉␊ |
151 | ␉}␊ |
152 | }␊ |
153 | ␊ |
154 | /**␊ |
155 | ** Module startup code. Replace console only print functions as well as␊ |
156 | ** replace various menu functions. Finaly, initialize the gui and hook␊ |
157 | ** into important events.␊ |
158 | **/␊ |
159 | void GUI_start(moduleList_t* module)␊ |
160 | {␊ |
161 | ␉register_hook_callback("GUI_Display", &GUI_diplay_hook);␉␉␉␉␊ |
162 | ␉␊ |
163 | }␊ |
164 | ␊ |
165 | /**␊ |
166 | ** Overriden chameleon function. Draws the updated menu.␊ |
167 | **/␊ |
168 | static int GUI_updateMenu( int key, void ** paramPtr )␊ |
169 | {␊ |
170 | int moved = 0;␊ |
171 | ␉␊ |
172 | union {␊ |
173 | struct {␊ |
174 | unsigned int␊ |
175 | ␉␉␉selectionUp : 1,␊ |
176 | ␉␉␉selectionDown : 1,␊ |
177 | ␉␉␉scrollUp : 1,␊ |
178 | ␉␉␉scrollDown : 1;␊ |
179 | } f;␊ |
180 | unsigned int w;␊ |
181 | } draw = {{0}};␊ |
182 | ␉␊ |
183 | if ( gMenuItems == NULL )␊ |
184 | ␉␉return 0;␊ |
185 | ␉␊ |
186 | ␉if( bootArgs->Video.v_display == GRAPHICS_MODE )␊ |
187 | ␉{␊ |
188 | ␉␉int res;␊ |
189 | ␉␉␊ |
190 | ␉␉// set navigation keys for horizontal layout as defaults␊ |
191 | ␉␉int previous␉= 0x4B00;␉␉// left arrow␊ |
192 | ␉␉int subsequent␉= 0x4D00;␉␉// right arrow␊ |
193 | ␉␉int menu␉␉= 0x5000;␉␉// down arrow␊ |
194 | ␉␉␊ |
195 | ␉␉if ( gui.layout == VerticalLayout )␊ |
196 | ␉␉{␊ |
197 | ␉␉␉// set navigation keys for vertical layout␊ |
198 | ␉␉␉previous␉= 0x4800;␉␉// up arrow␊ |
199 | ␉␉␉subsequent␉= 0x5000;␉␉// down arrow␊ |
200 | ␉␉␉menu␉␉= 0x4B00;␉␉// right arrow␊ |
201 | ␉␉} ␊ |
202 | ␉␉␊ |
203 | ␉␉if ( key == previous )␊ |
204 | ␉␉{␊ |
205 | ␉␉␉if ( gMenuSelection > gMenuTop )␊ |
206 | ␉␉␉␉draw.f.selectionUp = 1;␊ |
207 | ␉␉␉else if ( gMenuTop > 0 )␊ |
208 | ␉␉␉␉draw.f.scrollDown = 1;␊ |
209 | ␉␉␉␊ |
210 | ␉␉}␊ |
211 | ␉␉␊ |
212 | ␉␉else if ( key == subsequent )␊ |
213 | ␉␉{␊ |
214 | ␉␉␉if ( gMenuSelection != gMenuBottom)␊ |
215 | ␉␉␉␉draw.f.selectionDown = 1;␊ |
216 | ␉␉␉else if ( gMenuBottom < ( gMenuItemCount - 1 ) )␊ |
217 | ␉␉␉␉draw.f.scrollUp = 1;␊ |
218 | ␉␉}␊ |
219 | ␉␉␊ |
220 | ␉␉else if ( key == menu )␊ |
221 | ␉␉{␊ |
222 | ␉␉␉if ( gui.menu.draw )␊ |
223 | ␉␉␉␉updateInfoMenu(key);␊ |
224 | ␉␉␉else␊ |
225 | ␉␉␉␉drawInfoMenu();␊ |
226 | ␉␉}␊ |
227 | ␉␉␊ |
228 | ␉␉else if ( gui.menu.draw )␊ |
229 | ␉␉{␊ |
230 | ␉␉␉res = updateInfoMenu(key);␊ |
231 | ␉␉␉␊ |
232 | ␉␉␉if ( res == CLOSE_INFO_MENU )␊ |
233 | ␉␉␉␉gui.menu.draw = false;␊ |
234 | ␉␉␉else␊ |
235 | ␉␉␉{␊ |
236 | ␉␉␉␉shouldboot = ( res != DO_NOT_BOOT );␊ |
237 | ␉␉␉␉␊ |
238 | ␉␉␉␉if ( shouldboot )␊ |
239 | ␉␉␉␉␉gui.menu.draw = false;␊ |
240 | ␉␉␉␉␊ |
241 | ␉␉␉␉switch (res)␊ |
242 | ␉␉␉␉{␊ |
243 | ␉␉␉␉␉case BOOT_NORMAL:␊ |
244 | ␉␉␉␉␉␉gVerboseMode = false;␊ |
245 | ␉␉␉␉␉␉gBootMode = kBootModeNormal;␊ |
246 | ␉␉␉␉␉␉break;␊ |
247 | ␉␉␉␉␉␉␊ |
248 | ␉␉␉␉␉case BOOT_VERBOSE:␊ |
249 | ␉␉␉␉␉␉gVerboseMode = true;␊ |
250 | ␉␉␉␉␉␉gBootMode = kBootModeNormal;␊ |
251 | ␉␉␉␉␉␉addBootArg(kVerboseModeFlag);␊ |
252 | ␉␉␉␉␉␉break;␊ |
253 | ␉␉␉␉␉␉␊ |
254 | ␉␉␉␉␉case BOOT_IGNORECACHE:␊ |
255 | ␉␉␉␉␉␉gVerboseMode = false;␊ |
256 | ␉␉␉␉␉␉gBootMode = kBootModeNormal;␊ |
257 | ␉␉␉␉␉␉addBootArg(kIgnoreCachesFlag);␊ |
258 | ␉␉␉␉␉␉break;␊ |
259 | ␉␉␉␉␉␉␊ |
260 | ␉␉␉␉␉case BOOT_SINGLEUSER:␊ |
261 | ␉␉␉␉␉␉gVerboseMode = true;␊ |
262 | ␉␉␉␉␉␉gBootMode = kBootModeNormal;␊ |
263 | ␉␉␉␉␉␉addBootArg(kSingleUserModeFlag);␊ |
264 | ␉␉␉␉␉␉break;␊ |
265 | ␉␉␉␉␉default:␊ |
266 | ␉␉␉␉␉␉break;␊ |
267 | ␉␉␉␉}␊ |
268 | ␉␉␉␉␊ |
269 | ␉␉␉}␊ |
270 | ␉␉␉␊ |
271 | ␉␉}␉␊ |
272 | ␉␉␊ |
273 | ␉} else {␊ |
274 | ␉␉switch ( key )␊ |
275 | ␉␉{␊ |
276 | ␉case 0x4800: // Up Arrow␊ |
277 | ␉␉␉␉if ( gMenuSelection != gMenuTop )␊ |
278 | ␉␉␉␉{␊ |
279 | ␉␉␉␉␉draw.f.selectionUp = 1;␊ |
280 | ␉␉␉␉}␊ |
281 | ␉␉␉␉else if ( gMenuTop > 0 )␊ |
282 | ␉␉␉␉{␊ |
283 | ␉␉␉␉␉draw.f.scrollDown = 1;␊ |
284 | ␉␉␉␉}␊ |
285 | ␉␉␉␉break;␊ |
286 | ␉␉␉␉␊ |
287 | ␉␉␉case 0x5000: // Down Arrow␊ |
288 | ␉␉␉␉if ( gMenuSelection != gMenuBottom )␊ |
289 | ␉␉␉␉{␊ |
290 | ␉␉␉␉␉draw.f.selectionDown = 1;␊ |
291 | ␉␉␉␉}␊ |
292 | ␉␉␉␉else if ( gMenuBottom < (gMenuItemCount - 1) ) ␊ |
293 | ␉␉␉␉{␊ |
294 | ␉␉␉␉␉draw.f.scrollUp = 1;␊ |
295 | ␉␉␉␉}␊ |
296 | ␉␉␉␉break;␊ |
297 | ␉␉␉default:␊ |
298 | ␉␉␉␉break;␊ |
299 | ␉␉}␊ |
300 | ␉}␊ |
301 | ␉␊ |
302 | if ( draw.w )␊ |
303 | {␊ |
304 | if ( draw.f.scrollUp )␊ |
305 | {␊ |
306 | scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, 1);␊ |
307 | gMenuTop++; gMenuBottom++;␊ |
308 | ␉␉␉gMenuStart++; gMenuEnd++;␊ |
309 | draw.f.selectionDown = 1;␊ |
310 | }␊ |
311 | ␉␉␊ |
312 | if ( draw.f.scrollDown )␊ |
313 | {␊ |
314 | scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, -1);␊ |
315 | gMenuTop--; gMenuBottom--;␊ |
316 | gMenuStart--; gMenuEnd--;␊ |
317 | draw.f.selectionUp = 1;␊ |
318 | }␊ |
319 | ␉␉␊ |
320 | if ( draw.f.selectionUp || draw.f.selectionDown )␊ |
321 | {␊ |
322 | ␉␉␉␊ |
323 | ␉␉␉CursorState cursorState;␊ |
324 | ␉␉␉␊ |
325 | ␉␉␉// Set cursor at current position, and clear inverse video.␊ |
326 | ␉␉␉␊ |
327 | ␉␉␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
328 | ␉␉␉{␊ |
329 | ␉␉␉␉changeCursor( 0, (gMenuRow + gMenuSelection - gMenuTop), kCursorTypeHidden, &cursorState );␊ |
330 | ␉␉␉␉printMenuItem( &gMenuItems[gMenuSelection], 0 );␊ |
331 | ␉␉␉}␊ |
332 | ␉␉␉␊ |
333 | ␉␉␉if ( draw.f.selectionUp )␊ |
334 | ␉␉␉{␊ |
335 | ␉␉␉␉gMenuSelection--;␊ |
336 | ␉␉␉␉if(( gMenuSelection - gMenuStart) == -1 )␊ |
337 | ␉␉␉␉{␊ |
338 | ␉␉␉␉␉gMenuStart--;␊ |
339 | ␉␉␉␉␉gMenuEnd--;␊ |
340 | ␉␉␉␉}␊ |
341 | ␉␉␉␉␊ |
342 | ␉␉␉} else {␊ |
343 | ␉␉␉␉gMenuSelection++;␊ |
344 | ␉␉␉␉if(( gMenuSelection - ( gui.maxdevices - 1) - gMenuStart) > 0 )␊ |
345 | ␉␉␉␉{␊ |
346 | ␉␉␉␉␉gMenuStart++;␊ |
347 | ␉␉␉␉␉gMenuEnd++;␊ |
348 | ␉␉␉␉}␊ |
349 | ␉␉␉}␊ |
350 | ␉␉␉␊ |
351 | ␉␉␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
352 | ␉␉␉{␊ |
353 | ␉␉␉␉moveCursor( 0, gMenuRow + gMenuSelection - gMenuTop );␊ |
354 | ␉␉␉␉printMenuItem( &gMenuItems[gMenuSelection], 1 );␊ |
355 | ␉␉␉␉restoreCursor( &cursorState );␊ |
356 | ␉␉␉␉␊ |
357 | ␉␉␉}␊ |
358 | ␉␉␉else␊ |
359 | ␉␉␉{␊ |
360 | ␉␉␉␉drawDeviceList (gMenuStart, gMenuEnd, gMenuSelection);␊ |
361 | ␉␉␉}␊ |
362 | ␉␉␉␊ |
363 | ␉␉}␊ |
364 | ␉␉␊ |
365 | *paramPtr = gMenuItems[gMenuSelection].param; ␊ |
366 | moved = 1;␊ |
367 | }␊ |
368 | ␉␊ |
369 | ␉return moved;␊ |
370 | }␊ |
371 | ␊ |
372 | ␊ |
373 | static void GUI_showMenu( const MenuItem * items, int count,␊ |
374 | ␉␉␉␉␉␉ int selection, int row, int height )␊ |
375 | {␊ |
376 | int i;␊ |
377 | CursorState cursorState;␊ |
378 | ␉␊ |
379 | if ( items == NULL || count == 0 ) ␊ |
380 | ␉␉return;␊ |
381 | ␉␊ |
382 | // head and tail points to the start and the end of the list.␊ |
383 | // top and bottom points to the first and last visible items␊ |
384 | // in the menu window.␊ |
385 | ␉␊ |
386 | gMenuItems␉␉= items;␊ |
387 | gMenuRow␉␉= row;␊ |
388 | gMenuHeight␉␉= height;␊ |
389 | gMenuItemCount␉= count;␊ |
390 | gMenuTop␉␉= 0;␊ |
391 | gMenuBottom␉␉= min( count, height ) - 1;␊ |
392 | gMenuSelection␉= selection;␊ |
393 | ␉␊ |
394 | gMenuStart␉␉= 0;␊ |
395 | gMenuEnd␉ = min( count, gui.maxdevices ) - 1;␊ |
396 | ␉␊ |
397 | ␉// If the selected item is not visible, shift the list down.␊ |
398 | ␉␊ |
399 | if ( gMenuSelection > gMenuBottom )␊ |
400 | {␊ |
401 | gMenuTop += ( gMenuSelection - gMenuBottom );␊ |
402 | gMenuBottom = gMenuSelection;␊ |
403 | }␊ |
404 | ␉␊ |
405 | ␉if ( gMenuSelection > gMenuEnd )␊ |
406 | {␊ |
407 | ␉␉gMenuStart += ( gMenuSelection - gMenuEnd );␊ |
408 | gMenuEnd = gMenuSelection;␊ |
409 | }␊ |
410 | ␉␊ |
411 | ␉// Draw the visible items.␊ |
412 | ␉␊ |
413 | ␉if( bootArgs->Video.v_display == GRAPHICS_MODE )␊ |
414 | ␉{␊ |
415 | ␉␉drawDeviceList(gMenuStart, gMenuEnd, gMenuSelection);␊ |
416 | ␉}␊ |
417 | ␉else ␊ |
418 | ␉{␊ |
419 | ␉␉␊ |
420 | ␉␉changeCursor( 0, row, kCursorTypeHidden, &cursorState );␊ |
421 | ␉␉␊ |
422 | ␉␉for ( i = gMenuTop; i <= gMenuBottom; i++ )␊ |
423 | ␉␉{␊ |
424 | ␉␉␉printMenuItem( &items[i], (i == gMenuSelection) );␊ |
425 | ␉␉}␊ |
426 | ␉␉␊ |
427 | ␉␉restoreCursor( &cursorState );␊ |
428 | }␊ |
429 | }␊ |
430 | ␊ |
431 | ␊ |
432 | static void GUI_updateBootArgs( int key )␊ |
433 | {␊ |
434 | key &= kASCIIKeyMask;␊ |
435 | ␉␊ |
436 | switch ( key )␊ |
437 | {␊ |
438 | case kBackspaceKey:␊ |
439 | if ( gBootArgsPtr > gBootArgs )␊ |
440 | {␊ |
441 | int x, y, t;␊ |
442 | getCursorPositionAndType( &x, &y, &t );␊ |
443 | if ( x == 0 && y )␊ |
444 | {␊ |
445 | x = 80; y--;␊ |
446 | }␊ |
447 | if (x)␊ |
448 | ␉␉␉␉␉x--;␊ |
449 | ␉␉␉␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
450 | ␉␉␉␉{␊ |
451 | ␉␉␉␉␉setCursorPosition( x, y, 0 );␊ |
452 | ␉␉␉␉␉putca(' ', 0x07, 1);␊ |
453 | ␉␉␉␉} else␊ |
454 | ␉␉␉␉{␊ |
455 | ␉␉␉␉␉updateGraphicBootPrompt(kBackspaceKey);␊ |
456 | ␉␉␉␉}␊ |
457 | ␉␉␉␉␊ |
458 | ␉␉␉␉*gBootArgsPtr-- = '\0';␊ |
459 | ␉␉␉}␊ |
460 | ␊ |
461 | ␉␉␉break;␊ |
462 | ␉␉␉␊ |
463 | default:␊ |
464 | if ( key >= ' ' && gBootArgsPtr < gBootArgsEnd)␊ |
465 | {␊ |
466 | ␉␉␉␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
467 | ␉␉␉␉{␊ |
468 | ␉␉␉␉␉putchar(key); // echo to screen␊ |
469 | ␉␉␉␉}␊ |
470 | ␉␉␉␉else␊ |
471 | ␉␉␉␉{␊ |
472 | ␉␉␉␉␉updateGraphicBootPrompt(key);␊ |
473 | ␉␉␉␉}␊ |
474 | ␉␉␉␉*gBootArgsPtr++ = key;␊ |
475 | ␉␉␉}␊ |
476 | ␊ |
477 | ␉␉␉break;␊ |
478 | }␊ |
479 | }␊ |
480 | ␊ |
481 | ␊ |
482 | static void GUI_showBootPrompt(int row, bool visible)␊ |
483 | {␊ |
484 | ␉extern char bootPrompt[];␊ |
485 | ␉␊ |
486 | ␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
487 | ␉{␊ |
488 | ␉␉changeCursor( 0, row, kCursorTypeUnderline, 0 ); ␊ |
489 | ␉␉clearScreenRows( row, kScreenLastRow );␊ |
490 | ␉}␊ |
491 | ␉␊ |
492 | ␉clearBootArgs();␊ |
493 | ␉␊ |
494 | ␉if (visible)␊ |
495 | ␉{␊ |
496 | ␉␉if (bootArgs->Video.v_display == VGA_TEXT_MODE) ␊ |
497 | ␉␉{␊ |
498 | ␉␉␉if (gEnableCDROMRescan)␊ |
499 | ␉␉␉{␊ |
500 | ␉␉␉␉printf( GUI_bootRescanPrompt );␊ |
501 | ␉␉␉} ␊ |
502 | ␉␉␉else␊ |
503 | ␉␉␉{␊ |
504 | ␉␉␉␉printf( bootPrompt );␊ |
505 | ␉␉␉}␊ |
506 | ␉␉}␊ |
507 | ␉} ␊ |
508 | ␉else␊ |
509 | ␉{␊ |
510 | ␉␉if (bootArgs->Video.v_display == GRAPHICS_MODE)␊ |
511 | ␉␉{␊ |
512 | ␉␉␉clearGraphicBootPrompt();␊ |
513 | ␉␉} ␊ |
514 | ␉␉else␊ |
515 | ␉␉{␊ |
516 | ␉␉␉printf("Press Enter to start up the foreign OS. ");␊ |
517 | ␉␉}␊ |
518 | ␉}␊ |
519 | }␊ |
520 | ␊ |
521 | ␊ |
522 | void GUI_clearBootArgs(void)␊ |
523 | {␊ |
524 | ␉gBootArgsPtr = gBootArgs;␊ |
525 | ␉memset(gBootArgs, '\0', BOOT_STRING_LEN);␊ |
526 | ␉␊ |
527 | ␉if (bootArgs->Video.v_display == GRAPHICS_MODE) ␊ |
528 | ␉{␊ |
529 | ␉␉clearGraphicBootPrompt();␊ |
530 | ␉}␊ |
531 | }␊ |
532 | ␊ |
533 | ␊ |
534 | int GUI_getBootOptions(bool firstRun)␊ |
535 | {␊ |
536 | ␉int i;␊ |
537 | ␉int key;␊ |
538 | ␉int nextRow;␊ |
539 | ␉int timeout;␊ |
540 | #if UNUSED␊ |
541 | ␉int bvCount;␊ |
542 | #endif␊ |
543 | ␉BVRef bvr;␊ |
544 | ␉BVRef menuBVR;␊ |
545 | ␉bool showPrompt, newShowPrompt, isCDROM;␊ |
546 | ␉␊ |
547 | ␉// Initialize default menu selection entry.␊ |
548 | ␉gBootVolume = menuBVR = selectBootVolume(bvChain);␊ |
549 | ␉␊ |
550 | ␉if (biosDevIsCDROM(gBIOSDev))␊ |
551 | ␉{␊ |
552 | ␉␉isCDROM = true;␊ |
553 | ␉} ␊ |
554 | ␉else␊ |
555 | ␉{␊ |
556 | ␉␉isCDROM = false;␊ |
557 | ␉}␊ |
558 | ␉␊ |
559 | ␉// ensure we're in graphics mode if gui is setup␊ |
560 | ␉if (gui.initialised && bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
561 | ␉{␊ |
562 | #if UNUSED␊ |
563 | ␉␉setVideoMode(GRAPHICS_MODE, 0);␊ |
564 | #else␊ |
565 | ␉␉setVideoMode(GRAPHICS_MODE);␊ |
566 | #endif␊ |
567 | ␉}␊ |
568 | ␉␊ |
569 | ␉// Clear command line boot arguments␊ |
570 | ␉clearBootArgs();␊ |
571 | ␉␊ |
572 | ␉// Allow user to override default timeout.␊ |
573 | ␉if (!getIntForKey(kTimeoutKey, &timeout, &bootInfo->bootConfig))␊ |
574 | ␉{␊ |
575 | ␉␉/* If there is no timeout key in the file use the default timeout␊ |
576 | ␉␉ which is different for CDs vs. hard disks. However, if not booting␊ |
577 | ␉␉ a CD and no config file could be loaded set the timeout␊ |
578 | ␉␉ to zero which causes the menu to display immediately.␊ |
579 | ␉␉ This way, if no partitions can be found, that is the disk is unpartitioned␊ |
580 | ␉␉ or simply cannot be read) then an empty menu is displayed.␊ |
581 | ␉␉ If some partitions are found, for example a Windows partition, then␊ |
582 | ␉␉ these will be displayed in the menu as foreign partitions.␊ |
583 | ␉␉ */␊ |
584 | ␉␉if (isCDROM)␊ |
585 | ␉␉{␊ |
586 | ␉␉␉timeout = kCDBootTimeout;␊ |
587 | ␉␉}␊ |
588 | ␉␉else ␊ |
589 | ␉␉{␊ |
590 | ␉␉␉timeout = sysConfigValid ? kBootTimeout : 0;␊ |
591 | ␉␉}␊ |
592 | ␉}␊ |
593 | ␉␊ |
594 | ␉if (timeout < 0) ␊ |
595 | ␉{␊ |
596 | ␉␉gBootMode |= kBootModeQuiet;␊ |
597 | ␉}␊ |
598 | ␉␊ |
599 | ␉// If the user is holding down a modifier key, enter safe mode.␊ |
600 | ␉if ((readKeyboardShiftFlags() & 0x0F) != 0) ␊ |
601 | ␉{␊ |
602 | ␉␉␊ |
603 | ␉␉//gBootMode |= kBootModeSafe;␊ |
604 | ␉}␊ |
605 | ␉␊ |
606 | ␉// Checking user pressed keys␊ |
607 | ␉bool f8press = false, spress = false, vpress = false;␊ |
608 | ␉while (readKeyboardStatus())␊ |
609 | ␉{␊ |
610 | ␉␉key = bgetc ();␊ |
611 | ␉␉if (key == 0x4200) f8press = true;␊ |
612 | ␉␉if ((key & 0xff) == 's' || (key & 0xff) == 'S') spress = true;␊ |
613 | ␉␉if ((key & 0xff) == 'v' || (key & 0xff) == 'V') vpress = true;␊ |
614 | ␉}␊ |
615 | ␉// If user typed F8, abort quiet mode, and display the menu.␊ |
616 | ␉if (f8press)␊ |
617 | ␉{␊ |
618 | ␉␉gBootMode &= ~kBootModeQuiet;␊ |
619 | ␉␉timeout = 0;␊ |
620 | ␉}␊ |
621 | ␉// If user typed 'v' or 'V', boot in verbose mode.␊ |
622 | ␉if ((gBootMode & kBootModeQuiet) && firstRun && vpress)␊ |
623 | ␉{␊ |
624 | ␉␉addBootArg(kVerboseModeFlag);␊ |
625 | ␉}␊ |
626 | ␉// If user typed 's' or 'S', boot in single user mode.␊ |
627 | ␉if ((gBootMode & kBootModeQuiet) && firstRun && spress)␊ |
628 | ␉{␊ |
629 | ␉␉addBootArg(kSingleUserModeFlag);␊ |
630 | ␉}␊ |
631 | ␉␊ |
632 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
633 | ␉{␊ |
634 | ␉␉setCursorPosition(0, 0, 0);␊ |
635 | ␉␉clearScreenRows(0, kScreenLastRow);␊ |
636 | ␉␉if (!(gBootMode & kBootModeQuiet)) ␊ |
637 | ␉␉{␊ |
638 | ␉␉␉// Display banner and show hardware info.␊ |
639 | ␉␉␉printf(bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024);␊ |
640 | ␉␉␉printf(getVBEInfoString());␊ |
641 | ␉␉}␊ |
642 | ␉␉changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0);␊ |
643 | ␉␉verbose("Scanning device %x...", gBIOSDev);␊ |
644 | ␉}␊ |
645 | ␉␊ |
646 | ␉// When booting from CD, default to hard drive boot when possible. ␊ |
647 | ␉if (isCDROM && firstRun)␊ |
648 | ␉{␊ |
649 | ␉␉const char *val;␊ |
650 | ␉␉char *prompt = NULL;␊ |
651 | ␉␉char *name = NULL;␊ |
652 | ␉␉int cnt;␊ |
653 | ␉␉int optionKey;␊ |
654 | ␉␉␊ |
655 | ␉␉if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->bootConfig))␊ |
656 | ␉␉{␊ |
657 | ␉␉␉prompt = malloc(cnt + 1);␊ |
658 | ␉␉␉strncat(prompt, val, cnt);␊ |
659 | ␉␉}␊ |
660 | ␉␉else ␊ |
661 | ␉␉{␊ |
662 | ␉␉␉name = malloc(80);␊ |
663 | ␉␉␉getBootVolumeDescription(gBootVolume, name, 79, false);␊ |
664 | ␉␉␉prompt = malloc(256);␊ |
665 | ␉␉␉sprintf(prompt, "Press any key to start up from %s, or press F8 to enter startup options.", name);␊ |
666 | ␉␉␉free(name);␊ |
667 | ␉␉}␊ |
668 | ␉␉␊ |
669 | ␉␉if (getIntForKey( kCDROMOptionKey, &optionKey, &bootInfo->bootConfig ))␊ |
670 | ␉␉{␊ |
671 | ␉␉␉// The key specified is a special key.␊ |
672 | ␉␉}␊ |
673 | ␉␉else␊ |
674 | ␉␉{␊ |
675 | ␉␉␉// Default to F8.␊ |
676 | ␉␉␉optionKey = 0x4200;␊ |
677 | ␉␉}␊ |
678 | ␉␉␊ |
679 | ␉␉// If the timeout is zero then it must have been set above due to the␊ |
680 | ␉␉// early catch of F8 which means the user wants to set boot options␊ |
681 | ␉␉// which we ought to interpret as meaning he wants to boot the CD.␊ |
682 | ␉␉if (timeout != 0) {␊ |
683 | ␉␉␉key = GUI_countdown(prompt, kMenuTopRow, timeout);␊ |
684 | ␉␉} ␊ |
685 | ␉␉else ␊ |
686 | ␉␉{␊ |
687 | ␉␉␉key = optionKey;␊ |
688 | ␉␉}␊ |
689 | ␉␉␊ |
690 | ␉␉if (prompt != NULL)␊ |
691 | ␉␉{␊ |
692 | ␉␉␉free(prompt);␊ |
693 | ␉␉}␊ |
694 | ␉␉␊ |
695 | ␉␉clearScreenRows( kMenuTopRow, kMenuTopRow + 2 );␊ |
696 | ␉␉␊ |
697 | ␉␉// Hit the option key ?␊ |
698 | ␉␉if (key == optionKey) ␊ |
699 | ␉␉{␊ |
700 | ␉␉␉gBootMode &= ~kBootModeQuiet;␊ |
701 | ␉␉␉timeout = 0;␊ |
702 | ␉␉} ␊ |
703 | ␉␉else ␊ |
704 | ␉␉{␊ |
705 | ␉␉␉key = key & 0xFF;␊ |
706 | ␉␉␉␊ |
707 | ␉␉␉// Try booting hard disk if user pressed 'h'␊ |
708 | ␉␉␉if (biosDevIsCDROM(gBIOSDev) && key == 'h')␊ |
709 | ␉␉␉{␊ |
710 | ␉␉␉␉BVRef bvr;␊ |
711 | ␉␉␉␉␊ |
712 | ␉␉␉␉// Look at partitions hosting OS X other than the CD-ROM␊ |
713 | ␉␉␉␉for (bvr = bvChain; bvr; bvr=bvr->next)␊ |
714 | ␉␉␉␉{␊ |
715 | ␉␉␉␉␉if ((bvr->flags & kBVFlagSystemVolume) && bvr->biosdev != gBIOSDev)␊ |
716 | ␉␉␉␉␉{␊ |
717 | ␉␉␉␉␉␉gBootVolume = bvr;␊ |
718 | ␉␉␉␉␉}␊ |
719 | ␉␉␉␉}␊ |
720 | ␉␉␉}␊ |
721 | ␉␉␉goto done;␊ |
722 | ␉␉}␊ |
723 | ␉}␊ |
724 | ␉␊ |
725 | ␉if (gBootMode & kBootModeQuiet)␊ |
726 | ␉{␊ |
727 | ␉␉// No input allowed from user.␊ |
728 | ␉␉goto done;␊ |
729 | ␉}␊ |
730 | ␉␊ |
731 | ␉if (firstRun && timeout > 0 && GUI_countdown("Press any key to enter startup options.", kMenuTopRow, timeout) == 0)␊ |
732 | ␉{␊ |
733 | ␉␉// If the user is holding down a modifier key,␊ |
734 | ␉␉// enter safe mode.␊ |
735 | ␉␉if ((readKeyboardShiftFlags() & 0x0F) != 0)␊ |
736 | ␉␉{␊ |
737 | ␉␉␉gBootMode |= kBootModeSafe;␊ |
738 | ␉␉}␊ |
739 | ␉␉goto done;␊ |
740 | ␉}␊ |
741 | ␉␊ |
742 | ␉if (gDeviceCount)␊ |
743 | ␉{␊ |
744 | ␉␉// Allocate memory for an array of menu items.␊ |
745 | ␉␉menuItems = malloc(sizeof(MenuItem) * gDeviceCount);␊ |
746 | ␉␉if (menuItems == NULL) ␊ |
747 | ␉␉{␊ |
748 | ␉␉␉goto done;␊ |
749 | ␉␉}␊ |
750 | ␉␉␊ |
751 | ␉␉// Associate a menu item for each BVRef.␊ |
752 | ␉␉for (bvr=bvChain, i=gDeviceCount-1, selectIndex=0; bvr; bvr=bvr->next)␊ |
753 | ␉␉{␊ |
754 | ␉␉␉if (bvr->visible)␊ |
755 | ␉␉␉{␊ |
756 | ␉␉␉␉getBootVolumeDescription(bvr, menuItems[i].name, sizeof(menuItems[i].name) - 1, true);␊ |
757 | ␉␉␉␉menuItems[i].param = (void *) bvr;␊ |
758 | ␉␉␉␉if (bvr == menuBVR)␊ |
759 | ␉␉␉␉{␊ |
760 | ␉␉␉␉␉selectIndex = i;␊ |
761 | ␉␉␉␉}␊ |
762 | ␉␉␉␉i--;␊ |
763 | ␉␉␉}␊ |
764 | ␉␉}␊ |
765 | ␉}␊ |
766 | ␉␊ |
767 | ␉if (bootArgs->Video.v_display == GRAPHICS_MODE)␊ |
768 | ␉{␊ |
769 | ␉␉// redraw the background buffer␊ |
770 | ␉␉gui.logo.draw = true;␊ |
771 | ␉␉drawBackground();␊ |
772 | ␉␉gui.devicelist.draw = true;␊ |
773 | ␉␉gui.redraw = true;␊ |
774 | ␉␉if (!(gBootMode & kBootModeQuiet))␊ |
775 | ␉␉{␊ |
776 | ␉␉␉bool showBootBanner = true;␊ |
777 | ␉␉␉␊ |
778 | ␉␉␉// Check if "Boot Banner"=N switch is present in config file.␊ |
779 | ␉␉␉getBoolForKey(kBootBannerKey, &showBootBanner, &bootInfo->bootConfig); ␊ |
780 | ␉␉␉if (showBootBanner)␊ |
781 | ␉␉␉{␊ |
782 | ␉␉␉␉// Display banner and show hardware info.␊ |
783 | ␉␉␉␉gprintf(&gui.screen, bootBanner + 1, (bootInfo->convmem + bootInfo->extmem) / 1024);␊ |
784 | ␉␉␉}␊ |
785 | ␉␉␉␊ |
786 | ␉␉␉// redraw background␊ |
787 | ␉␉␉memcpy(gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4);␊ |
788 | ␉␉}␊ |
789 | ␉}␊ |
790 | ␉else ␊ |
791 | ␉{␊ |
792 | ␉␉// Clear screen and hide the blinking cursor.␊ |
793 | ␉␉clearScreenRows(kMenuTopRow, kMenuTopRow + 2);␊ |
794 | ␉␉changeCursor(0, kMenuTopRow, kCursorTypeHidden, 0);␊ |
795 | ␉}␊ |
796 | ␉␊ |
797 | ␉nextRow = kMenuTopRow;␊ |
798 | ␉showPrompt = true;␊ |
799 | ␉␊ |
800 | ␉if (gDeviceCount)␊ |
801 | ␉{␊ |
802 | ␉␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
803 | ␉␉{␊ |
804 | ␉␉␉printf("Use \30\31 keys to select the startup volume.");␊ |
805 | ␉␉}␊ |
806 | ␉␉GUI_showMenu( menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems );␊ |
807 | ␉␉nextRow += min( gDeviceCount, kMenuMaxItems ) + 3;␊ |
808 | ␉}␊ |
809 | ␉␊ |
810 | ␉// Show the boot prompt.␊ |
811 | ␉showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);␊ |
812 | ␉GUI_showBootPrompt( nextRow, showPrompt );␊ |
813 | ␉␊ |
814 | ␉do {␊ |
815 | ␉␉if (bootArgs->Video.v_display == GRAPHICS_MODE)␊ |
816 | ␉␉{␊ |
817 | ␉␉␉// redraw background␊ |
818 | ␉␉␉memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 );␊ |
819 | ␉␉␉// reset cursor co-ords␊ |
820 | ␉␉␉gui.debug.cursor = pos( gui.screen.width - 160 , 10 );␊ |
821 | ␉␉}␊ |
822 | ␉␉key = getc();␊ |
823 | ␉␉GUI_updateMenu( key, (void **) &menuBVR );␊ |
824 | ␉␉newShowPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);␊ |
825 | ␉␉␊ |
826 | ␉␉if (newShowPrompt != showPrompt)␊ |
827 | ␉␉{␊ |
828 | ␉␉␉showPrompt = newShowPrompt;␊ |
829 | ␉␉␉GUI_showBootPrompt( nextRow, showPrompt );␊ |
830 | ␉␉}␊ |
831 | ␉␉␊ |
832 | ␉␉if (showPrompt)␊ |
833 | ␉␉{␊ |
834 | ␉␉␉GUI_updateBootArgs(key);␊ |
835 | ␉␉}␊ |
836 | ␉␉␊ |
837 | ␉␉switch (key)␊ |
838 | ␉␉{␊ |
839 | ␉␉␉case kReturnKey:␊ |
840 | ␉␉␉␉if (gui.menu.draw)␊ |
841 | ␉␉␉␉{ ␊ |
842 | ␉␉␉␉␉key=0;␊ |
843 | ␉␉␉␉␉break;␊ |
844 | ␉␉␉␉}␊ |
845 | ␉␉␉␉if (*gBootArgs == '?')␊ |
846 | ␉␉␉␉{␊ |
847 | ␉␉␉␉␉char * argPtr = gBootArgs;␊ |
848 | ␉␉␉␉␉␊ |
849 | ␉␉␉␉␉// Skip the leading "?" character.␊ |
850 | ␉␉␉␉␉argPtr++;␊ |
851 | ␉␉␉␉␉getNextArg(&argPtr, booterCommand);␊ |
852 | ␉␉␉␉␉getNextArg(&argPtr, booterParam);␊ |
853 | ␉␉␉␉␉␊ |
854 | ␉␉␉␉␉/*␊ |
855 | ␉␉␉␉␉ * TODO: this needs to be refactored.␊ |
856 | ␉␉␉␉␉ */␊ |
857 | ␉␉␉␉␉if (strcmp( booterCommand, "video" ) == 0)␊ |
858 | ␉␉␉␉␉{␊ |
859 | ␉␉␉␉␉␉if (bootArgs->Video.v_display == GRAPHICS_MODE)␊ |
860 | ␉␉␉␉␉␉{␊ |
861 | ␉␉␉␉␉␉␉showInfoBox(getVBEInfoString(), getVBEModeInfoString());␊ |
862 | ␉␉␉␉␉␉}␊ |
863 | ␉␉␉␉␉␉else␊ |
864 | ␉␉␉␉␉␉{␊ |
865 | ␉␉␉␉␉␉␉printVBEModeInfo();␊ |
866 | ␉␉␉␉␉␉}␊ |
867 | ␉␉␉␉␉}␊ |
868 | ␉␉␉␉␉else if ( strcmp( booterCommand, "memory" ) == 0)␊ |
869 | ␉␉␉␉␉{␊ |
870 | ␉␉␉␉␉␉if (bootArgs->Video.v_display == GRAPHICS_MODE ) ␊ |
871 | ␉␉␉␉␉␉{␊ |
872 | ␉␉␉␉␉␉␉showInfoBox("Memory Map", getMemoryInfoString());␊ |
873 | ␉␉␉␉␉␉}␊ |
874 | ␉␉␉␉␉␉else␊ |
875 | ␉␉␉␉␉␉{␊ |
876 | ␉␉␉␉␉␉␉printMemoryInfo();␊ |
877 | ␉␉␉␉␉␉}␊ |
878 | ␉␉␉␉␉}␊ |
879 | ␉␉␉␉␉else if (strcmp(booterCommand, "lspci") == 0)␊ |
880 | ␉␉␉␉␉{␊ |
881 | ␉␉␉␉␉␉lspci();␊ |
882 | ␉␉␉␉␉}␊ |
883 | ␉␉␉␉␉else if (strcmp(booterCommand, "more") == 0)␊ |
884 | ␉␉␉␉␉{␊ |
885 | ␉␉␉␉␉␉showTextFile(booterParam);␊ |
886 | ␉␉␉␉␉}␊ |
887 | ␉␉␉␉␉else if (strcmp(booterCommand, "rd") == 0)␊ |
888 | ␉␉␉␉␉{␊ |
889 | ␉␉␉␉␉␉if (execute_hook("processRAMDiskCommand", (void*)argPtr, &booterParam, NULL, NULL, NULL, NULL) != EFI_SUCCESS)␊ |
890 | ␉␉␉␉␉␉␉showMessage("ramdisk module not found, please install RamdiskLoader.dylib in /Extra/modules/");␊ |
891 | ␉␉␉␉␉} ␊ |
892 | ␉␉␉␉␉else if (strcmp(booterCommand, "norescan") == 0)␊ |
893 | ␉␉␉␉␉{␊ |
894 | ␉␉␉␉␉␉if (gEnableCDROMRescan)␊ |
895 | ␉␉␉␉␉␉{␊ |
896 | ␉␉␉␉␉␉␉gEnableCDROMRescan = false;␊ |
897 | ␉␉␉␉␉␉␉break;␊ |
898 | ␉␉␉␉␉␉}␊ |
899 | ␉␉␉␉␉} ␊ |
900 | ␉␉␉␉␉else␊ |
901 | ␉␉␉␉␉{␊ |
902 | ␉␉␉␉␉␉showHelp();␊ |
903 | ␉␉␉␉␉}␊ |
904 | ␉␉␉␉␉key = 0;␊ |
905 | ␉␉␉␉␉GUI_showBootPrompt(nextRow, showPrompt);␊ |
906 | ␉␉␉␉␉break;␊ |
907 | ␉␉␉␉}␊ |
908 | ␉␉␉␉gBootVolume = menuBVR;␊ |
909 | ␉␉␉␉setRootVolume(menuBVR);␊ |
910 | ␉␉␉␉gBIOSDev = menuBVR->biosdev;␊ |
911 | ␉␉␉␉break;␊ |
912 | ␉␉␉␉␊ |
913 | ␉␉␉case kEscapeKey:␊ |
914 | ␉␉␉␉clearBootArgs();␊ |
915 | ␉␉␉␉break;␊ |
916 | ␉␉␉␉␊ |
917 | ␉␉␉case kF5Key:␊ |
918 | ␉␉␉␉// New behavior:␊ |
919 | ␉␉␉␉// Clear gBootVolume to restart the loop␊ |
920 | ␉␉␉␉// if the user enabled rescanning the optical drive.␊ |
921 | ␉␉␉␉// Otherwise boot the default boot volume.␊ |
922 | ␉␉␉␉if (gEnableCDROMRescan)␊ |
923 | ␉␉␉␉{␊ |
924 | ␉␉␉␉␉gBootVolume = NULL;␊ |
925 | ␉␉␉␉␉clearBootArgs();␊ |
926 | ␉␉␉␉}␊ |
927 | ␉␉␉␉break;␊ |
928 | ␉␉␉␉␊ |
929 | ␉␉␉case kF10Key:␊ |
930 | ␉␉␉␉gScanSingleDrive = false;␊ |
931 | #if UNUSED␊ |
932 | scanDisks(gBIOSDev, &bvCount);␊ |
933 | #else␊ |
934 | scanDisks();␊ |
935 | #endif␊ |
936 | ␉␉␉␉gBootVolume = NULL;␊ |
937 | ␉␉␉␉clearBootArgs();␊ |
938 | ␉␉␉␉break;␊ |
939 | ␉␉␉␉␊ |
940 | ␉␉␉case kTabKey:␊ |
941 | ␉␉␉␉// New behavior:␊ |
942 | ␉␉␉␉// Switch between text & graphic interfaces␊ |
943 | ␉␉␉␉// Only Permitted if started in graphics interface␊ |
944 | ␉␉␉␉if (useGUI)␊ |
945 | ␉␉␉␉{␊ |
946 | ␉␉␉␉␉if (bootArgs->Video.v_display == GRAPHICS_MODE)␊ |
947 | ␉␉␉␉␉{␊ |
948 | #if UNUSED␊ |
949 | ␉␉␉␉␉␉setVideoMode(VGA_TEXT_MODE, 0);␊ |
950 | #else␊ |
951 | ␉␉␉␉␉␉setVideoMode(VGA_TEXT_MODE);␊ |
952 | #endif␉␉␉␉␉␊ |
953 | ␉␉␉␉␉␉setCursorPosition(0, 0, 0);␊ |
954 | ␉␉␉␉␉␉clearScreenRows(0, kScreenLastRow);␊ |
955 | ␉␉␉␉␉␉␊ |
956 | ␉␉␉␉␉␉// Display banner and show hardware info.␊ |
957 | ␉␉␉␉␉␉printf(bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024);␊ |
958 | ␉␉␉␉␉␉printf(getVBEInfoString());␊ |
959 | ␉␉␉␉␉␉␊ |
960 | ␉␉␉␉␉␉clearScreenRows(kMenuTopRow, kMenuTopRow + 2);␊ |
961 | ␉␉␉␉␉␉changeCursor(0, kMenuTopRow, kCursorTypeHidden, 0);␊ |
962 | ␉␉␉␉␉␉␊ |
963 | ␉␉␉␉␉␉nextRow = kMenuTopRow;␊ |
964 | ␉␉␉␉␉␉showPrompt = true;␊ |
965 | ␉␉␉␉␉␉␊ |
966 | ␉␉␉␉␉␉if (gDeviceCount)␊ |
967 | ␉␉␉␉␉␉{␊ |
968 | ␉␉␉␉␉␉␉printf("Use \30\31 keys to select the startup volume.");␊ |
969 | ␉␉␉␉␉␉␉GUI_showMenu(menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems);␊ |
970 | ␉␉␉␉␉␉␉nextRow += min(gDeviceCount, kMenuMaxItems) + 3;␊ |
971 | ␉␉␉␉␉␉}␊ |
972 | ␉␉␉␉␉␉␊ |
973 | ␉␉␉␉␉␉showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);␊ |
974 | ␉␉␉␉␉␉GUI_showBootPrompt(nextRow, showPrompt);␊ |
975 | ␉␉␉␉␉␉//changeCursor( 0, kMenuTopRow, kCursorTypeUnderline, 0 );␊ |
976 | ␉␉␉␉␉} ␊ |
977 | ␉␉␉␉␉else ␊ |
978 | ␉␉␉␉␉{␊ |
979 | ␉␉␉␉␉␉gui.redraw = true;␊ |
980 | #if UNUSED␊ |
981 | ␉␉␉␉␉␉setVideoMode(GRAPHICS_MODE, 0);␊ |
982 | #else␊ |
983 | ␉␉␉␉␉␉setVideoMode(GRAPHICS_MODE);␊ |
984 | #endif␊ |
985 | ␉␉␉␉␉␉updateVRAM();␊ |
986 | ␉␉␉␉␉}␊ |
987 | ␉␉␉␉}␊ |
988 | ␉␉␉␉key = 0;␊ |
989 | ␉␉␉␉break;␊ |
990 | ␉␉␉␉␊ |
991 | ␉␉␉default:␊ |
992 | ␉␉␉␉key = 0;␊ |
993 | ␉␉␉␉break;␊ |
994 | ␉␉}␊ |
995 | ␉} while (0 == key);␊ |
996 | ␉␊ |
997 | done:␊ |
998 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
999 | ␉{␊ |
1000 | ␉␉clearScreenRows(kMenuTopRow, kScreenLastRow);␊ |
1001 | ␉␉changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0);␊ |
1002 | ␉}␊ |
1003 | ␉shouldboot = false;␊ |
1004 | ␉gui.menu.draw = false;␊ |
1005 | ␉if (menuItems)␊ |
1006 | ␉{␊ |
1007 | ␉␉free(menuItems);␊ |
1008 | ␉␉menuItems = NULL;␊ |
1009 | ␉}␊ |
1010 | ␉return 0;␊ |
1011 | }␊ |
1012 | ␊ |
1013 | ␊ |
1014 | ␊ |
1015 | int GUI_error(const char * fmt, ...)␊ |
1016 | {␊ |
1017 | va_list ap;␊ |
1018 | gErrors = true;␊ |
1019 | va_start(ap, fmt);␊ |
1020 | ␉␊ |
1021 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
1022 | ␉{␊ |
1023 | ␉␉prf(fmt, ap, putchar, 0);␊ |
1024 | }␊ |
1025 | ␉else␊ |
1026 | ␉{␊ |
1027 | ␉␉vprf(fmt, ap);␊ |
1028 | ␉}␊ |
1029 | ␉␊ |
1030 | ␉va_end(ap);␊ |
1031 | return(0);␊ |
1032 | }␊ |
1033 | ␊ |
1034 | int GUI_verbose(const char * fmt, ...)␊ |
1035 | {␊ |
1036 | va_list ap;␊ |
1037 | ␊ |
1038 | ␉va_start(ap, fmt);␊ |
1039 | ␉␊ |
1040 | if (gVerboseMode && (KernelStart == false))␊ |
1041 | {␊ |
1042 | ␉␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
1043 | ␉␉{␊ |
1044 | ␉␉␉prf(fmt, ap, putchar, 0);␊ |
1045 | ␉␉}␊ |
1046 | ␉␉else␊ |
1047 | ␉␉{␊ |
1048 | ␉␉␉vprf(fmt, ap);␊ |
1049 | ␉␉}␊ |
1050 | }␊ |
1051 | ␉␊ |
1052 | ␉/* Kabyl: BooterLog */␊ |
1053 | ␉struct putc_info pi;␊ |
1054 | ␉␊ |
1055 | ␉if (!msgbuf)␊ |
1056 | ␉␉return 0;␊ |
1057 | ␉␊ |
1058 | ␉if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))␊ |
1059 | ␉␉return 0;␊ |
1060 | ␉pi.str = cursor;␊ |
1061 | ␉pi.last_str = 0;␊ |
1062 | ␉prf(fmt, ap, sputc, &pi);␊ |
1063 | ␉cursor += strlen((char *)cursor);␊ |
1064 | ␉␊ |
1065 | ␉␊ |
1066 | va_end(ap);␊ |
1067 | return(0);␊ |
1068 | }␊ |
1069 | ␊ |
1070 | int GUI_printf(const char * fmt, ...)␊ |
1071 | {␊ |
1072 | va_list ap;␊ |
1073 | ␉va_start(ap, fmt);␊ |
1074 | ␉␊ |
1075 | ␉if (KernelStart == false) {␊ |
1076 | ␉␉␊ |
1077 | ␉␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
1078 | ␉␉{␊ |
1079 | ␉␉␉prf(fmt, ap, putchar, 0);␊ |
1080 | ␉␉}␊ |
1081 | ␉␉else␊ |
1082 | ␉␉{␊ |
1083 | ␉␉␉vprf(fmt, ap);␊ |
1084 | ␉␉}␊ |
1085 | ␉}␊ |
1086 | ␉/* Kabyl: BooterLog */␊ |
1087 | ␉struct putc_info pi;␊ |
1088 | ␉␊ |
1089 | ␉if (!msgbuf)␊ |
1090 | ␉␉return 0;␊ |
1091 | ␉␊ |
1092 | ␉if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))␊ |
1093 | ␉␉return 0;␊ |
1094 | ␉pi.str = cursor;␊ |
1095 | ␉pi.last_str = 0;␊ |
1096 | ␉prf(fmt, ap, sputc, &pi);␊ |
1097 | ␉cursor += strlen((char *)cursor);␊ |
1098 | ␉␊ |
1099 | ␉va_end(ap);␊ |
1100 | return 0;␊ |
1101 | }␊ |
1102 | ␊ |
1103 | void GUI_stop(const char * fmt, ...)␊ |
1104 | {␊ |
1105 | ␉va_list ap;␊ |
1106 | ␉␊ |
1107 | ␉printf("\n");␊ |
1108 | ␉va_start(ap, fmt);␊ |
1109 | ␉␊ |
1110 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
1111 | ␉{␊ |
1112 | ␉␉prf(fmt, ap, putchar, 0);␊ |
1113 | ␉} ␊ |
1114 | ␉else ␊ |
1115 | ␉{␊ |
1116 | ␉␉vprf(fmt, ap);␊ |
1117 | ␉}␊ |
1118 | ␉va_end(ap);␊ |
1119 | ␉␊ |
1120 | ␉printf("\nThis is a non recoverable error! System HALTED!!!");␊ |
1121 | ␉halt();␊ |
1122 | ␉while (1);␊ |
1123 | }␊ |
1124 | ␊ |
1125 | void GUI_showHelp(void)␊ |
1126 | {␊ |
1127 | ␉if (bootArgs->Video.v_display == GRAPHICS_MODE) {␊ |
1128 | ␉␉showInfoBox("Help. Press q to quit.\n", (char *)BootHelp_txt);␊ |
1129 | ␉} else {␊ |
1130 | ␉␉showTextBuffer((char *)BootHelp_txt, BootHelp_txt_len);␊ |
1131 | ␉}␊ |
1132 | }␊ |
1133 | ␊ |
1134 | void GUI_showMessage(char *message)␊ |
1135 | {␊ |
1136 | ␉if (bootArgs->Video.v_display == GRAPHICS_MODE) {␊ |
1137 | ␉␉showInfoBox("Help. Press q to quit.\n", message);␊ |
1138 | ␉} else {␊ |
1139 | ␉␉showTextBuffer(message, strlen(message));␊ |
1140 | ␉}␊ |
1141 | } |