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