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