Chameleon

Chameleon Svn Source Tree

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

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

Archive Download this file

Revision: 545