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