Chameleon

Chameleon Svn Source Tree

Root/branches/meklort/i386/modules/GUI/GUI_module.c

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

Archive Download this file

Revision: 549