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