Chameleon

Chameleon Commit Details

Date:2015-03-08 15:28:28 (4 years 4 months ago)
Author:zenith432
Commit:2594
Parents: 2593
Message:Sync with trunk (r.2593)
Changes:
M/branches/zenith432/i386/libsaio/convert.h
M/branches/zenith432/package/Scripts.templates/Pre/preinstall
M/branches/zenith432/i386/boot2/gui.c
M/branches/zenith432/i386/modules/Keylayout/layouts/cham-mklayout.c
M/branches/zenith432/i386/libsaio/platform.h
M/branches/zenith432/i386/libsaio/disk.c
M/branches/zenith432/i386/libsaio/saio_internal.h
M/branches/zenith432/i386/modules/Resolution/Resolution.c
M/branches/zenith432/i386/boot2/options.c
M/branches/zenith432/i386/libsaio/xml.c
M/branches/zenith432/i386/boot2/graphic_utils.c
M/branches/zenith432/i386/libsaio/device_inject.h
M/branches/zenith432/i386/libsaio/smbios.h
M/branches/zenith432/i386/modules/Keylayout/Keylayout.c
M/branches/zenith432/i386/libsaio/xml.h
M/branches/zenith432/i386/libsaio/efi.h
M/branches/zenith432/package/Scripts.templates/InstallModule/postinstall
M/branches/zenith432/i386/libsaio/vbe.c
M/branches/zenith432/CHANGES
M/branches/zenith432/i386/libsaio/ati.c
M/branches/zenith432/i386/libsaio/pci_root.c
M/branches/zenith432/i386/libsaio/device_tree.c
M/branches/zenith432/i386/libsaio/biosfn.c
M/branches/zenith432/i386/libsaio/hfs.c
M/branches/zenith432/i386/boot2/drivers.c
M/branches/zenith432/i386/libsaio/ati.h
M/branches/zenith432/i386/modules/Makefile
M/branches/zenith432/i386/boot2/mboot.c
M/branches/zenith432/package/Scripts.templates/Post/postinstall
M/branches/zenith432/i386/libsaio/spd.c
M/branches/zenith432/i386/libsaio/cpu.c
M/branches/zenith432/i386/libsaio/md5c.c
M/branches/zenith432/package/Scripts.templates/InstallTheme/postinstall
M/branches/zenith432/i386/libsaio/fake_efi.c
M/branches/zenith432/i386/libsaio/pci_setup.c
M/branches/zenith432/i386/boot2/lzvn.c
M/branches/zenith432/i386/libsaio/fake_efi.h
M/branches/zenith432/package/Scripts/Main/ESPpostinstall
M/branches/zenith432/i386/boot2/resume.c
M/branches/zenith432
M/branches/zenith432/i386/libsaio/gma.c
M/branches/zenith432/i386/util/segsize.c
M/branches/zenith432/i386/boot2/boot.c
M/branches/zenith432/i386/libsa/libsa.h
M/branches/zenith432/package/Scripts/Main/Standardpostinstall
M/branches/zenith432/i386/libsaio/ntfs_private.h
M/branches/zenith432/i386/libsaio/nvidia_helper.c
M/branches/zenith432/i386/modules/AcpiCodec/acpi_codec.c
M/branches/zenith432/package/buildpkg.sh
M/branches/zenith432/i386/libsaio/nvidia.c
M/branches/zenith432/i386/boot2/boot.h
M/branches/zenith432/i386/boot2/modules.c
M/branches/zenith432/i386/libsaio/pci.c
M/branches/zenith432/i386/util/dyldsymboltool.c
M/branches/zenith432/i386/libsa/string.c
M/branches/zenith432/i386/libsaio/load.c
M/branches/zenith432/i386/libsaio/convert.c
M/branches/zenith432/i386/boot2/modules.h
M/branches/zenith432/package/Scripts.templates/AddOption/postinstall

File differences

