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