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