Chameleon

Chameleon Commit Details

Date:2014-01-14 23:44:48 (5 years 6 months ago)
Author:ErmaC
Commit:2340
Parents: 2339
Message:Update Bungo's branch (sync with main trunk) and apply SMBIOS improvements
Changes:
M/branches/Bungo/i386/libsaio/ati.c
M/branches/Bungo/i386/libsaio/sys.c
M/branches/Bungo/i386/libsaio/pci_root.c
M/branches/Bungo/i386/libsaio/befs.c
M/branches/Bungo/i386/libsaio/biosfn.c
M/branches/Bungo/i386/boot2/drivers.c
M/branches/Bungo/i386/libsaio/saio_types.h
M/branches/Bungo/i386/libsaio/cpu.c
M/branches/Bungo/i386/libsaio/smbios_getters.c
M/branches/Bungo/i386/libsaio/openbsd.c
M/branches/Bungo/i386/libsaio/smbios_getters.h
M/branches/Bungo/i386/libsa/prf.c
M/branches/Bungo/i386/libsaio/openbsd.h
M/branches/Bungo/i386/klibc/strlcpy.c
M/branches/Bungo/i386/libsa/efi_tables.c
M/branches/Bungo/i386/boot2/boot2.s
M/branches/Bungo/i386/libsaio/dram_controllers.c
M/branches/Bungo/i386/libsa/printf.c
M/branches/Bungo/i386/libsaio/ntfs.c
M/branches/Bungo/i386/libsaio/ext2fs.c
M/branches/Bungo/i386/boot2/modules.c
M/branches/Bungo/i386/libsaio/pci.c
M/branches/Bungo/i386/libsaio/bootstruct.h
M/branches/Bungo/i386/libsaio/stringTable.c
M/branches/Bungo/i386/libsaio/load.c
M/branches/Bungo/i386/libsaio/freebsd.h
M/branches/Bungo/i386/libsaio/aml_generator.c
M/branches/Bungo/i386/libsaio/convert.c
M/branches/Bungo/i386/boot2/modules.h
M/branches/Bungo/i386/libsaio/pci.h
M/branches/Bungo/i386/libsaio/platform.c
M/branches/Bungo/i386/libsaio/aml_generator.h
M/branches/Bungo/i386/boot2/gui.c
M/branches/Bungo/i386/libsaio/platform.h
M/branches/Bungo/i386/config/lex.zconf.c
M/branches/Bungo/i386/libsaio/disk.c
M/branches/Bungo/i386/libsaio/device_inject.c
M/branches/Bungo/i386/boot2/ramdisk.c
M/branches/Bungo/i386/libsaio/xml.c
M/branches/Bungo/i386/libsaio/asm.s
M/branches/Bungo/i386/libsaio/device_inject.h
M/branches/Bungo/i386/boot2/picopng.c
M/branches/Bungo/i386/config/confdata.c
M/branches/Bungo/i386/libsaio/console.c
M/branches/Bungo/i386/boot2/graphics.c
M/branches/Bungo/doc/BootHelp.txt
M/branches/Bungo/i386/libsaio/fdisk.h
M/branches/Bungo/i386/libsaio/base64-decode.c
M/branches/Bungo/i386/libsaio/xml.h
M/branches/Bungo/i386/libsaio/efi.h
M/branches/Bungo/CHANGES
M/branches/Bungo/i386/libsaio/vbe.c
M/branches/Bungo/i386/libsaio/device_tree.c
M/branches/Bungo/i386/libsaio/hfs.c
M/branches/Bungo/i386/libsaio/vbe.h
M/branches/Bungo/i386/libsaio/device_tree.h
M/branches/Bungo/i386/libsaio/memvendors.h
M/branches/Bungo/i386/libsa/memory.h
M/branches/Bungo/i386/libsaio/hfs_compare.c
M/branches/Bungo/i386/libsaio/spd.c
M/branches/Bungo/i386/config/symbol.c
M/branches/Bungo/i386/libsaio/md5c.c
M/branches/Bungo/i386/libsaio/fake_efi.c
M/branches/Bungo/i386/libsa/zalloc.c
M/branches/Bungo/i386/libsaio/smbios_decode.c
M/branches/Bungo/i386/libsaio/cache.c
M/branches/Bungo/i386/libsaio/gma.c
M/branches/Bungo/i386/boot2/boot.c
M/branches/Bungo/i386/libsa/libsa.h
M/branches/Bungo/i386/libsaio/nvidia_helper.c
M/branches/Bungo/i386/libsaio/nvidia.c
M/branches/Bungo/i386/boot2/boot.h
M/branches/Bungo/i386/libsa/string.c
M/branches/Bungo/i386/libsaio/nvidia.h
M/branches/Bungo/i386/libsaio/acpi_patcher.c
M/branches/Bungo/i386/libsaio/sl.h
M/branches/Bungo/i386/libsaio/allocate.c
M/branches/Bungo/i386/libsaio/msdos.c
M/branches/Bungo/i386/libsaio/bootargs.h
M/branches/Bungo/i386/modules/Keylayout/layouts/cham-mklayout.c
M/branches/Bungo/i386/libsaio/saio_internal.h
M/branches/Bungo/i386/libsaio/hda.c
M/branches/Bungo/i386/libsaio/smbios.c
M/branches/Bungo/i386/boot2/options.c
M/branches/Bungo/i386/libsaio/smbios.h
M/branches/Bungo/i386/libsaio/bios.h

File differences

