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