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