branches/Bungo/i386/libsaio/smbios_getters.h
1010
1111
1212
13
13
1414
1515
1616
#define SMBIOS_RANGE_START 0x000F0000
#define SMBIOS_RANGE_END 0x000FFFFF
#define NOT_AVAILABLE"N/A"
#define NOT_AVAILABLE"N/A"
typedef enum
{
branches/Bungo/i386/libsaio/xml.c
6767
6868
6969
70
71
70
7271
7372
7473
......
7877
7978
8079
81
82
80
8381
8482
8583
......
9088
9189
9290
93
94
91
9592
9693
9794
......
103100
104101
105102
106
107
103
108104
109105
110106
......
134130
135131
136132
137
133
138134
139
140
141
142
143
144
145
146
147
135
136
137
138
139
140
141
142
143
144
148145
149146
150147
......
153150
154151
155152
156
157153
158154
159155
......
354350
355351
356352
357
353
354
358355
359356
360357
......
365362
366363
367364
368
369
365
370366
371367
372368
......
375371
376372
377373
378
379
380
374
381375
382
383
384
376
385377
386378
387379
388
389
380
390381
391382
392383
393384
394
395
385
396386
397
398
399
387
400388
401
402
389
403390
404391
405392
406393
407394
408395
409
410
411
412
396
397
413398
414
415
416
399
417400
418401
419402
......
422405
423406
424407
425
426
427
408
428409
429410
430411
431412
432413
433414
434
435
436
437
415
416
438417
439
440
441
418
442419
443420
444421
......
460437
461438
462439
463
464
440
465441
466
467
468
469
470
442
443
471444
472445
473446
474447
475448
476449
477
478
479
480
450
451
481452
482
483
484
453
485454
486455
487456
......
490459
491460
492461
493
494
495
462
496463
497464
498465
499466
500467
501468
502
503
504
505
469
470
506471
507
508
509
472
510473
511474
512475
......
520483
521484
522485
523
486
524487
525488
526489
527490
528
529
530
491
531492
532493
533494
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548495
549
550
551
552
553
554496
555497
556
557
498
558499
559500
501
560502
561
562
503
563504
564505
565506
566
567
568
569
507
508
509
510
511
512
513
514
515
516
517
518
519
570520
571
572
521
522
523
524
525
526
573527
574528
575
576
529
530
531
577532
578533
579534
580535
581
582
536
583537
584538
585539
......
595549
596550
597551
598
552
553
599554
600555
601556
......
603558
604559
605560
606
607
608
609
561
562
610563
611564
612565
......
622575
623576
624577
625
626
578
627579
628580
629581
630582
631583
632584
633
634
585
635586
636587
637588
......
650601
651602
652603
653
604
605
654606
655607
656608
......
693645
694646
695647
696
648
649
697650
698651
699652
......
727680
728681
729682
730
683
684
731685
732686
733687
734688
735689
736690
737
691
738692
739693
740694
......
752706
753707
754708
755
709
710
711
756712
757713
758
759714
715
716
717
760718
761719
762
763
720
764721
765
766
767
768
722
723
724
769725
770
771
772
726
773727
774
775
776
777
778
779
780
728
729
730
781731
782732
783733
784734
785735
786736
787
788
789
790
791
737
738
792739
793740
794741
795742
796743
797
798
799
800
801
802
744
745
746
803747
804748
805749
806750
807
751
808752
809753
810754
811755
812
756
813757
758
814759
815760
816761
......
827772
828773
829774
830
775
776
831777
832778
833779
......
858804
859805
860806
861
807
808
862809
863810
864811
......
886833
887834
888835
889
836
837
890838
891839
892840
......
907855
908856
909857
910
858
859
911860
912861
913862
914
863
864
865
915866
916
867
917868
918869
919
870
871
872
920873
921874
922875
923
876
877
878
924879
925880
926881
927882
928
883
884
885
929886
930887
931888
......
1001958
1002959
1003960
1004
1005
961
1006962
1007963
1008964
1009
1010
965
1011966
1012967
1013968
......
1044999
10451000
10461001
1047
1002
1003
10481004
10491005
10501006
......
10531009
10541010
10551011
1056
1057
1012
10581013
1059
1060
1014
10611015
10621016
10631017
......
10731027
10741028
10751029
1076
1077
1030
10781031
10791032
10801033
......
10851038
10861039
10871040
1088
1041
1042
10891043
10901044
10911045
10921046
10931047
10941048
1095
1096
1049
10971050
10981051
10991052
11001053
11011054
11021055
1103
1104
1056
11051057
11061058
11071059
11081060
1109
1110
1061
11111062
1112
1113
1114
1063
11151064
11161065
11171066
......
11231072
11241073
11251074
1126
1075
1076
11271077
11281078
11291079
11301080
11311081
11321082
1133
1134
1135
1136
1083
1084
11371085
11381086
11391087
......
11411089
11421090
11431091
1144
1145
1092
11461093
11471094
11481095
......
11511098
11521099
11531100
1154
1155
1101
11561102
11571103
11581104
......
11661112
11671113
11681114
1169
1170
1115
11711116
11721117
1173
1174
1175
1118
11761119
1177
1178
1179
1120
11801121
11811122
11821123
......
11931134
11941135
11951136
1196
1197
1137
11981138
11991139
1200
1201
1202
1140
12031141
1204
1205
1206
1142
12071143
12081144
12091145
......
12151151
12161152
12171153
1218
1219
1154
12201155
12211156
12221157
1223
1224
1158
12251159
12261160
12271161
......
12301164
12311165
12321166
1233
1234
1167
12351168
12361169
12371170
1238
1239
1171
12401172
12411173
12421174
......
12471179
12481180
12491181
1250
1251
1182
12521183
1253
1254
1255
1184
12561185
12571186
12581187
......
12641193
12651194
12661195
1267
1268
1196
12691197
12701198
1271
1272
1273
1199
12741200
12751201
1276
12771202
12781203
12791204
......
12841209
12851210
12861211
1287
1288
1212
12891213
12901214
12911215
1292
1293
1216
12941217
12951218
1296
12971219
12981220
12991221
13001222
13011223
1302
1303
1224
13041225
13051226
13061227
......
13081229
13091230
13101231
1311
1312
1232
13131233
13141234
1315
1235
13161236
1317
1318
1237
13191238
13201239
13211240
1322
1241
13231242
13241243
13251244
13261245
13271246
1328
1247
13291248
1330
1331
1249
13321250
13331251
13341252
13351253
13361254
1337
1338
1255
13391256
13401257
13411258
return "";
}
struct Module
{
struct Module {
struct Module *nextModule;
longwillLoad;
TagPtrdict;
};
typedef struct Module Module, *ModulePtr;
struct DriverInfo
{
struct DriverInfo {
char*plistAddr;
longplistLength;
void*moduleAddr;
#define kDriverPackageSignature1 'MKXT'
#define kDriverPackageSignature2 'MOSX'
struct DriversPackage
{
struct DriversPackage {
unsigned long signature1;
unsigned long signature2;
unsigned long length;
};
typedef struct DriversPackage DriversPackage;
enum
{
enum {
kCFBundleType2,
kCFBundleType3
};
TagPtr
XMLGetProperty(TagPtr dict, const char * key)
{
TagPtr tagList, tag;
TagPtr tagList, tag;
if (dict->type != kTagTypeDict) return 0;
tag = 0;
tagList = dict->tag;
while (tagList)
{
tag = tagList;
tagList = tag->tagNext;
if (dict->type != kTagTypeDict) {
return 0;
}
tag = 0;
tagList = dict->tag;
while (tagList) {
tag = tagList;
tagList = tag->tagNext;
if ((tag->type != kTagTypeKey) || (tag->string == 0)) {
continue;
}
return tag->tag;
}
}
return 0;
}
//==========================================================================
// ParseNextTag
// TODO: cleanup
long XMLParseNextTag( char * buffer, TagPtr * tag )
long
XMLParseNextTag( char * buffer, TagPtr * tag )
{
long length, pos;
char * tagName;
}
pos = length;
if (!strncmp(tagName, kXMLTagPList, 6))
{
if (!strncmp(tagName, kXMLTagPList, 6)) {
length = 0;
// just a header; nothing to parse
// return-via-reference tag should be left alone
else if (!strcmp(tagName, kXMLTagDict))
{
length = ParseTagList(buffer + pos, tag, kTagTypeDict, 0);
}
else if (!strncmp(tagName, kXMLTagDict, strlen(kXMLTagDict)) && tagName[strlen(tagName)-1] == '/')
{
} else if (!strncmp(tagName, kXMLTagDict, strlen(kXMLTagDict)) && tagName[strlen(tagName)-1] == '/') {
length = ParseTagList(buffer + pos, tag, kTagTypeDict, 1);
}
else if (!strncmp(tagName, kXMLTagDict " ", strlen(kXMLTagDict " ")))
{
} else if (!strncmp(tagName, kXMLTagDict " ", strlen(kXMLTagDict " "))) {
length = ParseTagList(buffer + pos, tag, kTagTypeDict, 0);
}
/***** key ****/
else if (!strcmp(tagName, kXMLTagKey))
{
else if (!strcmp(tagName, kXMLTagKey)) {
length = ParseTagKey(buffer + pos, tag);
}
/***** string ****/
else if (!strcmp(tagName, kXMLTagString))
{
else if (!strcmp(tagName, kXMLTagString)) {
length = ParseTagString(buffer + pos, tag);
}
else if (!strncmp(tagName, kXMLTagString " ", strlen(kXMLTagString " ")))
{
} else if (!strncmp(tagName, kXMLTagString " ", strlen(kXMLTagString " "))) {
// TODO: save tag if if found
if(!strncmp(tagName + strlen(kXMLTagString " "), kXMLStringID, strlen(kXMLStringID)))
{
if(!strncmp(tagName + strlen(kXMLTagString " "), kXMLStringID, strlen(kXMLStringID))) {
// ID=
int id = 0;
int cnt = strlen(kXMLTagString " " kXMLStringID "\"") + 1;
while ((tagName[cnt] != '\0') && (tagName[cnt] != '"')) cnt++;
tagName[cnt] = 0;
char* val = tagName + strlen(kXMLTagString " " kXMLStringID "\"");
while(*val)
{
if ((*val >= '0' && *val <= '9'))// 0 - 9
{
while(*val) {
if ((*val >= '0' && *val <= '9')) { // 0 - 9
id = (id * 10) + (*val++ - '0');
}
else
{
} else {
printf("ParseStringID error (0x%x)\n", *val);
getchar();
return -1;
length = ParseTagString(buffer + pos, tag);
SaveRefString(buffer + pos, id);
}
else if(!strncmp(tagName + strlen(kXMLTagString " "), kXMLStringIDRef, strlen(kXMLStringIDRef)))
{
} else if(!strncmp(tagName + strlen(kXMLTagString " "), kXMLStringIDRef, strlen(kXMLStringIDRef))) {
// IDREF=
int id = 0;
int cnt = strlen(kXMLTagString " " kXMLStringIDRef "\"") + 1;
while ((tagName[cnt] != '\0') && (tagName[cnt] != '"')) cnt++;
tagName[cnt] = 0;
char* val = tagName + strlen(kXMLTagString " " kXMLStringIDRef "\"");
while(*val)
{
if ((*val >= '0' && *val <= '9'))// 0 - 9
{
while(*val) {
if ((*val >= '0' && *val <= '9')) { // 0 - 9
id = (id * 10) + (*val++ - '0');
}
else
{
} else {
printf("ParseStringIDREF error (0x%x)\n", *val);
getchar();
return -1;
}
/***** integer ****/
else if (!strcmp(tagName, kXMLTagInteger))
{
else if (!strcmp(tagName, kXMLTagInteger)) {
length = ParseTagInteger(buffer + pos, tag);
}
else if (!strncmp(tagName, kXMLTagInteger " ", strlen(kXMLTagInteger " ")))
{
if(!strncmp(tagName + strlen(kXMLTagInteger " "), kXMLStringID, strlen(kXMLStringID)))
{
} else if (!strncmp(tagName, kXMLTagInteger " ", strlen(kXMLTagInteger " "))) {
if(!strncmp(tagName + strlen(kXMLTagInteger " "), kXMLStringID, strlen(kXMLStringID))) {
// ID=
int id = 0;
int cnt = strlen(kXMLTagInteger " " kXMLStringID "\"") + 1;
while ((tagName[cnt] != '\0') && (tagName[cnt] != '"')) cnt++;
tagName[cnt] = 0;
char* val = tagName + strlen(kXMLTagInteger " " kXMLStringID "\"");
while(*val)
{
if ((*val >= '0' && *val <= '9'))// 0 - 9
{
while(*val) {
if ((*val >= '0' && *val <= '9')) { // 0 - 9
id = (id * 10) + (*val++ - '0');
}
else
{
} else {
printf("ParseIntegerID error (0x%x)\n", *val);
getchar();
return -1;
length = ParseTagInteger(buffer + pos, tag);
SaveRefString((*tag)->string, id);
}
else if(!strncmp(tagName + strlen(kXMLTagInteger " "), kXMLStringIDRef, strlen(kXMLStringIDRef)))
{
} else if(!strncmp(tagName + strlen(kXMLTagInteger " "), kXMLStringIDRef, strlen(kXMLStringIDRef))) {
// IDREF=
int id = 0;
int cnt = strlen(kXMLTagInteger " " kXMLStringIDRef "\"") + 1;
while ((tagName[cnt] != '\0') && (tagName[cnt] != '"')) cnt++;
tagName[cnt] = 0;
char* val = tagName + strlen(kXMLTagInteger " " kXMLStringIDRef "\"");
while(*val)
{
if ((*val >= '0' && *val <= '9'))// 0 - 9
{
while(*val) {
if ((*val >= '0' && *val <= '9')) { // 0 - 9
id = (id * 10) + (*val++ - '0');
}
else
{
} else {
printf("ParseStringIDREF error (0x%x)\n", *val);
getchar();
return -1;
tmpTag->tag = 0;
tmpTag->tagNext = 0;
tmpTag->offset = buffer_start ? buffer - buffer_start + pos : 0;
*tag = tmpTag;
length = 0;
//printf("Located IDREF, id = %d, string = %s\n", id, str);
}
else
{
} else {
length = ParseTagInteger(buffer + pos, tag);
}
}
/***** data ****/
else if (!strcmp(tagName, kXMLTagData))
{
length = ParseTagData(buffer + pos, tag);
}
else if (!strncmp(tagName, kXMLTagData " ", strlen(kXMLTagData " ")))
{
length = ParseTagData(buffer + pos, tag);
}
else if (!strcmp(tagName, kXMLTagDate))
{
length = ParseTagDate(buffer + pos, tag);
}
/***** date ****/
else if (!strncmp(tagName, kXMLTagDate " ", strlen(kXMLTagDate " ")))
{
length = ParseTagDate(buffer + pos, tag);
}
/***** false ****/
else if (!strcmp(tagName, kXMLTagFalse))
{
else if (!strcmp(tagName, kXMLTagFalse)) {
length = ParseTagBoolean(buffer + pos, tag, kTagTypeFalse);
}
/***** true ****/
else if (!strcmp(tagName, kXMLTagTrue))
{
else if (!strcmp(tagName, kXMLTagTrue)) {
length = ParseTagBoolean(buffer + pos, tag, kTagTypeTrue);
}
/***** array ****/
else if (!strcmp(tagName, kXMLTagArray))
{
length = ParseTagList(buffer + pos, tag, kTagTypeArray, 0);
/***** plist ****/
/***** dict ****/
/***** data ****/
else if (!strcmp(tagName, kXMLTagData)) {
length = ParseTagData(buffer + pos, tag);
} else if (!strncmp(tagName, kXMLTagData " ", strlen(kXMLTagData " "))) {
length = ParseTagData(buffer + pos, tag);
} else if (!strcmp(tagName, kXMLTagDate)) {
length = ParseTagDate(buffer + pos, tag);
}
else if (!strncmp(tagName, kXMLTagArray " ", strlen(kXMLTagArray " ")))
{
/***** date ****/
else if (!strncmp(tagName, kXMLTagDate " ", strlen(kXMLTagDate " "))) {
length = ParseTagDate(buffer + pos, tag);
}/***** array ****/
else if (!strcmp(tagName, kXMLTagArray)) {
length = ParseTagList(buffer + pos, tag, kTagTypeArray, 0);
}
else if (!strcmp(tagName, kXMLTagArray "/"))
{
else if (!strncmp(tagName, kXMLTagArray " ", strlen(kXMLTagArray " "))) {
length = ParseTagList(buffer + pos, tag, kTagTypeArray, 0);
} else if (!strcmp(tagName, kXMLTagArray "/")) {
length = ParseTagList(buffer + pos, tag, kTagTypeArray, 1);
}
/***** unknown ****/
else
{
else {
// it wasn't parsed so we consumed no additional characters
*tag = 0;
length = 0;
//==========================================================================
// ParseTagList
static long ParseTagList( char * buffer, TagPtr * tag, long type, long empty )
static long
ParseTagList( char * buffer, TagPtr * tag, long type, long empty )
{
long length, pos;
TagPtr tagList, tmpTag;
tagList = 0;
pos = 0;
if (!empty)
{
while (1)
{
if (!empty) {
while (1) {
length = XMLParseNextTag(buffer + pos, &tmpTag);
if (length == -1) {
break;
tagList = tmpTag;
}
if (length == -1)
{
if (length == -1) {
XMLFreeTag(tagList);
return -1;
}
}
tmpTag = NewTag();
if (tmpTag == 0)
{
if (tmpTag == 0) {
XMLFreeTag(tagList);
return -1;
}
//==========================================================================
// ParseTagKey
static long ParseTagKey( char * buffer, TagPtr * tag )
static long
ParseTagKey( char * buffer, TagPtr * tag )
{
long length, length2;
char *string;
//==========================================================================
// ParseTagString
static long ParseTagString( char * buffer, TagPtr * tag )
static long
ParseTagString( char * buffer, TagPtr * tag )
{
long length;
char * string;
//==========================================================================
// ParseTagInteger
static long ParseTagInteger( char * buffer, TagPtr * tag )
static long
ParseTagInteger( char * buffer, TagPtr * tag )
{
long length, integer;
bool negative = false;
TagPtr tmpTag;
char* val = buffer;
int size;
if(buffer[0] == '<')
{
printf("Warning integer is non existant\n");
}
size = length = FixDataMatchingTag(buffer, kXMLTagInteger);
if (length == -1) return -1;
if (length == -1) {
return -1;
}
tmpTag = NewTag();
if (tmpTag == 0) return -1;
if (tmpTag == 0) {
return -1;
}
integer = 0;
if(size > 1 && (val[1] == 'x' || val[1] == 'X'))// Hex value
{
if(size > 1 && (val[1] == 'x' || val[1] == 'X')) { // Hex value
val += 2;
while(*val)
{
if ((*val >= '0' && *val <= '9'))// 0 - 9
{
while(*val) {
if ((*val >= '0' && *val <= '9')) { // 0 - 9
integer = (integer * 16) + (*val++ - '0');
}
else if ((*val >= 'a' && *val <= 'f'))// a - f
{
} else if ((*val >= 'a' && *val <= 'f')) { // a - f
integer = (integer * 16) + (*val++ - 'a' + 10);
}
else if ((*val >= 'A' && *val <= 'F'))// A - F
{
integer = (integer * 16) + (*val++ - 'a' + 10);
}
else
{
} else if ((*val >= 'A' && *val <= 'F')) { // A - F
integer = (integer * 16) + (*val++ - 'A' + 10);
} else {
printf("ParseTagInteger hex error (0x%x) in buffer %s\n", *val, buffer);
getchar();
XMLFreeTag(tmpTag);
return -1;
}
}
}
else if ( size )// Decimal value
{
if (*val == '-')
{
} else if ( size ) { // Decimal value
if (*val == '-') {
negative = true;
val++;
size--;
}
for (integer = 0; size > 0; size--)
{
if(*val) // UGLY HACK, fix me.
{
if (*val < '0' || *val > '9')
{
for (integer = 0; size > 0; size--) {
if(*val) { // UGLY HACK, fix me.
if (*val < '0' || *val > '9') {
printf("ParseTagInteger decimal error (0x%x) in buffer %s\n", *val, buffer);
getchar();
return -1;
}
integer = (integer * 10) + (*val++ - '0');
}
}
if (negative)
if (negative) {
integer = -integer;
}
}
tmpTag->type = kTagTypeInteger;
//==========================================================================
// ParseTagData
static long ParseTagData( char * buffer, TagPtr * tag )
static long
ParseTagData( char * buffer, TagPtr * tag )
{
int actuallen = 0;
long length;
//==========================================================================
// ParseTagDate
static long ParseTagDate( char * buffer, TagPtr * tag )
static long
ParseTagDate( char * buffer, TagPtr * tag )
{
long length;
TagPtr tmpTag;
//==========================================================================
// ParseTagBoolean
long ParseTagBoolean( char * buffer, TagPtr * tag, long type )
long
ParseTagBoolean( char * buffer, TagPtr * tag, long type )
{
TagPtr tmpTag;
//==========================================================================
// GetNextTag
static long GetNextTag( char * buffer, char ** tag, long * start )
static long
GetNextTag( char * buffer, char ** tag, long * start )
{
long cnt, cnt2;
if (tag == 0) return -1;
if (tag == 0) {
return -1;
}
// Find the start of the tag.
// Find the start of the tag.
cnt = 0;
while ((buffer[cnt] != '\0') && (buffer[cnt] != '<')) cnt++;
if (buffer[cnt] == '\0') return -1;
if (buffer[cnt] == '\0') {
return -1;
}
// Find the end of the tag.
cnt2 = cnt + 1;
while ((buffer[cnt2] != '\0') && (buffer[cnt2] != '>')) cnt2++;
if (buffer[cnt2] == '\0') return -1;
if (buffer[cnt2] == '\0') {
return -1;
}
// Fix the tag data.
*tag = buffer + cnt + 1;
buffer[cnt2] = '\0';
if (start) *start = cnt;
if (start) {
*start = cnt;
}
return cnt2 + 1;
}
XMLFreeTag( TagPtr tag )
{
#if DOFREE
if (tag == 0)
{
if (tag == 0) {
return;
}
if (!XMLIsInteger(tag) && tag->string)
{
if (!XMLIsInteger(tag) && tag->string) {
FreeSymbol(tag->string);
}
//==========================================================================
// NewSymbol
static char *NewSymbol( char * string )
static char *
NewSymbol( char * string )
{
static SymbolPtr lastGuy = 0;
SymbolPtr symbol;
symbol = FindSymbol(string, 0);
// Add the new symbol.
if (symbol == 0)
{
if (symbol == 0) {
symbol = (SymbolPtr)malloc(sizeof(Symbol) + 1 + strlen(string));
if (symbol == 0) //return 0;
{
if (symbol == 0) { //return 0;
stop("NULL symbol!");
}
// Update the refCount and return the string.
symbol->refCount++;
if (lastGuy && lastGuy->next != 0)
{
if (lastGuy && lastGuy->next != 0) {
stop("last guy not last!");
}
// FreeSymbol
#if DOFREE
static void FreeSymbol( char * string )
static void
FreeSymbol( char * string )
{
SymbolPtr symbol, prev;
prev = 0;
// Look for string in the list of symbols.
symbol = FindSymbol(string, &prev);
if (symbol == 0)
{
if (symbol == 0) {
return;
}
// Update the refCount.
symbol->refCount--;
if (symbol->refCount != 0)
{
if (symbol->refCount != 0) {
return;
}
// Remove the symbol from the list.
if (prev != 0)
{
if (prev != 0) {
prev->next = symbol->next;
}
else
{
} else {
gSymbolsHead = symbol->next;
}
//==========================================================================
// FindSymbol
static SymbolPtr FindSymbol( char * string, SymbolPtr * prevSymbol )
static SymbolPtr
FindSymbol( char * string, SymbolPtr * prevSymbol )
{
SymbolPtr symbol, prev;
symbol = gSymbolsHead;
prev = 0;
while (symbol != 0)
{
if (!strcmp(symbol->string, string))
{
while (symbol != 0) {
if (!strcmp(symbol->string, string)) {
break;
}
symbol = symbol->next;
}
if ((symbol != 0) && (prevSymbol != 0))
{
if ((symbol != 0) && (prevSymbol != 0)) {
*prevSymbol = prev;
}
bool XMLIsType(TagPtr dict, enum xmltype type)
{
if(!dict)
{
if(!dict) {
return (type == kTagTypeNone);
}
return (dict->type == type);
TagPtr XMLCastArray(TagPtr dict)
{
if(!dict)
{
if(!dict) {
return NULL;
}
if(dict->type == kTagTypeArray)
{
if(dict->type == kTagTypeArray) {
return dict;
}
else
{
} else {
return NULL;
}
}
TagPtr XMLCastDict(TagPtr dict)
{
if(!dict)
{
if(!dict) {
return NULL;
}
if(dict->type == kTagTypeDict)
{
if(dict->type == kTagTypeDict) {
return dict;
}
else
{
} else {
return NULL;
}
}
char* XMLCastString(TagPtr dict)
{
if(!dict)
{
if(!dict) {
return NULL;
}
if((dict->type == kTagTypeString) || (dict->type == kTagTypeKey))
{
if((dict->type == kTagTypeString) || (dict->type == kTagTypeKey)) {
return dict->string;
}
char* XMLCastData(TagPtr dict, int* length)
{
if(!dict)
{
if(!dict) {
return NULL;
}
if((dict->type == kTagTypeData) || (dict->type == kTagTypeKey))
{
if((dict->type == kTagTypeData) || (dict->type == kTagTypeKey)) {
*length = dict->offset;
return dict->string;
}
long XMLCastStringOffset(TagPtr dict)
{
if(dict && ((dict->type == kTagTypeString) || (dict->type == kTagTypeKey)))
{
if(dict && ((dict->type == kTagTypeString) || (dict->type == kTagTypeKey))) {
return dict->offset;
}
else
{
} else {
return -1;
}
}
bool XMLCastBoolean(TagPtr dict)
{
if(!dict)
{
if(!dict) {
return false;
}
if(dict->type == kTagTypeTrue)
{
if(dict->type == kTagTypeTrue) {
return true;
}
return false;
}
int XMLCastInteger(TagPtr dict)
{
if(!dict)
{
if(!dict) {
//printf("XMLCastInteger: null dict\n");
return 0;
}
if(dict->type == kTagTypeInteger)
{
if(dict->type == kTagTypeInteger) {
return (int)(dict->string);
}
return 0;
}
bool XMLAddTagToDictionary(TagPtr dict, char* key, TagPtr value)
{
if (!dict || dict->type != kTagTypeDict)
{
if (!dict || dict->type != kTagTypeDict) {
return false;
}
char* string;
tmpTag = NewTag();
if (tmpTag == 0)
{
if (tmpTag == 0) {
return false;
}
string = NewSymbol(key);
if (string == 0)
{
if (string == 0) {
XMLFreeTag(tmpTag);
return false;
}
tmpTag->type = kTagTypeKey;
tmpTag->string = string;
tmpTag->tag = value;
tmpTag->offset = 0;
tmpTag->tagNext = 0;
TagPtr tagList = dict->tag;
if(!tagList)
{
if(!tagList) {
// First tag
dict->tag = tmpTag;
return true;
}
while(tagList && tagList->tagNext) tagList = tagList->tagNext;
if(tagList)
{
if(tagList) {
tagList->tagNext = tmpTag;
return true;
}
branches/Bungo/i386/libsaio/asm.s
8282
8383
8484
85
85
8686
8787
8888
......
348348
349349
350350
351
351
352352
353353
354354
* New boot0 (boot1 has been deprecated). Booter must now reside in its own partition, no disk label required.
*
* Revision 1.1.1.2 1999/08/04 21:16:57 wsanchez
* Impoort of boot-66
* Import of boot-66
*
* Revision 1.3 1999/08/04 21:12:12 wsanchez
* Update APSL
push %ebp
mov %esp, %ebp
mov 0xc(%ebp), %eax // argument to program
mov 0xc(%ebp), %eax // argument to program - bootargs to mach_kernel
mov 0x8(%ebp), %ecx // entry offset
mov $0x28, %ebx // segment
push %ebx
branches/Bungo/i386/libsaio/console.c
5050
5151
5252
53
54
53
54
5555
5656
5757
......
6969
7070
7171
72
73
72
73
7474
7575
7676
......
8383
8484
8585
86
86
8787
8888
8989
......
9999
100100
101101
102
102
103103
104
104105
105
106
106107
108
107109
108110
109111
......
115117
116118
117119
118
120
119121
122
120123
121124
122125
......
129132
130133
131134
132
133
135
134136
135137
136138
137139
138
139
140
140141
141
142
142143
143144
144145
145
146
146147
147148
148149
149150
150
151
151152
152
153
154
155
153
154
155
156
157
156158
157159
158160
......
165167
166168
167169
168
170
169171
170172
171173
172174
173175
174
176
175177
176
178
177179
178
180
179181
182
180183
181184
182185
183186
184187
185
188
186189
190
187191
188
192
189193
194
190195
191196
192197
......
194199
195200
196201
197
202
198203
199204
200205
201206
202
207
203208
204209
205
206
207
210
211
208212
209
213
210214
211
215
216
212217
213218
214219
215220
216221
217
222
218223
224
219225
220
226
221227
228
222229
223230
224231
225232
226233
227234
228
229
235
236
230237
231238
232239
233240
234
235
236
237
241
242
243
244
238245
239
246
240247
248
241249
242
250
243251
244252
245253
extern intvprf(const char * fmt, va_list ap);
bool gVerboseMode;
bool gErrors;
bool gVerboseMode = false;
bool gErrors = false;
/*
* Azi: Doubled available log size; this seems to fix some hangs and instant reboots caused by
struct putc_info //Azi: exists on gui.c & printf.c
{
char * str;
char * last_str;
char * str;
char * last_str;
};
static int
return 0;
}
*(pi->str)++ = c;
return c;
return c;
}
void initBooterLog(void)
va_list ap;
struct putc_info pi;
if (!msgbuf)
if (!msgbuf) {
return;
}
if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))
if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) {
return;
}
va_start(ap, fmt);
pi.str = cursor;
void setupBooterLog(void)
{
if (!msgbuf)
if (!msgbuf) {
return;
}
Node *node = DT__FindNode("/", false);
if (node)
*/
int putchar(int c)
{
if ( c == '\t' )
{
if ( c == '\t' ) {
for (c = 0; c < 8; c++) bios_putchar(' ');
return c;
}
if ( c == '\n' )
{
if ( c == '\n' ) {
bios_putchar('\r');
}
}
bios_putchar(c);
return c;
return c;
}
int getc()
{
int c = bgetc();
int c = bgetc();
if ((c & 0xff) == 0)
return c;
else
return (c & 0xff);
if ((c & 0xff) == 0) {
return c;
} else {
return (c & 0xff);
}
}
// Read and echo a character from console. This doesn't echo backspace
//if ( c == '\r' ) c = '\n';
//if ( c >= ' ' && c < 0x7f) putchar(c);
return (c);
}
int printf(const char * fmt, ...)
{
va_list ap;
va_list ap;
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);
}
{
// Kabyl: BooterLog
struct putc_info pi;
if (!msgbuf)
if (!msgbuf) {
return 0;
}
if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))
if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) {
return 0;
}
pi.str = cursor;
pi.last_str = 0;
prf(fmt, ap, sputc, &pi);
}
va_end(ap);
return 0;
return 0;
}
int verbose(const char * fmt, ...)
{
va_list ap;
va_list ap;
va_start(ap, fmt);
if (gVerboseMode)
{
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
if (gVerboseMode) {
if (bootArgs->Video.v_display == VGA_TEXT_MODE) {
prf(fmt, ap, putchar, 0);
else
} else {
vprf(fmt, ap);
}
}
}
{
// Kabyl: BooterLog
struct putc_info pi;
if (!msgbuf)
if (!msgbuf) {
return 0;
}
if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))
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_end(ap);
return(0);
}
int error(const char * fmt, ...)
{
va_list ap;
gErrors = true;
va_start(ap, fmt);
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
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);
return(0);
}
void stop(const char * fmt, ...)
branches/Bungo/i386/libsaio/xml.h
2525
2626
2727
28
29
28
3029
3130
3231
......
7271
7372
7473
75
76
74
7775
7876
7977
#ifndef __LIBSAIO_XML_H
#define __LIBSAIO_XML_H
enum xmltype
{
enum xmltype {
kTagTypeNone = 0,
kTagTypeDict,
kTagTypeKey,
#define kPropIONameMatch ("IONameMatch")
/*
struct Tag
{
struct Tag {
long type;
char *string;
struct Tag *tag;
branches/Bungo/i386/libsaio/efi.h
7171
7272
7373
74
7574
76
75
7776
7877
7978
......
8281
8382
8483
85
8684
87
8885
8986
9087
......
118115
119116
120117
118
119
120
121
121122
122123
123124
124125
125126
127
126128
127129
128130
......
141143
142144
143145
144
146
145147
146148
147149
......
160162
161163
162164
163
164
165
166
167
168
169
170
171
172
173
165
166
167
168
169
170
171
172
173
174
175
174176
175177
176
178
177179
178
180
179181
180182
181183
182
184
183185
184
186
185187
186188
187189
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
203205
204206
205207
206
207
208
209
210
208
209
210
211
212
211213
212214
213
214215
215
216
216217
217218
218219
219220
220221
221222
222
223
223224
224
225
225226
226227
227228
228229
229
230
230231
231
232
232233
233234
234235
......
236237
237238
238239
239
240
241
242
243
244
240
241
242
243
244
245
245246
246247
247248
......
263264
264265
265266
266
267
267268
268
269
269270
270271
271272
......
302303
303304
304305
305
306
306307
307
308
308309
309
310
311
310
311
312
312313
313314
314315
......
371372
372373
373374
374
375375
376
377
378
379
380
381
382
376
377
378
379
380
383381
384
385
382
386383
387384
388385
......
404401
405402
406403
407
404
408405
409
410
411
412
413
414
415
406
407
408
409
410
416411
417
418
419
420
421
412
422413
423
424
425
426
427
428
414
415
429416
430
431
432
433
434
435417
418
419
420
421
422
423
424
425
426
436427
437
438
439
440
441
442
428
429
430
431
432
433
443434
444435
445436
446437
447438
448
439
449440
450
451
452
453
454
455
456
457441
458
459
460
461
462
442
463443
464
465
466
467
468
469
444
445
446
447
470448
471
472
473
474
475
449
476450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
477465
478
479
480
481
482
483
466
467
468
469
470
471
484472
485473
486474
......
489477
490478
491479
492
493
480
481
494482
495483
496484
497
498
485
486
499487
500488
501
489
502490
503
491
504492
505493
506494
......
508496
509497
510498
511
499
512500
513
514
501
502
515503
516
517
504
505
518506
519
520
507
508
521509
522
523
510
511
524512
525
526
513
514
527515
528
529
516
517
530518
531519
532520
533521
534
522
535523
536
537
524
525
538526
539
527
528
529
540530
541
542
531
532
543533
544
545
534
535
546536
547
548
537
538
549539
550
551
552
553
554
555
540
541
556542
557543
558544
*/
//
// Modifiers for EFI Runtime and Boot Services
//
#define EFI_RUNTIMESERVICE
#define EFIAPI
#define IN
#define EFI_MAX_BIT 0x80000000
//
// Set the upper bit to indicate EFI Error.
//
#define EFIERR(a) (EFI_MAX_BIT | (a))
#define EFIWARN(a) (a)
#define EFI_INCOMPATIBLE_VERSION EFIERR (25)
#define EFI_SECURITY_VIOLATION EFIERR (26)
#define EFI_CRC_ERROR EFIERR (27)
#define EFI_END_OF_MEDIA EFIERR (28)
#define EFI_END_OF_FILE EFIERR (31)
#define EFI_INVALID_LANGUAGE EFIERR (32)
#define EFI_COMPROMISED_DATA EFIERR (33)
#define EFI_WARN_UNKNOWN_GLYPH EFIWARN (1)
#define EFI_WARN_DELETE_FAILURE EFIWARN (2)
#define EFI_WARN_WRITE_FAILURE EFIWARN (3)
#define EFI_WARN_BUFFER_TOO_SMALL EFIWARN (4)
#define EFI_WARN_STALE_DATA EFIWARN (5)
//
// EFI Specification Revision information
{0xAC39C713, 0x7E50, 0x423D, {0x88, 0x9D, 0x27,0x8F, 0xCC, 0x34, 0x22, 0xB6} }
#define EFI_GLOBAL_VARIABLE_GUID \
{0x8BE4DF61, 0x93CA, 0x11d2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C} }
{0x8BE4DF61, 0x93CA, 0x11D2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C} }
typedef union {
EFI_GUID Guid;
// TimeZone: -1440 to 1440 or 2047
//
typedef struct {
EFI_UINT16 Year;
EFI_UINT8 Month;
EFI_UINT8 Day;
EFI_UINT8 Hour;
EFI_UINT8 Minute;
EFI_UINT8 Second;
EFI_UINT8 Pad1;
EFI_UINT32 Nanosecond;
EFI_INT16 TimeZone;
EFI_UINT8 Daylight;
EFI_UINT8 Pad2;
EFI_UINT16 Year;
EFI_UINT8 Month;
EFI_UINT8 Day;
EFI_UINT8 Hour;
EFI_UINT8 Minute;
EFI_UINT8 Second;
EFI_UINT8 Pad1;
EFI_UINT32 Nanosecond;
EFI_INT16 TimeZone;
EFI_UINT8 Daylight;
EFI_UINT8 Pad2;
} EFI_TIME;
//
// Bit definitions for EFI_TIME.Daylight
//
#define EFI_TIME_ADJUST_DAYLIGHT 0x01
#define EFI_TIME_IN_DAYLIGHT 0x02
//
// Value definition for EFI_TIME.TimeZone
//
#define EFI_UNSPECIFIED_TIMEZONE 0x07FF
typedef enum {
EfiReservedMemoryType,
EfiLoaderCode,
EfiLoaderData,
EfiBootServicesCode,
EfiBootServicesData,
EfiRuntimeServicesCode,
EfiRuntimeServicesData,
EfiConventionalMemory,
EfiUnusableMemory,
EfiACPIReclaimMemory,
EfiACPIMemoryNVS,
EfiMemoryMappedIO,
EfiMemoryMappedIOPortSpace,
EfiPalCode,
EfiMaxMemoryType
EfiReservedMemoryType,
EfiLoaderCode,
EfiLoaderData,
EfiBootServicesCode,
EfiBootServicesData,
EfiRuntimeServicesCode,
EfiRuntimeServicesData,
EfiConventionalMemory,
EfiUnusableMemory,
EfiACPIReclaimMemory,
EfiACPIMemoryNVS,
EfiMemoryMappedIO,
EfiMemoryMappedIOPortSpace,
EfiPalCode,
EfiMaxMemoryType
} EFI_MEMORY_TYPE;
typedef struct {
EFI_UINT64 Signature;
EFI_UINT32 Revision;
EFI_UINT32 HeaderSize;
EFI_UINT32 CRC32;
EFI_UINT32 Reserved;
EFI_UINT64Signature;
EFI_UINT32Revision;
EFI_UINT32HeaderSize;
EFI_UINT32CRC32;
EFI_UINT32Reserved;
} __attribute__((aligned(8))) EFI_TABLE_HEADER;
//
// possible caching types for the memory range
//
#define EFI_MEMORY_UC 0x0000000000000001ULL
#define EFI_MEMORY_WC 0x0000000000000002ULL
#define EFI_MEMORY_WT 0x0000000000000004ULL
#define EFI_MEMORY_WB 0x0000000000000008ULL
#define EFI_MEMORY_UCE 0x0000000000000010ULL
//
// physical memory protection on range
//
#define EFI_MEMORY_WP 0x0000000000001000ULL
#define EFI_MEMORY_RP 0x0000000000002000ULL
#define EFI_MEMORY_XP 0x0000000000004000ULL
//
// range requires a runtime mapping
//
#define EFI_MEMORY_RUNTIME 0x8000000000000000ULL
typedef EFI_UINT64 EFI_PHYSICAL_ADDRESS;
#define EFI_MEMORY_DESCRIPTOR_VERSION 1
typedef struct {
EFI_UINT32 Type;
EFI_UINT32 Pad;
EFI_PHYSICAL_ADDRESS PhysicalStart;
EFI_VIRTUAL_ADDRESS VirtualStart;
EFI_UINT64 NumberOfPages;
EFI_UINT64 Attribute;
EFI_UINT32 Type;
EFI_UINT32 Pad;
EFI_PHYSICAL_ADDRESS PhysicalStart;
EFI_VIRTUAL_ADDRESS VirtualStart;
EFI_UINT64 NumberOfPages;
EFI_UINT64 Attribute;
} __attribute__((aligned(8))) EFI_MEMORY_DESCRIPTOR;
IN OUT VOID **Address
) __attribute__((regparm(0)));
//
// Variable attributes
//
#define EFI_VARIABLE_NON_VOLATILE 0x00000001
#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
IN VOID * Data
) __attribute__((regparm(0)));
//
// EFI Time
//
typedef struct {
EFI_UINT32 Resolution;
EFI_UINT32 Accuracy;
EFI_BOOLEAN SetsToZero;
EFI_UINT32 Resolution;
EFI_UINT32 Accuracy;
EFI_BOOLEAN SetsToZero;
} __attribute__((aligned(4))) EFI_TIME_CAPABILITIES;
typedef
OUT EFI_UINT32 * HighCount
) __attribute__((regparm(0)));
//
// Definition of Status Code extended data header
//
// HeaderSize The size of the architecture. This is specified to enable
// the future expansion
//
// Size The size of the data in bytes. This does not include the size
// of the header structure.
//
// HeaderSize The size of the architecture. This is specified to enable the future expansion
// Size The size of the data in bytes. This does not include the size of the header structure.
// Type A GUID defining the type of the data
//
//
#ifdef TIANO_EXTENSION_FLAG
typedef
#define EFI_RUNTIME_SERVICES_REVISION ((EFI_SPECIFICATION_MAJOR_REVISION << 16) | (EFI_SPECIFICATION_MINOR_REVISION))
typedef struct {
EFI_TABLE_HEADER Hdr;
EFI_TABLE_HEADERHdr;
//
// Time services
//
EFI_PTR32 GetTime;
EFI_PTR32 SetTime;
EFI_PTR32 GetWakeupTime;
EFI_PTR32 SetWakeupTime;
// Time Services
EFI_PTR32GetTime;
EFI_PTR32SetTime;
EFI_PTR32GetWakeupTime;
EFI_PTR32SetWakeupTime;
//
// Virtual memory services
//
EFI_PTR32 SetVirtualAddressMap;
EFI_PTR32 ConvertPointer;
// Virtual Memory Services
//
// Variable services
//
EFI_PTR32 GetVariable;
EFI_PTR32 GetNextVariableName;
EFI_PTR32 SetVariable;
EFI_PTR32 SetVirtualAddressMap;
EFI_PTR32 ConvertPointer;
//
// Misc
//
EFI_PTR32 GetNextHighMonotonicCount;
EFI_PTR32 ResetSystem;
// Variable Services
EFI_PTR32 GetVariable;
EFI_PTR32 GetNextVariableName;
EFI_PTR32 SetVariable;
// Miscellaneous Services
EFI_PTR32 GetNextHighMonotonicCount;
EFI_PTR32 ResetSystem;
#ifdef TIANO_EXTENSION_FLAG
//
// ////////////////////////////////////////////////////
// Extended EFI Services
//////////////////////////////////////////////////////
//
EFI_PTR32 ReportStatusCode;
// ////////////////////////////////////////////////////
// Extended EFI Services
//////////////////////////////////////////////////////
EFI_PTR32 ReportStatusCode;
#endif
} __attribute__((aligned(8))) EFI_RUNTIME_SERVICES_32;
typedef struct {
EFI_TABLE_HEADER Hdr;
EFI_TABLE_HEADER Hdr;
//
// Time services
//
EFI_PTR64 GetTime;
EFI_PTR64 SetTime;
EFI_PTR64 GetWakeupTime;
EFI_PTR64 SetWakeupTime;
//
// Virtual memory services
//
EFI_PTR64 SetVirtualAddressMap;
EFI_PTR64 ConvertPointer;
// Time services
//
// Variable services
//
EFI_PTR64 GetVariable;
EFI_PTR64 GetNextVariableName;
EFI_PTR64 SetVariable;
EFI_PTR64 GetTime;
EFI_PTR64 SetTime;
EFI_PTR64 GetWakeupTime;
EFI_PTR64 SetWakeupTime;
//
// Misc
//
EFI_PTR64 GetNextHighMonotonicCount;
EFI_PTR64 ResetSystem;
// Virtual memory services
EFI_PTR64 SetVirtualAddressMap;
EFI_PTR64 ConvertPointer;
// Variable services
EFI_PTR64 GetVariable;
EFI_PTR64 GetNextVariableName;
EFI_PTR64 SetVariable;
// Misc
EFI_PTR64 GetNextHighMonotonicCount;
EFI_PTR64 ResetSystem;
#ifdef TIANO_EXTENSION_FLAG
//
// ////////////////////////////////////////////////////
// Extended EFI Services
//////////////////////////////////////////////////////
//
EFI_PTR64 ReportStatusCode;
// ////////////////////////////////////////////////////
// Extended EFI Services
//////////////////////////////////////////////////////
EFI_PTR64 ReportStatusCode;
#endif
} __attribute__((aligned(8))) EFI_RUNTIME_SERVICES_64;
// EFI Configuration Table
//
typedef struct {
EFI_GUID VendorGuid;
EFI_PTR32 VendorTable;
EFI_GUID VendorGuid;
EFI_PTR32 VendorTable;
} EFI_CONFIGURATION_TABLE_32;
typedef struct {
EFI_GUID VendorGuid;
EFI_PTR64 VendorTable;
EFI_GUID VendorGuid;
EFI_PTR64 VendorTable;
} __attribute__((aligned(8))) EFI_CONFIGURATION_TABLE_64;
//
// EFI System Table
//
#define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249ULL
#define EFI_SYSTEM_TABLE_REVISION ((EFI_SPECIFICATION_MAJOR_REVISION << 16) | (EFI_SPECIFICATION_MINOR_REVISION))
#define EFI_2_00_SYSTEM_TABLE_REVISION ((2 << 16) | 00)
#define EFI_1_10_SYSTEM_TABLE_REVISION ((1 << 16) | 10)
typedef struct EFI_SYSTEM_TABLE_32 {
EFI_TABLE_HEADER Hdr;
EFI_TABLE_HEADER Hdr;
EFI_PTR32 FirmwareVendor;
EFI_UINT32 FirmwareRevision;
EFI_PTR32 FirmwareVendor;
EFI_UINT32 FirmwareRevision;
EFI_HANDLE32 ConsoleInHandle;
EFI_PTR32 ConIn;
EFI_HANDLE32 ConsoleInHandle;
EFI_PTR32 ConIn;
EFI_HANDLE32 ConsoleOutHandle;
EFI_PTR32 ConOut;
EFI_HANDLE32 ConsoleOutHandle;
EFI_PTR32 ConOut;
EFI_HANDLE32 StandardErrorHandle;
EFI_PTR32 StdErr;
EFI_HANDLE32 StandardErrorHandle;
EFI_PTR32 StdErr;
EFI_PTR32 RuntimeServices;
EFI_PTR32 BootServices;
EFI_PTR32 RuntimeServices;
EFI_PTR32 BootServices;
EFI_UINT32 NumberOfTableEntries;
EFI_PTR32 ConfigurationTable;
EFI_UINT32 NumberOfTableEntries;
EFI_PTR32 ConfigurationTable;
} __attribute__((aligned(8))) EFI_SYSTEM_TABLE_32;
typedef struct EFI_SYSTEM_TABLE_64 {
EFI_TABLE_HEADER Hdr;
EFI_TABLE_HEADER Hdr;
EFI_PTR64 FirmwareVendor;
EFI_UINT32 FirmwareRevision;
EFI_PTR64 FirmwareVendor;
EFI_UINT32 FirmwareRevision;
EFI_UINT32 __pad;
EFI_UINT32 __pad;
EFI_HANDLE64 ConsoleInHandle;
EFI_PTR64 ConIn;
EFI_HANDLE64 ConsoleInHandle;
EFI_PTR64 ConIn;
EFI_HANDLE64 ConsoleOutHandle;
EFI_PTR64 ConOut;
EFI_HANDLE64 ConsoleOutHandle;
EFI_PTR64 ConOut;
EFI_HANDLE64 StandardErrorHandle;
EFI_PTR64 StdErr;
EFI_HANDLE64 StandardErrorHandle;
EFI_PTR64 StdErr;
EFI_PTR64 RuntimeServices;
EFI_PTR64 BootServices;
EFI_PTR64 RuntimeServices;
EFI_PTR64 BootServices;
EFI_UINT64 NumberOfTableEntries;
EFI_PTR64 ConfigurationTable;
EFI_UINT64 NumberOfTableEntries;
EFI_PTR64 ConfigurationTable;
} __attribute__((aligned(8))) EFI_SYSTEM_TABLE_64;
#endif /* _PEXPERT_I386_EFI_H */
branches/Bungo/i386/libsaio/ext2fs.c
2222
2323
2424
25
25
2626
27
2728
2829
29
30
30
3131
3232
3333
34
35
34
3635
3736
3837
......
4443
4544
4645
47
46
4847
48
4949
5050
51
52
51
5352
5453
5554
56
57
55
5856
5957
6058
{
char * buf=malloc (EX2ProbeSize);
str[0]=0;
if (!buf)
if (!buf) {
return;
}
Seek(ih, 0);
Read(ih, (long)buf, EX2ProbeSize);
if (!EX2Probe (buf))
{
if (!EX2Probe (buf)) {
free (buf);
return;
}
if (OSReadLittleInt32 (buf+0x44c,0)<1)
{
if (OSReadLittleInt32 (buf+0x44c,0)<1) {
free (buf);
return;
}
long EX2GetUUID(CICell ih, char *uuidStr)
{
uint8_t *b, *buf=malloc (EX2ProbeSize);
if (!buf)
if (!buf) {
return -1;
}
Seek(ih, 0);
Read(ih, (long)buf, EX2ProbeSize);
if (!EX2Probe (buf))
{
if (!EX2Probe (buf)) {
free (buf);
return -1;
}
if (OSReadLittleInt32 (buf+0x44c,0)<1)
{
if (OSReadLittleInt32 (buf+0x44c,0)<1) {
free (buf);
return -1;
}
branches/Bungo/i386/libsaio/vbe.c
2929
3030
3131
32
33
34
32
33
34
35
36
37
3538
3639
3740
3841
3942
4043
44
4145
4246
4347
......
4549
4650
4751
52
53
4854
4955
5056
......
5258
5359
5460
61
62
5563
56
64
5765
5866
5967
6068
6169
62
63
64
65
70
6671
6772
6873
......
7479
7580
7681
82
83
7784
7885
7986
......
8592
8693
8794
95
96
8897
8998
9099
......
95104
96105
97106
107
108
98109
99110
100111
#include "libsaio.h"
#include "vbe.h"
/*
* Various inline routines for video I/O
*/
// Various inline routines for video I/O
static biosBuf_t bb;
//==============================================================================
static inline void
outi (int port, int index, int val)
{
outw (port, (val << 8) | index);
}
//==============================================================================
static inline void
outib (int port, int index, int val)
{
outb (port + 1, val);
}
//==============================================================================
static inline int
ini (int port, int index)
{
return inb (port + 1);
}
//==============================================================================
static inline void
rmwi (int port, int index, int clear, int set)
rmwi(int port, int index, int clear, int set)
{
outb (port, index);
outb (port + 1, (inb (port + 1) & ~clear) | set);
}
/*
* Globals
*/
static biosBuf_t bb;
//==============================================================================
int getVBEInfo( void * infoBlock )
{
return(bb.eax.r.h);
}
//==============================================================================
int getVBEModeInfo( int mode, void * minfo_p )
{
bb.intno = 0x10;
return(bb.eax.r.h);
}
//==============================================================================
int getVBEDACFormat(unsigned char *format)
{
bb.intno = 0x10;
return(bb.eax.r.h);
}
//==============================================================================
int setVBEDACFormat(unsigned char format)
{
bb.intno = 0x10;
branches/Bungo/i386/libsaio/bootstruct.h
3030
3131
3232
33
34
33
34
3535
3636
3737
......
4444
4545
4646
47
4847
4948
5049
......
5857
5958
6059
61
62
63
64
65
66
67
68
69
70
71
72
73
74
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
7575
7676
7777
78
79
80
78
79
80
8181
8282
8383
......
9191
9292
9393
94
95
96
97
94
95
96
97
9898
99
99
100100
101101
102102
......
108108
109109
110110
111
112
111
112
113113
114
114
115115
116
116
117117
118
119
118
119
120120
121
121
122122
123123
124
124
125125
126
127
126
127
128128
129
130
131
132
133
134
129
130
131
132
133
134
135135
136136
137137
#include "bios.h"
#include "device_tree.h"
/*!
Kernel boot args global also used by booter for its own data.
/*
* Kernel boot args global also used by booter for its own data.
*/
extern boot_args *bootArgs;
extern boot_args_pre_lion *bootArgsPreLion;
//#define FB_TEXT_MODE 2
/*
* Maximum number of boot drivers that can be loaded.
*/
* PCI bus information.
*/
typedef struct _PCI_bus_info_t {
union {
struct {
unsigned char configMethod1 :1;
unsigned char configMethod2 :1;
unsigned char :2;
unsigned char specialCycle1 :1;
unsigned char specialCycle2 :1;
} s;
unsigned char d;
} u_bus;
unsigned char maxBusNum;
unsigned char majorVersion;
unsigned char minorVersion;
unsigned char BIOSPresent;
union {
struct {
unsigned char configMethod1 :1;
unsigned char configMethod2 :1;
unsigned char :2;
unsigned char specialCycle1 :1;
unsigned char specialCycle2 :1;
} s;
unsigned char d;
} u_bus;
unsigned char maxBusNum;
unsigned char majorVersion;
unsigned char minorVersion;
unsigned char BIOSPresent;
} PCI_bus_info_t;
typedef struct {
unsigned long address; // address where driver was loaded
unsigned long size; // number of bytes
unsigned long type; // driver type
unsigned long address; // address where driver was loaded
unsigned long size; // number of bytes
unsigned long type; // driver type
} driver_config_t;
/*
* ACPI defined memory range types.
*/
enum {
kMemoryRangeUsable = 1, // RAM usable by the OS.
kMemoryRangeReserved = 2, // Reserved. (Do not use)
kMemoryRangeACPI = 3, // ACPI tables. Can be reclaimed.
kMemoryRangeNVS = 4, // ACPI NVS memory. (Do not use)
kMemoryRangeUsable = 1, // RAM usable by the OS.
kMemoryRangeReserved = 2, // Reserved. (Do not use)
kMemoryRangeACPI = 3, // ACPI tables. Can be reclaimed.
kMemoryRangeNVS = 4, // ACPI NVS memory. (Do not use)
/* Undefined types should be treated as kMemoryRangeReserved */
/* Undefined types should be treated as kMemoryRangeReserved */
};
/*!
to the kernel and are thus located in bootArgs although with different field names.
*/
typedef struct PrivateBootInfo {
int convmem; // conventional memory
int extmem; // extended memory
int convmem; // conventional memory
int extmem; // extended memory
#if 0
int numBootDrivers; // number of drivers loaded
int numBootDrivers; // number of drivers loaded
#endif
char bootFile[128]; // kernel file name
char bootFile[128]; // kernel file name
unsigned long memoryMapCount;
MemoryRange memoryMap[kMemoryMapCountMax];
unsigned long memoryMapCount;
MemoryRange memoryMap[kMemoryMapCountMax];
PCI_bus_info_t pciInfo;
PCI_bus_info_t pciInfo;
#if 0
driver_config_t driverConfig[NDRIVERS];
driver_config_t driverConfig[NDRIVERS];
#endif
char * configEnd; // pointer to end of config files
char config[CONFIG_SIZE];
char * configEnd;// pointer to end of config files
char config[CONFIG_SIZE];
config_file_t bootConfig; // com.apple.Boot.plist
config_file_t chameleonConfig; // org.chameleon.Boot.plist which can override bootConfig keys
config_file_t themeConfig; // theme.plist
config_file_t smbiosConfig; // smbios.plist
config_file_t helperConfig; // boot helper partition's boot.plist
config_file_t ramdiskConfig; // RAMDisk.plist
config_file_t bootConfig;// com.apple.Boot.plist
config_file_t chameleonConfig;// org.chameleon.Boot.plist which can override bootConfig keys
config_file_t themeConfig;// theme.plist
config_file_t smbiosConfig;// smbios.plist
config_file_t helperConfig;// boot helper partition's boot.plist
config_file_t ramdiskConfig;// RAMDisk.plist
bool memDetect;
} PrivateBootInfo_t;
branches/Bungo/i386/libsaio/device_tree.c
11
2
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
320
421
522
623
7
24
825
926
1027
1128
1229
1330
14
15
31
32
1633
1734
1835
1936
2037
21
22
38
39
2340
2441
2542
2643
2744
28
45
46
2947
3048
3149
......
4967
5068
5169
52
53
54
70
71
72
5573
5674
5775
......
6179
6280
6381
82
83
84
6485
6586
6687
67
88
6889
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
90
9291
93
94
95
92
93
94
9695
97
98
99
100
101
102
103
104
96
10597
106
107
108
109
98
99
100
110101
111
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
112141
113142
143
144
145
114146
115147
116148
117
149
118150
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
151
152
153
144154
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
155204
156205
206
207
208
157209
158210
159211
160
161
212
213
162214
215
216
217
163218
164219
165220
166
167
221
222
168223
169224
225
226
170227
171228
172229
173
174
175
176
177
178
179
180
181
182
183
184
185
230
231
232
233
234
235
236
237
238
239
240
241
242
186243
187244
245
188246
189
190
247
191248
192249
193250
194251
195
196
252
253
197254
198
199
200
201
202
203
255
204256
205
206
207
208
209
210
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
211273
212
213
214
215
216
274
275
276
277
217278
218279
280
281
219282
220283
221284
222
223
224
225
285
286
287
288
226289
227
290
291
292
228293
229
230
294
295
231296
232
233
234
235
236
237
238
239
240
297
298
299
300
301
302
303
304
305
241306
242
243
244
245
307
246308
247
309
310
311
312
313
314
315
316
248317
249318
250
251
252
319
320
321
253322
254323
255324
......
258327
259328
260329
261
262
330
331
263332
264
333
334
265335
266
336
337
338
267339
268340
269
270
271
341
342
343
272344
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
291376
292377
378
379
293380
294381
295382
296
383
297384
298
299
300
301
302
303
304
305
306
307
385
386
387
388
389
390
391
392
393
394
395
396
397
308398
309399
400
401
310402
311403
312404
313
314
315
316
405
406
407
408
317409
318
410
319411
320
321
322
412
413
323414
324
325
326
415
327416
328
329
417
418
419
420
421
422
423
330424
331
332
333
334
335
425
426
427
428
336429
337
338
339
340
341
342
343
344
345
346
347
430
348431
349
350
351
352
353
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
354465
355466
356467
357468
469
470
358471
359472
360473
361
362
474
475
363476
364
365
366
477
478
479
480
367481
368
369
370
371
372
373
374
375
376
377
378
379
380
381
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
382505
383506
507
508
384509
385510
386511
387
388
389
390
512
513
514
515
516
517
518
519
391520
392521
522
523
393524
394525
395526
396
397
527
528
398529
399530
531
532
400533
401534
402535
403
404
405
406
407
536
537
538
539
540
408541
409
410
411
542
543
544
412545
413
414
415
416
417
418
419
420
421
422
423
546
547
548
549
550
551
552
553
554
555
556
557
558
424559
425
560
426561
427562
563
564
428565
429566
430567
431
568
432569
433
570
434571
435
436
437
438
439
440
441
442
443
572
573
574
575
576
577
578
579
580
581
582
444583
445584
585
586
446587
447588
448589
449
590
450591
451592
593
452594
453595
454596
455597
456
457
458
459
460
461
462
463
598
599
600
601
602
603
604
605
464606
465
607
466608
467
468
469
470
609
610
611
612
471613
472
473
474
475
614
615
616
617
476618
477
478
479
480
619
620
621
622
481623
482
483
624
625
484626
485
627
486628
487
629
488630
489
631
490632
491
633
492634
493
635
494636
495
637
496638
497
639
498640
499
641
500642
501
502
503
504
643
644
645
646
647
648
649
650
651
652
653
505654
506
507
508
509
510
511
512
655
656
513657
514
515
516
517
518
519
658
659
660
661
662
663
664
665
520666
521
522
523
524
525
526
527
528
529
530
531
532
533
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
534682
535683
536
684
537685
538686
539687
/*
* Copyright (c) 2005 Apple Computer, Inc. All Rights Reserved.
* Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
*
* Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
* Reserved. This file contains Original Code and/or Modifications of
* Original Code as defined in and that are subject to the Apple Public
* Source License Version 2.0 (the "License"). You may not use this file
* except in compliance with the License. Please obtain a copy of the
* License at http://www.apple.com/publicsource and read it before using
* this file.
*
* The Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
*/
#if 1
/*
Structures for a Flattened Device Tree
*/
#define kPropNameLength 32
typedef struct DeviceTreeNodeProperty {
char name[kPropNameLength]; // NUL terminated property name
unsigned long length; // Length (bytes) of folloing prop value
char name[kPropNameLength]; // NUL terminated property name
unsigned long length; // Length (bytes) of folloing prop value
// unsigned long value[1]; // Variable length value of property
// Padded to a multiple of a longword?
} DeviceTreeNodeProperty;
typedef struct OpaqueDTEntry {
unsigned long nProperties; // Number of props[] elements (0 => end)
unsigned long nChildren; // Number of children[] elements
unsigned long nProperties; // Number of props[] elements (0 => end)
unsigned long nChildren; // Number of children[] elements
// DeviceTreeNodeProperty props[];// array size == nProperties
// DeviceTreeNode children[]; // array size == nChildren
} DeviceTreeNode;
typedef char DTPropertyNameBuf[32];
/* Entry Name Definitions (Entry Names are C-Strings)*/
// Entry Name Definitions (Entry Names are C-Strings).
enum {
kDTMaxEntryNameLength = 31 /* Max length of a C-String Entry Name (terminator not included) */
};
#define RoundToLong(x)(((x) + 3) & ~3)
static struct _DTSizeInfo {
uint32_t numNodes;
uint32_t numProperties;
uint32_t totalPropertySize;
uint32_tnumNodes;
uint32_tnumProperties;
uint32_ttotalPropertySize;
} DTInfo;
#define kAllocSize 4096
static Node *freeNodes, *allocedNodes;
static Property *freeProperties, *allocedProperties;
//==============================================================================
Property *
DT__AddProperty(Node *node, const char *name, uint32_t length, void *value)
{
Property *prop;
Property *prop;
DPRINTF("DT__AddProperty([Node '%s'], '%s', %d, 0x%x)\n", DT__GetName(node), name, length, value);
if (freeProperties == NULL) {
void *buf = malloc(kAllocSize);
int i;
DPRINTF("Allocating more free properties\n");
if (buf == 0) return 0;
bzero(buf, kAllocSize);
// Use the first property to record the allocated buffer
// for later freeing.
prop = (Property *)buf;
prop->next = allocedProperties;
allocedProperties = prop;
prop->value = buf;
prop++;
for (i=1; i<(kAllocSize / sizeof(Property)); i++) {
prop->next = freeProperties;
freeProperties = prop;
prop++;
}
}
prop = freeProperties;
freeProperties = prop->next;
DPRINTF("DT__AddProperty([Node '%s'], '%s', %d, 0x%x)\n", DT__GetName(node), name, length, value);
prop->name = name;
prop->length = length;
prop->value = value;
if (freeProperties == NULL) {
void *buf = malloc(kAllocSize);
int i;
// Always add to end of list
if (node->properties == 0) {
node->properties = prop;
} else {
node->last_prop->next = prop;
}
node->last_prop = prop;
prop->next = 0;
DPRINTF("Allocating more free properties\n");
DPRINTF("Done [0x%x]\n", prop);
DTInfo.numProperties++;
DTInfo.totalPropertySize += RoundToLong(length);
if (buf == 0) {
return 0;
}
return prop;
bzero(buf, kAllocSize);
// Use the first property to record the allocated buffer
// for later freeing.
prop = (Property *)buf;
prop->next = allocedProperties;
allocedProperties = prop;
prop->value = buf;
prop++;
for (i = 1; i < (kAllocSize / sizeof(Property)); i++) {
prop->next = freeProperties;
freeProperties = prop;
prop++;
}
}
prop = freeProperties;
freeProperties = prop->next;
prop->name = name;
prop->length = length;
prop->value = value;
// Always add to end of list
if (node->properties == 0) {
node->properties = prop;
} else {
node->last_prop->next = prop;
}
node->last_prop = prop;
prop->next = 0;
DPRINTF("Done [0x%x]\n", prop);
DTInfo.numProperties++;
DTInfo.totalPropertySize += RoundToLong(length);
return prop;
}
//==============================================================================
Node *
DT__AddChild(Node *parent, const char *name)
{
Node *node;
Node *node;
if (freeNodes == NULL) {
void *buf = malloc(kAllocSize);
int i;
DPRINTF("Allocating more free nodes\n");
if (buf == 0) return 0;
bzero(buf, kAllocSize);
node = (Node *)buf;
// Use the first node to record the allocated buffer
// for later freeing.
node->next = allocedNodes;
allocedNodes = node;
node->children = (Node *)buf;
node++;
for (i=1; i<(kAllocSize / sizeof(Node)); i++) {
node->next = freeNodes;
freeNodes = node;
node++;
}
}
DPRINTF("DT__AddChild(0x%x, '%s')\n", parent, name);
node = freeNodes;
freeNodes = node->next;
DPRINTF("Got free node 0x%x\n", node);
DPRINTF("prop = 0x%x, children = 0x%x, next = 0x%x\n", node->properties, node->children, node->next);
if (freeNodes == NULL)
{
void *buf = malloc(kAllocSize);
if (parent == NULL) {
rootNode = node;
node->next = 0;
} else {
node->next = parent->children;
parent->children = node;
}
DTInfo.numNodes++;
DT__AddProperty(node, "name", strlen(name) + 1, (void *) name);
return node;
if (buf == 0)
{
return 0;
}
int i;
DPRINTF("Allocating more free nodes\n");
bzero(buf, kAllocSize);
node = (Node *)buf;
// Use the first node to record the allocated buffer for later freeing.
node->next = allocedNodes;
allocedNodes = node;
node->children = (Node *)buf;
node++;
for (i = 1; i < (kAllocSize / sizeof(Node)); i++)
{
node->next = freeNodes;
freeNodes = node;
node++;
}
}
DPRINTF("DT__AddChild(0x%x, '%s')\n", parent, name);
node = freeNodes;
freeNodes = node->next;
DPRINTF("Got free node 0x%x\n", node);
DPRINTF("prop = 0x%x, children = 0x%x, next = 0x%x\n", node->properties, node->children, node->next);
if (parent == NULL)
{
rootNode = node;
node->next = 0;
}
else
{
node->next = parent->children;
parent->children = node;
}
DTInfo.numNodes++;
DT__AddProperty(node, "name", strlen(name) + 1, (void *) name);
return node;
}
//==============================================================================
void
DT__FreeProperty(Property *prop)
{
prop->next = freeProperties;
freeProperties = prop;
prop->next = freeProperties;
freeProperties = prop;
}
//==============================================================================
void
DT__FreeNode(Node *node)
{
node->next = freeNodes;
freeNodes = node;
node->next = freeNodes;
freeNodes = node;
}
//==============================================================================
void
DT__Initialize(void)
{
DPRINTF("DT__Initialize\n");
freeNodes = 0;
allocedNodes = 0;
freeProperties = 0;
allocedProperties = 0;
DTInfo.numNodes = 0;
DTInfo.numProperties = 0;
DTInfo.totalPropertySize = 0;
rootNode = DT__AddChild(NULL, "/");
DPRINTF("DT__Initialize done\n");
DPRINTF("DT__Initialize\n");
freeNodes = 0;
allocedNodes = 0;
freeProperties = 0;
allocedProperties = 0;
DTInfo.numNodes = 0;
DTInfo.numProperties = 0;
DTInfo.totalPropertySize = 0;
rootNode = DT__AddChild(NULL, "/");
DPRINTF("DT__Initialize done\n");
}
//==============================================================================
/*
* Free up memory used by in-memory representation
* of device tree.
* Free up memory used by in-memory representation of device tree.
*/
void
DT__Finalize(void)
{
Node *node;
Property *prop;
Node *node;
Property *prop;
DPRINTF("DT__Finalize\n");
for (prop = allocedProperties; prop != NULL; prop = prop->next) {
free(prop->value);
}
allocedProperties = NULL;
freeProperties = NULL;
DPRINTF("DT__Finalize\n");
for (node = allocedNodes; node != NULL; node = node->next) {
free((void *)node->children);
}
allocedNodes = NULL;
freeNodes = NULL;
rootNode = NULL;
for (prop = allocedProperties; prop != NULL; prop = prop->next)
{
free(prop->value);
}
allocedProperties = NULL;
freeProperties = NULL;
for (node = allocedNodes; node != NULL; node = node->next)
{
free((void *)node->children);
}
allocedNodes = NULL;
freeNodes = NULL;
rootNode = NULL;
// XXX leaks any created strings
DTInfo.numNodes = 0;
DTInfo.numProperties = 0;
DTInfo.totalPropertySize = 0;
// XXX leaks any created strings
DTInfo.numNodes = 0;
DTInfo.numProperties = 0;
DTInfo.totalPropertySize = 0;
}
//==============================================================================
static void *
FlattenNodes(Node *node, void *buffer)
{
Property *prop;
DeviceTreeNode *flatNode;
DeviceTreeNodeProperty *flatProp;
int count;
Property *prop;
DeviceTreeNode *flatNode;
DeviceTreeNodeProperty *flatProp;
int count;
if (node == 0) return buffer;
if (node == 0) {
return buffer;
}
flatNode = (DeviceTreeNode *)buffer;
buffer += sizeof(DeviceTreeNode);
flatNode = (DeviceTreeNode *)buffer;
buffer += sizeof(DeviceTreeNode);
for (count = 0, prop = node->properties; prop != 0; count++, prop = prop->next) {
flatProp = (DeviceTreeNodeProperty *)buffer;
strcpy(flatProp->name, prop->name);
flatProp->length = prop->length;
buffer += sizeof(DeviceTreeNodeProperty);
bcopy(prop->value, buffer, prop->length);
buffer += RoundToLong(prop->length);
}
flatNode->nProperties = count;
for (count = 0, prop = node->properties; prop != 0; count++, prop = prop->next)
{
flatProp = (DeviceTreeNodeProperty *)buffer;
strcpy(flatProp->name, prop->name);
flatProp->length = prop->length;
buffer += sizeof(DeviceTreeNodeProperty);
bcopy(prop->value, buffer, prop->length);
buffer += RoundToLong(prop->length);
}
for (count = 0, node = node->children; node != 0; count++, node = node->next) {
buffer = FlattenNodes(node, buffer);
}
flatNode->nChildren = count;
flatNode->nProperties = count;
return buffer;
for (count = 0, node = node->children; node != 0; count++, node = node->next)
{
buffer = FlattenNodes(node, buffer);
}
flatNode->nChildren = count;
return buffer;
}
/*
* Flatten the in-memory representation of the device tree
* into a binary DT block.
/*==============================================================================
* Flatten the in-memory representation of the device tree into a binary DT block.
* To get the buffer size needed, call with result = 0.
* To have a buffer allocated for you, call with *result = 0.
* To use your own buffer, call with *result = &buffer.
void
DT__FlattenDeviceTree(void **buffer_p, uint32_t *length)
{
uint32_t totalSize;
void *buf;
uint32_t totalSize;
void * buf;
DPRINTF("DT__FlattenDeviceTree(0x%x, 0x%x)\n", buffer_p, length);
DPRINTF("DT__FlattenDeviceTree(0x%x, 0x%x)\n", buffer_p, length);
#if DEBUG
if (buffer_p) DT__PrintTree(rootNode);
if (buffer_p) {
DT__PrintTree(rootNode);
}
#endif
totalSize = DTInfo.numNodes * sizeof(DeviceTreeNode) +
DTInfo.numProperties * sizeof(DeviceTreeNodeProperty) +
DTInfo.totalPropertySize;
totalSize = DTInfo.numNodes * sizeof(DeviceTreeNode) +
DTInfo.numProperties * sizeof(DeviceTreeNodeProperty) +
DTInfo.totalPropertySize;
DPRINTF("Total size 0x%x\n", totalSize);
if (buffer_p != 0) {
if (totalSize == 0) {
buf = 0;
} else {
if (*buffer_p == 0) {
buf = malloc(totalSize);
} else {
buf = *buffer_p;
}
bzero(buf, totalSize);
FlattenNodes(rootNode, buf);
}
*buffer_p = buf;
}
if (length)
*length = totalSize;
DPRINTF("Total size 0x%x\n", totalSize);
if (buffer_p != 0)
{
if (totalSize == 0)
{
buf = 0;
}
else
{
if (*buffer_p == 0)
{
buf = malloc(totalSize);
}
else
{
buf = *buffer_p;
}
bzero(buf, totalSize);
FlattenNodes(rootNode, buf);
}
*buffer_p = buf;
}
if (length)
{
*length = totalSize;
}
}
//==============================================================================
char *
DT__GetName(Node *node)
{
Property *prop;
Property *prop;
//DPRINTF("DT__GetName(0x%x)\n", node);
//DPRINTF("Node properties = 0x%x\n", node->properties);
for (prop = node->properties; prop; prop = prop->next) {
//DPRINTF("Prop '%s'\n", prop->name);
if (strcmp(prop->name, "name") == 0) {
return prop->value;
}
}
//DPRINTF("DT__GetName returns 0\n");
return "(null)";
//DPRINTF("DT__GetName(0x%x)\n", node);
//DPRINTF("Node properties = 0x%x\n", node->properties);
for (prop = node->properties; prop; prop = prop->next)
{
//DPRINTF("Prop '%s'\n", prop->name);
if (strcmp(prop->name, "name") == 0)
{
return prop->value;
}
}
//DPRINTF("DT__GetName returns 0\n");
return "(null)";
}
//==============================================================================
Node *
DT__FindNode(const char *path, bool createIfMissing)
{
Node *node, *child;
DTPropertyNameBuf nameBuf;
char *bp;
int i;
Node *node, *child;
DTPropertyNameBuf nameBuf;
char *bp;
int i;
DPRINTF("DT__FindNode('%s', %d)\n", path, createIfMissing);
DPRINTF("DT__FindNode('%s', %d)\n", path, createIfMissing);
// Start at root
node = rootNode;
DPRINTF("root = 0x%x\n", rootNode);
// Start at root
node = rootNode;
while (node) {
// Skip leading slash
while (*path == '/') path++;
DPRINTF("root = 0x%x\n", rootNode);
for (i=0, bp = nameBuf; ++i < kDTMaxEntryNameLength && *path && *path != '/'; bp++, path++) *bp = *path;
*bp = '\0';
while (node)
{
// Skip leading slash
while (*path == '/')
{
path++;
}
if (nameBuf[0] == '\0') {
// last path entry
break;
}
DPRINTF("Node '%s'\n", nameBuf);
for (i = 0, bp = nameBuf; ++i < kDTMaxEntryNameLength && *path && *path != '/'; bp++, path++)
{
*bp = *path;
}
for (child = node->children; child != 0; child = child->next) {
DPRINTF("Child 0x%x\n", child);
if (strcmp(DT__GetName(child), nameBuf) == 0) {
break;
}
}
if (child == 0 && createIfMissing) {
DPRINTF("Creating node\n");
char *str = malloc(strlen(nameBuf) + 1);
// XXX this will leak
strcpy(str, nameBuf);
*bp = '\0';
child = DT__AddChild(node, str);
}
node = child;
}
return node;
if (nameBuf[0] == '\0')
{
// last path entry
break;
}
DPRINTF("Node '%s'\n", nameBuf);
for (child = node->children; child != 0; child = child->next)
{
DPRINTF("Child 0x%x\n", child);
if (strcmp(DT__GetName(child), nameBuf) == 0)
{
break;
}
}
if (child == 0 && createIfMissing)
{
DPRINTF("Creating node\n");
char *str = malloc(strlen(nameBuf) + 1);
// XXX this will leak
strcpy(str, nameBuf);
child = DT__AddChild(node, str);
}
node = child;
}
return node;
}
#if DEBUG
//==============================================================================
void
DT__PrintNode(Node *node, int level)
{
char spaces[10], *cp = spaces;
Property *prop;
char spaces[10], *cp = spaces;
Property *prop;
if (level > 9) level = 9;
while (level--) *cp++ = ' ';
*cp = '\0';
if (level > 9)
{
level = 9;
}
printf("%s===Node===\n", spaces);
for (prop = node->properties; prop; prop = prop->next) {
char c = *((char *)prop->value);
if (prop->length < 64 && (
strcmp(prop->name, "name") == 0 ||
(c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') || c == '_')) {
printf("%s Property '%s' [%d] = '%s'\n", spaces, prop->name, prop->length, prop->value);
} else {
printf("%s Property '%s' [%d] = (data)\n", spaces, prop->name, prop->length);
}
}
printf("%s==========\n", spaces);
while (level--)
{
*cp++ = ' ';
}
*cp = '\0';
printf("%s===Node===\n", spaces);
for (prop = node->properties; prop; prop = prop->next)
{
char c = *((char *)prop->value);
if (prop->length < 64 && (strcmp(prop->name, "name") == 0 || (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'))
{
printf("%s Property '%s' [%d] = '%s'\n", spaces, prop->name, prop->length, prop->value);
}
else
{
printf("%s Property '%s' [%d] = (data)\n", spaces, prop->name, prop->length);
}
}
printf("%s==========\n", spaces);
}
//==============================================================================
static void
_PrintTree(Node *node, int level)
{
DT__PrintNode(node, level);
level++;
for (node = node->children; node; node = node->next)
_PrintTree(node, level);
DT__PrintNode(node, level);
level++;
for (node = node->children; node; node = node->next)
{
_PrintTree(node, level);
}
}
//==============================================================================
void
DT__PrintTree(Node *node)
{
if (node == 0) node = rootNode;
_PrintTree(node, 0);
if (node == 0) node = rootNode;
_PrintTree(node, 0);
}
//==============================================================================
void
DT__PrintFlattenedNode(DTEntry entry, int level)
{
char spaces[10], *cp = spaces;
DTPropertyIterator propIter;
char *name;
void *prop;
int propSize;
char spaces[10], *cp = spaces;
DTPropertyIterator propIter;
char *name;
void *prop;
int propSize;
if (level > 9) level = 9;
while (level--) *cp++ = ' ';
*cp = '\0';
if (level > 9) level = 9;
while (level--) *cp++ = ' ';
*cp = '\0';
printf("%s===Entry %p===\n", spaces, entry);
if (kSuccess != DTCreatePropertyIterator(entry, &propIter)) {
printf("Couldn't create property iterator\n");
return;
}
while( kSuccess == DTIterateProperties( propIter, &name)) {
if( kSuccess != DTGetProperty( entry, name, &prop, &propSize ))
continue;
printf("%s Property %s = %s\n", spaces, name, prop);
}
DTDisposePropertyIterator(propIter);
printf("%s===Entry %p===\n", spaces, entry);
if (kSuccess != DTCreatePropertyIterator(entry, &propIter))
{
printf("Couldn't create property iterator\n");
return;
}
while( kSuccess == DTIterateProperties( propIter, &name))
{
if( kSuccess != DTGetProperty( entry, name, &prop, &propSize ))
continue;
printf("%s Property %s = %s\n", spaces, name, prop);
}
DTDisposePropertyIterator(propIter);
printf("%s==========\n", spaces);
printf("%s==========\n", spaces);
}
//==============================================================================
static void
_PrintFlattenedTree(DTEntry entry, int level)
{
DTEntryIterator entryIter;
DTEntryIterator entryIter;
PrintFlattenedNode(entry, level);
PrintFlattenedNode(entry, level);
if (kSuccess != DTCreateEntryIterator(entry, &entryIter)) {
printf("Couldn't create entry iterator\n");
return;
}
level++;
while (kSuccess == DTIterateEntries( entryIter, &entry )) {
_PrintFlattenedTree(entry, level);
}
DTDisposeEntryIterator(entryIter);
if (kSuccess != DTCreateEntryIterator(entry, &entryIter))
{
printf("Couldn't create entry iterator\n");
return;
}
level++;
while (kSuccess == DTIterateEntries( entryIter, &entry ))
{
_PrintFlattenedTree(entry, level);
}
DTDisposeEntryIterator(entryIter);
}
//==============================================================================
void
DT__PrintFlattenedTree(DTEntry entry)
{
_PrintFlattenedTree(entry, 0);
_PrintFlattenedTree(entry, 0);
}
//==============================================================================
int
main(int argc, char **argv)
{
DTEntry dtEntry;
DTPropertyIterator propIter;
DTEntryIterator entryIter;
void*prop;
intpropSize;
char*name;
void *flatTree;
uint32_t flatSize;
DTEntrydtEntry;
DTPropertyIteratorpropIter;
DTEntryIteratorentryIter;
void*prop;
intpropSize;
char*name;
void*flatTree;
uint32_tflatSize;
Node *node;
Node *node;
node = AddChild(NULL, "device-tree");
AddProperty(node, "potato", 4, "foo");
AddProperty(node, "chemistry", 4, "bar");
AddProperty(node, "physics", 4, "baz");
node = AddChild(NULL, "device-tree");
AddProperty(node, "potato", 4, "foo");
AddProperty(node, "chemistry", 4, "bar");
AddProperty(node, "physics", 4, "baz");
node = AddChild(node, "dev");
AddProperty(node, "one", 4, "one");
AddProperty(node, "two", 4, "two");
AddProperty(node, "three", 6, "three");
node = AddChild(node, "dev");
AddProperty(node, "one", 4, "one");
AddProperty(node, "two", 4, "two");
AddProperty(node, "three", 6, "three");
node = AddChild(rootNode, "foo");
AddProperty(node, "aaa", 4, "aab");
AddProperty(node, "bbb", 4, "bbc");
AddProperty(node, "cccc", 6, "ccccd");
node = AddChild(rootNode, "foo");
AddProperty(node, "aaa", 4, "aab");
AddProperty(node, "bbb", 4, "bbc");
AddProperty(node, "cccc", 6, "ccccd");
node = FindNode("/this/is/a/test", 1);
AddProperty(node, "dddd", 12, "abcdefghijk");
node = FindNode("/this/is/a/test", 1);
AddProperty(node, "dddd", 12, "abcdefghijk");
printf("In-memory tree:\n\n");
printf("In-memory tree:\n\n");
PrintTree(rootNode);
PrintTree(rootNode);
FlattenDeviceTree(&flatTree, &flatSize);
FlattenDeviceTree(&flatTree, &flatSize);
printf("Flat tree = %p, size %d\n", flatTree, flatSize);
printf("Flat tree = %p, size %d\n", flatTree, flatSize);
dtEntry = (DTEntry)flatTree;
dtEntry = (DTEntry)flatTree;
printf("\n\nPrinting flat tree\n\n");
printf("\n\nPrinting flat tree\n\n");
DTInit(dtEntry);
DTInit(dtEntry);
PrintFlattenedTree((DTEntry)flatTree);
PrintFlattenedTree((DTEntry)flatTree);
#if 0
printf("=== Entry %p ===\n", dtEntry);
if (kSuccess != DTCreatePropertyIterator(dtEntry, &propIter)) {
printf("Couldn't create property iterator\n");
return 1;
printf("=== Entry %p ===\n", dtEntry);
if (kSuccess != DTCreatePropertyIterator(dtEntry, &propIter))
{
printf("Couldn't create property iterator\n");
return 1;
}
while( kSuccess == DTIterateProperties( propIter, &name))
{
if( kSuccess != DTGetProperty( dtEntry, name, &prop, &propSize ))
continue;
printf(" Property %s = %s\n", name, prop);
}
while( kSuccess == DTIterateProperties( propIter, &name)) {
if( kSuccess != DTGetProperty( dtEntry, name, &prop, &propSize ))
continue;
printf(" Property %s = %s\n", name, prop);
}
DTDisposePropertyIterator(propIter);
printf("========\n");
DTDisposePropertyIterator(propIter);
printf("========\n");
if (kSuccess != DTCreateEntryIterator(dtEntry, &entryIter)) {
printf("Couldn't create entry iterator\n");
return 1;
}
while (kSuccess == DTIterateEntries( entryIter, &dtEntry )) {
printf("=== Entry %p ===\n", dtEntry);
if (kSuccess != DTCreateEntryIterator(dtEntry, &entryIter))
{
printf("Couldn't create entry iterator\n");
return 1;
}
while (kSuccess == DTIterateEntries( entryIter, &dtEntry ))
{
printf("=== Entry %p ===\n", dtEntry);
if (kSuccess != DTCreatePropertyIterator(dtEntry, &propIter)) {
printf("Couldn't create property iterator\n");
return 1;
}
while( kSuccess == DTIterateProperties( propIter, &name)) {
if( kSuccess != DTGetProperty( dtEntry, name, &prop, &propSize ))
continue;
printf(" Property %s = %s\n", name, prop);
}
DTDisposePropertyIterator(propIter);
printf("========\n");
}
DTDisposeEntryIterator(entryIter);
if (kSuccess != DTCreatePropertyIterator(dtEntry, &propIter))
{
printf("Couldn't create property iterator\n");
return 1;
}
while( kSuccess == DTIterateProperties( propIter, &name))
{
if( kSuccess != DTGetProperty( dtEntry, name, &prop, &propSize ))
continue;
printf(" Property %s = %s\n", name, prop);
}
DTDisposePropertyIterator(propIter);
printf("========\n");
}
DTDisposeEntryIterator(entryIter);
#endif
return 0;
return 0;
}
#endif
branches/Bungo/i386/libsaio/hfs.c
109109
110110
111111
112
113
112114
113115
114
115
116
117
116
117
118
119
118120
119121
122
123
124
120125
121126
122
123
124
127
128
129
130
125131
126132
133
134
135
127136
128137
129138
130139
131
132
140
141
133142
134
143
135144
136
137
145
146
147
138148
149
139150
140151
141152
153
154
155
142156
143157
144
145
158
159
146160
147
161
162
148163
149
164
150165
151
152
166
167
153168
154169
155
156
157
158
159
160
161
162
163
164
165
166
167
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
168196
169197
170
171
172
173
174
198
199
200
201
202
175203
176
177
178
204
205
206
179207
180
181
208
209
210
182211
183
184
185
186
187
188
212
213
214
215
216
217
218
189219
190
191
220
221
192222
193
194
195
196
197
198
223
224
225
226
227
199228
200
201
229
202230
203
204
205
206
207
231
232
233
234
235
236
208237
209
210
238
239
211240
212
213
241
242
214243
215
244
216245
217
218
219
246
247
248
220249
221
222
223
224
225
226
227
250
251
252
253
254
255
256
228257
229
230
231
232
258
259
260
261
233262
234263
235
236
237
238264
239
240
241
242
265
266
243267
244
245
268
269
270
271
246272
247
248
273
249274
250
251
252
253
254
275
255276
256
277
278
279
280
281
282
283
284
257285
258286
287
288
289
259290
260291
261
292
262293
263294
264295
265296
266
267
268
297
298
299
269300
270
271
272
273
274
275
276
277
278
301
302
279303
280
281
282
283
284
304
285305
286
287
288
289
306
307
308
309
310
311
312
313
314
315
316
317
318
319
290320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
291339
292
293
294
340
341
342
343
344
345
295346
296347
297
298
299
300
348
349
350
351
352
301353
302
303
304
305
306
354
355
356
357
358
307359
308360
309361
......
10301082
10311083
10321084
1033
1085
10341086
10351087
1036
1088
10371089
1038
1039
1090
1091
10401092
10411093
10421094
u_int16_t *uniStr2, u_int32_t len2);
//==============================================================================
static void SwapFinderInfo(FndrFileInfo *dst, FndrFileInfo *src)
{
dst->fdType = SWAP_BE32(src->fdType);
dst->fdCreator = SWAP_BE32(src->fdCreator);
dst->fdFlags = SWAP_BE16(src->fdFlags);
// Don't bother with location
dst->fdType = SWAP_BE32(src->fdType);
dst->fdCreator = SWAP_BE32(src->fdCreator);
dst->fdFlags = SWAP_BE16(src->fdFlags);
// Don't bother with location
}
//==============================================================================
void HFSFree(CICell ih)
{
if(gCurrentIH == ih)
gCurrentIH = 0;
free(ih);
if(gCurrentIH == ih) {
gCurrentIH = 0;
}
free(ih);
}
//==============================================================================
bool HFSProbe (const void *buf)
{
const HFSMasterDirectoryBlock *mdb;
const HFSPlusVolumeHeader *header;
mdb=(const HFSMasterDirectoryBlock *)(((const char*)buf)+kMDBBaseOffset);
header=(const HFSPlusVolumeHeader *)(((const char*)buf)+kMDBBaseOffset);
mdb = (const HFSMasterDirectoryBlock *)(((const char*)buf)+kMDBBaseOffset);
header = (const HFSPlusVolumeHeader *)(((const char*)buf)+kMDBBaseOffset);
if ( SWAP_BE16(mdb->drSigWord) == kHFSSigWord )
if ( SWAP_BE16(mdb->drSigWord) == kHFSSigWord ) {
return true;
if (SWAP_BE16(header->signature) != kHFSPlusSigWord &&
SWAP_BE16(header->signature) != kHFSXSigWord)
}
if (SWAP_BE16(header->signature) != kHFSPlusSigWord && SWAP_BE16(header->signature) != kHFSXSigWord) {
return false;
}
return true;
}
//==============================================================================
long HFSInitPartition(CICell ih)
{
long extentSize, extentFile, nodeSize;
void *extent;
long extentSize, extentFile, nodeSize;
void *extent;
if (ih == gCurrentIH) {
if (ih == gCurrentIH)
{
#ifdef __i386__
CacheInit(ih, gCacheBlockSize);
CacheInit(ih, gCacheBlockSize);
#endif
return 0;
}
return 0;
}
#ifdef __i386__
if (!gTempStr) gTempStr = (char *)malloc(4096);
if (!gLinkTemp) gLinkTemp = (char *)malloc(64);
if (!gBTreeHeaderBuffer) gBTreeHeaderBuffer = (char *)malloc(512);
if (!gHFSMdbVib) {
gHFSMdbVib = (char *)malloc(kBlockSize);
gHFSMDB = (HFSMasterDirectoryBlock *)gHFSMdbVib;
}
if (!gHFSPlusHeader) {
gHFSPlusHeader = (char *)malloc(kBlockSize);
gHFSPlus = (HFSPlusVolumeHeader *)gHFSPlusHeader;
}
if (!gTempStr || !gLinkTemp || !gBTreeHeaderBuffer ||
!gHFSMdbVib || !gHFSPlusHeader) return -1;
if (!gTempStr)
{
gTempStr = (char *)malloc(4096);
}
if (!gLinkTemp)
{
gLinkTemp = (char *)malloc(64);
}
if (!gBTreeHeaderBuffer)
{
gBTreeHeaderBuffer = (char *)malloc(512);
}
if (!gHFSMdbVib)
{
gHFSMdbVib = (char *)malloc(kBlockSize);
gHFSMDB = (HFSMasterDirectoryBlock *)gHFSMdbVib;
}
if (!gHFSPlusHeader)
{
gHFSPlusHeader = (char *)malloc(kBlockSize);
gHFSPlus = (HFSPlusVolumeHeader *)gHFSPlusHeader;
}
if (!gTempStr || !gLinkTemp || !gBTreeHeaderBuffer || !gHFSMdbVib || !gHFSPlusHeader)
{
return -1;
}
#endif /* __i386__ */
gAllocationOffset = 0;
gIsHFSPlus = 0;
gCaseSensitive = 0;
gBTHeaders[0] = 0;
gBTHeaders[1] = 0;
gAllocationOffset = 0;
gIsHFSPlus = 0;
gCaseSensitive = 0;
gBTHeaders[0] = 0;
gBTHeaders[1] = 0;
// Look for the HFS MDB
Seek(ih, kMDBBaseOffset);
Read(ih, (long)gHFSMdbVib, kBlockSize);
// Look for the HFS MDB
Seek(ih, kMDBBaseOffset);
Read(ih, (long)gHFSMdbVib, kBlockSize);
if ( SWAP_BE16(gHFSMDB->drSigWord) == kHFSSigWord ) {
gAllocationOffset = SWAP_BE16(gHFSMDB->drAlBlSt) * kBlockSize;
if (SWAP_BE16(gHFSMDB->drSigWord) == kHFSSigWord)
{
gAllocationOffset = SWAP_BE16(gHFSMDB->drAlBlSt) * kBlockSize;
// See if it is HFSPlus
if (SWAP_BE16(gHFSMDB->drEmbedSigWord) != kHFSPlusSigWord) {
// Normal HFS;
gCacheBlockSize = gBlockSize = SWAP_BE32(gHFSMDB->drAlBlkSiz);
CacheInit(ih, gCacheBlockSize);
gCurrentIH = ih;
// See if it is HFSPlus
if (SWAP_BE16(gHFSMDB->drEmbedSigWord) != kHFSPlusSigWord)
{
// Normal HFS;
gCacheBlockSize = gBlockSize = SWAP_BE32(gHFSMDB->drAlBlkSiz);
CacheInit(ih, gCacheBlockSize);
gCurrentIH = ih;
// grab the 64 bit volume ID
bcopy(&gHFSMDB->drFndrInfo[6], &gVolID, 8);
// grab the 64 bit volume ID
bcopy(&gHFSMDB->drFndrInfo[6], &gVolID, 8);
// Get the Catalog BTree node size.
extent = (HFSExtentDescriptor *)&gHFSMDB->drCTExtRec;
extentSize = SWAP_BE32(gHFSMDB->drCTFlSize);
extentFile = kHFSCatalogFileID;
ReadExtent(extent, extentSize, extentFile, 0, 256,
gBTreeHeaderBuffer + kBTreeCatalog * 256, 0);
// Get the Catalog BTree node size.
extent = (HFSExtentDescriptor *)&gHFSMDB->drCTExtRec;
extentSize = SWAP_BE32(gHFSMDB->drCTFlSize);
extentFile = kHFSCatalogFileID;
ReadExtent(extent, extentSize, extentFile, 0, 256, gBTreeHeaderBuffer + kBTreeCatalog * 256, 0);
nodeSize = SWAP_BE16(((BTHeaderRec *)(gBTreeHeaderBuffer + kBTreeCatalog * 256 +
sizeof(BTNodeDescriptor)))->nodeSize);
nodeSize = SWAP_BE16(((BTHeaderRec *)(gBTreeHeaderBuffer + kBTreeCatalog * 256 + sizeof(BTNodeDescriptor)))->nodeSize);
// If the BTree node size is larger than the block size, reset the cache.
if (nodeSize > gBlockSize) {
gCacheBlockSize = nodeSize;
CacheInit(ih, gCacheBlockSize);
}
// If the BTree node size is larger than the block size, reset the cache.
if (nodeSize > gBlockSize)
{
gCacheBlockSize = nodeSize;
CacheInit(ih, gCacheBlockSize);
}
return 0;
}
return 0;
}
// Calculate the offset to the embeded HFSPlus volume.
gAllocationOffset += (long long)SWAP_BE16(gHFSMDB->drEmbedExtent.startBlock) *
// Calculate the offset to the embeded HFSPlus volume.
gAllocationOffset += (long long)SWAP_BE16(gHFSMDB->drEmbedExtent.startBlock) *
SWAP_BE32(gHFSMDB->drAlBlkSiz);
}
}
// Look for the HFSPlus Header
Seek(ih, gAllocationOffset + kMDBBaseOffset);
Read(ih, (long)gHFSPlusHeader, kBlockSize);
// Look for the HFSPlus Header
Seek(ih, gAllocationOffset + kMDBBaseOffset);
Read(ih, (long)gHFSPlusHeader, kBlockSize);
// Not a HFS+ or HFSX volume.
if (SWAP_BE16(gHFSPlus->signature) != kHFSPlusSigWord &&
SWAP_BE16(gHFSPlus->signature) != kHFSXSigWord) {
verbose("HFS signature was not present.\n");
gCurrentIH = 0;
return -1;
}
// Not a HFS+ or HFSX volume.
if (SWAP_BE16(gHFSPlus->signature) != kHFSPlusSigWord && SWAP_BE16(gHFSPlus->signature) != kHFSXSigWord)
{
verbose("HFS signature was not present.\n");
gCurrentIH = 0;
return -1;
}
gIsHFSPlus = 1;
gCacheBlockSize = gBlockSize = SWAP_BE32(gHFSPlus->blockSize);
CacheInit(ih, gCacheBlockSize);
gCurrentIH = ih;
gIsHFSPlus = 1;
gCacheBlockSize = gBlockSize = SWAP_BE32(gHFSPlus->blockSize);
CacheInit(ih, gCacheBlockSize);
gCurrentIH = ih;
ih->modTime = SWAP_BE32(gHFSPlus->modifyDate) - 2082844800;
// grab the 64 bit volume ID
bcopy(&gHFSPlus->finderInfo[24], &gVolID, 8);
// Get the Catalog BTree node size.
extent = &gHFSPlus->catalogFile.extents;
extentSize = SWAP_BE64(gHFSPlus->catalogFile.logicalSize);
extentFile = kHFSCatalogFileID;
// grab the 64 bit volume ID
bcopy(&gHFSPlus->finderInfo[24], &gVolID, 8);
ReadExtent(extent, extentSize, extentFile, 0, 256,
gBTreeHeaderBuffer + kBTreeCatalog * 256, 0);
// Get the Catalog BTree node size.
extent = &gHFSPlus->catalogFile.extents;
extentSize = SWAP_BE64(gHFSPlus->catalogFile.logicalSize);
extentFile = kHFSCatalogFileID;
nodeSize = SWAP_BE16(((BTHeaderRec *)(gBTreeHeaderBuffer + kBTreeCatalog * 256 +
sizeof(BTNodeDescriptor)))->nodeSize);
ReadExtent(extent, extentSize, extentFile, 0, 256, gBTreeHeaderBuffer + kBTreeCatalog * 256, 0);
// If the BTree node size is larger than the block size, reset the cache.
if (nodeSize > gBlockSize) {
gCacheBlockSize = nodeSize;
CacheInit(ih, gCacheBlockSize);
}
nodeSize = SWAP_BE16(((BTHeaderRec *)(gBTreeHeaderBuffer + kBTreeCatalog * 256 + sizeof(BTNodeDescriptor)))->nodeSize);
return 0;
// If the BTree node size is larger than the block size, reset the cache.
if (nodeSize > gBlockSize)
{
gCacheBlockSize = nodeSize;
CacheInit(ih, gCacheBlockSize);
}
return 0;
}
//==============================================================================
long HFSLoadFile(CICell ih, char * filePath)
{
return HFSReadFile(ih, filePath, (void *)gFSLoadAddress, 0, 0);
return HFSReadFile(ih, filePath, (void *)gFSLoadAddress, 0, 0);
}
long HFSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length)
{
char entry[512];
char devStr[12];
long dirID, result, flags;
char entry[512];
char devStr[12];
long dirID, result, flags;
if (HFSInitPartition(ih) == -1) return -1;
dirID = kHFSRootFolderID;
// Skip a lead '\'. Start in the system folder if there are two.
if (filePath[0] == '/') {
if (filePath[1] == '/') {
if (gIsHFSPlus) dirID = SWAP_BE32(((long *)gHFSPlus->finderInfo)[5]);
else dirID = SWAP_BE32(gHFSMDB->drFndrInfo[5]);
if (dirID == 0) {
if (HFSInitPartition(ih) == -1)
{
return -1;
}
filePath++;
}
filePath++;
}
}
result = ResolvePathToCatalogEntry(filePath, &flags, entry, dirID, 0);
if ((result == -1) || ((flags & kFileTypeMask) != kFileTypeFlat)) {
return -1;
}
dirID = kHFSRootFolderID;
// Skip a lead '\'. Start in the system folder if there are two.
if (filePath[0] == '/')
{
if (filePath[1] == '/')
{
if (gIsHFSPlus)
{
dirID = SWAP_BE32(((long *)gHFSPlus->finderInfo)[5]);
}
else
{
dirID = SWAP_BE32(gHFSMDB->drFndrInfo[5]);
}
if (dirID == 0)
{
return -1;
}
filePath++;
}
filePath++;
}
result = ResolvePathToCatalogEntry(filePath, &flags, entry, dirID, 0);
if ((result == -1) || ((flags & kFileTypeMask) != kFileTypeFlat))
{
return -1;
}
#if UNUSED
// Not yet for Intel. System.config/Default.table will fail this check.
// Check file owner and permissions.
if (flags & (kOwnerNotRoot | kPermGroupWrite | kPermOtherWrite)) return -1;
// Not yet for Intel. System.config/Default.table will fail this check.
// Check file owner and permissions.
if (flags & (kOwnerNotRoot | kPermGroupWrite | kPermOtherWrite))
{
return -1;
}
#endif
result = ReadFile(entry, &length, base, offset);
if (result == -1) {
return -1;
}
result = ReadFile(entry, &length, base, offset);
if (result == -1)
{
return -1;
}
getDeviceDescription(ih, devStr);
verbose("Read HFS%s file: [%s/%s] %d bytes.\n",
(gIsHFSPlus ? "+" : ""), devStr, filePath, (uint32_t)length);
return length;
getDeviceDescription(ih, devStr);
verbose("Read HFS%s file: [%s/%s] %d bytes.\n",
(gIsHFSPlus ? "+" : ""), devStr, filePath, (uint32_t)length);
return length;
}
long HFSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex, char ** name,
{
HFSPlusExtentKey *searchKey, *trialKey;
long result;
searchKey = key;
trialKey = testKey;
// assume searchKey < trialKey
result = -1;
result = -1;
if (searchKey->fileID == trialKey->fileID) {
// FileNum's are equal; compare fork types
if (searchKey->forkType == trialKey->forkType) {
branches/Bungo/i386/libsaio/vbe.h
5757
5858
5959
60
61
62
63
64
65
66
67
68
69
70
71
60
61
62
63
64
65
66
67
68
69
70
71
7272
7373
7474
* Functions
*/
enum {
funcGetControllerInfo = 0x4F00,
funcGetModeInfo = 0x4F01,
funcSetMode = 0x4F02,
funcGetCurrentMode = 0x4F03,
funcSaveRestoreState = 0x4F04,
funcWindowControl = 0x4F05,
funcGetSetScanLineLength = 0x4F06,
funcGetSetDisplayStart = 0x4F07,
funcGetSetPaletteFormat = 0x4F08,
funcGetSetPaletteData = 0x4F09,
funcGetProtModeInterdace = 0x4F0A,
funcGetSetPixelClock = 0x4F0B
funcGetControllerInfo= 0x4F00,
funcGetModeInfo= 0x4F01,
funcSetMode= 0x4F02,
funcGetCurrentMode= 0x4F03,
funcSaveRestoreState= 0x4F04,
funcWindowControl= 0x4F05,
funcGetSetScanLineLength= 0x4F06,
funcGetSetDisplayStart= 0x4F07,
funcGetSetPaletteFormat= 0x4F08,
funcGetSetPaletteData= 0x4F09,
funcGetProtModeInterdace= 0x4F0A,
funcGetSetPixelClock= 0x4F0B
};
enum {
branches/Bungo/i386/libsaio/acpi_patcher.c
9393
9494
9595
96
9697
9798
9899
99
100
100101
101102
102103
103
104
104105
105
106
107
106
107
108108
109109
110110
111
111
112112
113
114
113
115114
116115
117116
......
119118
120119
121120
122
123
124
125
126
127
128
129
130
131121
132122
133123
......
281271
282272
283273
284
274
285275
286
287
288
276
277
278
289279
290280
291
281
292282
293283
294284
......
522512
523513
524514
525
526
515
527516
528517
529
530
531
518
532519
533520
534521
535522
536
523
537524
525
538526
539527
540528
541529
542530
543531
544
545
532
546533
547534
548535
549536
550537
551
552
553
538
539
554540
555
556
557
541
542
558543
559544
560545
561
546
562547
548
563549
564550
565551
......
602588
603589
604590
605
606
607
591
608592
609593
610594
......
613597
614598
615599
616
617
600
618601
619602
620
621
622
603
623604
624605
625606
626
627
607
628608
629609
630610
631611
632612
633613
634
614
635615
636616
637617
......
642622
643623
644624
645
646
625
647626
648627
649
628
650629
651630
652
653
654
631
632
633
655634
656
657
658
635
636
659637
660638
661639
......
666644
667645
668646
669
670
647
671648
672649
673650
......
693670
694671
695672
696
697
698
673
699674
700675
701676
......
713688
714689
715690
716
717
691
718692
719693
720
721
694
722695
723
724
725
696
726697
727698
728
729
730
699
731700
732701
733702
734703
735
736
704
737705
738706
739707
......
744712
745713
746714
747
748
749
715
750716
751717
752718
753719
754720
755721
756
757
758
759
722
723
760724
761
762
763
725
764726
765727
766728
767
768
769
729
770730
771731
772732
773733
774
775
776
777
734
735
778736
779737
780738
781
782
783
739
784740
785741
786742
......
790746
791747
792748
793
794
795
796
749
750
797751
798752
799753
......
802756
803757
804758
805
806
807
759
808760
809761
810762
......
818770
819771
820772
821
822
773
823774
824775
825776
826
827
777
828778
829779
830780
......
868818
869819
870820
871
872
873
874
875
876
821
822
823
877824
878825
879826
......
896843
897844
898845
899
900846
901847
902848
903
904849
905850
906851
907852
908
909
853
910854
911855
912856
913857
914
915
858
916859
917
918
919
860
920861
921862
922863
......
930871
931872
932873
933
934
874
935875
936
937
876
938877
939
940
941
878
942879
943880
944881
......
959896
960897
961898
962
963
899
964900
965901
966902
......
971907
972908
973909
974
975
910
976911
977
978
912
979913
980914
981915
......
983917
984918
985919
986
987
920
921
988922
989923
990924
991
992
925
993926
994927
995
996
928
997929
998930
999931
1000932
1001933
1002934
1003
1004
935
1005936
1006937
1007938
1008939
1009940
1010
1011
941
1012942
1013943
1014944
......
1017947
1018948
1019949
1020
1021
950
1022951
1023952
1024953
1025954
1026955
1027956
1028
1029
957
1030958
1031959
1032960
......
1047975
1048976
1049977
1050
1051
978
1052979
1053980
1054
981
1055982
983
1056984
1057985
1058986
......
1065993
1066994
1067995
1068
1069
1070
996
1071997
1072998
1073999
10741000
1075
1076
1001
10771002
10781003
10791004
......
10811006
10821007
10831008
1084
1085
1009
10861010
10871011
10881012
......
10941018
10951019
10961020
1097
1098
1021
10991022
1100
1101
1023
11021024
11031025
11041026
11051027
1106
1107
1028
11081029
11091030
11101031
11111032
1112
1113
1033
11141034
11151035
1116
1117
1036
11181037
11191038
11201039
......
11221041
11231042
11241043
1125
1126
1044
11271045
11281046
11291047
11301048
11311049
11321050
1133
1134
1051
11351052
11361053
11371054
......
11421059
11431060
11441061
1145
1146
1062
11471063
11481064
11491065
11501066
11511067
1152
1153
1068
11541069
11551070
11561071
11571072
1158
1159
1160
1161
1162
1163
11641073
11651074
11661075
......
11781087
11791088
11801089
1181
1182
1090
11831091
11841092
1185
1093
11861094
1095
11871096
11881097
1189
11901098
11911099
11921100
11931101
11941102
1195
1196
1197
1103
11981104
11991105
12001106
......
12171123
12181124
12191125
1220
1221
1126
12221127
12231128
12241129
12251130
12261131
12271132
1228
12291133
12301134
12311135
1232
1233
1136
12341137
12351138
12361139
1237
1238
1239
1140
12401141
12411142
12421143
}
/* The folowing ACPI Table search algo. should be reused anywhere needed:*/
/* WARNING: outDirspec string will be overwritten by subsequent calls! */
int search_and_get_acpi_fd(const char * filename, const char ** outDirspec)
{
int fd = 0;
char dirSpec[512];
static char dirSpec[512];
// Try finding 'filename' in the usual places
// Start searching any potential location for ACPI Table
sprintf(dirSpec, "%s", filename);
snprintf(dirSpec, sizeof(dirSpec), "%s", filename);
fd = open(dirSpec, 0);
if (fd < 0)
{
sprintf(dirSpec, "/Extra/%s", filename);
if (fd < 0) {
snprintf(dirSpec, sizeof(dirSpec), "/Extra/%s", filename);
fd = open(dirSpec, 0);
if (fd < 0)
{
sprintf(dirSpec, "bt(0,0)/Extra/%s", filename);
snprintf(dirSpec, sizeof(dirSpec), "bt(0,0)/Extra/%s", filename);
fd = open(dirSpec, 0);
if (fd < 0)
{
if (fd < 0) {
// NOT FOUND:
verbose("ACPI Table not found: %s\n", filename);
*dirSpec = '\0';
}
}
// Bungo
/*** Moved above
if (fd < 0)
{
// NOT FOUND:
verbose("ACPI Table not found: %s\n", filename);
*dirSpec = '\0';
}
***/
if (outDirspec) *outDirspec = dirSpec;
return fd;
}
unsigned char cstates_count = 1 + (c2_enabled ? 1 : 0) + (c3_enabled ? 1 : 0);
struct aml_chunk* root = aml_create_node(NULL);
AML_CHUNK* root = aml_create_node(NULL);
aml_add_buffer(root, ssdt_header, sizeof(ssdt_header)); // SSDT header
struct aml_chunk* scop = aml_add_scope(root, "\\_PR_");
struct aml_chunk* name = aml_add_name(scop, "CST_");
struct aml_chunk* pack = aml_add_package(name);
AML_CHUNK* scop = aml_add_scope(root, "\\_PR_");
AML_CHUNK* name = aml_add_name(scop, "CST_");
AML_CHUNK* pack = aml_add_package(name);
aml_add_byte(pack, cstates_count);
struct aml_chunk* tmpl = aml_add_package(pack);
AML_CHUNK* tmpl = aml_add_package(pack);
if (cst_using_systemio)
{
// C1
minimum.CID = ((minimum.FID & 0x1F) << 1) >> cpu_dynamic_fsb;
// Sanity check
if (maximum.CID < minimum.CID)
{
if (maximum.CID < minimum.CID) {
DBG("P-States: Insane FID values!");
p_states_count = 0;
}
else
{
} else {
// Finalize P-States
// Find how many P-States machine supports
p_states_count = maximum.CID - minimum.CID + 1;
if (p_states_count > 32)
if (p_states_count > 32) {
p_states_count = 32;
}
uint8_t vidstep;
uint8_t i = 0, u, invalid = 0;
vidstep = ((maximum.VID << 2) - (minimum.VID << 2)) / (p_states_count - 1);
for (u = 0; u < p_states_count; u++)
{
for (u = 0; u < p_states_count; u++) {
i = u - invalid;
p_states[i].CID = maximum.CID - u;
p_states[i].FID = (p_states[i].CID >> 1);
if (p_states[i].FID < 0x6)
{
if (cpu_dynamic_fsb)
if (p_states[i].FID < 0x6) {
if (cpu_dynamic_fsb) {
p_states[i].FID = (p_states[i].FID << 1) | 0x80;
}
else if (cpu_noninteger_bus_ratio)
{
}
} else if (cpu_noninteger_bus_ratio) {
p_states[i].FID = p_states[i].FID | (0x40 * (p_states[i].CID & 0x1));
}
if (i && p_states[i].FID == p_states[i-1].FID)
if (i && p_states[i].FID == p_states[i-1].FID) {
invalid++;
}
p_states[i].VID = ((maximum.VID << 2) - (vidstep * u)) >> 2;
(Platform.CPU.Model == CPU_MODEL_HASWELL_ULT) || (Platform.CPU.Model == CPU_MODEL_CRYSTALWELL))
{
maximum.Control = (rdmsr64(MSR_IA32_PERF_STATUS) >> 8) & 0xff;
}
else
{
} else {
maximum.Control = rdmsr64(MSR_IA32_PERF_STATUS) & 0xff;
}
verbose("P-States: min 0x%x, max 0x%x\n", minimum.Control, maximum.Control);
// Sanity check
if (maximum.Control < minimum.Control)
{
if (maximum.Control < minimum.Control) {
DBG("Insane control values!");
p_states_count = 0;
}
else
{
} else {
uint8_t i;
p_states_count = 0;
for (i = maximum.Control; i >= minimum.Control; i--)
{
for (i = maximum.Control; i >= minimum.Control; i--) {
p_states[p_states_count].Control = i;
p_states[p_states_count].CID = p_states[p_states_count].Control << 1;
p_states[p_states_count].Frequency = (Platform.CPU.FSBFrequency / 1000000) * i;
p_states_count++;
}
}
break;
}
default:
}
// Generating SSDT
if (p_states_count > 0)
{
if (p_states_count > 0) {
int i;
struct aml_chunk* root = aml_create_node(NULL);
AML_CHUNK* root = aml_create_node(NULL);
aml_add_buffer(root, ssdt_header, sizeof(ssdt_header)); // SSDT header
struct aml_chunk* scop = aml_add_scope(root, "\\_PR_");
struct aml_chunk* name = aml_add_name(scop, "PSS_");
struct aml_chunk* pack = aml_add_package(name);
AML_CHUNK* scop = aml_add_scope(root, "\\_PR_");
AML_CHUNK* name = aml_add_name(scop, "PSS_");
AML_CHUNK* pack = aml_add_package(name);
for (i = 0; i < p_states_count; i++)
{
struct aml_chunk* pstt = aml_add_package(pack);
for (i = 0; i < p_states_count; i++) {
AML_CHUNK* pstt = aml_add_package(pack);
aml_add_dword(pstt, p_states[i].Frequency);
aml_add_dword(pstt, 0x00000000); // Power
}
// Add aliaces
for (i = 0; i < acpi_cpu_count; i++)
{
for (i = 0; i < acpi_cpu_count; i++) {
char name[9];
sprintf(name, "_PR_%c%c%c%c", acpi_cpu_name[i][0], acpi_cpu_name[i][1], acpi_cpu_name[i][2], acpi_cpu_name[i][3]);
return ssdt;
}
}
else
{
} else {
verbose ("ACPI CPUs not found: P-States not generated !!!\n");
}
const char * value;
// Restart Fix
if (Platform.CPU.Vendor == 0x756E6547)
{/* Intel */
if (Platform.CPU.Vendor == 0x756E6547) { /* Intel */
fix_restart = true;
fix_restart_ps2 = false;
if ( getBoolForKey(kPS2RestartFix, &fix_restart_ps2, &bootInfo->chameleonConfig) && fix_restart_ps2)
{
if ( getBoolForKey(kPS2RestartFix, &fix_restart_ps2, &bootInfo->chameleonConfig) && fix_restart_ps2) {
fix_restart = true;
}
else
{
} else {
getBoolForKey(kRestartFix, &fix_restart, &bootInfo->chameleonConfig);
}
}
else
{
} else {
verbose ("Not an Intel platform: Restart Fix not applied !!!\n");
fix_restart = false;
}
if (fix_restart)
{
if (fix_restart) {
fadt_rev2_needed = true;
}
memcpy(fadt_mod, fadt, fadt->Length);
fadt_mod->Length = 0x84;
fadt_mod->Revision = 0x02; // FADT rev 2 (ACPI 1.0B MS extensions)
}
else
{
} else {
fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(fadt->Length);
memcpy(fadt_mod, fadt, fadt->Length);
}
// Determine system type / PM_Model
if ( (value=getStringForKey(kSystemType, &bootInfo->chameleonConfig))!=NULL)
{
if (Platform.Type > 6)
{
if(fadt_mod->PM_Profile<=6)
{
if (Platform.Type > 6) {
if(fadt_mod->PM_Profile<=6) {
Platform.Type = fadt_mod->PM_Profile; // get the fadt if correct
}
else
{
} else {
Platform.Type = 1;/* Set a fixed value (Desktop) */
}
verbose("Error: system-type must be 0..6. Defaulting to %d !\n", Platform.Type);
}
else
{
} else {
Platform.Type = (unsigned char) strtoul(value, NULL, 10);
}
}
// Set PM_Profile from System-type if only user wanted this value to be forced
if (fadt_mod->PM_Profile != Platform.Type)
{
if (value)
{
if (fadt_mod->PM_Profile != Platform.Type) {
if (value) {
// user has overriden the SystemType so take care of it in FACP
verbose("FADT: changing PM_Profile from 0x%02x to 0x%02x\n", fadt_mod->PM_Profile, Platform.Type);
fadt_mod->PM_Profile = Platform.Type;
}
else
{
} else {
// PM_Profile has a different value and no override has been set, so reflect the user value to ioregs
Platform.Type = fadt_mod->PM_Profile <= 6 ? fadt_mod->PM_Profile : 1;
}
setupSystemType();
// Patch FADT to fix restart
if (fix_restart)
{
if (fix_restart_ps2)
{
if (fix_restart) {
if (fix_restart_ps2) {
fadt_mod->Flags|= 0x400;
fadt_mod->Reset_SpaceID= 0x01; // System I/O
fadt_mod->Reset_BitWidth= 0x08; // 1 byte
fadt_mod->Reset_Address= 0x64; // Address of the register
fadt_mod->Reset_Value= 0xfe; // Value to write to reset the system
msglog("FADT: PS2 Restart Fix applied!\n");
}
else
{
} else {
fadt_mod->Flags|= 0x400;
fadt_mod->Reset_SpaceID= 0x01; // System I/O
fadt_mod->Reset_BitWidth= 0x08; // 1 byte
}
// Patch DSDT Address if we have loaded DSDT.aml
if(new_dsdt)
{
if(new_dsdt) {
DBG("DSDT: Old @%x,%x, ",fadt_mod->DSDT,fadt_mod->X_DSDT);
fadt_mod->DSDT=(uint32_t)new_dsdt;
if ((uint32_t)(&(fadt_mod->X_DSDT))-(uint32_t)fadt_mod+8<=fadt_mod->Length)
{
if ((uint32_t)(&(fadt_mod->X_DSDT))-(uint32_t)fadt_mod+8<=fadt_mod->Length) {
fadt_mod->X_DSDT=(uint32_t)new_dsdt;
}
acpi_cpu_count = 0;
/* Try using the file specified with the DSDT option */
if (getValueForKey(kDSDT, &filename, &len, &bootInfo->chameleonConfig))
{
sprintf(dirSpec, filename);
}
else
{
if (getValueForKey(kDSDT, &filename, &len, &bootInfo->chameleonConfig)) {
snprintf(dirSpec, sizeof(dirSpec), filename);
} else {
sprintf(dirSpec, "DSDT.aml");
//verbose("dirSpec, DSDT.aml");
}
getBoolForKey(kDropSSDT, &drop_ssdt, &bootInfo->chameleonConfig);
getBoolForKey(kGeneratePStates, &generate_pstates, &bootInfo->chameleonConfig);
getBoolForKey(kGenerateCStates, &generate_cstates, &bootInfo->chameleonConfig);
//getBoolForKey(kGenerateTStates, &generate_tstates, &bootInfo->chameleonConfig);
DBG("Generating P-States config: %d\n", generate_pstates);
DBG("Generating C-States config: %d\n", generate_cstates);
//DBG("Generating T-States config: %d\n", generate_tstates);
{
int i;
for (i = 0; i < 30; i++)
{
for (i = 0; i < 30; i++) {
char filename[512];
sprintf(filename, i > 0?"SSDT-%d.aml":"SSDT.aml", i);
if ( (new_ssdt[ssdt_count] = loadACPITable(filename)) )
{
if ( (new_ssdt[ssdt_count] = loadACPITable(filename)) ) {
ssdt_count++;
}
else
{
} else {
break;
}
}
// Find original rsdp
rsdp=(struct acpi_2_rsdp *)(version?getAddressOfAcpi20Table():getAddressOfAcpiTable());
if (!rsdp)
{
if (!rsdp) {
DBG("No ACPI version %d found. Ignoring\n", version+1);
if (version)
{
if (version) {
addConfigurationTable(&gEfiAcpi20TableGuid, NULL, "ACPI_20");
}
else
{
} else {
addConfigurationTable(&gEfiAcpiTableGuid, NULL, "ACPI");
}
continue;
DBG("RSDT @%x, Length %d\n",rsdt, rsdt->Length);
if (rsdt && (uint32_t)rsdt !=0xffffffff && rsdt->Length<0x10000)
{
if (rsdt && (uint32_t)rsdt !=0xffffffff && rsdt->Length<0x10000) {
uint32_t *rsdt_entries;
int rsdt_entries_num;
int dropoffset=0, i;
rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod;
rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4;
rsdt_entries=(uint32_t *)(rsdt_mod+1);
for (i=0;i<rsdt_entries_num;i++)
{
for (i=0;i<rsdt_entries_num;i++) {
char *table=(char *)(rsdt_entries[i]);
if (!table)
{
if (!table) {
continue;
}
rsdt_entries[i-dropoffset]=rsdt_entries[i];
if (drop_ssdt && tableSign(table, "SSDT"))
{
if (drop_ssdt && tableSign(table, "SSDT")) {
verbose("OEM SSDT tables was dropped\n");
dropoffset++;
continue;
}
if (tableSign(table, "DSDT"))
{
if (tableSign(table, "DSDT")) {
DBG("DSDT found\n");
verbose("Custom DSDT table was found\n");
if(new_dsdt)
{
if(new_dsdt) {
rsdt_entries[i-dropoffset]=(uint32_t)new_dsdt;
}
continue;
}
if (tableSign(table, "FACP"))
{
if (tableSign(table, "FACP")) {
struct acpi_2_fadt *fadt, *fadt_mod;
fadt=(struct acpi_2_fadt *)rsdt_entries[i];
DBG("FADT found @%x, Length %d\n",fadt, fadt->Length);
if (!fadt || (uint32_t)fadt == 0xffffffff || fadt->Length>0x10000)
{
if (!fadt || (uint32_t)fadt == 0xffffffff || fadt->Length>0x10000) {
printf("FADT incorrect. Not modified\n");
continue;
}
rsdt_entries[i-dropoffset]=(uint32_t)fadt_mod;
// Generate _CST SSDT
if (generate_cstates && (new_ssdt[ssdt_count] = generate_cst_ssdt(fadt_mod)))
{
if (generate_cstates && (new_ssdt[ssdt_count] = generate_cst_ssdt(fadt_mod))) {
DBG("C-States generated\n");
generate_cstates = false; // Generate SSDT only once!
ssdt_count++;
}
// Generating _PSS SSDT
if (generate_pstates && (new_ssdt[ssdt_count] = generate_pss_ssdt((void*)fadt_mod->DSDT)))
{
if (generate_pstates && (new_ssdt[ssdt_count] = generate_pss_ssdt((void*)fadt_mod->DSDT))) {
DBG("P-States generated\n");
generate_pstates = false; // Generate SSDT only once!
ssdt_count++;
rsdt_entries=(uint32_t *)(rsdt_mod+1);
// Mozodojo: Insert additional SSDTs into RSDT
if(ssdt_count>0)
{
if(ssdt_count>0) {
int j;
for (j=0; j<ssdt_count; j++)
for (j=0; j<ssdt_count; j++) {
rsdt_entries[i-dropoffset+j]=(uint32_t)new_ssdt[j];
}
verbose("RSDT: Added %d SSDT table(s)\n", ssdt_count);
rsdt_mod->Checksum=256-checksum8(rsdt_mod,rsdt_mod->Length);
DBG("New checksum %d at %x\n", rsdt_mod->Checksum,rsdt_mod);
}
else
{
} else {
rsdp_mod->RsdtAddress=0;
printf("RSDT not found or incorrect\n");
}
if (version)
{
if (version) {
struct acpi_2_xsdt *xsdt, *xsdt_mod;
// FIXME: handle 64-bit address correctly
xsdt=(struct acpi_2_xsdt*) ((uint32_t)rsdp->XsdtAddress);
DBG("XSDT @%x;%x, Length=%d\n", (uint32_t)(rsdp->XsdtAddress>>32),(uint32_t)rsdp->XsdtAddress, xsdt->Length);
if (xsdt && (uint64_t)rsdp->XsdtAddress<0xffffffff && xsdt->Length<0x10000)
{
if (xsdt && (uint64_t)rsdp->XsdtAddress<0xffffffff && xsdt->Length<0x10000) {
uint64_t *xsdt_entries;
int xsdt_entries_num, i;
int dropoffset=0;
rsdp_mod->XsdtAddress=(uint32_t)xsdt_mod;
xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8;
xsdt_entries=(uint64_t *)(xsdt_mod+1);
for (i=0;i<xsdt_entries_num;i++)
{
for (i=0;i<xsdt_entries_num;i++) {
char *table=(char *)((uint32_t)(xsdt_entries[i]));
if (!table)
{
if (!table) {
continue;
}
xsdt_entries[i-dropoffset]=xsdt_entries[i];
if (drop_ssdt && tableSign(table, "SSDT"))
{
if (drop_ssdt && tableSign(table, "SSDT")) {
verbose("OEM SSDT tables was dropped\n");
dropoffset++;
continue;
}
if (tableSign(table, "DSDT"))
{
if (tableSign(table, "DSDT")) {
DBG("DSDT found\n");
if (new_dsdt)
{
if (new_dsdt) {
xsdt_entries[i-dropoffset]=(uint32_t)new_dsdt;
}
continue;
}
if (tableSign(table, "FACP"))
{
if (tableSign(table, "FACP")) {
struct acpi_2_fadt *fadt, *fadt_mod;
fadt=(struct acpi_2_fadt *)(uint32_t)xsdt_entries[i];
DBG("FADT found @%x,%x, Length %d\n",(uint32_t)(xsdt_entries[i]>>32),fadt,
fadt->Length);
if (!fadt || (uint64_t)xsdt_entries[i] >= 0xffffffff || fadt->Length>0x10000)
{
if (!fadt || (uint64_t)xsdt_entries[i] >= 0xffffffff || fadt->Length>0x10000) {
verbose("FADT incorrect or after 4GB. Dropping XSDT\n");
goto drop_xsdt;
}
DBG("TABLE %c%c%c%c@%x,",table[0],table[1],table[2],table[3],xsdt_entries[i]);
// Generate _CST SSDT
if (generate_cstates && (new_ssdt[ssdt_count] = generate_cst_ssdt(fadt_mod)))
{
if (generate_cstates && (new_ssdt[ssdt_count] = generate_cst_ssdt(fadt_mod))) {
generate_cstates = false; // Generate SSDT only once!
ssdt_count++;
}
// Generating _PSS SSDT
if (generate_pstates && (new_ssdt[ssdt_count] = generate_pss_ssdt((void*)fadt_mod->DSDT)))
{
if (generate_pstates && (new_ssdt[ssdt_count] = generate_pss_ssdt((void*)fadt_mod->DSDT))) {
generate_pstates = false; // Generate SSDT only once!
ssdt_count++;
}
// Generating _TSS SSDT
/*if (generate_tstates && (new_ssdt[ssdt_count] = generate_tss_ssdt((void*)fadt_mod->DSDT)))
{
generate_tstates = false; // Generate SSDT only once!
ssdt_count++;
}*/
continue;
}
xsdt_entries=(uint64_t *)(xsdt_mod+1);
// Mozodojo: Insert additional SSDTs into XSDT
if(ssdt_count > 0)
{
if(ssdt_count > 0) {
int j;
for (j=0; j<ssdt_count; j++)
for (j=0; j<ssdt_count; j++) {
xsdt_entries[i-dropoffset+j]=(uint32_t)new_ssdt[j];
}
verbose("Added %d SSDT table(s) into XSDT\n", ssdt_count);
}
// Correct the checksum of XSDT
xsdt_mod->Checksum=0;
xsdt_mod->Checksum=256-checksum8(xsdt_mod,xsdt_mod->Length);
}
else
{
} else {
drop_xsdt:
DBG("About to drop XSDT\n");
DBG("New checksum %d\n", rsdp_mod->Checksum);
if (version)
{
if (version) {
DBG("RSDP: Original extended checksum %d", rsdp_mod->ExtendedChecksum);
rsdp_mod->ExtendedChecksum=0;
rsdp_mod->ExtendedChecksum=256-checksum8(rsdp_mod,rsdp_mod->Length);
DBG("New extended checksum %d\n", rsdp_mod->ExtendedChecksum);
}
//verbose("Patched ACPI version %d DSDT\n", version+1);
if (version)
{
if (version) {
/* XXX aserebln why uint32 cast if pointer is uint64 ? */
acpi20_p = (uint32_t)rsdp_mod;
addConfigurationTable(&gEfiAcpi20TableGuid, &acpi20_p, "ACPI_20");
}
else
{
} else {
/* XXX aserebln why uint32 cast if pointer is uint64 ? */
acpi10_p = (uint32_t)rsdp_mod;
addConfigurationTable(&gEfiAcpiTableGuid, &acpi10_p, "ACPI");
branches/Bungo/i386/libsaio/device_tree.h
11
2
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
323
424
525
......
828
929
1030
31
32
33
1134
12
13
14
15
16
35
36
37
38
1739
1840
41
42
43
1944
20
21
22
23
24
25
45
46
47
48
2649
2750
2851
......
4770
4871
4972
50
51
52
53
73
74
75
5476
5577
5678
/*
* Copyright (c) 2005 Apple Computer, Inc. All Rights Reserved.
* Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
* Reserved. This file contains Original Code and/or Modifications of
* Original Code as defined in and that are subject to the Apple Public
* Source License Version 2.0 (the "License"). You may not use this file
* except in compliance with the License. Please obtain a copy of the
* License at http://www.apple.com/publicsource and read it before using
* this file.
*
* The Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef __DEVICE_TREE_H
#include <stdbool.h>
#include <stdint.h>
//==============================================================================
typedef struct _Property {
const char * name;
uint32_t length;
void * value;
struct _Property * next;
const char *name;
uint32_tlength;
void *value;
struct _Property *next;
} Property;
//==============================================================================
typedef struct _Node {
struct _Property * properties;
struct _Property * last_prop;
struct _Node * children;
struct _Node * next;
struct _Property *properties;
struct _Property *last_prop;
struct _Node *children;
struct _Node *next;
} Node;
void
DT__Initialize(void);
/*
* Free up memory used by in-memory representation
* of device tree.
*/
// Free up memory used by in-memory representation of device tree.
extern void
DT__Finalize(void);
branches/Bungo/i386/libsaio/allocate.c
3333
3434
3535
36
37
3638
3739
3840
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
5564
5665
66
67
68
5769
58
70
5971
60
72
6173
62
63
64
65
66
67
74
75
76
77
78
6879
69
70
71
72
73
80
81
82
7483
75
84
85
86
7687
#define RoundPage(x) ((((unsigned)(x)) + kPageSize - 1) & ~(kPageSize - 1))
//==============================================================================
long
AllocateMemoryRange(char * rangeName, long start, long length, long type)
{
char *nameBuf;
uint32_t *buffer;
nameBuf = malloc(strlen(rangeName) + 1);
if (nameBuf == 0) return -1;
strcpy(nameBuf, rangeName);
buffer = malloc(2 * sizeof(uint32_t));
if (buffer == 0) return -1;
buffer[0] = start;
buffer[1] = length;
DT__AddProperty(gMemoryMapNode, nameBuf, 2 * sizeof(uint32_t), (char *)buffer);
return 0;
char *nameBuf;
uint32_t *buffer;
nameBuf = malloc(strlen(rangeName) + 1);
if (nameBuf == 0) {
return -1;
}
buffer = malloc(2 * sizeof(uint32_t));
if (buffer == 0) {
free(nameBuf);
return -1;
}
strcpy(nameBuf, rangeName);
buffer[0] = start;
buffer[1] = length;
DT__AddProperty(gMemoryMapNode, nameBuf, 2 * sizeof(uint32_t), (char *)buffer);
return 0;
}
//==============================================================================
long
AllocateKernelMemory( long inSize )
AllocateKernelMemory(long inSize)
{
long addr;
long addr;
if (gImageLastKernelAddr == 0) {
gImageLastKernelAddr = RoundPage( bootArgs->kaddr +
bootArgs->ksize );
}
addr = gImageLastKernelAddr;
gImageLastKernelAddr += RoundPage(inSize);
if (gImageLastKernelAddr == 0) {
gImageLastKernelAddr = RoundPage(bootArgs->kaddr + bootArgs->ksize);
}
addr = gImageLastKernelAddr;
gImageLastKernelAddr += RoundPage(inSize);
if ( gImageLastKernelAddr >= (KERNEL_ADDR + KERNEL_LEN) ) {
stop ("AllocateKernelMemory error");
}
bootArgs->ksize = gImageLastKernelAddr - bootArgs->kaddr;
if ( gImageLastKernelAddr >= (KERNEL_ADDR + KERNEL_LEN) ) {
stop ("AllocateKernelMemory error");
}
return addr;
bootArgs->ksize = gImageLastKernelAddr - bootArgs->kaddr;
return addr;
}
branches/Bungo/i386/libsaio/bootargs.h
4545
4646
4747
48
49
48
49
5050
5151
5252
......
5757
5858
5959
60
60
6161
6262
6363
......
9393
9494
9595
96
97
96
97
9898
9999
100100
101101
102102
103
104
103
104
105105
106106
107107
......
109109
110110
111111
112
113
112
113
114114
115115
116116
117117
118
118
119119
120120
121121
122
122
123123
124
124
125125
126126
127127
128128
129
129
130130
131
131
132132
133133
134
134
135135
136136
137
137
138138
139139
140140
141
141
142142
143143
144
144
145145
146146
147
147
148148
149149
150150
......
152152
153153
154154
155
155
156156
157157
158158
159159
160160
161
161
162162
163
163
164164
165165
166166
167167
168
168
169169
170
170
171171
172172
173
173
174174
175175
176
176
177177
178178
179179
180
180
181181
182182
183183
......
185185
186186
187187
188
188
189189
190190
191191
enum {
kEfiReservedMemoryType= 0,
kEfiLoaderCode= 1,
kEfiLoaderData= 2,
kEfiLoaderCode= 1,
kEfiLoaderData= 2,
kEfiBootServicesCode= 3,
kEfiBootServicesData= 4,
kEfiRuntimeServicesCode= 5,
kEfiACPIMemoryNVS= 10,
kEfiMemoryMappedIO= 11,
kEfiMemoryMappedIOPortSpace = 12,
kEfiPalCode= 13,
kEfiPalCode= 13,
kEfiMaxMemoryType= 14
};
/* Values for v_display */
#define GRAPHICS_MODE1
#define FB_TEXT_MODE2
#define GRAPHICS_MODE1
#define FB_TEXT_MODE2
/* Boot argument structure - passed into Mach kernel at boot time.
* "Revision" can be incremented for compatible changes
*/
// Lion
#define kBootArgsRevision0
#define kBootArgsVersion2
#define kBootArgsRevision0
#define kBootArgsVersion2
// Snow Leopard and older
#define kBootArgsPreLionRevision6
/* Snapshot constants of previous revisions that are supported */
#define kBootArgsEfiMode3232
#define kBootArgsEfiMode6464
#define kBootArgsEfiMode3232
#define kBootArgsEfiMode6464
typedef struct boot_args {
uint16_t Revision;/* Revision of boot_args structure */
uint16_t Version;/* Version of boot_args structure */
uint8_t efiMode; /* 32 = 32-bit, 64 = 64-bit */
uint8_t debugMode; /* Bit field with behavior changes */
uint8_t __reserved1[2];
char CommandLine[BOOT_LINE_LENGTH];/* Passed in command line */
uint32_t MemoryMap; /* Physical address of memory map */
uint32_t MemoryMapSize;
uint32_t MemoryMapDescriptorSize;
uint32_t MemoryMapDescriptorVersion;
Boot_VideoVideo;/* Video Information */
uint32_t deviceTreeP; /* Physical address of flattened device tree */
uint32_t deviceTreeLength; /* Length of flattened tree */
uint32_t kaddr; /* Physical address of beginning of kernel text */
uint32_t ksize; /* Size of combined kernel text+data+efi */
uint32_t efiRuntimeServicesPageStart; /* physical address of defragmented runtime pages */
uint32_t efiRuntimeServicesPageCount;
uint64_t efiRuntimeServicesVirtualPageStart; /* virtual address of defragmented runtime pages */
uint32_t efiSystemTable; /* physical address of system table in runtime area */
uint32_t __reserved2;
uint32_t performanceDataStart; /* physical address of log */
uint32_t performanceDataSize;
uint32_t keyStoreDataStart; /* physical address of key store data */
uint32_t keyStoreDataSize;
uint64_tbootMemStart;
uint64_t PhysicalMemorySize;
uint64_t FSBFrequency;
uint32_t __reserved4[734];
</