branches/zenith432/i386/libsaio/fake_efi.h
2929
3030
3131
32
32
3333
3434
3535
#define __LIBSAIO_FAKE_EFI_H
/* Set up space for up to 10 configuration table entries */
#define MAX_CONFIGURATION_TABLE_ENTRIES 10
#define MAX_CONFIGURATION_TABLE_ENTRIES (uint32_t)10
extern void setupFakeEfi(void);
branches/zenith432/i386/libsaio/xml.c
22
33
44
5
5
66
7
7
88
99
1010
1111
1212
13
13
1414
1515
1616
......
1818
1919
2020
21
21
2222
2323
2424
......
3030
3131
3232
33
33
3434
35
35
3636
3737
38
38
3939
4040
4141
......
5555
5656
5757
58
58
5959
60
60
6161
6262
6363
6464
6565
6666
67
67
6868
6969
7070
......
127127
128128
129129
130
131
130
132131
133132
134133
135
134
135
136136
137137
138138
......
142142
143143
144144
145
145
146
146147
147148
148149
149
150
151
150152
151153
152154
......
156158
157159
158160
159
160
161
161162
162163
163
164
164
165
166
165167
166168
167169
......
173175
174176
175177
176
178
179
177180
178181
179182
180183
181
184
185
182186
183187
184188
......
188192
189193
190194
191
195
196
192197
193198
194199
......
204209
205210
206211
207
212
213
208214
209215
210216
......
214220
215221
216222
217
223
218224
219225
220
226
227
221228
222229
223
230
224231
225232
226233
227234
228
235
229236
230237
231238
232239
233240
234
241
242
235243
236244
237245
......
243251
244252
245253
246
254
247255
248256
257
249258
250259
251
252
260
253261
254262
255
263
256264
257265
258266
......
269277
270278
271279
272
280
281
273282
274283
275284
......
277286
278287
279288
280
289
290
281291
282292
283293
284294
285295
286296
287
297
298
288299
289300
290301
291302
292
303
304
293305
294306
295307
......
303315
304316
305317
306
307318
308319
309320
......
311322
312323
313324
314
315
325
316326
317
318
319
320
327
328
329
330
321331
322332
323333
324334
335
325336
326337
327338
328339
329
330
331
332
340
341
342
343
333344
334
345
335346
336
337
338
339
340
347
348
349
350
351
352
353
354
355
356
357
358
341359
342
343
344
345
346
360
361
362
363
364
365
347366
348
349367
350368
351369
352370
353
354
371
355372
356
357
373
374
358375
376
377
378
359379
360
380
381
361382
362383
363384
364385
365
386
387
366388
367389
368390
......
371393
372394
373395
374
396
397
398
375399
376
400
401
402
377403
378404
379405
380
406
407
381408
382409
383410
384411
385
412
413
386414
387
415
416
417
388418
389
419
420
390421
391422
392423
393424
394425
395426
396
397
427
428
429
430
398431
399
432
433
434
400435
401436
402437
403438
404439
405440
406
441
407442
408
443
444
445
409446
410447
411448
412449
413450
414451
415
416
452
453
454
455
417456
418
457
458
459
419460
420461
421462
......
430471
431472
432473
433
474
434475
435476
436477
437478
438479
439480
440
481
482
441483
442
443
484
485
486
487
488
444489
445490
446491
447492
448493
449494
450
451
495
496
497
498
452499
453
500
501
502
454503
455504
456505
457506
458507
459508
460
509
461510
462
511
512
513
463514
464515
465516
466517
467518
468519
469
470
520
521
522
523
471524
472
525
526
527
473528
474529
475530
476531
477532
478533
479
534
480535
481536
482537
......
485540
486541
487542
488
543
489544
490545
491
546
547
548
492549
493550
494551
495552
496553
497554
498
555
556
499557
500558
501559
502560
503
561
562
504563
505564
506565
......
511570
512571
513572
514
573
574
515575
516
576
577
578
517579
518
580
581
582
519583
520584
521585
522586
523
587
588
524589
525590
526
591
592
527593
528594
529
595
596
530597
531
598
599
600
532601
533602
534603
535604
536
537
605
606
607
538608
539609
540610
541611
542
612
613
543614
544615
545616
......
549620
550621
551622
552
553
623
554624
555
556
625
626
627
628
629
557630
558
559
560
561
562
631
632
633
634
563635
564
636
637
565638
566639
567640
568641
569642
570643
571
644
645
572646
573647
574648
575649
576650
577651
578
652
653
579654
580655
581656
582657
583658
584659
585
660
661
586662
587663
588664
......
601677
602678
603679
604
605
680
606681
607
608
609
682
683
684
685
686
610687
611688
612
689
690
613691
614692
615693
616694
617
695
696
618697
619698
620699
621700
622
701
702
623703
624704
625705
626706
627707
628
708
709
629710
630711
631712
......
638719
639720
640721
641
722
642723
643724
644725
645726
646727
647728
648
649
729
650730
651
652
731
732
653733
654734
655
735
736
656737
657738
658739
659740
660
741
742
661743
662744
663
745
664746
665
747
748
666749
667750
668751
......
670753
671754
672755
756
673757
674
675758
676759
677760
......
680763
681764
682765
683
684
766
685767
686768
687769
......
704786
705787
706788
707
789
708790
709
791
792
710793
711794
712795
713796
714797
715
798
799
716800
717801
718802
719803
720
804
805
721806
722
723
724
807
808
809
810
725811
726
812
813
814
727815
728
816
817
818
729819
730
820
821
822
731823
732824
733825
734826
735827
736828
737
738
829
830
831
832
833
739834
740835
741836
742837
743838
744
745
746
839
840
841
842
843
844
747845
748846
749847
......
772870
773871
774872
775
776
873
777874
778
779
780
875
876
877
878
781879
782880
783
881
882
883
884
784885
785886
786
887
888
889
890
787891
788892
789893
790894
791895
792
896
793897
794898
899
795900
796901
902
797903
798904
799905
......
804910
805911
806912
807
808
913
809914
810
811
915
916
812917
813918
814
919
920
921
922
815923
816924
817
925
926
927
928
818929
819930
820931
......
822933
823934
824935
936
825937
826
827938
828939
829940
......
833944
834945
835946
836
837
947
838948
839949
840950
841951
842
952
953
954
955
843956
844957
845958
846959
960
847961
848
849962
850963
851964
......
855968
856969
857970
858
859
971
860972
861
973
974
862975
863
976
977
864978
865979
866980
867981
868982
869
870
983
984
985
986
987
988
989
871990
872991
873992
874993
875
876
994
995
996
997
998
999
1000
8771001
8781002
8791003
8801004
8811005
8821006
883
1007
1008
8841009
8851010
8861011
......
8931018
8941019
8951020
896
897
1021
8981022
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
9151048
9161049
9171050
......
9211054
9221055
9231056
924
925
1057
9261058
927
928
1059
1060
9291061
930
931
932
933
934
935
936
937
938
939
940
941
942
943
1062
1063
1064
1065
1066
1067
1068
9441069
945
946
1070
1071
1072
1073
1074
1075
1076
1077
1078
9471079
948
949
950
951
1080
1081
1082
1083
1084
1085
1086
9521087
9531088
9541089
9551090
9561091
957
958
1092
9591093
9601094
961
1095
1096
9621097
9631098
9641099
965
1100
1101
9661102
9671103
9681104
......
9921128
9931129
9941130
995
1131
9961132
9971133
9981134
9991135
10001136
10011137
1002
1003
1138
10041139
10051140
1006
10071141
1142
1143
10081144
10091145
10101146
1011
1012
1147
1148
1149
10131150
1014
1151
1152
10151153
10161154
10171155
......
10271165
10281166
10291167
1030
1168
1169
10311170
10321171
10331172
......
10381177
10391178
10401179
1041
1042
1180
10431181
10441182
10451183
10461184
10471185
10481186
1049
1187
1188
10501189
10511190
10521191
10531192
10541193
10551194
1056
1195
1196
10571197
10581198
10591199
10601200
1061
1201
1202
10621203
1063
1204
1205
1206
10641207
10651208
10661209
......
10721215
10731216
10741217
1075
1076
1218
10771219
10781220
1079
1221
10801222
10811223
10821224
1083
1084
1225
1226
1227
1228
10851229
10861230
10871231
......
10891233
10901234
10911235
1092
1236
1237
10931238
10941239
10951240
......
10981243
10991244
11001245
1101
1246
1247
11021248
11031249
11041250
......
11121258
11131259
11141260
1115
1261
1262
11161263
11171264
1118
1265
1266
1267
11191268
11201269
11211270
......
11341283
11351284
11361285
1137
1286
1287
11381288
11391289
1140
1290
1291
1292
11411293
1142
1294
1295
1296
11431297
11441298
11451299
......
11491303
11501304
11511305
1152
1306
11531307
1154
1308
1309
11551310
11561311
11571312
1158
1313
1314
11591315
11601316
11611317
11621318
11631319
11641320
1165
1321
11661322
1167
1323
1324
11681325
11691326
11701327
1171
1328
1329
11721330
11731331
11741332
......
11791337
11801338
11811339
1182
1340
1341
11831342
1184
1343
1344
1345
11851346
11861347
11871348
......
11931354
11941355
11951356
1196
1357
1358
11971359
11981360
1199
1361
1362
1363
12001364
12011365
12021366
......
12091373
12101374
12111375
1212
1376
1377
12131378
12141379
12151380
1216
1381
1382
1383
12171384
12181385
12191386
12201387
12211388
1222
1389
12231390
1224
1391
1392
12251393
12261394
12271395
......
12291397
12301398
12311399
1232
1400
1401
12331402
12341403
12351404
12361405
1237
1406
1407
12381408
12391409
12401410
......
12461416
12471417
12481418
1249
1419
1420
12501421
12511422
12521423
12531424
12541425
1255
1426
1427
12561428
12571429
12581430
* Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
*
* Portions Copyright (c) 2003 Apple Computer, Inc. All Rights
* Reserved.
* Reserved.
* The contents of this file constitute Original Code as defined in and
* 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.
*
*
* This 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,
* 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@
*/
string_ref *ref_strings = NULL;
/// TODO: remove below
static char* buffer_start = NULL;
static char *buffer_start = NULL;
// TODO: redo the next two functions
void SaveRefString(char* string, int id)
void SaveRefString(char *string, int id)
{
//printf("Adding Ref String %d (%s)\n", id, string);
string_ref* tmp = ref_strings;
string_ref *tmp = ref_strings;
while(tmp)
{
if(tmp->id == id)
ref_strings = new_ref;
}
char* GetRefString(int id)
char *GetRefString(int id)
{
string_ref* tmp = ref_strings;
string_ref *tmp = ref_strings;
while(tmp)
{
if(tmp->id == id) return tmp->string;
tmp = tmp->next;
}
//verbose("Unable to locate Ref String %d\n", id);
return "";
return "Unknown";
}
struct Module {
//==========================================================================
// XMLGetProperty
TagPtr
XMLGetProperty(TagPtr dict, const char * key)
TagPtr XMLGetProperty(TagPtr dict, const char *key)
{
TagPtr tagList, tag;
if (dict->type != kTagTypeDict) {
if (dict->type != kTagTypeDict)
{
return 0;
}
tag = tagList;
tagList = tag->tagNext;
if ((tag->type != kTagTypeKey) || (tag->string == 0)) {
if ((tag->type != kTagTypeKey) || (tag->string == 0))
{
continue;
}
if (!strcmp(tag->string, key)) {
if (!strcmp(tag->string, key))
{
return tag->tag;
}
}
//==========================================================================
// XMLGetProperty
TagPtr
XMLGetKey( TagPtr dict, int id )
TagPtr XMLGetKey( TagPtr dict, int id )
{
TagPtr tagList, tag;
if (dict->type != kTagTypeDict) {
if (dict->type != kTagTypeDict)
{
return 0;
}
tag = tagList;
tagList = tag->tagNext;
if ((tag->type != kTagTypeKey) || (tag->string == 0)) {
if ((tag->type != kTagTypeKey) || (tag->string == 0))
{
continue;
}
element++;
if(id == element) {
if(id == element)
{
return tag;
}
TagPtr XMLGetValueForKey(TagPtr key)
{
if (!key || key->type != kTagTypeKey) {
if (!key || key->type != kTagTypeKey)
{
return 0;
}
int count = 0;
TagPtr tagList, tag;
if (dict->type != kTagTypeDict && dict->type != kTagTypeArray) {
if (dict->type != kTagTypeDict && dict->type != kTagTypeArray)
{
return 0;
}
{
tag = tagList;
tagList = tag->tagNext;
if (((tag->type != kTagTypeKey) && ((tag->string == 0) || (tag->string[0] == 0)))
&& (dict->type != kTagTypeArray)// If we are an array, any element is valid
) {
)
{
continue;
}
//if(tag->type == kTagTypeKey) printf("Located key %s\n", tag->string);
count++;
}
return count;
}
TagPtr XMLGetElement( TagPtr dict, int id )
{
if(dict->type != kTagTypeArray) {
if(dict->type != kTagTypeArray)
{
return 0;
}
element++;
tmp = tmp->tagNext;
}
return tmp;
}
/* Function for basic XML character entities parsing */
char*
XMLDecode(const char* src)
char *XMLDecode(const char* src)
{
typedef const struct XMLEntity {
const char* name;
const char *name;
size_t nameLen;
char value;
} XMLEntity;
const char *s;
char *out, *o;
if ( !src || !(len = strlen(src)) || !(out = malloc(len+1)) ) {
if ( !src || !(len = strlen(src)) || !(out = malloc(len+1)) )
{
return 0;
}
s = src;
while (s <= src+len) /* Make sure the terminator is also copied */
{
if ( *s == '&' ) {
if ( *s == '&' )
{
bool entFound = false;
int i;
s++;
for ( i = 0; i < sizeof(ents)/sizeof(ents[0]); i++)
{
if ( strncmp(s, ents[i].name, ents[i].nameLen) == 0 ) {
if ( strncmp(s, ents[i].name, ents[i].nameLen) == 0 )
{
entFound = true;
break;
}
}
if ( entFound ) {
if ( entFound )
{
*o++ = ents[i].value;
s += ents[i].nameLen;
return out;
}
//#if UNUSED
//==========================================================================
// XMLParseFile
// Expects to see one dictionary in the XML file, the final pos will be returned
// Puts the first dictionary it finds in the
// tag pointer and returns the end of the dic, or returns -1 if not found.
//
long
XMLParseFile( char * buffer, TagPtr * dict )
long XMLParseFile( char * buffer, TagPtr *dict )
{
long length, pos;
TagPtr tag;
pos = 0;
char *configBuffer;
longlength;
longpos = 0;
TagPtrtag;
char*configBuffer;
int strlength = strlen(buffer);
configBuffer = malloc(strlength+1);
bcopy(buffer, configBuffer, strlength);
configBuffer[strlength] = 0;
buffer_start = configBuffer;
while (1)
{
length = XMLParseNextTag(configBuffer + pos, &tag);
if (length == -1) break;
while (1)
{
length = XMLParseNextTag(configBuffer + pos, &tag);
if (length == -1) break;
pos += length;
pos += length;
if (tag == 0) continue;
if (tag->type == kTagTypeDict) break;
XMLFreeTag(tag);
}
if (tag == 0)
{
continue;
}
if (tag->type == kTagTypeDict)
{
break;
}
XMLFreeTag(tag);
}
free(configBuffer);
if (length < 0) {
return -1;
}
*dict = tag;
return pos;
if (length < 0)
{
return -1;
}
*dict = tag;
return pos;
}
//#endif /* UNUSED */
//==========================================================================
// ParseNextTag
// TODO: cleanup
long
XMLParseNextTag( char * buffer, TagPtr * tag )
long XMLParseNextTag( char *buffer, TagPtr *tag )
{
long length, pos;
char * tagName;
longlength = 0;
longpos = 0;
char*tagName;
length = GetNextTag(buffer, &tagName, 0);
if (length == -1) {
if (length == -1)
{
return -1;
}
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;
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);
}
}
/***** 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;
}
}
int integer = (int)GetRefString(id);
TagPtr tmpTag = NewTag();
tmpTag->type = kTagTypeInteger;
tmpTag->string = (char*) integer;
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);
}
}
/***** 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);
}
/***** data ****/
else if (!strcmp(tagName, kXMLTagData)) {
else if (!strcmp(tagName, kXMLTagData))
{
length = ParseTagData(buffer + pos, tag);
} else if (!strncmp(tagName, kXMLTagData " ", strlen(kXMLTagData " "))) {
}
else if (!strncmp(tagName, kXMLTagData " ", strlen(kXMLTagData " ")))
{
length = ParseTagData(buffer + pos, tag);
} else if (!strcmp(tagName, kXMLTagDate)) {
}
else if (!strcmp(tagName, kXMLTagDate))
{
length = ParseTagDate(buffer + pos, tag);
}
/***** date ****/
else if (!strncmp(tagName, kXMLTagDate " ", strlen(kXMLTagDate " "))) {
else if (!strncmp(tagName, kXMLTagDate " ", strlen(kXMLTagDate " ")))
{
length = ParseTagDate(buffer + pos, tag);
}/***** array ****/
else if (!strcmp(tagName, kXMLTagArray)) {
else if (!strcmp(tagName, kXMLTagArray))
{
length = ParseTagList(buffer + pos, tag, kTagTypeArray, 0);
}
else if (!strncmp(tagName, kXMLTagArray " ", strlen(kXMLTagArray " "))) {
else if (!strncmp(tagName, kXMLTagArray " ", strlen(kXMLTagArray " ")))
{
length = ParseTagList(buffer + pos, tag, kTagTypeArray, 0);
} else if (!strcmp(tagName, kXMLTagArray "/")) {
}
else if (!strcmp(tagName, kXMLTagArray "/"))
{
length = ParseTagList(buffer + pos, tag, kTagTypeArray, 1);
}
/***** unknown ****/
else {
// it wasn't parsed so we consumed no additional characters
else
{
// it wasn't parsed so we consumed no additional characters
*tag = 0;
length = 0;
}
if (length == -1) {
if (length == -1)
{
return -1;
}
//==========================================================================
// 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;
longpos = 0;
longlength = 0;
TagPtrtagList = 0;
TagPtrtmpTag;
tagList = 0;
pos = 0;
if (!empty) {
while (1) {
if (!empty)
{
while (1)
{
length = XMLParseNextTag(buffer + pos, &tmpTag);
if (length == -1) {
if (length == -1)
{
break;
}
pos += length;
// detect end of list
if (tmpTag == 0) {
if (tmpTag == 0)
{
break;
}
tmpTag->tagNext = tagList;
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;
TagPtr tmpTag, subTag;
longlength = 0;
longlength2 = 0;
char*string;
TagPtrtmpTag;
TagPtrsubTag;
length = FixDataMatchingTag(buffer, kXMLTagKey);
if (length == -1) {
if (length == -1)
{
return -1;
}
length2 = XMLParseNextTag(buffer + length, &subTag);
if (length2 == -1) {
if (length2 == -1)
{
return -1;
}
tmpTag = NewTag();
if (tmpTag == 0) {
if (tmpTag == 0)
{
XMLFreeTag(subTag);
return -1;
}
string = NewSymbol(buffer);
if (string == 0) {
if (string == 0)
{
XMLFreeTag(subTag);
XMLFreeTag(tmpTag);
return -1;
tmpTag->tagNext = 0;
*tag = tmpTag;
return length + length2;
}
//==========================================================================
// ParseTagString
static long
ParseTagString( char * buffer, TagPtr * tag )
static long ParseTagString( char *buffer, TagPtr *tag )
{
long length;
char * string;
longlength = 0;
char*string;
length = FixDataMatchingTag(buffer, kXMLTagString);
if (length == -1) {
if (length == -1)
{
return -1;
}
TagPtr tmpTag = NewTag();
if (tmpTag == 0) {
if (tmpTag == 0)
{
return -1;
}
string = NewSymbol(buffer);
if (string == 0) {
if (string == 0)
{
XMLFreeTag(tmpTag);
return -1;
}
tmpTag->type = kTagTypeString;
tmpTag->string = string;
tmpTag->tag = 0;
tmpTag->tagNext = 0;
tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
tmpTag->tagNext = 0;
*tag = tmpTag;
return length;
//==========================================================================
// ParseTagInteger
static long
ParseTagInteger( char * buffer, TagPtr * tag )
static long ParseTagInteger( char *buffer, TagPtr *tag )
{
long length, integer;
bool negative = false;
return 0;
}
size = length = FixDataMatchingTag(buffer, kXMLTagInteger);
if (length == -1) {
if (length == -1)
{
return -1;
}
tmpTag = NewTag();
if (tmpTag == 0) {
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
}
else if ((*val >= 'A' && *val <= 'F'))// A - F
{
integer = (integer * 16) + (*val++ - 'A' + 10);
} else {
}
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;
//==========================================================================
// ParseTagData
static long
ParseTagData( char * buffer, TagPtr * tag )
static long ParseTagData( char *buffer, TagPtr *tag )
{
int actuallen = 0;
long length;
TagPtr tmpTag;
intactuallen = 0;
longlength = 0;
TagPtrtmpTag;
char*string;
length = FixDataMatchingTag(buffer, kXMLTagData);
if (length == -1) return -1;
if (length == -1)
{
return -1;
}
tmpTag = NewTag();
if (tmpTag == 0) return -1;
if (tmpTag == 0)
{
return -1;
}
//printf("ParseTagData unimplimented\n");
//printf("Data: %s\n", buffer);
//getchar();
char* string = BASE64Decode(buffer, strlen(buffer), &actuallen);
string = BASE64Decode(buffer, strlen(buffer), &actuallen);
tmpTag->type = kTagTypeData;
tmpTag->string = string;
tmpTag->tag = 0;
tmpTag->offset = actuallen; // buffer_start ? buffer - buffer_start: 0;
tmpTag->tagNext = 0;
*tag = tmpTag;
//==========================================================================
// ParseTagDate
static long
ParseTagDate( char * buffer, TagPtr * tag )
static long ParseTagDate( char *buffer, TagPtr *tag )
{
long length;
TagPtr tmpTag;
longlength = 0;
TagPtrtmpTag;
length = FixDataMatchingTag(buffer, kXMLTagDate);
if (length == -1) return -1;
if (length == -1)
{
return -1;
}
tmpTag = NewTag();
if (tmpTag == 0) return -1;
if (tmpTag == 0)
{
return -1;
}
printf("ParseTagDate unimplimented\n");
getchar();
tmpTag->type = kTagTypeDate;
tmpTag->string = 0;
tmpTag->tag = 0;
tmpTag->tagNext = 0;
tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
tmpTag->tagNext = 0;
*tag = tmpTag;
//==========================================================================
// ParseTagBoolean
long
ParseTagBoolean( char * buffer, TagPtr * tag, long type )
long ParseTagBoolean( char *buffer, TagPtr *tag, long type )
{
TagPtr tmpTag;
tmpTag = NewTag();
if (tmpTag == 0) return -1;
if (tmpTag == 0)
{
return -1;
}
tmpTag->type = type;
tmpTag->string = 0;
tmpTag->tag = 0;
tmpTag->tagNext = 0;
tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
tmpTag->tagNext = 0;
*tag = tmpTag;
//==========================================================================
// GetNextTag
static long
GetNextTag( char * buffer, char ** tag, long * start )
static long GetNextTag( char *buffer, char **tag, long *start )
{
long cnt, cnt2;
longcnt;
longcnt2;
if (tag == 0) {
if (tag == 0)
{
return -1;
}
// Find the start of the tag.
cnt = 0;
while ((buffer[cnt] != '\0') && (buffer[cnt] != '<')) cnt++;
if (buffer[cnt] == '\0') {
while ((buffer[cnt] != '\0') && (buffer[cnt] != '<'))
{
cnt++;
}
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') {
while ((buffer[cnt2] != '\0') && (buffer[cnt2] != '>'))
{
cnt2++;
}
if (buffer[cnt2] == '\0')
{
return -1;
}
// Fix the tag data.
*tag = buffer + cnt + 1;
buffer[cnt2] = '\0';
if (start) {
if (start)
{
*start = cnt;
}
// Returns the length of the data found, counting the end tag,
// or -1 if the end tag was not found.
static long
FixDataMatchingTag( char * buffer, char * tag )
static long FixDataMatchingTag( char *buffer, char *tag )
{
long length, start, stop;
char * endTag;
start = 0;
while (1)
{
length = GetNextTag(buffer + start, &endTag, &stop);
if (length == -1) return -1;
if ((*endTag == '/') && !strcmp(endTag + 1, tag)) break;
start += length;
}
buffer[start + stop] = '\0';
return start + length;
longlength;
longstart;
longstop;
char*endTag;
start = 0;
while (1)
{
length = GetNextTag(buffer + start, &endTag, &stop);
if (length == -1)
{
return -1;
}
if ((*endTag == '/') && !strcmp(endTag + 1, tag))
{
break;
}
start += length;
}
buffer[start + stop] = '\0';
return start + length;
}
//==========================================================================
static TagPtr gTagsFree;
static TagPtr
NewTag( void )
static TagPtr NewTag( void )
{
long cnt;
TagPtr tag;
longcnt;
TagPtrtag;
if (gTagsFree == 0)
{
tag = (TagPtr)malloc(kTagsPerBlock * sizeof(Tag));
if (tag == 0) return 0;
// Initalize the new tags.
for (cnt = 0; cnt < kTagsPerBlock; cnt++)
{
tag[cnt].type = kTagTypeNone;
tag[cnt].string = 0;
tag[cnt].tag = 0;
tag[cnt].tagNext = tag + cnt + 1;
}
tag[kTagsPerBlock - 1].tagNext = 0;
if (gTagsFree == 0)
{
tag = (TagPtr)malloc(kTagsPerBlock *sizeof(Tag));
if (tag == 0)
{
return 0;
}
gTagsFree = tag;
}
// Initalize the new tags.
for (cnt = 0; cnt < kTagsPerBlock; cnt++)
{
tag[cnt].type = kTagTypeNone;
tag[cnt].string = 0;
tag[cnt].tag = 0;
tag[cnt].tagNext = tag + cnt + 1;
}
tag[kTagsPerBlock - 1].tagNext = 0;
tag = gTagsFree;
gTagsFree = tag->tagNext;
return tag;
gTagsFree = tag;
}
tag = gTagsFree;
gTagsFree = tag->tagNext;
return tag;
}
//==========================================================================
// XMLFreeTag
void
XMLFreeTag( TagPtr tag )
void 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);
}
};
typedef struct Symbol Symbol, *SymbolPtr;
static SymbolPtr FindSymbol(char * string, SymbolPtr * prevSymbol);
static SymbolPtr FindSymbol(char *string, SymbolPtr *prevSymbol);
static SymbolPtr gSymbolsHead;
//==========================================================================
// NewSymbol
static char *
NewSymbol( char * string )
static char *NewSymbol( char *string )
{
static SymbolPtr lastGuy = 0;
SymbolPtr symbol;
SymbolPtrsymbol;
// Look for string in the list of symbols.
symbol = FindSymbol(string, 0);
// Add the new symbol.
if (symbol == 0) {
// Add the new symbol.
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 != NULL)
{
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 {
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;
}
}
return entry && ((entry->type == kTagTypeString) || (entry->type == kTagTypeKey));
}
char* XMLCastString(TagPtr dict)
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;
}
return NULL;
}
char* XMLCastData(TagPtr dict, int* length)
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)
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->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/zenith432/i386/libsaio/xml.h
22
33
44
5
5
66
77
88
......
1010
1111
1212
13
13
1414
1515
1616
......
1818
1919
2020
21
21
2222
2323
2424
......
4040
4141
4242
43
43
4444
45
45
4646
4747
4848
49
49
5050
5151
5252
......
6363
6464
6565
66
67
68
69
70
71
66
67
68
69
70
71
7272
73
74
75
76
77
78
79
80
81
82
8373
8474
8575
86
76
8777
8878
8979
......
9888
9989
10090
101
91
10292
10393
10494
......
10898
10999
110100
111
101
112102
113103
114104
......
119109
120110
121111
122
112
123113
124114
125115
126
116
127117
128118
129119
* Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
*
* Portions Copyright (c) 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
* 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,
* 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@
*/
struct string_ref
{
char* string;
char *string;
int id;
struct string_ref* next;
struct string_ref *next;
};
typedef struct string_ref string_ref;
extern string_ref* ref_strings;
extern string_ref *ref_strings;
#define kXMLTagPList "plist "
#define kXMLTagDict "dict"
#define kXMLStringID "ID="
#define kXMLStringIDRef "IDREF="
#define kPropCFBundleIdentifier ("CFBundleIdentifier")
#define kPropCFBundleExecutable ("CFBundleExecutable")
#define kPropOSBundleRequired ("OSBundleRequired")
#define kPropOSBundleLibraries ("OSBundleLibraries")
#define kPropIOKitPersonalities ("IOKitPersonalities")
#define kPropIONameMatch ("IONameMatch")
#define kPropCFBundleIdentifier("CFBundleIdentifier")
#define kPropCFBundleExecutable("CFBundleExecutable")
#define kPropOSBundleRequired("OSBundleRequired")
#define kPropOSBundleLibraries("OSBundleLibraries")
#define kPropIOKitPersonalities("IOKitPersonalities")
#define kPropIONameMatch("IONameMatch")
/*
struct Tag {
long type;
char *string;
struct Tag *tag;
struct Tag *tagNext;
};
typedef struct Tag Tag, *TagPtr;
*/
extern long gImageFirstBootXAddr;
extern long gImageLastKernelAddr;
TagPtr XMLGetProperty( TagPtr dict, const char * key );
TagPtr XMLGetProperty( TagPtr dict, const char *key );
TagPtr XMLGetElement( TagPtr dict, int id );
TagPtr XMLGetKey( TagPtr dict, int id );
TagPtr XMLGetValueForKey(TagPtr key);
int XMLCastInteger ( TagPtr dict );
TagPtr XMLCastDict ( TagPtr dict );
TagPtr XMLCastArray( TagPtr dict );
char* XMLCastData( TagPtr dict, int* length );
char* XMLCastData( TagPtr dict, int *length );
bool XMLIsBoolean(TagPtr entry);
bool XMLIsString (TagPtr entry);
bool XMLIsData (TagPtr entry);
bool XMLAddTagToDictionary(TagPtr dict, char* key, TagPtr value);
bool XMLAddTagToDictionary(TagPtr dict, char *key, TagPtr value);
long XMLParseNextTag(char *buffer, TagPtr *tag);
void XMLFreeTag(TagPtr tag);
// Puts the first dictionary it finds in the
// tag pointer and returns 0, or returns -1 if not found.
//
long XMLParseFile( char * buffer, TagPtr * dict );
long XMLParseFile( char *buffer, TagPtr *dict );
//==========================================================================
// ParseTag*
long ParseTagBoolean( char * buffer, TagPtr * tag, long type );
long ParseTagBoolean( char *buffer, TagPtr *tag, long type );
#endif /* __LIBSAIO_XML_H */
branches/zenith432/i386/libsaio/efi.h
254254
255255
256256
257
257
258258
259259
260260
......
262262
263263
264264
265
265
266266
267267
268268
......
281281
282282
283283
284
284
285285
286286
287287
......
290290
291291
292292
293
293
294294
295295
296296
......
301301
302302
303303
304
304
305305
306306
307307
......
318318
319319
320320
321
321
322322
323323
324324
325325
326326
327327
328
328
329329
330330
331331
......
334334
335335
336336
337
337
338338
339339
340340
......
342342
343343
344344
345
345
346346
347347
348348
......
363363
364364
365365
366
366
367367
368368
369369
......
391391
392392
393393
394
394
395395
396396
397397
IN EFI_UINTN DescriptorSize,
IN EFI_UINT32 DescriptorVersion,
IN EFI_MEMORY_DESCRIPTOR * VirtualMap
);
) __attribute__((regparm(0)));
typedef
EFI_RUNTIMESERVICE
(EFIAPI *EFI_CONVERT_POINTER) (
IN EFI_UINTN DebugDisposition,
IN OUT VOID **Address
);
) __attribute__((regparm(0)));
// Variable attributes
OUT EFI_UINT32 * Attributes OPTIONAL,
IN OUT EFI_UINTN * DataSize,
OUT VOID * Data
);
) __attribute__((regparm(0)));
typedef
EFI_RUNTIMESERVICE
IN OUT EFI_UINTN * VariableNameSize,
IN OUT EFI_CHAR16 * VariableName,
IN OUT EFI_GUID * VendorGuid
);
) __attribute__((regparm(0)));
typedef
EFI_RUNTIMESERVICE
IN EFI_UINT32 Attributes,
IN EFI_UINTN DataSize,
IN VOID * Data
);
) __attribute__((regparm(0)));
// EFI Time
(EFIAPI *EFI_GET_TIME) (
OUT EFI_TIME * Time,
OUT EFI_TIME_CAPABILITIES * Capabilities OPTIONAL
);
) __attribute__((regparm(0)));
typedef
EFI_RUNTIMESERVICE
EFI_STATUS
(EFIAPI *EFI_SET_TIME) (
IN EFI_TIME * Time
);
) __attribute__((regparm(0)));
typedef
EFI_RUNTIMESERVICE
OUT EFI_BOOLEAN * Enabled,
OUT EFI_BOOLEAN * Pending,
OUT EFI_TIME * Time
);
) __attribute__((regparm(0)));
typedef
EFI_RUNTIMESERVICE
(EFIAPI *EFI_SET_WAKEUP_TIME) (
IN EFI_BOOLEAN Enable,
IN EFI_TIME * Time OPTIONAL
);
) __attribute((regparm(0)));
typedef enum {
EfiResetCold,
IN EFI_STATUS ResetStatus,
IN EFI_UINTN DataSize,
IN EFI_CHAR16 * ResetData OPTIONAL
);
) __attribute__((regparm(0)));
typedef
EFI_RUNTIMESERVICE
IN EFI_UINT32 Instance,
IN EFI_GUID * CallerId OPTIONAL,
IN EFI_STATUS_CODE_DATA * Data OPTIONAL
);
) __attribute__((regparm(0)));
#endif
//
branches/zenith432/i386/libsaio/ntfs_private.h
147147
148148
149149
150
150
151151
152152
153153
u_int64_t t_write;
u_int64_t t_mftwrite;
u_int64_t t_access;
} ntfs_times_t;
} ntfs_times_t;
#define NTFS_FFLAG_RDONLY0x01LL
#define NTFS_FFLAG_HIDDEN0x02LL
branches/zenith432/i386/libsaio/vbe.c
129129
130130
131131
132
132
133133
134134
135135
#define kC 30.0 // C = (C'-J) * (K/256) + J
#define kM 300.0 // M = K/256 * M'
int Round(double f)
static int Round(double f)
{
return (int)(f + 0.5);
}
branches/zenith432/i386/libsaio/device_tree.c
8282
8383
8484
85
86
85
8786
8887
8988
......
143142
144143
145144
146
147
145
148146
149147
150148
......
206204
207205
208206
209
210
207
211208
212209
213210
......
215212
216213
217214
218
219
215
220216
221217
222218
......
224220
225221
226222
227
228
223
229224
230225
231226
......
246241
247242
248243
249
250
244
251245
252246
253247
......
280274
281275
282276
283
284
277
285278
286279
287280
......
325318
326319
327320
328
329
321
330322
331323
332324
......
378370
379371
380372
381
382
373
383374
384375
385376
......
400391
401392
402393
403
404
394
405395
406396
407397
......
418408
419409
420410
421
422
411
423412
424413
425414
......
486475
487476
488477
489
490
478
491479
492480
493481
......
524512
525513
526514
527
528
515
529516
530517
531518
......
539526
540527
541528
542
543
529
544530
545531
546532
......
548534
549535
550536
551
552
537
553538
554539
555540
......
580565
581566
582567
583
584
568
585569
586570
587571
......
602586
603587
604588
605
606
589
607590
608591
609592
610593
611594
612595
613
614
596
615597
616598
617599
//==============================================================================
Property *
DT__AddProperty(Node *node, const char *name, uint32_t length, void *value)
Property *DT__AddProperty(Node *node, const char *name, uint32_t length, void *value)
{
Property *prop;
//==============================================================================
Node *
DT__AddChild(Node *parent, const char *name)
Node *DT__AddChild(Node *parent, const char *name)
{
Node *node;
//==============================================================================
void
DT__FreeProperty(Property *prop)
void DT__FreeProperty(Property *prop)
{
prop->next = freeProperties;
freeProperties = prop;
//==============================================================================
void
DT__FreeNode(Node *node)
void DT__FreeNode(Node *node)
{
node->next = freeNodes;
freeNodes = node;
//==============================================================================
void
DT__Initialize(void)
void DT__Initialize(void)
{
DPRINTF("DT__Initialize\n");
/*
* Free up memory used by in-memory representation of device tree.
*/
void
DT__Finalize(void)
void DT__Finalize(void)
{
Node *node;
Property *prop;
//==============================================================================
static void *
FlattenNodes(Node *node, void *buffer)
static void *FlattenNodes(Node *node, void *buffer)
{
Property *prop;
DeviceTreeNode *flatNode;
* To use your own buffer, call with *result = &buffer.
*/
void
DT__FlattenDeviceTree(void **buffer_p, uint32_t *length)
void DT__FlattenDeviceTree(void **buffer_p, uint32_t *length)
{
uint32_t totalSize;
void * buf;
//==============================================================================
char *
DT__GetName(Node *node)
char *DT__GetName(Node *node)
{
Property *prop;
//==============================================================================
// Bungo
Property *
DT__GetProperty(Node *node, const char *name)
Property *DT__GetProperty(Node *node, const char *name)
{
Property *prop;
//==============================================================================
Node *
DT__FindNode(const char *path, bool createIfMissing)
Node *DT__FindNode(const char *path, bool createIfMissing)
{
Node *node, *child;
DTPropertyNameBuf nameBuf;
//==============================================================================
void
DT__PrintNode(Node *node, int level)
void DT__PrintNode(Node *node, int level)
{
char spaces[10], *cp = spaces;
Property *prop;
//==============================================================================
static void
_PrintTree(Node *node, int level)
static void _PrintTree(Node *node, int level)
{
DT__PrintNode(node, level);
//==============================================================================
void
DT__PrintTree(Node *node)
void DT__PrintTree(Node *node)
{
if (node == 0) node = rootNode;
_PrintTree(node, 0);
//==============================================================================
void
DT__PrintFlattenedNode(DTEntry entry, int level)
void DT__PrintFlattenedNode(DTEntry entry, int level)
{
char spaces[10], *cp = spaces;
DTPropertyIterator propIter;
//==============================================================================
static void
_PrintFlattenedTree(DTEntry entry, int level)
static void _PrintFlattenedTree(DTEntry entry, int level)
{
DTEntryIterator entryIter;
//==============================================================================
void
DT__PrintFlattenedTree(DTEntry entry)
void DT__PrintFlattenedTree(DTEntry entry)
{
_PrintFlattenedTree(entry, 0);
}
//==============================================================================
int
main(int argc, char **argv)
int main(int argc, char **argv)
{
DTEntrydtEntry;
DTPropertyIteratorpropIter;
branches/zenith432/i386/libsaio/hfs.c
295295
296296
297297
298
298
299299
300300
301301
......
647647
648648
649649
650
651
650652
651653
652654
......
920922
921923
922924
925
926
927
928
929
930
923931
924932
925933
......
9921000
9931001
9941002
995
1003
9961004
9971005
9981006
......
10181026
10191027
10201028
1029
1030
10211031
10221032
10231033
char entry[512];
char devStr[12];
u_int32_t dirID;
long result, flags;
long result, flags = 0;
if (HFSInitPartition(ih) == -1)
{
*flags = kFileTypeUnknown;
tmpTime = 0;
break;
default:
break;
}
if (time != 0)
curNode = SWAP_BE32(gBTHeaders[btree]->rootNode);
nodeSize = SWAP_BE16(gBTHeaders[btree]->nodeSize);
nodeBuf = (char *)malloc(nodeSize);
if (!nodeBuf)
{
return -1;
}
node = (BTNodeDescriptor *)nodeBuf;
while (1)
}
// Return error if the file was not found.
if (result != 0)
if (result != 0 || !recordData)
{
free(nodeBuf);
return -1;
break;
case kHFSPlusFileThreadRecord : entrySize = 264;
break;
default:
break;
}
}
else
branches/zenith432/i386/libsaio/spd.c
126126
127127
128128
129
129
130130
131131
132132
......
232232
233233
234234
235
235
236236
237237
238238
......
296296
297297
298298
299
299
300300
301301
302302
#define READ_SPD(spd, base, slot, x) spd[x] = smb_read_byte_intel(base, 0x50 + slot, x)
/** Read from spd *used* values only*/
static void init_spd(char * spd, uint32_t base, int slot)
static void init_spd(char *spd, uint32_t base, int slot)
{
int i;
for (i = 0; i < SPD_INDEXES_SIZE; i++)
#define SLST(a) ((uint8_t)(spd[a] & 0x0f))
/* Get DDR3 or DDR2 serial number, 0 most of the times, always return a valid ptr */
const char *getDDRSerial(const char* spd)
const char *getDDRSerial(const char *spd)
{
static char asciiSerial[17];
inti, speed;
uint8_tspd_size, spd_type;
uint32_tbase, mmio, hostc;
uint16_tcmd;// Command
uint16_tcmd;
//booldump = false;
RamSlotInfo_t*slot;
branches/zenith432/i386/libsaio/gma.c
630630
631631
632632
633
633
634634
635635
636636
637
637
638638
639639
640640
case GMA_HASWELL_ULT_M_GT2: // 0a16
case GMA_HASWELL_ULT_E_GT2: // 0a1e
verbose("Injecting a valid desktop GPU device id (0x0412) instead of patching kexts.\n");
device_id = 0x0412;// Inject a valid desktop GPU device id (0x0412) instead of patching kexts
device_id = 0x00000412;// Inject a valid desktop GPU device id (0x0412) instead of patching kexts
devprop_add_value(device, "vendor-id",(uint8_t *)INTEL_VENDORID, 4);
devprop_add_value(device, "device-id",(uint8_t *)&device_id, sizeof(device_id));
devprop_add_value(device, "compatible",(uint8_t *)"pci8086,0412", 13); // GT2 Desktop
devprop_add_value(device, "IOName",(uint8_t *)"pci8086,0412", 13); // GT2 Desktop
//devprop_add_value(device, "IOName",(uint8_t *)"pci8086,0412", 13); // GT2 Desktop
devprop_add_value(device, "name",(uint8_t *)"pci8086,0412", 13); // GT2 Desktop
verbose("Injeting done: was [%04x:%04x] now is [%04x:%04x]\n", gma_dev->vendor_id, gma_dev->device_id, gma_dev->vendor_id, device_id);
branches/zenith432/i386/libsaio/pci_root.c
4949
5050
5151
52
52
5353
5454
5555
void *new_dsdt;
const char *val;
int len,fsize;
int len, fsize;
const char * dsdt_filename = NULL;
extern int search_and_get_acpi_fd(const char *, const char **);
branches/zenith432/i386/libsaio/device_inject.h
5252
5353
5454
55
55
5656
5757
5858
// ------------------------
uint8_t num_pci_devpaths;
struct DevPropString *string;
// ------------------------
// ------------------------
};
typedef struct DevPropDevice DevPropDevice;
branches/zenith432/i386/libsaio/nvidia.c
19631963
19641964
19651965
1966
19671966
19681967
19691968
......
23232322
23242323
23252324
2326
2327
2328
2329
2330
2325
2326
2327
2328
2329
23312330
23322331
23332332
unsigned long long mem_detect(volatile uint8_t *regs, uint8_t nvCardType, pci_dt_t *nvda_dev, uint32_t device_id, uint32_t subsys_id)
{
uint64_t vram_size = 0;
// unsigned long long vram_size = 0;
// First check if any value exist in the plist
cardList_t * nvcard = FindCardWithIds(device_id, subsys_id);
devprop_add_nvidia_template(device);
devprop_add_value(device, "NVCAP", default_NVCAP, NVCAP_LEN);
devprop_add_value(device, "NVPM", default_NVPM, NVPM_LEN);
devprop_add_value(device, "VRAM,totalsize", (uint8_t*)&videoRam, 4);
devprop_add_value(device, "model", (uint8_t*)model, strlen(model) + 1);
devprop_add_value(device, "rom-revision", (uint8_t*)biosVersion, strlen(biosVersion) + 1);
devprop_add_value(device, "@0,display-cfg", default_dcfg_0, DCFG0_LEN);
devprop_add_value(device, "@1,display-cfg", default_dcfg_1, DCFG1_LEN);
devprop_add_value(device, "VRAM,totalsize", (uint8_t *)&videoRam, 4);
devprop_add_value(device, "model", (uint8_t *)model, strlen(model) + 1);
devprop_add_value(device, "rom-revision", (uint8_t *)biosVersion, strlen(biosVersion) + 1);
devprop_add_value(device, "@0,display-cfg", (uint8_t *)&default_dcfg_0, DCFG0_LEN);
devprop_add_value(device, "@1,display-cfg", (uint8_t *)&default_dcfg_1, DCFG1_LEN);
/******************** Added Marchrius.**********************/
// For the AppleBacklightDisplay //
branches/zenith432/i386/libsaio/ati.c
137137
138138
139139
140
140
141
142
143
144
145
141146
142147
143148
......
15001505
15011506
15021507
1503
1508
1509
15041510
15051511
15061512
......
16411647
16421648
16431649
1644
1645
1650
1651
16461652
16471653
16481654
......
17701776
17711777
17721778
1773
1779
17741780
17751781
17761782
......
18501856
18511857
18521858
1853
1859
18541860
18551861
18561862
......
22842290
22852291
22862292
2293
2294
2295
22872296
22882297
22892298
2290
2291
22922299
22932300
22942301
......
23472354
23482355
23492356
2350
2357
23512358
23522359
23532360
{"Hamachi",4},
{"OPM", 6},
{"Ikura", 6},
{"IkuraS", 1}
{"IkuraS", 1},
/* AMD8000Controller */
{"Baladi", 5},//desktop
{"Exmoor", 4},//mobile
{"Basset", 4}
};
static radeon_card_info_t radeon_cards[] = {
//{ 0x99A2,0x00000000, CHIP_FAMILY_ARUBA,"AMD Radeon HD", kNull }, // Mobile
//{ 0x99A4,0x00000000, CHIP_FAMILY_ARUBA,"AMD Radeon HD", kNull },
{ 0x6613,0x00000000, CHIP_FAMILY_BONAIRE,"AMD Radeon R7 240",kFutomaki},
{ 0x6610,0x00000000, CHIP_FAMILY_OLAND,"AMD Radeon R7 250",kFutomaki},
{ 0x6613,0x00000000, CHIP_FAMILY_OLAND,"AMD Radeon R7 240",kFutomaki},
{ 0x665C,0x00000000, CHIP_FAMILY_BONAIRE,"AMD Radeon HD 7790",kFutomaki},
{ 0x665D,0x00000000, CHIP_FAMILY_BONAIRE,"AMD Radeon R9 260",kFutomaki},
//{ 0x67A8,0x00000000, CHIP_FAMILY_HAWAII,"AMD Radeon", kFutomaki},
//{ 0x67A9,0x00000000, CHIP_FAMILY_HAWAII,"AMD Radeon", kFutomaki},
//{ 0x67AA,0x00000000, CHIP_FAMILY_HAWAII,"AMD Radeon", kFutomaki},
{ 0x67B0,0x00000000, CHIP_FAMILY_HAWAII,"AMD Radeon R9 290X", kFutomaki},
{ 0x67B1,0x00000000, CHIP_FAMILY_HAWAII,"AMD Radeon R9 290", kFutomaki}, // CHIP_FAMILY_HAWAII
{ 0x67B0,0x00000000, CHIP_FAMILY_HAWAII,"AMD Radeon R9 290X", kBaladi},
{ 0x67B1,0x00000000, CHIP_FAMILY_HAWAII,"AMD Radeon R9 290", kBaladi}, // CHIP_FAMILY_HAWAII
//{ 0x67B8,0x00000000, CHIP_FAMILY_HAWAII,"AMD Radeon", kFutomaki},
//{ 0x67B9,0x00000000, CHIP_FAMILY_HAWAII,"AMD Radeon", kFutomaki},
//{ 0x67BA,0x00000000, CHIP_FAMILY_HAWAII,"AMD Radeon", kFutomaki},
val->type = kCst;
val->size = 4;
val->data = (uint8_t *)&v;
return true;
}
val->type = kPtr;
val->size = card->rom_size;
val->data = card->rom;
return true;
}
}
#endif
static charname[24];
static charname_parent[24];
static bool init_card(pci_dt_t *pci_dev)
{
booladd_vbios = true;
charname[24];
charname_parent[24];
inti;
intn_ports = 0;
{
read_disabled_vbios();
}
verbose("\n");
verbose("Video BIOS read from file\n");
}
}
branches/zenith432/i386/libsaio/load.c
5757
5858
5959
60
60
6161
6262
6363
6464
6565
66
66
67
6768
6869
6970
70
71
72
73
7174
7275
7376
......
7881
7982
8083
81
84
85
86
8287
8388
8489
......
258263
259264
260265
261
262
263
264
266
267
268
269
265270
266
271
272
273
267274
268275
269276
......
276283
277284
278285
279
286
280287
281288
282289
......
289296
290297
291298
292
299
300
293301
294302
295303
296
304
305
297306
298307
299308
300309
301
310
311
302312
303313
304314
305315
306
316
317
307318
308319
309320
......
317328
318329
319330
320
331
332
321333
322334
323335
......
355367
356368
357369
358
359
370
371
360372
361373
362374
struct fat_arch *fap = (struct fat_arch *)((unsigned long)*binary + sizeof(struct fat_header));
cpu_type_t fapcputype;
uint32_t fapoffset;
uint32_t fapsize;
uint32_t fapsize;
if (fhp->magic == FAT_MAGIC)/* 0xcafebabe */
{
nfat = fhp->nfat_arch;
swapped = 0;
} else if (fhp->magic == FAT_CIGAM)/* 0xbebafeca */
}
else if (fhp->magic == FAT_CIGAM)/* 0xbebafeca */
{
nfat = OSSwapInt32(fhp->nfat_arch);
swapped = 1;
} else {
}
else
{
return -1;
}
fapcputype = OSSwapInt32(fap->cputype);
fapoffset = OSSwapInt32(fap->offset);
fapsize = OSSwapInt32(fap->size);
} else {
}
else
{
fapcputype = fap->cputype;
fapoffset = fap->offset;
fapsize = fap->size;
segname = segCmd->segname;
#ifdef DEBUG
printf("segname: %s, vmaddr: %x, vmsize: %x, fileoff: %x, filesize: %x, nsects: %d, flags: %x.\n",
segCmd->segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize,
(unsigned) segCmd->nsects, (unsigned)segCmd->flags);
getchar();
printf("segname: %s, vmaddr: %x, vmsize: %x, fileoff: %x, filesize: %x, nsects: %d, flags: %x.\n",
segCmd->segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize,
(unsigned) segCmd->nsects, (unsigned)segCmd->flags);
getchar();
#endif
} else {
}
else
{
struct segment_command *segCmd;
segCmd = (struct segment_command *)cmdBase;
#ifdef DEBUG
printf("segname: %s, vmaddr: %x, vmsize: %x, fileoff: %x, filesize: %x, nsects: %d, flags: %x.\n",
segCmd->segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize, (unsigned) segCmd->nsects, (unsigned)segCmd->flags);
segCmd->segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize, (unsigned) segCmd->nsects, (unsigned)segCmd->flags);
getchar();
#endif
}
}
if (! ((vmaddr >= KERNEL_ADDR && (vmaddr + vmsize) <= (KERNEL_ADDR + KERNEL_LEN)) ||
(vmaddr >= HIB_ADDR && (vmaddr + vmsize) <= (HIB_ADDR + HIB_LEN)))) {
(vmaddr >= HIB_ADDR && (vmaddr + vmsize) <= (HIB_ADDR + HIB_LEN))))
{
stop("Kernel overflows available space");
}
if (vmsize && ((strcmp(segname, "__PRELINK_INFO") == 0) || (strcmp(segname, "__PRELINK") == 0))) {
if (vmsize && ((strcmp(segname, "__PRELINK_INFO") == 0) || (strcmp(segname, "__PRELINK") == 0)))
{
gHaveKernelCache = true;
}
// Copy from file load area.
if (vmsize>0 && filesize > 0) {
if (vmsize>0 && filesize > 0)
{
bcopy((char *)fileaddr, (char *)vmaddr, vmsize > filesize ? filesize : vmsize);
}
// Zero space at the end of the segment.
if (vmsize > filesize) {
if (vmsize > filesize)
{
bzero((char *)(vmaddr + filesize), vmsize - filesize);
}
static long DecodeUnixThread(long cmdBase, unsigned int *entry)
{
switch (archCpuType) {
switch (archCpuType)
{
case CPU_TYPE_I386:
{
i386_thread_state_t *i386ThreadState;
symTab = (struct symtab_command *)cmdBase;
#if DEBUG
printf("symoff: %x, nsyms: %x, stroff: %x, strsize: %x\n", symTab->symoff, symTab->nsyms, symTab->stroff, symTab->strsize);
printf("symoff: %x, nsyms: %x, stroff: %x, strsize: %x\n",
symTab->symoff, symTab->nsyms, symTab->stroff, symTab->strsize);
getchar();
#endif
branches/zenith432/i386/libsaio/ati.h
179179
180180
181181
182
183
184
185
182186
183187
184188
kOPM,
kIkura,
kIkuraS,
/* AMD8000Controller */
kBaladi,
kExmoor,
kBasset,
kCfgEnd
} ati_config_name_t;
branches/zenith432/i386/libsaio/cpu.c
312312
313313
314314
315
315
316316
317317
318318
319
319
320320
321321
322322
cores_per_package = 1;
}
if (p->CPU.CPUID[CPUID_0][0] >= 0x5) // Monitor/Mwait
if (p->CPU.CPUID[CPUID_0][0] >= 0x5)// Monitor/Mwait
{
do_cpuid(5, p->CPU.CPUID[CPUID_5]);
}
if (p->CPU.CPUID[CPUID_0][0] >= 6) // Thermal/Power
if (p->CPU.CPUID[CPUID_0][0] >= 6)// Thermal/Power
{
do_cpuid(6, p->CPU.CPUID[CPUID_6]);
}
branches/zenith432/i386/libsaio/platform.h
3535
3636
3737
38
38
3939
4040
4141
......
337337
338338
339339
340
340341
341342
342343
#define CPUID_MODEL_DOTHAN0x0D// Dothan Pentium M, Celeron M (90nm)
#define CPUID_MODEL_YONAH0x0E// Sossaman, Yonah
#define CPUID_MODEL_MEROM0x0F// Allendale, Conroe, Kentsfield, Woodcrest, Clovertown, Tigerton, Merom
#define CPUID_MODEL_CONROE0x0F//
#define CPUID_MODEL_CONROE0x0F//
#define CPUID_MODEL_CELERON0x16// Merom, Conroe (65nm), Celeron (45nm)
#define CPUID_MODEL_PENRYN0x17// Wolfdale, Yorkfield, Harpertown, Penryn
#define CPUID_MODEL_WOLFDALE0x17// Xeon 31xx, 33xx, 52xx, 54xx, Core 2 Quad 8xxx and 9xxx
/* Maximum number of ram slots */
#define MAX_RAM_SLOTS8
#define RAM_SLOT_ENUMERATOR{0, 2, 4, 1, 3, 5, 6, 8, 10, 7, 9, 11}
/* Maximum number of SPD bytes */
branches/zenith432/i386/libsaio/disk.c
844844
845845
846846
847
847
848848
849849
850850
......
975975
976976
977977
978
978
979
980
981
982
983
984
979985
980986
981987
......
14301436
14311437
14321438
1433
1439
14341440
14351441
14361442
......
14931499
14941500
14951501
1502
1503
14961504
14971505
14981506
......
22182226
22192227
22202228
2221
2229
22222230
22232231
22242232
// same as Apple ZFS
//EFI_GUID const GPT_ZFS_GUID= { 0x6A898CC3, 0x1DD2, 0x11B2, { 0x99, 0xA6, 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }; // 0xBF01 "Solaris /usr & Apple ZFS
BVRef newGPTBVRef( int biosdev,
static BVRef newGPTBVRef( int biosdev,
int partno,
unsigned int blkoff,
const gpt_ent *part,
{
// Create a new mapping.
map = (struct DiskBVMap *)malloc(sizeof(*map));
map = (struct DiskBVMap *) malloc(sizeof(*map));
if ( !map )
{
return NULL;
}
if ( map )
{
map->biosdev = biosdev;
// Determine whether the partition header signature is present.
if (memcmp(headerMap->hdr_sig, GPT_HDR_SIG, strlen(GPT_HDR_SIG)))
if ( memcmp(headerMap->hdr_sig, GPT_HDR_SIG, strlen(GPT_HDR_SIG)) )
{
goto scanErr;
}
goto scanErr;
}
bzero(buffer,bufferSize);
if (readBytes(biosdev, gptBlock, 0, bufferSize, buffer) != 0)
{
goto scanErr;
* hd(x,y)|uuid|"label" "alias";hd(m,n)|uuid|"label" "alias"; etc...
*/
bool getVolumeLabelAlias(BVRef bvr, char* str, long strMaxLen)
static bool getVolumeLabelAlias(BVRef bvr, char* str, long strMaxLen)
{
char *aliasList, *entryStart, *entryNext;
branches/zenith432/i386/libsaio/pci_setup.c
22
33
44
5
6
7
85
96
7
8
9
10
11
12
13
14
15
16
1017
1118
1219
......
3744
3845
3946
47
4048
4149
4250
4351
4452
45
53
4654
55
4756
4857
4958
......
5160
5261
5362
63
5464
5565
5666
......
95105
96106
97107
108
98109
99110
100111
......
102113
103114
104115
116
105117
106118
107119
108120
121
109122
110123
111124
......
115128
116129
117130
118
131
119132
120133
121134
#include "boot.h"
#include "bootstruct.h"
#include "pci.h"
#include "gma.h"
#include "nvidia.h"
#include "hda.h"
#include "modules.h"
#ifndef DEBUG_PCI_SETUP
#define DEBUG_PCI_SETUP 0
#endif
#if DEBUG_PCI_SETUP
#define DBG(x...)printf(x)
#else
#define DBG(x...)
#endif
extern bool setup_ati_devprop(pci_dt_t *ati_dev);
extern bool setup_nvidia_devprop(pci_dt_t *nvda_dev);
extern bool setup_gma_devprop(pci_dt_t *gma_dev);
switch (current->class_id)
{
case PCI_CLASS_BRIDGE_HOST:
DBG("Setup BRIDGE_HOST \n");
if (current->dev.addr == PCIADDR(0, 0, 0))
{
dram_controller_dev = current;
}
break; // PCI_CLASS_BRIDGE_HOST
case PCI_CLASS_NETWORK_ETHERNET:
DBG("Setup ETHERNET %s enabled\n", do_eth_devprop? "is":"is not");
if (do_eth_devprop)
{
set_eth_builtin(current);
break; // PCI_CLASS_NETWORK_ETHERNET
case PCI_CLASS_DISPLAY_VGA:
DBG("GraphicsEnabler %s enabled\n", do_gfx_devprop? "is":"is not");
if (do_gfx_devprop)
{
switch (current->vendor_id)
break; // PCI_CLASS_DISPLAY_VGA
case PCI_CLASS_MULTIMEDIA_AUDIO_DEV:
DBG("Setup HDEF %s enabled\n", do_hda_devprop? "is":"is not");
if (do_hda_devprop)
{
setup_hda_devprop(current);
break; // PCI_CLASS_MULTIMEDIA_AUDIO_DEV
case PCI_CLASS_SERIAL_USB:
DBG("USB\n");
notify_usb_dev(current);
break; // PCI_CLASS_SERIAL_USB
case PCI_CLASS_BRIDGE_ISA:
DBG("Force HPET %s enabled\n", do_enable_hpet? "is":"is not");
if (do_enable_hpet)
{
force_enable_hpet(current);
}
execute_hook("PCIDevice", current, NULL, NULL, NULL);
DBG("setup_pci_devs current device ID = [%04x:%04x]\n", current->vendor_id, current->device_id);
setup_pci_devs(current->children);
current = current->next;
}
branches/zenith432/i386/libsaio/smbios.h
833833
834834
835835
836
836
837837
838838
839839
typedef struct SMBOemProcessorBusSpeed
{
SMB_STRUCT_HEADER// Type 132
SMBWord ProcessorBusSpeed; // MT/s unit
SMBWord ProcessorBusSpeed;// MT/s unit
} __attribute__((packed)) SMBOemProcessorBusSpeed;
//----------------------------------------------------------------------------------------------------------
branches/zenith432/i386/libsaio/nvidia_helper.c
5252
5353
5454
55
55
5656
57
57
5858
5959
60
60
6161
6262
6363
6464
6565
6666
67
68
69
70
67
68
69
70
7171
7272
7373
74
74
7575
76
76
7777
7878
7979
......
108108
109109
110110
111
112
113
114
111
112
113
114
115
116
117
118
115119
116
120
117121
118122
119123
......
127131
128132
129133
130
134
135
131136
132137
133138
134
139
140
135141
136142
137143
138
144
145
139146
140147
141148
*/
cardList_t* cardList = NULL;
cardList_t *cardList = NULL;
void add_card(char* model, uint32_t id, uint32_t subid, uint64_t videoRam)
void add_card(char *model, uint32_t id, uint32_t subid, uint64_t videoRam)
{
cardList_t* new_card = malloc(sizeof(cardList_t));
cardList_t *new_card = malloc(sizeof(cardList_t));
if (new_card)
{
new_card->next = cardList;
cardList = new_card;
new_card->id = id;
new_card->subid = subid;
new_card->videoRam = videoRam;
new_card->model = model;
new_card->id= id;
new_card->subid= subid;
new_card->videoRam= videoRam;
new_card->model= model;
}
}
cardList_t* FindCardWithIds(uint32_t id, uint32_t subid)
cardList_t *FindCardWithIds(uint32_t id, uint32_t subid)
{
cardList_t* entry = cardList;
cardList_t *entry = cardList;
while(entry)
{
if((entry->id == id) && (entry->subid == subid))
void fill_card_list(void)
{
unsigned inti, count;
TagPtr NVDIATag;
char *model_name = NULL, *match_id = NULL, *sub_id = NULL, *vram_size = NULL;
uint32_t dev_id = 0, subdev_id = 0;
uint64_t VramSize = 0;
TagPtrNVDIATag;
char*model_name = NULL;
char*match_id = NULL;
char*sub_id = NULL;
char*vram_size = NULL;
uint32_tdev_id = 0;
uint32_tsubdev_id = 0;
uint64_tVramSize = 0;
if ((NVDIATag = XMLCastArray(XMLGetProperty(bootInfo->chameleonConfig.dictionary, (const char*)"NVIDIA"))))
if ((NVDIATag = XMLCastArray(XMLGetProperty(bootInfo->chameleonConfig.dictionary, (const char *)"NVIDIA"))))
{
count = XMLTagCount(NVDIATag);
model_name = XMLCastString(XMLGetProperty(element, (const char*)"Chipset Name"));
vram_size = XMLCastString(XMLGetProperty(element, (const char*)"VRam Size"));
if (match_id) {
if (match_id)
{
dev_id = strtoul(match_id, NULL, 16);
}
if (sub_id) {
if (sub_id)
{
subdev_id = strtoul(sub_id, NULL, 16);
}
if (vram_size) {
if (vram_size)
{
VramSize = strtoul(vram_size, NULL, 10);
}
branches/zenith432/i386/libsaio/pci.c
1414
1515
1616
17
17
1818
19
19
2020
2121
2222
......
213213
214214
215215
216
216
217217
218218
219219
#endif
#if DEBUG_PCI
#define DBG(x...)printf(x)
#define DBG(x...)printf(x)
#else
#define DBG(x...)
#define DBG(x...)msglog(x)
#endif
pci_dt_t*root_pci_dev;
while (current) {
printf("%02x:%02x.%x [%04x%02x] [%04x:%04x] (subsys [%04x:%04x]):: %s\n",
current->dev.bits.bus, current->dev.bits.dev, current->dev.bits.func,
current->class_id, 0 /* FIXME: what should this be? */,
current->class_id, current->progif,
current->vendor_id, current->device_id,
current->subsys_id.subsys.vendor_id, current->subsys_id.subsys.device_id,
get_pci_dev_path(current));
branches/zenith432/i386/libsaio/biosfn.c
127127
128128
129129
130
131
130132
131133
132134
......
590592
591593
592594
593
595
594596
595597
596598
......
821823
822824
823825
824
826
825827
826828
827829
......
834836
835837
836838
837
839
838840
839841
840842
......
10171019
10181020
10191021
1020
1022
10211023
10221024
10231025
10241026
10251027
10261028
1027
1029
10281030
10291031
10301032
}
#if 0
static unsigned long rerangeMemoryMap(unsigned long count);
static unsigned long rerangeMemoryMap(unsigned long count)
{
int i, still_changing, newcount = count;
/*
* BIOS drive information.
*/
void print_drive_info(boot_drive_info_t *dp)
static void print_drive_info(boot_drive_info_t *dp)
{
//printf("buf_size = %x\n", dp->params.buf_size);
printf("info_flags = %x\n", dp->params.info_flags);
#if DEBUG
int terminateDiskEmulation()
static int terminateDiskEmulation()
{
static char cd_spec[0x13];
return bb.eax.r.h;
}
int readDriveParameters(int drive, struct driveParameters *dp)
static int readDriveParameters(int drive, struct driveParameters *dp)
{
bb.intno = 0x13;
bb.edx.r.l = drive;
void sleep(int n)
{
// FIXME: doesn't handle midnight wraparound
unsigned int endtime = (time18() + 18*n);
unsigned int endtime = (time18() + 18*n);
#ifdef __i386__
while (time18() < endtime)
{
__asm__ volatile ("rep; nop");
}
#else
while (time18() < endtime);
while (time18() < endtime);
#endif
}
branches/zenith432/i386/libsaio/convert.c
88
99
1010
11
11
1212
1313
1414
......
2121
2222
2323
24
25
24
25
2626
2727
2828
......
100100
101101
102102
103
104
105
106
107
108
103109
104110
105111
......
119125
120126
121127
122
128
123129
124130
125131
......
149155
150156
151157
152
158
153159
154160
155161
......
165171
166172
167173
168
174
169175
170176
#include "convert.h"
/** Transform a 16 bytes hexadecimal value UUID to a string */
const char * getStringFromUUID(const EFI_CHAR8* eUUID)
const char *getStringFromUUID(const EFI_CHAR8 *eUUID)
{
static char msg[UUID_LEN*2 + 8] = "";
if (!eUUID) return "";
return msg ;
}
/** Parse an UUID string into an (EFI_CHAR8*) buffer */
EFI_CHAR8* getUUIDFromString(const char *source)
/** Parse an UUID string into an (EFI_CHAR8 *) buffer */
EFI_CHAR8 *getUUIDFromString(const char *source)
{
if (!source)
{
{
// the resulting binary will be the half size of the input hex string
binStr = malloc(len / 2);
if (!binStr)
{
*outLength = 0;
return NULL;
}
bzero(binStr,len / 2 );
binStrIdx = 0;
hexNibbleIdx = 0;
{
binChar = 0;
for (hexNibbleIdx = 0; hexNibbleIdx < sizeof(hexByte); hexNibbleIdx++)
for (hexNibbleIdx = 0; (unsigned)hexNibbleIdx < sizeof(hexByte); hexNibbleIdx++)
{
if (hexNibbleIdx > 0)
{
// FIXME: can't use my original code here,
// Ironically, trying to reuse convertHexStr2Binary() would RESET the system!
/*
static EFI_CHAR8* getUUIDFromString2(const char * szInUUID)
static EFI_CHAR8 *getUUIDFromString2(const char * szInUUID)
{
char szUUID[UUID_LEN+1], *p=szUUID;
int size=0;
verbose("UUID: cannot convert string <%s> to valid UUID.\n", szUUID);
return (EFI_CHAR8*) 0;
}
return (EFI_CHAR8*) ret; // new allocated buffer containing the converted string to bin
return (EFI_CHAR8 *) ret; // new allocated buffer containing the converted string to bin
}
*/
branches/zenith432/i386/libsaio/convert.h
1111
1212
1313
14
15
16
17
14
15
16
17
1818
1919
2020
#define UUID_LEN16
const char * getStringFromUUID(const EFI_CHAR8* uuid);
EFI_CHAR8* getUUIDFromString(const char *source);
void *convertHexStr2Binary(const char *hexStr, int *outLength);
uint32_t ascii_hex_to_int(char *buff);
const char*getStringFromUUID(const EFI_CHAR8* uuid);
EFI_CHAR8*getUUIDFromString(const char *source);
void*convertHexStr2Binary(const char *hexStr, int *outLength);
uint32_tascii_hex_to_int(char *buff);
static inline uint16_t dp_swap16(uint16_t toswap)
{
branches/zenith432/i386/libsaio/md5c.c
166166
167167
168168
169
169
170
170171
171172
172173
173
174
175
176
174177
175178
176179
partLen);
MD5Transform (context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64) {
for (i = partLen; i + 63 < inputLen; i += 64)
{
MD5Transform (context->state, &((const unsigned char *)input)[i]);
}
index = 0;
} else {
}
else
{
i = 0;
}
branches/zenith432/i386/libsaio/fake_efi.c
145145
146146
147147
148
148
149149
150150
151151
152152
153
153
154154
155155
156156
......
192192
193193
194194
195
196
197
195
196
197
198198
199199
200200
......
262262
263263
264264
265
266
265
266
267267
268268
269269
......
303303
304304
305305
306
306
307307
308308
309309
......
371371
372372
373373
374
375
374
375
376376
377377
378378
......
451451
452452
453453
454
454
455455
456456
457457
......
465465
466466
467467
468
468
469469
470470
471471
......
491491
492492
493493
494
494
495495
496
497
498
496
497
498
499
500
499501
500
502
501503
502504
503505
......
526528
527529
528530
529
531
530532
531533
532534
......
543545
544546
545547
546
548
547549
548550
549551
......
566568
567569
568570
569
571
570572
571
572
573
574
573575
574576
575577
......
584586
585587
586588
587
589
588590
589591
590
592
591593
592594
593595
594
595596
596
597
597598
598599
599600
......
636637
637638
638639
639
640
641
640642
641643
642644
643645
644
646
647
645648
646649
647650
648
651
652
649653
650654
651655
......
653657
654658
655659
656
657
660
661
662
658663
659664
660665
661666
662667
663668
664
669
670
665671
666672
667673
668674
669
675
676
670677
671678
672679
DT__AddProperty(tableNode, "guid", sizeof(EFI_GUID), (void *)pGuid);
// The "table" property is the 32-bit (in our implementation) physical address of the table
DT__AddProperty(tableNode, "table", sizeof(void*) * 2, table);
DT__AddProperty(tableNode, "table", sizeof(void *) * 2, table);
// Assume the alias pointer is a global or static piece of data
if (alias != NULL)
{
DT__AddProperty(tableNode, "alias", strlen(alias)+1, (char*)alias);
DT__AddProperty(tableNode, "alias", strlen(alias)+1, (char *)alias);
}
return EFI_SUCCESS;
uint8_t voidret_instructions[sizeof(VOIDRET_INSTRUCTIONS)/sizeof(uint8_t)];
uint8_t unsupportedret_instructions[sizeof(UNSUPPORTEDRET_INSTRUCTIONS_32)/sizeof(uint8_t)];
};
struct fake_efi_pages *fakeEfiPages = (struct fake_efi_pages*)AllocateKernelMemory(sizeof(struct fake_efi_pages));
struct fake_efi_pages *fakeEfiPages = (struct fake_efi_pages *)AllocateKernelMemory(sizeof(struct fake_efi_pages));
// Zero out all the tables in case fields are added later
//bzero(fakeEfiPages, sizeof(struct fake_efi_pages));
// but it is nice if we can at least prevent a complete crash by
// at least providing some sort of implementation until one can be provided
// nicely in a kext.
void (*voidret_fp)() = (void*)fakeEfiPages->voidret_instructions;
void (*unsupportedret_fp)() = (void*)fakeEfiPages->unsupportedret_instructions;
void (*voidret_fp)() = (void *)fakeEfiPages->voidret_instructions;
void (*unsupportedret_fp)() = (void *)fakeEfiPages->unsupportedret_instructions;
efiRuntimeServices->GetTime = (EFI_PTR32)unsupportedret_fp;
efiRuntimeServices->SetTime = (EFI_PTR32)unsupportedret_fp;
efiRuntimeServices->GetWakeupTime = (EFI_PTR32)unsupportedret_fp;
uint8_t unsupportedret_instructions[sizeof(UNSUPPORTEDRET_INSTRUCTIONS_64)/sizeof(uint8_t)];
};
struct fake_efi_pages *fakeEfiPages = (struct fake_efi_pages*)AllocateKernelMemory(sizeof(struct fake_efi_pages));
struct fake_efi_pages *fakeEfiPages = (struct fake_efi_pages *)AllocateKernelMemory(sizeof(struct fake_efi_pages));
// Zero out all the tables in case fields are added later
//bzero(fakeEfiPages, sizeof(struct fake_efi_pages));
// at least providing some sort of implementation until one can be provided
// nicely in a kext.
void (*voidret_fp)() = (void*)fakeEfiPages->voidret_instructions;
void (*unsupportedret_fp)() = (void*)fakeEfiPages->unsupportedret_instructions;
void (*voidret_fp)() = (void *)fakeEfiPages->voidret_instructions;
void (*unsupportedret_fp)() = (void *)fakeEfiPages->unsupportedret_instructions;
efiRuntimeServices->GetTime = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->SetTime = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->GetWakeupTime = ptov64((EFI_PTR32)unsupportedret_fp);
static const char FIRMWARE_REVISION_PROP[] = "firmware-revision";
static const char FIRMWARE_ABI_PROP[] = "firmware-abi";
static const char FIRMWARE_VENDOR_PROP[] = "firmware-vendor";
//static const char FIRMWARE_ABI_32_PROP_VALUE[] = "EFI32";
static const char FIRMWARE_ABI_32_PROP_VALUE[] = "EFI32";
static const char FIRMWARE_ABI_64_PROP_VALUE[] = "EFI64";
static const char EFI_MODE_PROP[] = "efi-mode"; //Bungo
static const char SYSTEM_ID_PROP[] = "system-id";
/*
* Get an smbios option string option to convert to EFI_CHAR16 string
*/
static EFI_CHAR16* getSmbiosChar16(const char * key, size_t* len)
static EFI_CHAR16 *getSmbiosChar16(const char *key, size_t *len)
{
const char*src = getStringForKey(key, &bootInfo->smbiosConfig);
EFI_CHAR16* dst = 0;
/*
* Get the SystemID from the bios dmi info
staticEFI_CHAR8* getSmbiosUUID()
staticEFI_CHAR8 *getSmbiosUUID()
{
static EFI_CHAR8 uuid[UUID_LEN];
int i, isZero, isOnes;
SMBByte*p;
static EFI_CHAR8uuid[UUID_LEN];
inti;
intisZero;
intisOnes;
SMBByte*p;
p = (SMBByte*)Platform.UUID;
p = (SMBByte *)Platform.UUID;
for (i=0, isZero=1, isOnes=1; i<UUID_LEN; i++)
{
// return a binary UUID value from the overriden SystemID and SMUUID if found,
// or from the bios if not, or from a fixed value if no bios value is found
static EFI_CHAR8* getSystemID()
static EFI_CHAR8 *getSystemID()
{
// unable to determine UUID for host. Error: 35 fix
// Rek: new SMsystemid option conforming to smbios notation standards, this option should
if (!ret)
{
// no bios dmi UUID available, set a fixed value for system-id
ret=getUUIDFromString((sysId = (const char*) SYSTEM_ID));
ret=getUUIDFromString((sysId = (const char *) SYSTEM_ID));
}
verbose("Customizing SystemID with : %s\n", getStringFromUUID(ret)); // apply a nice formatting to the displayed output
return ret;
DT__AddProperty(node, SYSTEM_TYPE_PROP, sizeof(Platform.Type), &Platform.Type);
}
void setupEfiDeviceTree(void)
static void setupEfiDeviceTree(void)
{
// EFI_CHAR8* ret = 0; Bungo: not used
EFI_CHAR16* ret16 = 0;
// EFI_CHAR8*ret = 0; Bungo: not used
EFI_CHAR16*ret16 = 0;
size_t len = 0;
Node*node;
// But I think eventually we want to fill stuff in the efi node
// too so we might as well create it so we have a pointer for it too.
node = DT__AddChild(node, "efi");
/* Bungo
if (archCpuType == CPU_TYPE_I386)
{
DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_32_PROP_VALUE), (char*)FIRMWARE_ABI_32_PROP_VALUE);
DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_32_PROP_VALUE), (char *)FIRMWARE_ABI_32_PROP_VALUE);
}
else
{
*/
DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_64_PROP_VALUE), (char *)FIRMWARE_ABI_64_PROP_VALUE);
//}
}
DT__AddProperty(node, EFI_MODE_PROP, sizeof(EFI_UINT8), (EFI_UINT8 *)&bootArgs->efiMode);
// the value in the fsbFrequency global and not an malloc'd pointer
// because the DT_AddProperty function does not copy its args.
if (Platform.CPU.FSBFrequency != 0) {
if (Platform.CPU.FSBFrequency != 0)
{
DT__AddProperty(efiPlatformNode, FSB_Frequency_prop, sizeof(uint64_t), &Platform.CPU.FSBFrequency);
}
// Export TSC and CPU frequencies for use by the kernel or KEXTs
if (Platform.CPU.TSCFrequency != 0) {
if (Platform.CPU.TSCFrequency != 0)
{
DT__AddProperty(efiPlatformNode, TSC_Frequency_prop, sizeof(uint64_t), &Platform.CPU.TSCFrequency);
}
if (Platform.CPU.CPUFrequency != 0) {
if (Platform.CPU.CPUFrequency != 0)
{
DT__AddProperty(efiPlatformNode, CPU_Frequency_prop, sizeof(uint64_t), &Platform.CPU.CPUFrequency);
}
// Bungo
/* Export system-id. Can be disabled with SystemId=No in com.apple.Boot.plist
if ((ret=getSystemID())) {
DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, UUID_LEN, (EFI_UINT32*) ret);
if ((ret=getSystemID()))
{
DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, UUID_LEN, (EFI_UINT32 *) ret);
}
*/
DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, UUID_LEN, (EFI_UINT32 *)Platform.UUID);
// Export SystemSerialNumber if present
if ((ret16=getSmbiosChar16("SMserial", &len))) {
if ((ret16=getSmbiosChar16("SMserial", &len)))
{
DT__AddProperty(efiPlatformNode, SYSTEM_SERIAL_PROP, len, ret16);
}
// Export Model if present
if ((ret16=getSmbiosChar16("SMproductname", &len))) {
if ((ret16=getSmbiosChar16("SMproductname", &len)))
{
DT__AddProperty(efiPlatformNode, MODEL_PROP, len, ret16);
}
branches/zenith432/i386/libsaio/saio_internal.h
134134
135135
136136
137
137
138138
139139
140140
/* memory.c */
long AllocateKernelMemory( long inSize );
long AllocateMemoryRange(char * rangeName, long start, long length, long type);
long AllocateMemoryRange(char *rangeName, long start, long length, long type);
/* misc.c */
extern void enableA20(void);
branches/zenith432/i386/boot2/drivers.c
740740
741741
742742
743
744
743
745744
746
747
745
746
747
748
748749
749750
750751
......
798799
799800
800801
801
802
802
803803
804804
805805
......
825825
826826
827827
828
829
828
830829
831
832
833
834
835
836
830
831
832
833
834
835
837836
838837
839838
//==========================================================================
// MatchLibraries
static long
MatchLibraries( void )
static long MatchLibraries( void )
{
TagPtr prop, prop2;
ModulePtr module, module2;
TagPtr prop;
TagPtr prop2;
ModulePtr module;
ModulePtr module2;
long done;
do {
// FindModule
#if NOTDEF
static ModulePtr
FindModule( char * name )
static ModulePtr FindModule( char *name )
{
ModulePtr module;
TagPtr prop;
//==========================================================================
// ParseXML
static long
ParseXML( char * buffer, ModulePtr * module, TagPtr * personalities )
static long ParseXML( char *buffer, ModulePtr *module, TagPtr *personalities )
{
long length, pos;
TagPtr moduleDict, required;
ModulePtr tmpModule;
pos = 0;
longlength;
longpos = 0;
TagPtrmoduleDict;
TagPtrrequired;
ModulePtrtmpModule;
while (1)
{
length = XMLParseNextTag(buffer + pos, &moduleDict);
branches/zenith432/i386/boot2/mboot.c
290290
291291
292292
293
294
293
294
295295
296296
297297
......
404404
405405
406406
407
407
408408
409409
410410
......
415415
416416
417417
418
419
418
419
420420
421421
422422
continue_at_low_address();
// Now fix our return address.
// JrCs: this macro should be rewritten because the code generated by XCode 4.x
// change the value of the argument passed as parameter (multiboot_magic)
// JrCs: this macro should be rewritten because the code generated by XCode 4.x
// change the value of the argument passed as parameter (multiboot_magic)
// FIX_RETURN_ADDRESS_USING_FIRST_ARG(multiboot_magic);
// We can now do just about anything, including return to our caller correctly.
else
doSelectDevice = true;
}
if(getValueForBootKey(mi->mi_cmdline, "timeout", &val, &size))
{
char *endptr;
multiboot_timeout = intVal;
multiboot_timeout_set = 1;
}
}
}
if(getValueForBootKey(mi->mi_cmdline, "partno", &val, &size))
{
char *endptr;
branches/zenith432/i386/boot2/lzvn.c
5757
5858
5959
60
60
6161
62
62
6363
6464
6565
} while (0)
size_t lzvn_decode(void * dst,
size_t lzvn_decode(void *dst,
size_t dst_size,
const void * src,
const void *src,
size_t src_size)
{
size_t rax = 0;
branches/zenith432/i386/boot2/resume.c
5454
5555
5656
57
5758
5859
5960
dst = (unsigned long *) (header->restore1CodePhysPage << 12);
count = header->restore1PageCount;
proc = (header->restore1CodeOffset + ((uint32_t) dst));
newSP = header->restore1StackOffset + (header->restore1CodePhysPage << 12);
src = (unsigned long *) (((u_int32_t) &header->fileExtentMap[0])
branches/zenith432/i386/boot2/boot.c
7777
7878
7979
80
80
8181
8282
8383
......
230230
231231
232232
233
233
234
235
236
234237
235238
236239
......
243246
244247
245248
246
249
250
251
252
247253
254
248255
249256
250257
......
252259
253260
254261
255
256262
257263
258264
......
435441
436442
437443
438
439
440
444
445
446
441447
442448
443449
......
451457
452458
453459
454
460
461
462
463
455464
456465
457466
......
847856
848857
849858
850
859
860
861
862
863
851864
852865
853866
boolgScanSingleDrive;
booluseGUI;
static int interruptsAvailable = 0;
static intinterruptsAvailable = 0;
static boolgUnloadPXEOnExit = false;
// Notify modules that the kernel is about to be started
execute_hook("Kernel Start", (void *)kernelEntry, (void *)bootArgs, NULL, NULL);
if (interruptsAvailable) DisableInterrupts();
if (interruptsAvailable)
{
DisableInterrupts();
}
// Masking out so that Lion doesn't doublefault
outb(0x21, 0xff);/* Maskout all interrupts Pic1 */
// Notify modules that the kernel is about to be started
execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgsPreLion, NULL, NULL);
if (interruptsAvailable) DisableInterrupts();
if (interruptsAvailable)
{
DisableInterrupts();
}
startprog( kernelEntry, bootArgsPreLion );
}
__builtin_unreachable();
}
//==========================================================================
// LoadKernelCache - Try to load Kernel Cache.
// return the length of the loaded cache file or -1 on error
bool firstRun = true;
bool instantMenu;
bool rescanPrompt;
intstatus;
unsigned intallowBVFlags = kBVFlagSystemVolume | kBVFlagForeignBoot;
unsigned intdenyBVFlags = kBVFlagEFISystem;
intstatus;
unsigned intallowBVFlags = kBVFlagSystemVolume | kBVFlagForeignBoot;
unsigned intdenyBVFlags = kBVFlagEFISystem;
// Set reminder to unload the PXE base code. Neglect to unload
// the base code will result in a hang or kernel panic.
// Enable interrupts
interruptsAvailable = SetupInterrupts();
if (interruptsAvailable) EnableInterrupts();
if (interruptsAvailable)
{
EnableInterrupts();
}
// Initialize boot info structure.
initKernBootStruct();
{
nbpUnloadBaseCode();
}
if (interruptsAvailable) DisableInterrupts();
if (interruptsAvailable)
{
DisableInterrupts();
}
}
/*!
branches/zenith432/i386/boot2/boot.h
119119
120120
121121
122
122
123123
124124
125
125
126126
127127
128
128
129129
130130
131131
......
154154
155155
156156
157
157
158158
159159
160160
......
180180
181181
182182
183
183
184184
185185
186
186
187187
188188
189189
#define kEHCIhard"EHCIhard"/* usb.c */
#define kDefaultPartition"Default Partition"/* sys.c */
/* Zenith432: added this */
/* Zenith432: added this key */
#define kXHCILegacyOff"XHCILegacyOff"/* usb.c */
/* Duvel300: added this */
/* Duvel300: added this key */
#define kRestartFix"RestartFix"/* acpi_patcher.c */
/* Slice: added this */
/* Slice: added these keys */
#define kPS2RestartFix"PS2RestartFix"/* acpi_patcher.c */
#define kUseIntelHDMI"UseIntelHDMI"/* ati.c && nvidia.c && gma.c */
#define kDcfg0"display_0"/* nvidia.c */
#define kDcfg1"display_1"/* nvidia.c */
/* Marchrius: added these keys */
/* Marchrius: added this key */
#define kEnableBacklight"EnableBacklight"/* nvidia.c */
/* Kabyl: added these keys */
#define kHDEFLayoutID"HDEFLayoutID"/* hda.c */
#define kHDAULayoutID"HDAULayoutID"/* hda.c */
/* Karas: added these keys */
/* Karas: added this key */
#define kMemFullInfo"ForceFullMemInfo"/* smbios.c */
/* Bungo: added these keys */
/* Bungo: added this key */
#define kPrivateData"PrivateData"/* smbios_decode.c */
branches/zenith432/i386/boot2/modules.c
2525
2626
2727
28
29
28
29
3030
3131
3232
......
118118
119119
120120
121
121
122122
123123
124124
......
271271
272272
273273
274
274
275275
276276
277277
......
300300
301301
302302
303
303
304304
305305
306306
......
10691069
10701070
10711071
1072
10731072
10741073
10751074
......
11061105
11071106
11081107
1109
1110
11111108
11121109
11131110
......
12291226
12301227
12311228
1232
1233
1234
1229
1230
1231
12351232
12361233
12371234
#define DBGPAUSE()
#endif
static inline voidrebase_location(UInt32* location, char* base, int type);
static inline voidbind_location(UInt32* location, char* value, UInt32 addend, int type);
static inline voidrebase_location(UInt32 *location, char *base, int type);
static inline voidbind_location(UInt32 *location, char *value, UInt32 addend, int type);
// NOTE: Global so that modules can link with this
static UInt64 textAddress = 0;
last = mod->mm_string;
}
char* name = strdup(last);
char *name = strdup(last);
name[strlen(last) - sizeof("dylib")] = 0;
DBG("Loading multiboot module %s\n", name);
* adjust it's internal symbol list (sort) to optimize locating new symbols
* NOTE: returns the address if the symbol is "start", else returns 0xFFFFFFFF
*/
long long add_symbol(char* symbol, long long addr, char is64)
long long add_symbol(char *symbol, long long addr, char is64)
{
// This only can handle 32bit symbols
symbolList_t* entry;
*/
void module_loaded(const char* name, void* start, const char* author, const char* description, UInt32 version, UInt32 compat)
{
moduleList_t* new_entry = malloc(sizeof(moduleList_t));
moduleList_t *new_entry = malloc(sizeof(moduleList_t));
new_entry->next = loadedModules;
loadedModules = new_entry;
return 0;
}
/*
*execute_hook( const char* name )
*name - Name of the module hook
}
}
/*
*register_hook_callback( const char* name, void(*callback)())
*name - Name of the module hook to attach to.
return 0;
}
void start_built_in_module(const char* name,
const char* author,
const char* description,
void start_built_in_module(const char *name,
const char *author,
const char *description,
UInt32 version,
UInt32 compat,
void(*start_function)(void))
branches/zenith432/i386/boot2/modules.h
3434
3535
3636
37
37
3838
3939
4040
4141
42
43
44
42
43
44
4545
4646
4747
......
6868
6969
7070
71
71
7272
7373
7474
......
7676
7777
7878
79
80
79
80
8181
8282
8383
8484
8585
8686
87
87
8888
8989
90
90
9191
9292
93
93
9494
9595
96
96
9797
98
98
9999
100100
101101
102102
103103
104
105
106
107
104
105
106
107
108108
109109
110110
typedef struct callbackList_t
{
void(*callback)(void*, void*, void*, void*);
struct callbackList_t* next;
struct callbackList_t *next;
} callbackList_t;
typedef struct moduleHook_t
{
const char* name;
callbackList_t* callbacks;
struct moduleHook_t* next;
const char *name;
callbackList_t *callbacks;
struct moduleHook_t *next;
} moduleHook_t;
typedef struct modulesList_t
int load_module(char* module);
int is_module_loaded(const char* name);
void module_loaded(const char* name, void* start, const char* author, const char* description, UInt32 version, UInt32 compat);
void module_loaded(const char *name, void *start, const char *author, const char *description, UInt32 version, UInt32 compat);
/********************************************************************************/
/*Symbol Functions*/
/********************************************************************************/
long longadd_symbol(char* symbol, long long addr, char is64);
unsigned intlookup_all_symbols(const char* name);
long longadd_symbol(char *symbol, long long addr, char is64);
unsigned intlookup_all_symbols(const char *name);
/********************************************************************************/
/*Macho Parser*/
/********************************************************************************/
void*parse_mach(void* binary,
void*parse_mach(void *binary,
int(*dylib_loader)(char*),
long long(*symbol_handler)(char*, long long, char),
void (*section_handler)(char* section, char* segment, void* cmd, UInt64 offset, UInt64 address)
void (*section_handler)(char *section, char *segment, void *cmd, UInt64 offset, UInt64 address)
);
unsigned inthandle_symtable(UInt32 base,
struct symtab_command* symtabCommand,
struct symtab_command *symtabCommand,
long long(*symbol_handler)(char*, long long, char),
char is64);
voidrebase_macho(void* base, char* rebase_stream, UInt32 size);
voidrebase_macho(void *base, char *rebase_stream, UInt32 size);
voidbind_macho(void* base, UInt8* bind_stream, UInt32 size);
voidbind_macho(void *base, UInt8 *bind_stream, UInt32 size);
/********************************************************************************/
/*Module Interface*/
/********************************************************************************/
intreplace_function(const char* symbol, void* newAddress);
intexecute_hook(const char* name, void*, void*, void*, void*);
voidregister_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*));
moduleHook_t*hook_exists(const char* name);
intreplace_function(const char *symbol, void *newAddress);
intexecute_hook(const char *name, void*, void*, void*, void*);
voidregister_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*));
moduleHook_t*hook_exists(const char* name);
#if DEBUG_MODULES
voidprint_hook_list();
branches/zenith432/i386/boot2/gui.c
1313
1414
1515
16
17
18
19
20
21
22
23
24
25
1626
1727
1828
......
456466
457467
458468
469
470
459471
460472
461473
......
524536
525537
526538
527
539
540
541
528542
529543
544
530545
531
546
547
532548
533549
550
534551
535552
536553
......
545562
546563
547564
548
565
566
567
549568
550569
551570
552571
553
572
573
554574
555575
576
556577
557578
558579
......
566587
567588
568589
569
590
591
570592
571593
572594
573595
596
574597
575598
576599
......
620643
621644
622645
623
646
647
624648
625649
626650
627
651
652
628653
629654
630655
631656
632657
633
634
658
659
660
661
635662
636663
637664
......
756783
757784
758785
759
786
760787
761788
762789
......
907934
908935
909936
937
938
939
910940
941
911942
912943
913944
......
931962
932963
933964
934
965
966
935967
936968
937969
938970
939971
940
941
942
943
944
945
972
973
974
975
976
977
978
979
980
981
982
983
946984
947985
948986
949987
988
950989
990
951991
952992
953993
......
958998
959999
9601000
961
962
963
964
965
966
967
968
1001
9691002
1003
1004
1005
1006
1007
1008
1009
1010
1011
9701012
9711013
9721014
......
11301172
11311173
11321174
1133
1175
1176
11341177
11351178
11361179
......
11721215
11731216
11741217
1175
1218
1219
11761220
11771221
1178
1222
1223
11791224
11801225
11811226
......
12031248
12041249
12051250
1206
1251
1252
12071253
12081254
12091255
......
12451291
12461292
12471293
1248
1294
1295
12491296
1250
1251
1297
1298
1299
1300
1301
1302
12521303
1253
1254
1304
1305
1306
1307
12551308
12561309
12571310
1258
1311
1312
12591313
12601314
12611315
......
12701324
12711325
12721326
1327
1328
12731329
12741330
12751331
......
12801336
12811337
12821338
1283
1284
1339
1340
1341
1342
12851343
12861344
1287
1345
1346
12881347
12891348
1290
1291
1349
1350
1351
12921352
1293
1353
1354
12941355
12951356
12961357
12971358
12981359
12991360
1300
1361
1362
13011363
13021364
13031365
......
13161378
13171379
13181380
1319
1320
1381
1382
1383
1384
13211385
13221386
13231387
......
13331397
13341398
13351399
1336
1400
13371401
13381402
1339
1403
1404
13401405
13411406
13421407
......
13601425
13611426
13621427
1363
1428
1429
13641430
13651431
13661432
13671433
13681434
1369
1435
1436
13701437
13711438
13721439
1373
1440
1441
13741442
13751443
13761444
13771445
13781446
13791447
1380
1448
1449
13811450
13821451
13831452
13841453
1385
1454
1455
13861456
13871457
13881458
13891459
13901460
13911461
1392
1462
1463
13931464
13941465
13951466
13961467
13971468
1398
1469
1470
13991471
14001472
14011473
......
14171489
14181490
14191491
1420
1492
14211493
14221494
14231495
1424
1425
1496
1497
1498
14261499
14271500
14281501
......
14321505
14331506
14341507
1435
1508
14361509
14371510
1438
1511
14391512
14401513
14411514
......
14461519
14471520
14481521
1449
1522
1523
14501524
14511525
14521526
14531527
14541528
1455
1529
1530
14561531
14571532
14581533
1459
1534
1535
14601536
14611537
14621538
14631539
14641540
14651541
1466
1542
1543
14671544
14681545
14691546
1470
1547
1548
14711549
14721550
14731551
14741552
14751553
1476
1554
1555
14771556
14781557
14791558
14801559
14811560
1482
1561
1562
14831563
14841564
14851565
......
15091589
15101590
15111591
1512
1592
1593
15131594
15141595
15151596
......
15221603
15231604
15241605
1525
1606
1607
15261608
15271609
15281610
15291611
1530
1612
1613
15311614
15321615
1533
1616
1617
15341618
15351619
15361620
......
15401624
15411625
15421626
1543
1627
1628
15441629
15451630
15461631
15471632
15481633
15491634
1550
1635
1636
15511637
15521638
15531639
15541640
15551641
1556
1642
1643
15571644
15581645
15591646
15601647
15611648
1562
1649
1650
15631651
15641652
15651653
......
15741662
15751663
15761664
1577
1665
1666
15781667
1579
1668
1669
15801670
15811671
15821672
......
15851675
15861676
15871677
1588
1678
1679
15891680
1590
1681
1682
15911683
15921684
1593
1685
1686
1687
15941688
15951689
15961690
......
16021696
16031697
16041698
1605
1699
1700
16061701
1607
1702
1703
16081704
16091705
16101706
16111707
16121708
16131709
1614
1710
1711
16151712
16161713
16171714
......
16301727
16311728
16321729
1633
1634
1730
1731
1732
1733
16351734
16361735
1637
1736
1737
1738
16381739
1639
1740
1741
1742
16401743
1641
1744
1745
16421746
16431747
16441748
1645
1749
1750
16461751
16471752
16481753
......
16581763
16591764
16601765
1661
1662
1663
1766
1767
1768
1769
1770
1771
16641772
16651773
16661774
......
16821790
16831791
16841792
1685
1793
1794
16861795
16871796
16881797
1689
1798
1799
16901800
16911801
1692
1802
1803
16931804
16941805
1695
1696
1806
1807
1808
16971809
16981810
1699
1700
1811
1812
1813
1814
17011815
17021816
17031817
1704
1818
17051819
1706
1820
1821
17071822
17081823
17091824
17101825
1711
1826
17121827
17131828
17141829
17151830
17161831
17171832
1718
1833
1834
17191835
17201836
17211837
1722
1838
1839
17231840
17241841
17251842
......
17321849
17331850
17341851
1735
1852
1853
17361854
17371855
17381856
......
17401858
17411859
17421860
1743
1861
1862
17441863
17451864
1746
1747
1865
1866
1867
1868
17481869
1749
1870
1871
17501872
17511873
17521874
......
17811903
17821904
17831905
1784
1785
1906
1907
1908
1909
17861910
1787
1911
1912
17881913
17891914
17901915
......
18451970
18461971
18471972
1848
1973
1974
18491975
1850
1851
1976
1977
1978
1979
18521980
18531981
1854
1982
1983
1984
18551985
18561986
18571987
18581988
18591989
1860
1861
1990
1991
1992
1993
18621994
18631995
1864
1996
1997
1998
18651999
18662000
18672001
......
18852019
18862020
18872021
1888
2022
2023
18892024
18902025
18912026
18922027
1893
2028
2029
18942030
18952031
18962032
......
19022038
19032039
19042040
1905
2041
19062042
19072043
19082044
......
19412077
19422078
19432079
1944
2080
2081
19452082
19462083
19472084
......
21342271
21352272
21362273
2274
2275
21372276
21382277
21392278
......
21552294
21562295
21572296
2158
2297
2298
21592299
21602300
21612301
#include "appleboot.h"
#include "vers.h"
#ifndef DEBUG_GUI
#define DEBUG_GUI 0
#endif
#if DEBUG_GUI
#define DBG(x...)printf(x)
#else
#define DBG(x...)
#endif
#define IMG_REQUIRED -1
#define THEME_NAME_DEFAULT"Default"
static const char *theme_name = THEME_NAME_DEFAULT;
initFont( &font_console, &images[iFontConsole]);
initFont( &font_small, &images[iFontSmall]);
//DBG("Graphic objects successfully loaded !!\n",theme_name);
return 0;
}
int createBackBuffer( window_t *window )
{
gui.backbuffer = malloc(sizeof(pixmap_t));
if(!gui.backbuffer) {
if(!gui.backbuffer)
{
DBG("Unable to allocate memory for gui.backbuffer");
return 1;
}
gui.backbuffer->pixels = malloc( window->width * window->height * 4 );
if(!gui.backbuffer->pixels) {
if(!gui.backbuffer->pixels)
{
free(gui.backbuffer);
gui.backbuffer = 0;
DBG("Unable to allocate memory for gui.backbuffer->pixels");
return 1;
}
int createWindowBuffer( window_t *window )
{
window->pixmap = malloc(sizeof(pixmap_t));
if(!window->pixmap) {
if(!window->pixmap)
{
DBG("Unable to allocate memory for window->pixmap");
return 1;
}
window->pixmap->pixels = malloc( window->width * window->height * 4 );
if(!window->pixmap->pixels) {
if(!window->pixmap->pixels)
{
free(window->pixmap);
window->pixmap = 0;
DBG("Unable to allocate memory for window->pixmap->pixels");
return 1;
}
int freeWindowBuffer( window_t *window )
{
if (window->pixmap && window->pixmap->pixels) {
if (window->pixmap && window->pixmap->pixels)
{
free(window->pixmap->pixels);
free(window->pixmap);
return 0;
}
return 1;
}
int val, len;
const char *string;
if(getIntForKey("devices_max_visible", &val, theme )) {
if(getIntForKey("devices_max_visible", &val, theme ))
{
gui.maxdevices = MIN( val, gDeviceCount );
}
if(getIntForKey("devices_iconspacing", &val, theme )) {
if(getIntForKey("devices_iconspacing", &val, theme ))
{
gui.devicelist.iconspacing = val;
}
// check layout for horizontal or vertical
gui.layout = HorizontalLayout;
if(getValueForKey( "devices_layout", &string, &len, theme)) {
if (!strcmp (string, "vertical")) {
if(getValueForKey( "devices_layout", &string, &len, theme))
{
if (!strcmp (string, "vertical"))
{
gui.layout = VerticalLayout;
}
}
gui.countdown.pos.y = pixel;
}
/*
/*
* Parse devicelist parameters
*/
setupDeviceList(theme);
return 1;
}
#else
DBG("Unable to load %s theme plist.\n",theme_name);
return 1;
#endif
}
// parse display size parameters
gui.screen.height = screen_params[1];
// load graphics otherwise fail and return
if (loadGraphics() == 0) {
if (loadGraphics() == 0)
{
loadThemeValues(&bootInfo->themeConfig);
colorFont(&font_small, gui.screen.font_small_color);
colorFont(&font_console, gui.screen.font_console_color);
// create the screen & window buffers
if (createBackBuffer(&gui.screen) == 0) {
if (createWindowBuffer(&gui.screen) == 0) {
if (createWindowBuffer(&gui.devicelist) == 0) {
if (createWindowBuffer(&gui.bootprompt) == 0) {
if (createWindowBuffer(&gui.infobox) == 0) {
if (createWindowBuffer(&gui.menu) == 0) {
if (createBackBuffer(&gui.screen) == 0)
{
if (createWindowBuffer(&gui.screen) == 0)
{
if (createWindowBuffer(&gui.devicelist) == 0)
{
if (createWindowBuffer(&gui.bootprompt) == 0)
{
if (createWindowBuffer(&gui.infobox) == 0)
{
if (createWindowBuffer(&gui.menu) == 0)
{
gui.logo.draw = true;
drawBackground();
// lets copy the screen into the back buffer
memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 );
setVideoMode( GRAPHICS_MODE, 0 );
gui.initialised = true;
return 0;
}
}
}
// not available memory, freeing resources
freeWindowBuffer(&gui.menu);
freeWindowBuffer(&gui.infobox);
freeWindowBuffer(&gui.bootprompt);
freeWindowBuffer(&gui.devicelist);
freeWindowBuffer(&gui.screen);
freeBackBuffer(&gui.screen);
unloadGraphics();
DBG("Loading error occurred, reseting...\n",theme_name);
// Loading error occurred, freeing resources
freeWindowBuffer(&gui.menu);
freeWindowBuffer(&gui.infobox);
freeWindowBuffer(&gui.bootprompt);
freeWindowBuffer(&gui.devicelist);
freeWindowBuffer(&gui.screen);
freeBackBuffer(&gui.screen);
unloadGraphics();
return 1;
}
}
// draw visible device icons
for (i = 0; i < gui.maxdevices; i++) {
for (i = 0; i < gui.maxdevices; i++)
{
BVRef param = menuItems[start + i].param;
bool isSelected = ((start + i) == selection) ? true : false;
drawDeviceIcon( param, gui.devicelist.pixmap, p, isSelected);
if (gui.layout == HorizontalLayout) {
if (gui.layout == HorizontalLayout)
{
p.x += images[iSelection].image->width + gui.devicelist.iconspacing;
}
if (gui.layout == VerticalLayout) {
if (gui.layout == VerticalLayout)
{
p.y += ( images[iSelection].image->height + font_console.chars[0]->height + gui.devicelist.iconspacing );
}
}
//prompt_pos=0;
if( gui.bootprompt.draw == true ) {
if(gui.bootprompt.draw == true )
{
gui.bootprompt.draw = false;
gui.redraw = true;
// this causes extra frames to be drawn
static inline
void vramwrite (void *data, int width, int height)
{
if (VIDEO (depth) == 32 && VIDEO (rowBytes) == gui.backbuffer->width * 4) {
if (VIDEO (depth) == 32 && VIDEO (rowBytes) == gui.backbuffer->width * 4)
{
memcpy((uint8_t *)vram, gui.backbuffer->pixels, VIDEO (rowBytes)*VIDEO (height));
} else {
uint32_t r, g, b;
}
else
{
uint32_t r;
uint32_t g;
uint32_t b;
int i, j;
for (i = 0; i < VIDEO (height); i++) {
for (j = 0; j < VIDEO (width); j++) {
for (i = 0; i < VIDEO (height); i++)
{
for (j = 0; j < VIDEO (width); j++)
{
b = ((uint8_t *) data)[4*i*width + 4*j];
g = ((uint8_t *) data)[4*i*width + 4*j + 1];
r = ((uint8_t *) data)[4*i*width + 4*j + 2];
switch (VIDEO (depth)) {
switch (VIDEO (depth))
{
case 32:
*(uint32_t *)(((uint8_t *)vram)+i*VIDEO (rowBytes) + j*4) = (b&0xff) | ((g&0xff)<<8) | ((r&0xff)<<16);
break;
case 15:
*(uint16_t *)(((uint8_t *)vram)+i*VIDEO (rowBytes) + j*2) = ((b&0xf8)>>3) | ((g&0xf8)<<2) | ((r&0xf8)<<7);
break;
default:
break;
}
}
}
void updateVRAM()
{
if (gui.redraw) {
if (gui.devicelist.draw) {
if (gui.redraw)
{
if (gui.devicelist.draw)
{
blend( gui.devicelist.pixmap, gui.backbuffer, gui.devicelist.pos );
}
if (gui.bootprompt.draw) {
if (gui.bootprompt.draw)
{
blend( gui.bootprompt.pixmap, gui.backbuffer, gui.bootprompt.pos );
}
if (gui.menu.draw) {
blend( gui.menu.pixmap, gui.backbuffer, gui.menu.pos );
if (gui.menu.draw)
{
blend( gui.menu.pixmap, gui.backbuffer, gui.menu.pos );
}
if (gui.infobox.draw) {
if (gui.infobox.draw)
{
blend( gui.infobox.pixmap, gui.backbuffer, gui.infobox.pos );
}
}
vramwrite ( gui.backbuffer->pixels, gui.backbuffer->width, gui.backbuffer->height );
if (gui.redraw) {
if (gui.redraw)
{
memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 );
gui.redraw = false;
}
static int
sputc(int c, struct putc_info * pi) //Azi: same as above
{
if (pi->last_str) {
if (pi->str == pi->last_str) {
if (pi->last_str)
{
if (pi->str == pi->last_str)
{
*(pi->str) = '\0';
return 0;
}
char *formattedtext;
va_list ap;
struct putc_info pi;
if ((formattedtext = malloc(1024)) != NULL) {
if ((formattedtext = malloc(1024)) != NULL)
{
// format the text
va_start(ap, fmt);
pi.str = formattedtext;
font_t *font = &font_console;
for( i=0; i< strlen(formattedtext); i++ ) {
for( i=0; i< strlen(formattedtext); i++ )
{
character = formattedtext[i];
character -= 32;
// newline ?
if( formattedtext[i] == '\n' ) {
if( formattedtext[i] == '\n' )
{
cursor.x = window->hborder;
cursor.y += font->height;
if ( cursor.y > bounds.y ) {
if ( cursor.y > bounds.y )
{
cursor.y = origin.y;
}
continue;
}
// tab ?
if( formattedtext[i] == '\t' ) {
if( formattedtext[i] == '\t' )
{
cursor.x += ( font->chars[0]->width * 5 );
}
// draw the character
if( font->chars[character]) {
if( font->chars[character])
{
blend(font->chars[character], window->pixmap, cursor);
}
cursor.x += font->chars[character]->width;
// check x pos and do newline
if ( cursor.x > bounds.x ) {
if ( cursor.x > bounds.x )
{
cursor.x = origin.x;
cursor.y += font->height;
}
// check y pos and reset to origin.y
if ( cursor.y > bounds.y ) {
if ( cursor.y > bounds.y )
{
cursor.y = origin.y;
}
}
char *formattedtext;
va_list ap;
//window = &gui.debug;
struct putc_info pi;
if ((formattedtext = malloc(1024)) != NULL) {
if ((formattedtext = malloc(1024)) != NULL)
{
// format the text
va_start(ap, fmt);
pi.str = formattedtext;
va_end(ap);
position_torigin, cursor, bounds;
int i;
int character;
origin.x = MAX( gui.debug.cursor.x, window->hborder );
origin.y = MAX( gui.debug.cursor.y, window->vborder );
font_t *font = &font_console;
for( i=0; i< strlen(formattedtext); i++ ) {
for( i=0; i< strlen(formattedtext); i++ )
{
character = formattedtext[i];
character -= 32;
// newline ?
if( formattedtext[i] == '\n' ) {
if( formattedtext[i] == '\n' )
{
cursor.x = window->hborder;
cursor.y += font->height;
if ( cursor.y > bounds.y ) {
if ( cursor.y > bounds.y )
{
cursor.y = origin.y;
}
continue;
}
// tab ?
if( formattedtext[i] == '\t' ) {
if( formattedtext[i] == '\t' )
{
cursor.x += ( font->chars[0]->width * 5 );
}
// draw the character
if( font->chars[character]) {
if( font->chars[character])
{
blend(font->chars[character], gui.backbuffer, cursor);
}
cursor.x += font->chars[character]->width;
// check x pos and do newline
if ( cursor.x > bounds.x ) {
if ( cursor.x > bounds.x )
{
cursor.x = origin.x;
cursor.y += font->height;
}
// check y pos and reset to origin.y
if ( cursor.y > bounds.y ) {
if ( cursor.y > bounds.y )
{
cursor.y = origin.y;
}
}
position_torigin, cursor, bounds;
font_t *font = &font_console;
if ((formattedtext = malloc(1024)) != NULL) {
if ((formattedtext = malloc(1024)) != NULL)
{
// format the text
pi.str = formattedtext;
pi.last_str = 0;
bounds.y = ( window->height - ( window->vborder * 2 ) );
cursor = origin;
for( i=0; i< strlen(formattedtext); i++ ) {
for( i=0; i< strlen(formattedtext) ; i++ )
{
character = formattedtext[i];
character -= 32;
// newline ?
if( formattedtext[i] == '\n' ) {
if( formattedtext[i] == '\n' )
{
cursor.x = window->hborder;
cursor.y += font->height;
if ( cursor.y > bounds.y ) {
if ( cursor.y > bounds.y )
{
gui.redraw = true;
updateVRAM();
cursor.y = window->vborder;
}
// tab ?
if( formattedtext[i] == '\t' ) {
if( formattedtext[i] == '\t' )
{
cursor.x = ( cursor.x / ( font->chars[0]->width * 8 ) + 1 ) * ( font->chars[0]->width * 8 );
continue;
}
cursor.x += font->chars[character]->width;
// check x pos and do newline
if ( cursor.x > bounds.x ) {
if ( cursor.x > bounds.x )
{
cursor.x = origin.x;
cursor.y += font->height;
}
// check y pos and reset to origin.y
if ( cursor.y > ( bounds.y + font->chars[0]->height) ) {
if ( cursor.y > ( bounds.y + font->chars[0]->height) )
{
gui.redraw = true;
updateVRAM();
cursor.y = window->vborder;
}
// draw the character
if( font->chars[character]) {
if( font->chars[character])
{
blend(font->chars[character], gui.backbuffer, cursor);
}
}
// ====================================================================
pixmap_t* charToPixmap(unsigned char ch, font_t *font) {
pixmap_t *charToPixmap(unsigned char ch, font_t *font)
{
unsigned int cha = (unsigned int)ch - 32;
if (cha >= font->count) {
if (cha >= font->count)
{
// return ? if the font for the char doesn't exists
cha = '?' - 32;
}
// ====================================================================
position_t drawChar(unsigned char ch, font_t *font, pixmap_t *blendInto, position_t p) {
position_t drawChar(unsigned char ch, font_t *font, pixmap_t *blendInto, position_t p)
{
pixmap_t* pm = charToPixmap(ch, font);
if (pm && ((p.x + pm->width) < blendInto->width)) {
if (pm && ((p.x + pm->width) < blendInto->width))
{
blend(pm, blendInto, p);
return pos(p.x + pm->width, p.y);
} else {
}
else
{
return p;
}
}
int i=0;
position_t current_pos = pos(p.x, p.y);
for (i=0; i < strlen(ch); i++) {
for (i=0; i < strlen(ch); i++)
{
// newline ?
if ( ch[i] == '\n' ) {
if ( ch[i] == '\n' )
{
current_pos.x = p.x;
current_pos.y += font->height;
continue;
}
// tab ?
if ( ch[i] == '\t' ) {
if ( ch[i] == '\t' )
{
current_pos.x += TAB_PIXELS_WIDTH;
continue;
}
int height = font->height;
// calculate the width in pixels
for (i=0; i < strlen(text); i++) {
if (text[i] == '\n') {
for (i=0; i < strlen(text); i++)
{
if (text[i] == '\n')
{
width = 0;
height += font->height;
} else if (text[i] == '\t') {
}
else if (text[i] == '\t')
{
width += TAB_PIXELS_WIDTH;
} else {
}
else
{
pixmap_t* pm = charToPixmap(text[i], font);
if (pm){
if (pm)
{
width += pm->width;
}
}
if (width > max_width) {
if (width > max_width)
{
max_width = width;
}
}
int destroyFont(font_t *font)
{
int i;
for (i = 0; i < CHARACTERS_COUNT; i++) {
if (font->chars[i]) {
if (font->chars[i]->pixels) {
for (i = 0; i < CHARACTERS_COUNT; i++)
{
if (font->chars[i])
{
if (font->chars[i]->pixels)
{
free (font->chars[i]->pixels);
}
free (font->chars[i]);
font->height = data->image->height;
for( x = 0; x < data->image->width && count < CHARACTERS_COUNT; x++) {
for( x = 0; x < data->image->width && count < CHARACTERS_COUNT; x++)
{
start = end;
// if the pixel is red we've reached the end of the char
if( pixel( data->image, x, 0 ).value == 0xFFFF0000) {
if( pixel( data->image, x, 0 ).value == 0xFFFF0000)
{
end = x + 1;
if( (font->chars[count] = malloc(sizeof(pixmap_t)) ) ) {
if( (font->chars[count] = malloc(sizeof(pixmap_t)) ) )
{
font->chars[count]->width = ( end - start) - 1;
font->chars[count]->height = font->height;
if ( ( font->chars[count]->pixels = malloc( font->chars[count]->width * data->image->height * 4) ) ) {
if ( ( font->chars[count]->pixels = malloc( font->chars[count]->width * data->image->height * 4) ) )
{
space += ( font->chars[count]->width * data->image->height * 4 );
// we skip the first line because there are just the red pixels for the char width
for( y = 1; y< (font->height); y++) {
for( x2 = start, x3 = 0; x2 < end; x2++, x3++) {
for( y = 1; y< (font->height); y++)
{
for( x2 = start, x3 = 0; x2 < end; x2++, x3++)
{
pixel( font->chars[count], x3, y ) = pixel( data->image, x2, y );
}
}
// check if font is monospaced
if( ( count > 0 ) && ( font->width != font->chars[count]->width ) ) {
if( ( count > 0 ) && ( font->width != font->chars[count]->width ) )
{
monospaced = true;
}
font->width = font->chars[count]->width;
count++;
}
}
}
}
for (x = count; x < CHARACTERS_COUNT; x++) {
for (x = count; x < CHARACTERS_COUNT; x++)
{
font->chars[x] = NULL;
}
if(monospaced) {
if(monospaced)
{
font->width = 0;
}
void colorFont(font_t *font, uint32_t color)
{
if( !color ) {
if( !color )
{
return;
}
int count = 0;
pixel_t *buff;
while( font->chars[count++] ) {
while( font->chars[count++] )
{
width = font->chars[count-1]->width;
height = font->chars[count-1]->height;
for( y = 0; y < height; y++ ) {
for( x = 0; x < width; x++ ) {
for( y = 0; y < height; y++ )
{
for( x = 0; x < width; x++ )
{
buff = &(pixel( font->chars[count-1], x, y ));
if( buff->ch.a ) {
if( buff->ch.a )
{
buff->ch.r = (color & 0xFFFF0000) >> 16;
buff->ch.g = (color & 0xFF00FF00) >> 8;
buff->ch.b = (color & 0xFF0000FF);
uint8_t alpha=0;
for( y=0; y<10; y++) {
for( x=0; x<10; x++) {
for( y=0; y<10; y++)
{
for( x=0; x<10; x++)
{
// skip if the pixel should be visible
if(roundedCorner[y][x] != 0xFF){
if(roundedCorner[y][x] != 0xFF)
{
alpha = ( roundedCorner[y][x] ? (uint8_t) (roundedCorner[y][x] * pixel(p, x, y).ch.a) / 255 : 0 );
// Upper left corner
pixel(p, x, y).ch.a = alpha;
visiblelines = ( ( gui.infobox.height - ( gui.infobox.vborder * 2 ) ) / font_console.height ) - 1;
// lets display the text and allow scroll thru using up down / arrows
while(1) {
while(1)
{
// move to current line in text
for( offset = 0, i = 0; offset < strlen(text); offset++ ) {
if( currentline == i) {
for( offset = 0, i = 0; offset < strlen(text); offset++ )
{
if( currentline == i)
{
break;
}
if( text[offset] =='\n') {
if( text[offset] =='\n')
{
i++;
}
}
// find last visible line in text and place \0
for( i = offset, cnt = 0; i < strlen(text); i++) {
if(text[i]=='\n') {
for( i = offset, cnt = 0; i < strlen(text); i++)
{
if(text[i]=='\n')
{
cnt++;
}
if ( cnt == visiblelines ) {
if ( cnt == visiblelines )
{
text[i]='\0';
break;
}
position_t pos_indicator = pos( gui.infobox.width - ( images[iTextScrollPrev].image->width - ( gui.infobox.vborder / 2) ), pos_text.y );
// draw prev indicator
if(offset) {
if(offset)
{
blend( images[iTextScrollPrev].image, gui.infobox.pixmap, centeredAt( images[iTextScrollPrev].image, pos_indicator ));
}
// draw next indicator
if( lines > ( currentline + visiblelines ) ) {
if( lines > ( currentline + visiblelines ) )
{
pos_indicator.y = ( gui.infobox.height - ( ( images[iTextScrollNext].image->width + gui.infobox.vborder ) / 2 ) );
blend( images[iTextScrollNext].image, gui.infobox.pixmap, centeredAt( images[iTextScrollNext].image, pos_indicator ) );
}
updateVRAM();
key = getchar();
if( key == KEY_UP ) {
if( currentline > 0 ) {
currentline--;
{
int y;
if( time18() > lasttime) {
if( time18() > lasttime)
{
lasttime = time18();
pixmap_t *buffBar = images[iProgressBar].image;
return buff;
}
break;
default:
break;
}
return DO_NOT_BOOT;
}
char dirspec[256];
if ((strlen(theme_name) + 24) > sizeof(dirspec)) {
if ((strlen(theme_name) + 24) > sizeof(dirspec))
{
usePngImage = false;
return;
}
branches/zenith432/i386/boot2/options.c
197197
198198
199199
200
200
201
202
203
201204
202205
203206
......
423426
424427
425428
426
429
427430
428431
429432
......
461464
462465
463466
464
467
465468
466
467
468
469
470
471
472
473
474
475
469
470
471
472
473
474
475
476
477
478
476479
477
480
478481
479482
480483
481484
482485
483
486
484487
485488
486489
487
488
490
491
489492
490493
491494
492495
493496
494497
495
498
496499
497500
498501
......
500503
501504
502505
503
506
504507
505508
506509
......
528531
529532
530533
531
534
532535
533536
534537
......
538541
539542
540543
541
544
542545
543546
544547
545548
546549
547
550
548551
549552
550553
551554
552555
553
556
554557
555558
556559
557560
558561
559562
560
563
561564
562
563
564
565
565
566
567
568
569
570
566571
567572
568573
......
581586
582587
583588
584
585
586
587
588
589
589
590
591
592
593
594
590595
591
592
596
597
593598
594
595
596
597
598
599
600
599
600
601
602
603
604
605
601606
602
603
604
607
608
605609
606610
607611
608
612
609613
610614
611615
......
620624
621625
622626
623
624
625
626
627
628
629
627630
628
629
631
632
633
634
635
636
630637
631
632638
633
634
635
636
637
639
640
641
642
643
638644
639
645
646
647
648
649
650
640651
641
642
652
653
643654
644655
645
646
647
648
649656
650657
651658
......
760767
761768
762769
763
770
771
764772
765773
766774
......
770778
771779
772780
773
781
782
774783
775784
776785
......
11661175
11671176
11681177
1178
11691179
11701180
11711181
......
12101220
12111221
12121222
1223
12131224
12141225
12151226
......
12531264
12541265
12551266
1256
1257
1258
1259
1260
1261
1262
1263
1264
1267
1268
1269
1270
1271
1272
1273
1274
1275
12651276
12661277
12671278
if( currenttime > lasttime)
{
multi -= (currenttime - lasttime);
if (multi < 0) multi = 0;
if (multi < 0)
{
multi = 0;
}
lasttime=currenttime;
}
}
gMenuStart= 0;
gMenuEnd = MIN( count, gui.maxdevices ) - 1;
// If the selected item is not visible, shift the list down.
if ( gMenuSelection > gMenuBottom )
static int updateMenu( int key, void ** paramPtr )
{
int moved = 0;
int moved = 0;
union {
struct {
unsigned int
selectionUp : 1,
selectionDown : 1,
scrollUp : 1,
scrollDown : 1;
} f;
unsigned int w;
} draw = {{0}};
union {
struct {
unsigned int
selectionUp : 1,
selectionDown : 1,
scrollUp : 1,
scrollDown : 1;
} f;
unsigned int w;
} draw = {{0}};
if ( gMenuItems == NULL )
if ( gMenuItems == NULL )
return 0;
if( bootArgs->Video.v_display != VGA_TEXT_MODE )
{
int res;
// set navigation keys for horizontal layout as defaults
int previous= 0x4B00;// left arrow
int subsequent= 0x4D00;// right arrow