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