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