Chameleon

Chameleon Svn Source Tree

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

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

Archive Download this file

Revision: 521