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