Chameleon

Chameleon Svn Source Tree

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

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

Archive Download this file

Revision: 560