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