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