Chameleon

Chameleon Svn Source Tree

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

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

Archive Download this file

Revision: 538