Chameleon

Chameleon Commit Details

Date:2010-09-20 04:25:18 (8 years 11 months ago)
Author:Evan Lojewski
Commit:532
Parents: 531
Message:More module changes, temperary hack to disable static variables in modules until I get it fixed.
Changes:
M/branches/meklort/i386/modules/GUI/GUI_module.c
M/branches/meklort/i386/modules/GUI/graphic_utils.c
M/branches/meklort/artwork/themes/embed/theme.plist
M/branches/meklort/i386/boot2/modules.c
M/branches/meklort/i386/boot2/options.c
M/branches/meklort/i386/modules/GUI/gui.c
M/branches/meklort/i386/boot2/modules.h

File differences

branches/meklort/artwork/themes/embed/theme.plist
66
77
88
9
109
1110
12
1311
1412
1513
16
14
1715
1816
1917
2018
2119
2220
23
2421
2522
2623
2724
28
2925
3026
3127
......
3430
3531
3632
37
3833
3934
4035
......
4944
5045
5146
52
5347
5448
5549
......
6660
6761
6862
69
7063
7164
7265
......
8376
8477
8578
86
8779
8880
8981
......
9688
9789
9890
99
10091
10192
10293
......
10596
10697
10798
108
10999
110100
111101
112102
113
114103
115104
116105
<string>Blackosx</string>
<key>Version</key>
<string>1.0</string>
<key>Enabled</key>
<string>no</string>
<key>screen_width</key>
<string>1024</string>
<key>screen_height</key>
<string>768</string>
<string>600</string>
<key>screen_textmargin_h</key>
<string>10</string>
<key>screen_textmargin_v</key>
<string>10</string>
<key>screen_bgcolor</key>
<string>#767f73</string>
<key>background_pos_x</key>
<string>50%</string>
<key>background_pos_y</key>
<string>0</string>
<key>logo_pos_x</key>
<string></string>
<key>logo_pos_y</key>
<string>#000000</string>
<key>logo_transparency</key>
<string>255</string>
<key>devices_pos_x</key>
<string></string>
<key>devices_pos_y</key>
<string>35</string>
<key>devices_layout</key>
<string>horizontal</string>
<key>bootprompt_pos_x</key>
<string></string>
<key>bootprompt_pos_y</key>
<string>#3e3e3e</string>
<key>bootprompt_transparency</key>
<string>1</string>
<key>infobox_pos_x</key>
<string></string>
<key>infobox_pos_y</key>
<string>#3e3e3e</string>
<key>infobox_transparency</key>
<string>35</string>
<key>menu_pos_x</key>
<string></string>
<key>menu_pos_y</key>
<string>#3e3e3e</string>
<key>menu_transparency</key>
<string>1</string>
<key>progressbar_pos_x</key>
<string></string>
<key>progressbar_pos_y</key>
<string>100</string>
<key>progressbar_height</key>
<string>40</string>
<key>countdown_pos_x</key>
<string></string>
<key>countdown_pos_y</key>
<string>-20%</string>
<key>boot_width</key>
<string>1024</string>
<key>boot_height</key>
branches/meklort/i386/boot2/modules.c
545545
546546
547547
548
548549
549550
550551
......
608609
609610
610611
611
612
612613
613614
614615
......
627628
628629
629630
630
631
631632
632633
633634
......
642643
643644
644645
645
646
646647
647648
648649
......
669670
670671
671672
672
673
674
673675
674676
675677
......
835837
836838
837839
838
839
840
841
840
842841
843842
844843
......
867866
868867
869868
870
871
872
873
874
869
870
875871
876872
877873
......
888884
889885
890886
891
892
893
894
895
887
888
896889
897890
898891
......
934927
935928
936929
930
931
937932
938
939
940
941
942
943933
944934
945935
......
956946
957947
958948
959
960
961
949
950
951
952
953
954
955
956
957
958
959
960
962961
963962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
964986
965987
966988
case REBASE_OPCODE_SET_TYPE_IMM:
// Set rebase type (pointer, absolute32, pcrel32)
//printf("Rebase type = 0x%X\n", immediate);
//getc();
// NOTE: This is currently NOT used
type = immediate;
break;
case REBASE_OPCODE_DO_REBASE_IMM_TIMES:
index = 0;
for (index = 0; index < immediate; ++index) {
rebase_location(base + segmentAddress, (char*)base);
rebase_location(base + segmentAddress, (char*)base, type);
segmentAddress += sizeof(void*);
}
break;
index = 0;
for (index = 0; index < tmp; ++index) {
//DBG("\tRebasing 0x%X\n", segmentAddress);
rebase_location(base + segmentAddress, (char*)base);
rebase_location(base + segmentAddress, (char*)base, type);
segmentAddress += sizeof(void*);
}
break;
}
while(rebase_stream[i] & 0x80);
rebase_location(base + segmentAddress, (char*)base);
rebase_location(base + segmentAddress, (char*)base, type);
segmentAddress += tmp + sizeof(void*);
break;
index = 0;
for (index = 0; index < tmp; ++index) {
rebase_location(base + segmentAddress, (char*)base);
rebase_location(base + segmentAddress, (char*)base, type);
segmentAddress += tmp2 + sizeof(void*);
}
{
address = segmentAddress + (UInt32)base;
((char*)address)[0] = (symbolAddr & 0x000000FF) >> 0;
((char*)address)[1] = (symbolAddr & 0x0000FF00) >> 8;
((char*)address)[2] = (symbolAddr & 0x00FF0000) >> 16;
((char*)address)[3] = (symbolAddr & 0xFF000000) >> 24;
bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER);
}
else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0)
{
if(symbolAddr != 0xFFFFFFFF)
{
address = segmentAddress + (UInt32)base;
((char*)address)[0] = (symbolAddr & 0x000000FF) >> 0;
((char*)address)[1] = (symbolAddr & 0x0000FF00) >> 8;
((char*)address)[2] = (symbolAddr & 0x00FF0000) >> 16;
((char*)address)[3] = (symbolAddr & 0xFF000000) >> 24;
bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER);
}
else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0)
{
if(symbolAddr != 0xFFFFFFFF)
{
address = segmentAddress + (UInt32)base;
((char*)address)[0] = (symbolAddr & 0x000000FF) >> 0;
((char*)address)[1] = (symbolAddr & 0x0000FF00) >> 8;
((char*)address)[2] = (symbolAddr & 0x00FF0000) >> 16;
((char*)address)[3] = (symbolAddr & 0xFF000000) >> 24;
bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER);
}
else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0)
{
{
address = segmentAddress + (UInt32)base;
bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER);
((char*)address)[0] = (symbolAddr & 0x000000FF) >> 0;
((char*)address)[1] = (symbolAddr & 0x0000FF00) >> 8;
((char*)address)[2] = (symbolAddr & 0x00FF0000) >> 16;
((char*)address)[3] = (symbolAddr & 0xFF000000) >> 24;
segmentAddress += tmp2 + sizeof(void*);
}
}
}
}
inline void rebase_location(UInt32* location, char* base)
{
*location += (UInt32)base;
inline void rebase_location(UInt32* location, char* base, int type)
{
switch(type)
{
case REBASE_TYPE_POINTER:
case REBASE_TYPE_TEXT_ABSOLUTE32:
*location += (UInt32)base;
break;
default:
break;
}
}
inline void bind_location(UInt32* location, char* value, UInt32 addend, int type)
{
// do actual update
char* newValue = value + addend;
switch (type) {
case BIND_TYPE_POINTER:
case BIND_TYPE_TEXT_ABSOLUTE32:
break;
case BIND_TYPE_TEXT_PCREL32:
newValue -= ((UInt32)location + 4);
break;
default:
return;
}
*location = (UInt32)newValue;
}
/*
* add_symbol
* This function adds a symbol from a module to the list of known symbols
branches/meklort/i386/boot2/modules.h
77
88
99
10
11
12
13
14
15
1016
1117
1218
......
6975
7076
7177
72
78
79
7380
7481
7582
#include <mach-o/loader.h>
#include <mach-o/nlist.h>
// There is a bug with the module system / rebasing / binding
// that causes static variables to be incorrectly rebased or bound
// Disable static variables for the moment
#define static
#ifndef __BOOT_MODULES_H
#define __BOOT_MODULES_H
int execute_hook(const char* name, void*, void*, void*, void*);
void register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*));
inline void rebase_location(UInt32* location, char* base);
inline void rebase_location(UInt32* location, char* base, int type);
inline void bind_location(UInt32* location, char* value, UInt32 addend, int type);
void rebase_macho(void* base, char* rebase_stream, UInt32 size);
void bind_macho(void* base, char* bind_stream, UInt32 size);
branches/meklort/i386/boot2/options.c
10911091
10921092
10931093
1094
1094
10951095
10961096
10971097
//==========================================================================
// Load the help file and display the file contents on the screen.
static void showTextBuffer(char *buf, int size)
void showTextBuffer(char *buf, int size)
{
char*bp;
intline;
branches/meklort/i386/modules/GUI/gui.c
2222
2323
2424
25
25
2626
2727
2828
......
169169
170170
171171
172
173
172
173
174174
175
175
176176
177
177
178178
179
179
180180
181181
182182
......
239239
240240
241241
242
243242
244243
245244
......
250249
251250
252251
252
253253
254254
255255
......
811811
812812
813813
814
814
815815
816816
817817
......
888888
889889
890890
891
892
891
892
893893
894894
895895
......
17121712
17131713
17141714
1715
17151716
1717
17161718
17171719
17181720
1721
17191722
17201723
1724
17211725
1726
17221727
17231728
1729
17241730
17251731
17261732
......
17521758
17531759
17541760
1761
17551762
1756
1763
17571764
1765
17581766
1767
17591768
17601769
17611770
1762
1771
1772
1773
17631774
17641775
17651776
......
18071818
18081819
18091820
1810
1821
18111822
18121823
18131824
#define IMG_REQUIRED -1
#define THEME_NAME_DEFAULT"Default"
static const char *theme_name = THEME_NAME_DEFAULT;
static const char* theme_name = THEME_NAME_DEFAULT;
#ifdef EMBED_THEME
#include "art.h"
void colorFont(font_t *font, uint32_t color);
void makeRoundedCorners(pixmap_t *p);
static int infoMenuSelection = 0;
static int infoMenuItemsCount = sizeof(infoMenuItems)/sizeof(infoMenuItems[0]);
int infoMenuSelection = 0;
int infoMenuItemsCount = sizeof(infoMenuItems)/sizeof(infoMenuItems[0]);
static bool infoMenuNativeBoot = false;
bool infoMenuNativeBoot = false;
static unsigned long screen_params[4] = {DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 32, 0};// here we store the used screen resolution
unsigned long screen_params[4] = {DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 32, 0};// here we store the used screen resolution
static int getImageIndexByName(const char *name)
int getImageIndexByName(const char *name)
{
int i;
for (i = 0; i < sizeof(images) / sizeof(images[0]); i++)
uint16_twidth;
uint16_theight;
uint8_t*imagedata;
if ((strlen(image) + strlen(theme_name) + 20 ) > sizeof(dirspec)) {
return 1;
}
images[i].image = malloc(sizeof(pixmap_t));
}
sprintf(dirspec, "/Extra/Themes/%s/%s.png", theme_name, image);
width = 0;
height = 0;
imagedata = NULL;
if (isSelected)
{
blend(images[iSelection].image, buffer, centeredAt(images[iSelection].image, p));
devicetype++;
devicetype++; // selec override image
}
// draw icon
gui.debug.cursor = pos( 10, 100);
dprintf( &gui.screen, "label %s\n", param->label );
dprintf( &gui.screen, "biosdev 0x%x\n", param->biosdev );
dprintf(&gui.screen, "width %d\n", gui.screen.width);
dprintf(&gui.screen, "height %d\n", gui.screen.height);
dprintf( &gui.screen, "width %d\n", gui.screen.width);
dprintf( &gui.screen, "height %d\n", gui.screen.height);
dprintf( &gui.screen, "type 0x%x\n", param->type );
dprintf( &gui.screen, "flags 0x%x\n", param->flags );
dprintf( &gui.screen, "part_no %d\n", param->part_no );
for ( i = 0, n = iMenuBoot; i < infoMenuItemsCount; i++, n++)
{
if (i == infoMenuSelection)
{
blend(selection, gui.menu.pixmap, position);
}
pbuff = images[n].image;
if (offset && i >= INFOMENU_NATIVEBOOT_START && i <= INFOMENU_NATIVEBOOT_END)
{
blend( images[n + (iMenuHelp - iMenuBoot)].image , gui.menu.pixmap,
pos((position.x + (gui.menu.hborder / 2)), position.y + ((selection->height - pbuff->height) / 2)));
}
else
{
blend( pbuff, gui.menu.pixmap,
pos((position.x + (gui.menu.hborder / 2)), position.y + ((selection->height - pbuff->height) / 2)));
}
drawStr(infoMenuItems[i].text, &font_console, gui.menu.pixmap,
pos(position.x + (pbuff->width + gui.menu.hborder),
if (infoMenuSelection > 0)
{
if(!infoMenuNativeBoot && infoMenuSelection == INFOMENU_NATIVEBOOT_END + 1)
{
infoMenuSelection -= 4;
}
else
{
infoMenuSelection--;
}
drawInfoMenuItems();
updateVRAM();
} else {
}
else
{
gui.menu.draw = false;
gui.redraw = true;
uint16_t bootImageWidth = 0;
uint16_t bootImageHeight = 0;
uint8_t *bootImageData = NULL;
static bool usePngImage = true;
bool usePngImage = true;
//==========================================================================
// loadBootGraphics
branches/meklort/i386/modules/GUI/GUI_module.c
77
88
99
10
11
1012
1113
1214
......
2931
3032
3133
34
3235
3336
3437
......
4548
4649
4750
48
51
52
53
54
4955
5056
5157
......
5561
5662
5763
64
65
66
5867
5968
6069
......
7079
7180
7281
73
82
83
84
85
86
7487
7588
7689
7790
7891
92
7993
8094
8195
8296
8397
84
85
8698
99
100
87101
88102
89103
......
98112
99113
100114
115
116
117
101118
102119
103120
......
206223
207224
208225
226
209227
228
210229
230
211231
232
212233
213234
214235
215236
237
216238
239
217240
241
218242
243
219244
220245
221246
......
275300
276301
277302
278
279
303
304
305
280306
307
281308
282309
283310
......
290317
291318
292319
293
320
294321
295322
296323
......
330357
331358
332359
333
360
334361
335
336
362
363
364
337365
338366
339367
......
369397
370398
371399
400
372401
402
373403
374404
375405
......
380410
381411
382412
413
383414
415
384416
417
385418
419
386420
387421
388422
......
396430
397431
398432
399
433
434
400435
401436
402437
403438
404439
405440
406
407
408
441
442
443
444
445
446
409447
410
448
449
450
411451
412452
413453
414
415
454
455
456
457
458
416459
417
460
461
462
418463
419464
420465
......
426471
427472
428473
429
474
475
430476
431477
432478
......
446492
447493
448494
449
495
496
450497
451
498
499
500
452501
453502
454503
......
462511
463512
464513
465
514
515
466516
467517
468518
......
472522
473523
474524
475
525
526
476527
477
528
529
530
478531
479532
480533
481534
482
535
536
483537
484538
485539
486540
487
541
542
488543
489544
490545
491546
492547
493548
494
549
550
495551
496552
497553
498554
499555
500556
501
557
558
502559
503560
504561
505562
506
563
564
507565
508566
509567
510
568
569
511570
512571
513572
514
573
574
515575
516576
517
577
578
518579
519580
520581
......
524585
525586
526587
527
588
589
528590
529591
530592
531593
532594
533595
534
596
597
535598
536599
537
600
601
602
538603
539604
540605
......
542607
543608
544609
545
610
611
546612
547
613
614
615
548616
549617
550618
......
554622
555623
556624
557
625
626
627
558628
559629
560630
561
631
632
562633
563634
564635
565636
566637
567638
568
639
640
569641
570642
571
643
644
645
572646
573647
574648
575
649
650
576651
577652
578653
579
580
654
655
656
657
581658
582659
583660
......
586663
587664
588665
589
666
667
590668
591669
592670
593671
594
672
673
595674
596675
597
676
677
598678
599679
600680
601681
602682
603
683
684
604685
605686
606
687
688
607689
608690
609691
610692
611
612
693
694
695
696
613697
614698
615
699
700
616701
617702
618703
......
620705
621706
622707
623
708
709
624710
625711
626712
627713
628714
629
715
716
630717
631718
632719
633720
634
721
722
635723
636724
637725
......
639727
640728
641729
642
730
731
732
643733
644734
645735
......
648738
649739
650740
651
652
741
742
743
744
653745
654746
655747
......
661753
662754
663755
664
756
757
665758
666759
667760
......
671764
672765
673766
674
767
768
675769
676770
677771
678772
679
773
774
680775
681776
682777
683
778
779
684780
685
781
782
686783
687784
688785
689
786
787
690788
691789
692790
......
697795
698796
699797
700
701
798
799
800
801
702802
703
803
804
805
704806
705807
706
707
808
809
810
811
812
708813
709
814
815
816
710817
711818
712
819
820
821
713822
714
823
824
825
715826
716
827
828
829
717830
718
719
831
832
833
834
835
720836
721837
722838
723
839
840
841
724842
725843
726844
......
741859
742860
743861
744
862
863
745864
746865
747866
......
758877
759878
760879
761
762
880
881
882
883
763884
764885
765886
......
775896
776897
777898
778
899
900
779901
780902
781903
......
784906
785907
786908
787
909
910
911
788912
789913
790914
......
800924
801925
802926
803
927
928
804929
805930
806931
807932
808933
809
934
935
810936
811937
812938
......
820946
821947
822948
949
823950
951
824952
825
953
954
955
826956
957
958
827959
828960
829961
......
836968
837969
838970
971
839972
973
840974
975
841976
977
842978
843979
844
845
846
847
848
849
850
851
852
853
854
855
856
857
980
981
858982
983
984
985
986
987
988
989
990
991
992
993
859994
860995
861996
......
8651000
8661001
8671002
1003
8681004
1005
8691006
1007
8701008
871
872
873
874
875
876
877
878
879
880
881
882
883
884
8851009
8861010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
8871024
8881025
8891026
......
8941031
8951032
8961033
897
1034
1035
1036
8981037
899
1038
1039
1040
9001041
9011042
9021043
1044
9031045
9041046
9051047
9061048
1049
1050
1051
1052
1053
1054
1055
1056
1057
#include "options.h"
#include "graphic_utils.h"
#include "ramdisk.h"
#include "embedded.h"
#include "picopng.h"
#include "gui.h"
static void GUI_showBootPrompt(int row, bool visible);
static void GUI_showMenu( const MenuItem * items, int count, int selection, int row, int height );
static int GUI_updateMenu( int key, void ** paramPtr );
static void GUI_showHelp(void);
int GUI_printf(const char * fmt, ...);
int GUI_verbose(const char * fmt, ...);
extern char *msgbuf;
extern char *cursor;
/**
** The kernel is about to start, draw the boot graphics if we are not in
** verbose mode.
**/
void GUI_Kernel_Start_hook(void* kernelEntry, void* arg2, void* arg3, void* arg4)
{
if(!gVerboseMode)
}
/**
** A boot option has been selected, disable the graphical elements on screen.
**/
void GUI_PreBoot_hook(void* arg1, void* arg2, void* arg3, void* arg4)
{
// Turn off any GUI elements
}
}
/**
** Module startup code. Replace console only print functions as well as
** replace various menu functions. Finaly, initialize the gui and hook
** into important events.
**/
void GUI_start()
{
replace_function("_initGraphicsMode", &GUI_initGraphicsMode);
replace_function("_getBootOptions", &GUI_getBootOptions);
replace_function("_clearBootArgs", &GUI_clearBootArgs);
replace_function("_showHelp", &GUI_showHelp);
replace_function("_printf", &GUI_printf);
replace_function("_verbose", &GUI_verbose);
replace_function("_error", &GUI_error);
replace_function("_stop", &GUI_stop);
// Start the gui
// Start the gui
useGUI = true;
// Override useGUI default
getBoolForKey(kGUIKey, &useGUI, &bootInfo->bootConfig);
register_hook_callback("PreBoot", &GUI_PreBoot_hook);
}
/**
** Overriden chameleon function. Draws the updated menu.
**/
static int GUI_updateMenu( int key, void ** paramPtr )
{
int moved = 0;
{
case 0x4800: // Up Arrow
if ( gMenuSelection != gMenuTop )
{
draw.f.selectionUp = 1;
}
else if ( gMenuTop > 0 )
{
draw.f.scrollDown = 1;
}
break;
case 0x5000: // Down Arrow
if ( gMenuSelection != gMenuBottom )
{
draw.f.selectionDown = 1;
}
else if ( gMenuBottom < (gMenuItemCount - 1) )
{
draw.f.scrollUp = 1;
}
break;
}
}
printMenuItem( &gMenuItems[gMenuSelection], 1 );
restoreCursor( &cursorState );
} else
}
else
{
drawDeviceList (gMenuStart, gMenuEnd, gMenuSelection);
}
}
static void GUI_showMenu( const MenuItem * items, int count,
int selection, int row, int height )
int selection, int row, int height )
{
int i;
CursorState cursorState;
// Draw the visible items.
if( bootArgs->Video.v_display == GRAPHICS_MODE )
{
drawDeviceList(gMenuStart, gMenuEnd, gMenuSelection);
else {
}
else
{
changeCursor( 0, row, kCursorTypeHidden, &cursorState );
setCursorPosition( x, y, 0 );
putca(' ', 0x07, 1);
} else
{
updateGraphicBootPrompt(kBackspaceKey);
}
*gBootArgsPtr-- = '\0';
}
if ( key >= ' ' && gBootArgsPtr < gBootArgsEnd)
{
if( bootArgs->Video.v_display == VGA_TEXT_MODE )
{
putchar(key); // echo to screen
}
else
{
updateGraphicBootPrompt(key);
}
*gBootArgsPtr++ = key;
}
extern char bootPrompt[];
extern char bootRescanPrompt[];
if( bootArgs->Video.v_display == VGA_TEXT_MODE ) {
if( bootArgs->Video.v_display == VGA_TEXT_MODE )
{
changeCursor( 0, row, kCursorTypeUnderline, 0 );
clearScreenRows( row, kScreenLastRow );
}
clearBootArgs();
if (visible) {
if (bootArgs->Video.v_display == VGA_TEXT_MODE) {
if (gEnableCDROMRescan) {
if (visible)
{
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
{
if (gEnableCDROMRescan)
{
printf( bootRescanPrompt );
} else {
}
else
{
printf( bootPrompt );
}
}
} else {
if (bootArgs->Video.v_display == GRAPHICS_MODE) {
}
else
{
if (bootArgs->Video.v_display == GRAPHICS_MODE)
{
clearGraphicBootPrompt();
} else {
}
else
{
printf("Press Enter to start up the foreign OS. ");
}
}
gBootArgsPtr = gBootArgs;
memset(gBootArgs, '\0', BOOT_STRING_LEN);
if (bootArgs->Video.v_display == GRAPHICS_MODE) {
if (bootArgs->Video.v_display == GRAPHICS_MODE)
{
clearGraphicBootPrompt();
}
}
// Initialize default menu selection entry.
gBootVolume = menuBVR = selectBootVolume(bvChain);
if (biosDevIsCDROM(gBIOSDev)) {
if (biosDevIsCDROM(gBIOSDev))
{
isCDROM = true;
} else {
}
else
{
isCDROM = false;
}
clearBootArgs();
// Allow user to override default timeout.
if (!getIntForKey(kTimeoutKey, &timeout, &bootInfo->bootConfig)) {
if (!getIntForKey(kTimeoutKey, &timeout, &bootInfo->bootConfig))
{
/* If there is no timeout key in the file use the default timeout
which is different for CDs vs. hard disks. However, if not booting
a CD and no config file could be loaded set the timeout
If some partitions are found, for example a Windows partition, then
these will be displayed in the menu as foreign partitions.
*/
if (isCDROM) {
if (isCDROM)
{
timeout = kCDBootTimeout;
} else {
}
else
{
timeout = sysConfigValid ? kBootTimeout : 0;
}
}
if (timeout < 0) {
if (timeout < 0)
{
gBootMode |= kBootModeQuiet;
}
// If the user is holding down a modifier key, enter safe mode.
if ((readKeyboardShiftFlags() & 0x0F) != 0) {
if ((readKeyboardShiftFlags() & 0x0F) != 0)
{
//gBootMode |= kBootModeSafe;
}
// Checking user pressed keys
bool f8press = false, spress = false, vpress = false;
while (readKeyboardStatus()) {
while (readKeyboardStatus())
{
key = bgetc ();
if (key == 0x4200) f8press = true;
if ((key & 0xff) == 's' || (key & 0xff) == 'S') spress = true;
if ((key & 0xff) == 'v' || (key & 0xff) == 'V') vpress = true;
}
// If user typed F8, abort quiet mode, and display the menu.
if (f8press) {
if (f8press)
{
gBootMode &= ~kBootModeQuiet;
timeout = 0;
}
// If user typed 'v' or 'V', boot in verbose mode.
if ((gBootMode & kBootModeQuiet) && firstRun && vpress) {
if ((gBootMode & kBootModeQuiet) && firstRun && vpress)
{
addBootArg(kVerboseModeFlag);
}
// If user typed 's' or 'S', boot in single user mode.
if ((gBootMode & kBootModeQuiet) && firstRun && spress) {
if ((gBootMode & kBootModeQuiet) && firstRun && spress)
{
addBootArg(kSingleUserModeFlag);
}
if (bootArgs->Video.v_display == VGA_TEXT_MODE) {
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
{
setCursorPosition(0, 0, 0);
clearScreenRows(0, kScreenLastRow);
if (!(gBootMode & kBootModeQuiet)) {
if (!(gBootMode & kBootModeQuiet))
{
// Display banner and show hardware info.
printf(bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024);
printf(getVBEInfoString());
}
// When booting from CD, default to hard drive boot when possible.
if (isCDROM && firstRun) {
if (isCDROM && firstRun)
{
const char *val;
char *prompt = NULL;
char *name = NULL;
int cnt;
int optionKey;
if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->bootConfig)) {
if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->bootConfig))
{
prompt = malloc(cnt + 1);
strncat(prompt, val, cnt);
} else {
}
else
{
name = malloc(80);
getBootVolumeDescription(gBootVolume, name, 79, false);
prompt = malloc(256);
free(name);
}
if (getIntForKey( kCDROMOptionKey, &optionKey, &bootInfo->bootConfig )) {
if (getIntForKey( kCDROMOptionKey, &optionKey, &bootInfo->bootConfig ))
{
// The key specified is a special key.
} else {
}
else
{
// Default to F8.
optionKey = 0x4200;
}
// which we ought to interpret as meaning he wants to boot the CD.
if (timeout != 0) {
key = GUI_countdown(prompt, kMenuTopRow, timeout);
} else {
}
else
{
key = optionKey;
}
if (prompt != NULL) {
if (prompt != NULL)
{
free(prompt);
}
clearScreenRows( kMenuTopRow, kMenuTopRow + 2 );
// Hit the option key ?
if (key == optionKey) {
if (key == optionKey)
{
gBootMode &= ~kBootModeQuiet;
timeout = 0;
} else {
}
else
{
key = key & 0xFF;
// Try booting hard disk if user pressed 'h'
if (biosDevIsCDROM(gBIOSDev) && key == 'h') {
if (biosDevIsCDROM(gBIOSDev) && key == 'h')
{
BVRef bvr;
// Look at partitions hosting OS X other than the CD-ROM
for (bvr = bvChain; bvr; bvr=bvr->next) {
if ((bvr->flags & kBVFlagSystemVolume) && bvr->biosdev != gBIOSDev) {
for (bvr = bvChain; bvr; bvr=bvr->next)
{
if ((bvr->flags & kBVFlagSystemVolume) && bvr->biosdev != gBIOSDev)
{
gBootVolume = bvr;
}
}
}
}
if (gBootMode & kBootModeQuiet) {
if (gBootMode & kBootModeQuiet)
{
// No input allowed from user.
goto done;
}
if (firstRun && timeout > 0 && GUI_countdown("Press any key to enter startup options.", kMenuTopRow, timeout) == 0) {
if (firstRun && timeout > 0 && GUI_countdown("Press any key to enter startup options.", kMenuTopRow, timeout) == 0)
{
// If the user is holding down a modifier key,
// enter safe mode.
if ((readKeyboardShiftFlags() & 0x0F) != 0) {
if ((readKeyboardShiftFlags() & 0x0F) != 0)
{
gBootMode |= kBootModeSafe;
}
goto done;
}
if (gDeviceCount) {
if (gDeviceCount)
{
// Allocate memory for an array of menu items.
menuItems = malloc(sizeof(MenuItem) * gDeviceCount);
if (menuItems == NULL) {
if (menuItems == NULL)
{
goto done;
}
// Associate a menu item for each BVRef.
for (bvr=bvChain, i=gDeviceCount-1, selectIndex=0; bvr; bvr=bvr->next) {
if (bvr->visible) {
for (bvr=bvChain, i=gDeviceCount-1, selectIndex=0; bvr; bvr=bvr->next)
{
if (bvr->visible)
{
getBootVolumeDescription(bvr, menuItems[i].name, sizeof(menuItems[i].name) - 1, true);
menuItems[i].param = (void *) bvr;
if (bvr == menuBVR) {
if (bvr == menuBVR)
{
selectIndex = i;
}
i--;
}
}
if (bootArgs->Video.v_display == GRAPHICS_MODE) {
if (bootArgs->Video.v_display == GRAPHICS_MODE)
{
// redraw the background buffer
gui.logo.draw = true;
drawBackground();
gui.devicelist.draw = true;
gui.redraw = true;
if (!(gBootMode & kBootModeQuiet)) {
if (!(gBootMode & kBootModeQuiet))
{
bool showBootBanner = true;
// Check if "Boot Banner"=N switch is present in config file.
getBoolForKey(kBootBannerKey, &showBootBanner, &bootInfo->bootConfig);
if (showBootBanner) {
if (showBootBanner)
{
// Display banner and show hardware info.
gprintf(&gui.screen, bootBanner + 1, (bootInfo->convmem + bootInfo->extmem) / 1024);
}
// redraw background
memcpy(gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4);
}
} else {
}
else
{
// Clear screen and hide the blinking cursor.
clearScreenRows(kMenuTopRow, kMenuTopRow + 2);
changeCursor(0, kMenuTopRow, kCursorTypeHidden, 0);
nextRow = kMenuTopRow;
showPrompt = true;
if (gDeviceCount) {
if( bootArgs->Video.v_display == VGA_TEXT_MODE ) {
if (gDeviceCount)
{
if( bootArgs->Video.v_display == VGA_TEXT_MODE )
{
printf("Use \30\31 keys to select the startup volume.");
}
GUI_showMenu( menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems );
GUI_showBootPrompt( nextRow, showPrompt );
do {
if (bootArgs->Video.v_display == GRAPHICS_MODE) {
if (bootArgs->Video.v_display == GRAPHICS_MODE)
{
// redraw background
memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 );
// reset cursor co-ords
GUI_updateMenu( key, (void **) &menuBVR );
newShowPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);
if (newShowPrompt != showPrompt) {
if (newShowPrompt != showPrompt)
{
showPrompt = newShowPrompt;
GUI_showBootPrompt( nextRow, showPrompt );
}
if (showPrompt) {
if (showPrompt)
{
GUI_updateBootArgs(key);
}
switch (key) {
switch (key)
{
case kReturnKey:
if (gui.menu.draw) {
if (gui.menu.draw)
{
key=0;
break;
}
if (*gBootArgs == '?') {
if (*gBootArgs == '?')
{
char * argPtr = gBootArgs;
// Skip the leading "?" character.
/*
* TODO: this needs to be refactored.
*/
if (strcmp( booterCommand, "video" ) == 0) {
if (bootArgs->Video.v_display == GRAPHICS_MODE) {
if (strcmp( booterCommand, "video" ) == 0)
{
if (bootArgs->Video.v_display == GRAPHICS_MODE)
{
showInfoBox(getVBEInfoString(), getVBEModeInfoString());
} else {
}
else
{
printVBEModeInfo();
}
} else if ( strcmp( booterCommand, "memory" ) == 0) {
if (bootArgs->Video.v_display == GRAPHICS_MODE ) {
}
else if ( strcmp( booterCommand, "memory" ) == 0)
{
if (bootArgs->Video.v_display == GRAPHICS_MODE )
{
showInfoBox("Memory Map", getMemoryInfoString());
} else {
}
else
{
printMemoryInfo();
}
} else if (strcmp(booterCommand, "lspci") == 0) {
}
else if (strcmp(booterCommand, "lspci") == 0)
{
lspci();
} else if (strcmp(booterCommand, "more") == 0) {
}
else if (strcmp(booterCommand, "more") == 0)
{
showTextFile(booterParam);
} else if (strcmp(booterCommand, "rd") == 0) {
}
else if (strcmp(booterCommand, "rd") == 0)
{
processRAMDiskCommand(&argPtr, booterParam);
} else if (strcmp(booterCommand, "norescan") == 0) {
if (gEnableCDROMRescan) {
}
else if (strcmp(booterCommand, "norescan") == 0)
{
if (gEnableCDROMRescan)
{
gEnableCDROMRescan = false;
break;
}
} else {
}
else
{
showHelp();
}
key = 0;
// Clear gBootVolume to restart the loop
// if the user enabled rescanning the optical drive.
// Otherwise boot the default boot volume.
if (gEnableCDROMRescan) {
if (gEnableCDROMRescan)
{
gBootVolume = NULL;
clearBootArgs();
}
// New behavior:
// Switch between text & graphic interfaces
// Only Permitted if started in graphics interface
if (useGUI) {
if (bootArgs->Video.v_display == GRAPHICS_MODE) {
if (useGUI)
{
if (bootArgs->Video.v_display == GRAPHICS_MODE)
{
setVideoMode(VGA_TEXT_MODE, 0);
setCursorPosition(0, 0, 0);
nextRow = kMenuTopRow;
showPrompt = true;
if (gDeviceCount) {
if (gDeviceCount)
{
printf("Use \30\31 keys to select the startup volume.");
GUI_showMenu(menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems);
nextRow += min(gDeviceCount, kMenuMaxItems) + 3;
showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);
GUI_showBootPrompt(nextRow, showPrompt);
//changeCursor( 0, kMenuTopRow, kCursorTypeUnderline, 0 );
} else {
}
else
{
gui.redraw = true;
setVideoMode(GRAPHICS_MODE, 0);
updateVRAM();
} while (0 == key);
done:
if (bootArgs->Video.v_display == VGA_TEXT_MODE) {
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
{
clearScreenRows(kMenuTopRow, kScreenLastRow);
changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0);
}
shouldboot = false;
gui.menu.draw = false;
if (menuItems) {
if (menuItems)
{
free(menuItems);
menuItems = NULL;
}
va_list ap;
gErrors = true;
va_start(ap, fmt);
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
{
prf(fmt, ap, putchar, 0);
else
}
else
{
vprf(fmt, ap);
}
va_end(ap);
return(0);
}
if (gVerboseMode)
{
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
{
prf(fmt, ap, putchar, 0);
}
else
{
vprf(fmt, ap);
}
}
{
/* Kabyl: BooterLog */
struct putc_info pi;
if (!msgbuf)
return 0;
if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))
return 0;
pi.str = cursor;
pi.last_str = 0;
prf(fmt, ap, sputc, &pi);
cursor += strlen((char *)cursor);
}
/* Kabyl: BooterLog */
struct putc_info pi;
if (!msgbuf)
return 0;
if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))
return 0;
pi.str = cursor;
pi.last_str = 0;
prf(fmt, ap, sputc, &pi);
cursor += strlen((char *)cursor);
va_end(ap);
return(0);
}
va_list ap;
va_start(ap, fmt);
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
{
prf(fmt, ap, putchar, 0);
}
else
{
vprf(fmt, ap);
{
/* Kabyl: BooterLog */
struct putc_info pi;
if (!msgbuf)
return 0;
if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))
return 0;
pi.str = cursor;
pi.last_str = 0;
prf(fmt, ap, sputc, &pi);
cursor += strlen((char *)cursor);
}
/* Kabyl: BooterLog */
struct putc_info pi;
if (!msgbuf)
return 0;
if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))
return 0;
pi.str = cursor;
pi.last_str = 0;
prf(fmt, ap, sputc, &pi);
cursor += strlen((char *)cursor);
va_end(ap);
return 0;
}
printf("\n");
va_start(ap, fmt);
if (bootArgs->Video.v_display == VGA_TEXT_MODE) {
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
{
prf(fmt, ap, putchar, 0);
} else {
}
else
{
vprf(fmt, ap);
}
va_end(ap);
printf("\nThis is a non recoverable error! System HALTED!!!");
halt();
while (1);
}
void GUI_showHelp(void)
{
if (bootArgs->Video.v_display == GRAPHICS_MODE) {
showInfoBox("Help. Press q to quit.\n", (char *)BootHelp_txt);
} else {
showTextBuffer((char *)BootHelp_txt, BootHelp_txt_len);
}
}
branches/meklort/i386/modules/GUI/graphic_utils.c
11
2
3
4
5
2
3
4
5
66
77
88
99
1010
11
12
11
12
1313
1414
1515
......
1717
1818
1919
20
21
20
21
22
23
2224
23
24
25
26
27
28
29
30
31
32
33
34
35
36
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
3740
3841
3942
/* Graphic utility functions and data types
* Prashant Vaibhav (C) 12/12/2008
* Chameleon
*/
/* Graphic utility functions and data types
* Prashant Vaibhav (C) 12/12/2008
* Chameleon
*/
#include "boot.h"
#include "graphic_utils.h"
#include "gui.h"
void blend( const pixmap_t *blendThis, // Source image
pixmap_t *blendInto, // Dest image
const position_t position) // Where to place the source image
pixmap_t *blendInto, // Dest image
const position_t position) // Where to place the source image
{
uint16_t sx, sy, dx, dy;
uint32_t dstrb, dstag, srcrb, srcag, drb, dag, rb, ag, alpha;
uint16_t width = (blendThis->width + position.x < blendInto->width) ? blendThis->width: blendInto->width-position.x;
uint16_t height = (blendThis->height + position.y < blendInto->height) ? blendThis->height: blendInto->height-position.y;
for (dy = position.y, sy = 0; sy < height; dy++, sy++) {
for (dx = position.x, sx = 0; sx < width; dx++, sx++) {
for (dy = position.y, sy = 0; sy < height; dy++, sy++)
{
for (dx = position.x, sx = 0; sx < width; dx++, sx++)
{
alpha = (pixel(blendThis, sx, sy).ch.a);
/* Skip blending for fully transparent pixel */
if (alpha == 0) continue;
/* For fully opaque pixel, there is no need to interpolate */
if (alpha == 255) {
pixel(blendInto, dx, dy).value = pixel(blendThis, sx, sy).value;
continue;
}
/* For semi-transparent pixels, do a full blend */
//alpha++
/* This is needed to spread the alpha over [0..256] instead of [0..255]
Boundary conditions were handled above */
/* Skip blending for fully transparent pixel */
if (alpha == 0) continue;
/* For fully opaque pixel, there is no need to interpolate */
if (alpha == 255)
{
pixel(blendInto, dx, dy).value = pixel(blendThis, sx, sy).value;
continue;
}
/* For semi-transparent pixels, do a full blend */
//alpha++
/* This is needed to spread the alpha over [0..256] instead of [0..255]
Boundary conditions were handled above */
dstrb = pixel(blendInto, dx, dy).value & 0xFF00FF;
dstag = (pixel(blendInto, dx, dy).value >> 8) & 0xFF00FF;
srcrb = pixel(blendThis, sx, sy).value & 0xFF00FF;

Archive Download the corresponding diff file

Revision: 532