Chameleon

Chameleon Commit Details

Date:2015-03-08 15:28:28 (9 years 1 month 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
int menu= 0x5000;// down arrow
int menu= 0x5000;// down arrow
if ( gui.layout == VerticalLayout )
{
// set navigation keys for vertical layout
previous= 0x4800;// up arrow
subsequent= 0x5000;// down arrow
menu= 0x4B00;// right arrow
}
}
if ( key == previous )
{
draw.f.selectionUp = 1;
else if ( gMenuTop > 0 )
draw.f.scrollDown = 1;
}
else if ( key == subsequent )
else
{
shouldboot = ( res != DO_NOT_BOOT );
if ( shouldboot )
gui.menu.draw = false;
gVerboseMode = false;
gBootMode = kBootModeNormal;
break;
case BOOT_VERBOSE:
gVerboseMode = true;
gBootMode = kBootModeNormal;
addBootArg(kVerboseModeFlag);
break;
case BOOT_IGNORECACHE:
gVerboseMode = false;
gBootMode = kBootModeNormal;
addBootArg(kIgnoreCachesFlag);
break;
case BOOT_SINGLEUSER:
gVerboseMode = true;
gBootMode = kBootModeNormal;
addBootArg(kSingleUserModeFlag);
break;
}
}
}
} else {
}
}
else
{
switch ( key )
{
case 0x4800: // Up Arrow
}
}
if ( draw.w )
{
if ( draw.f.scrollUp )
{
scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, 1);
gMenuTop++; gMenuBottom++;
if ( draw.w )
{
if ( draw.f.scrollUp )
{
scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, 1);
gMenuTop++; gMenuBottom++;
gMenuStart++; gMenuEnd++;
draw.f.selectionDown = 1;
}
draw.f.selectionDown = 1;
}
if ( draw.f.scrollDown )
{
scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, -1);
gMenuTop--; gMenuBottom--;
gMenuStart--; gMenuEnd--;
draw.f.selectionUp = 1;
}
if ( draw.f.scrollDown )
{
scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, -1);
gMenuTop--; gMenuBottom--;
gMenuStart--; gMenuEnd--;
draw.f.selectionUp = 1;
}
if ( draw.f.selectionUp || draw.f.selectionDown )
{
if ( draw.f.selectionUp || draw.f.selectionDown )
{
CursorState cursorState;
// Set cursor at current position, and clear inverse video.
if( bootArgs->Video.v_display == VGA_TEXT_MODE )
{
changeCursor( 0, gMenuRow + gMenuSelection - gMenuTop, kCursorTypeHidden, &cursorState );
gMenuStart--;
gMenuEnd--;
}
} else {
gMenuSelection++;
if(( gMenuSelection - ( gui.maxdevices - 1) - gMenuStart) > 0 )
}
else
{
gMenuStart++;
gMenuEnd++;
gMenuSelection++;
if(( gMenuSelection - ( gui.maxdevices - 1) - gMenuStart) > 0 )
{
gMenuStart++;
gMenuEnd++;
}
}
}
if( bootArgs->Video.v_display == VGA_TEXT_MODE )
{
moveCursor( 0, gMenuRow + gMenuSelection - gMenuTop );
printMenuItem( &gMenuItems[gMenuSelection], 1 );
restoreCursor( &cursorState );
if( bootArgs->Video.v_display == VGA_TEXT_MODE )
{
moveCursor( 0, gMenuRow + gMenuSelection - gMenuTop );
printMenuItem( &gMenuItems[gMenuSelection], 1 );
restoreCursor( &cursorState );
} else
}
else
{
drawDeviceList (gMenuStart, gMenuEnd, gMenuSelection);
}
}
drawDeviceList (gMenuStart, gMenuEnd, gMenuSelection);
*paramPtr = gMenuItems[gMenuSelection].param;
moved = 1;
}
*paramPtr = gMenuItems[gMenuSelection].param;
moved = 1;
}
return moved;
}
void lspci(void)
{
if (bootArgs->Video.v_display == VGA_TEXT_MODE) {
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
{
setActiveDisplayPage(1);
clearScreenRows(0, 24);
setCursorPosition(0, 0, 1);
pause();
if (bootArgs->Video.v_display == VGA_TEXT_MODE) {
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
{
setActiveDisplayPage(0);
}
}
clearScreenRows(kMenuTopRow, kScreenLastRow);
changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0);
}
shouldboot = false;
gui.menu.draw = false;
if (menuItems) {
*argP += cnt;
*argP[0] = ' ';
(*argP)++;
*cntRemainingP -= len;
return true;
int processBootOptions()
{
const char *cp = gBootArgs;
const char *val = 0;
const char *kernel;
int cnt;
int userCnt;
int cntRemaining;
char *argP;
char *configKernelFlags;
char *valueBuffer;
const char*cp = gBootArgs;
const char*val = 0;
const char*kernel;
intcnt;
intuserCnt;
intcntRemaining;
char*argP;
char*configKernelFlags;
char*valueBuffer;
valueBuffer = malloc(VALUE_SIZE);
branches/zenith432/i386/boot2/graphic_utils.c
7878
7979
8080
81
81
82
8283
8384
8485
uint32_t x;
register uint8_t tempB;
for (x = 0; x < (p->height) * (p->width) ; x++) {
for (x = 0; x < (p->height) * (p->width) ; x++)
{
tempB = (p->pixels[x]).ch.b;
(p->pixels[x]).ch.b = (p->pixels[x]).ch.r;
(p->pixels[x]).ch.r = tempB;
branches/zenith432/i386/modules/Resolution/Resolution.c
99
1010
1111
12
13
12
13
1414
15
16
17
15
16
17
1818
1919
void Resolution_start();
void Resolution_start()
{
UInt32 bp = 0;
UInt32 x, y;
UInt32 bp = 0;
UInt32 x, y;
patchVideoBios();
getResolution(&x, &y, &bp);
gui.screen.width = x;
gui.screen.height = y;
getResolution(&x, &y, &bp);
gui.screen.width = x;
gui.screen.height = y;
}
branches/zenith432/i386/modules/Keylayout/layouts/cham-mklayout.c
365365
366366
367367
368
369
370
368
369
370
371371
372372
373373
struct keyboard_layout* new_layout = create_keylayout(in);
if (new_layout) {
write_layout(new_layout, out);
free(new_layout);
new_layout = NULL;
}
free(new_layout);
new_layout = NULL;
}
fclose(out);
fclose(in);
branches/zenith432/i386/modules/Keylayout/Keylayout.c
1313
1414
1515
16
17
18
19
20
21
22
23
24
25
1626
1727
1828
29
1930
2031
2132
......
5061
5162
5263
53
64
65
5466
5567
5668
5769
58
70
71
5972
6073
6174
62
75
76
6377
6478
6579
6680
67
81
82
6883
6984
70
85
7186
72
87
88
7389
7490
7591
7692
77
93
94
7895
79
96
8097
8198
8299
83100
101
84102
85
103
104
86105
87106
107
88108
109
89110
90111
91112
92
113
114
93115
94116
95117
......
97119
98120
99121
100
101
122
123
102124
103
125
126
104127
105128
106129
......
113136
114137
115138
116
139
140
117141
118142
119143
120144
121145
122
123
124
146
147
148
125149
126
150
151
152
127153
128154
129155
#include "Keylayout.h"
#include "bootstruct.h"
#ifndef DEBUG_KLAYOUT
#define DEBUG_KLAYOUT 0
#endif
#if DEBUG_KLAYOUT
#define DBG(x...)printf(x)
#else
#define DBG(x...)
#endif
#define kKeyboardLayout "KeyboardLayout"
struct keyboard_layout *current_layout = NULL;
int getchar_replacement();
int getchar_replacement() {
int code = bgetc();
return (code);
}
static uint32_t load_keyboard_layout_file(const char *filename) {
static uint32_t load_keyboard_layout_file(const char *filename)
{
int fd;
char magic[KEYBOARD_LAYOUTS_MAGIC_SIZE];
uint32_t version;
if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0) {
if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0)
{
goto fail; // fail
}
if (read(fd, magic, sizeof(magic)) != sizeof(magic)) {
if (read(fd, magic, sizeof(magic)) != sizeof(magic))
{
printf("Can't find magic in keyboard layout file: %s\n", filename);
goto fail;
}
if (memcmp (magic, KEYBOARD_LAYOUTS_MAGIC, KEYBOARD_LAYOUTS_MAGIC_SIZE) != 0) {
if (memcmp (magic, KEYBOARD_LAYOUTS_MAGIC, KEYBOARD_LAYOUTS_MAGIC_SIZE) != 0)
{
printf("Invalid magic code in keyboard layout file: %s\n", filename);
goto fail;
}
}
if (read(fd, (char*) &version, sizeof(version)) != sizeof(version)) {
if (read(fd, (char*) &version, sizeof(version)) != sizeof(version))
{
printf("Can't get version of keyboard layout file: %s\n", filename);
goto fail;
}
if (version != KEYBOARD_LAYOUTS_VERSION) {
if (version != KEYBOARD_LAYOUTS_VERSION)
{
verbose("Bad version for keyboard layout file %s expected v%d found v%d\n",
filename, KEYBOARD_LAYOUTS_VERSION, version);
filename, KEYBOARD_LAYOUTS_VERSION, version);
goto fail;
}
if (current_layout)
{
free(current_layout);
}
current_layout = malloc(sizeof(*current_layout));
if (!current_layout)
{
goto fail;
}
b_lseek(fd, KEYBOARD_LAYOUTS_MAP_OFFSET, 0);
if (read(fd, (char*) current_layout, sizeof(*current_layout)) != sizeof(*current_layout)) {
if (read(fd, (char*) current_layout, sizeof(*current_layout)) != sizeof(*current_layout))
{
printf("Wrong keyboard layout file %s size\n", filename);
goto fail;
}
close(fd);
return 1;
fail:
fail:
if (current_layout) {
if (current_layout)
{
free(current_layout);
current_layout = NULL;
}
const char*val;
intlen;
if (getValueForKey("KeyLayout", &val, &len, &bootInfo->chameleonConfig)) {
if (getValueForKey("KeyLayout", &val, &len, &bootInfo->chameleonConfig))
{
sprintf(layoutPath, "/Extra/Keymaps/%s", val);
// Add the extension if needed
if (len <= 4 || strcmp(val+len-4,".lyt") != 0)
strncat(layoutPath, ".lyt", sizeof(layoutPath) - strlen(layoutPath) - 1);
if (!load_keyboard_layout_file(layoutPath)) {
printf("Can't load %s keyboard layout file. Keylayout will not be used !\n",
layoutPath);
if (!load_keyboard_layout_file(layoutPath))
{
DBG("Can't load %s keyboard layout file. Keylayout will not be used !\n", layoutPath);
sleep(2);
} else if (!replace_function("_getchar", &getchar_replacement)) {
}
else if (!replace_function("_getchar", &getchar_replacement))
{
printf("Can't replace function getchar: Keylayout module can't be used !\n");
sleep(2);
}
branches/zenith432/i386/modules/AcpiCodec/acpi_codec.c
10051005
10061006
10071007
1008
1008
10091009
10101010
10111011
10121012
10131013
10141014
1015
1016
1015
1016
1017
10171018
10181019
10191020
10201021
1021
1022
1022
1023
10231024
10241025
10251026
......
10271028
10281029
10291030
1030
1031
10311032
10321033
10331034
1034
1035
1035
1036
10361037
10371038
10381039
10391040
10401041
1041
1042
10421043
10431044
10441045
......
10551056
10561057
10571058
1058
1059
10591060
1060
1061
1062
10611063
10621064
10631065
10641066
1065
1067
10661068
1067
1069
10681070
10691071
10701072
......
10771079
10781080
10791081
1080
1082
10811083
10821084
1083
1085
10841086
10851087
10861088
10871089
1088
1090
10891091
10901092
10911093
10921094
10931095
10941096
1095
1097
10961098
1097
1099
10981100
1099
1101
11001102
11011103
11021104
......
11041106
11051107
11061108
1107
1109
11081110
11091111
11101112
......
11181120
11191121
11201122
1121
1123
11221124
11231125
11241126
......
11311133
11321134
11331135
1134
1136
11351137
11361138
11371139
11381140
11391141
11401142
1141
1143
11421144
11431145
11441146
11451147
1146
1148
11471149
11481150
11491151
1150
11511152
1152
1153
1154
11531155
11541156
11551157
......
11661168
11671169
11681170
1169
1171
11701172
1173
1174
11711175
1172
1173
11741176
11751177
11761178
......
11781180
11791181
11801182
1181
1183
11821184
1183
1185
11841186
11851187
11861188
11871189
11881190
11891191
1190
1192
11911193
11921194
11931195
1194
1196
11951197
11961198
1197
1199
11981200
11991201
1200
1202
12011203
1202
1203
1204
12041205
12051206
12061207
......
13111312
13121313
13131314
1314
13151315
13161316
1317
1318
1319
1320
1321
1322
1317
1318
13231319
1320
1321
1322
1323
13241324
13251325
1326
1326
13271327
13281328
13291329
......
43304330
43314331
43324332
4333
4333
43344334
43354335
43364336
boolean_tfine_grain_clock_mod = 0;
#if BUILD_ACPI_TSS || pstate_power_support
if (Platform.CPU.CPUID[CPUID_0][0] >= 0x5) {
if (Platform.CPU.CPUID[CPUID_0][0] >= 0x5) {
/*
* Extract the Monitor/Mwait Leaf info:
*/
sub_Cstates = Platform.CPU.CPUID[CPUID_5][3];
extensions = Platform.CPU.CPUID[CPUID_5][2];
}
if (Platform.CPU.CPUID[CPUID_0][0] >= 6) {
if (Platform.CPU.CPUID[CPUID_0][0] >= 6)
{
dynamic_acceleration = bitfield(Platform.CPU.CPUID[CPUID_6][0], 1, 1); // "Dynamic Acceleration Technology (Turbo Mode)"
invariant_APIC_timer = bitfield(Platform.CPU.CPUID[CPUID_6][0], 2, 2); // "Invariant APIC Timer"
fine_grain_clock_mod = bitfield(Platform.CPU.CPUID[CPUID_6][0], 4, 4);
}
cpu->turbo_available = (U32)dynamic_acceleration;
cpu->turbo_available = (U32)dynamic_acceleration;
{
U32 temp32 = 0;
U64 temp64= 0;
if (getIntForKey("TDP", &tdp, &bootInfo->chameleonConfig))
{
temp32 = (U32) (tdp*8) ;
int tdc;
if (getIntForKey("TDC", &tdc, &bootInfo->chameleonConfig))
{
temp32 = (U32) (temp32) | tdc<<16 ;
temp32 = (U32) (temp32) | tdc<<16 ;
}
else if (tdp)
{
temp32 = (U32) (temp32) | ((tdp)*8)<<16 ;
}
}
else if (!is_sandybridge() && !is_jaketown())
{
// in your boot.plist
temp32 = (U32)0x02a802f8;
}
}
if (temp32) {
if (temp32)
{
cpu->tdp_limit = ( temp32 & 0x7fff );
cpu->tdc_limit = ( (temp32 >> 16) & 0x7fff );
}
}
#endif
switch (Platform.CPU.Family)
{
case 0x06:
case CPUID_MODEL_PENRYN: // Penryn
case CPUID_MODEL_ATOM: // Intel Atom (45nm)
{
cpu->core_c1_supported = ((sub_Cstates >> 4) & 0xf) ? 1 : 0;
cpu->core_c4_supported = ((sub_Cstates >> 16) & 0xf) ? 1 : 0;
if (Platform.CPU.Model == CPUID_MODEL_ATOM)
{
cpu->core_c2_supported = cpu->core_c3_supported = ((sub_Cstates >> 8) & 0xf) ? 1 : 0;
cpu->core_c6_supported = ((sub_Cstates >> 12) & 0xf) ? 1 : 0;
}
else
{
cpu->core_c3_supported = ((sub_Cstates >> 12) & 0xf) ? 1 : 0;
cpu->core_c2_supported = ((sub_Cstates >> 8) & 0xf) ? 1 : 0;
cpu->core_c6_supported = 0;
}
cpu->core_c7_supported = 0;
#if BETA
GetMaxRatio(&cpu->max_ratio_as_mfg);
U64 msr = rdmsr64(MSR_IA32_PERF_STATUS);
U16 idhi = (msr >> 32) & 0xffff;
cpu->min_ratio = (U32) (idlo >> 8) & 0xff;
cpu->max_ratio_as_cfg = (U32) (idhi >> 8) & 0xff;
#else
if (Platform.CPU.MaxCoef)
{
}
}
#endif
break;
}
case CPUID_MODEL_FIELDS:
case CPUID_MODEL_SANDYBRIDGE:
case CPUID_MODEL_JAKETOWN:
{
cpu->core_c1_supported = ((sub_Cstates >> 4) & 0xf) ? 1 : 0;
cpu->core_c3_supported = ((sub_Cstates >> 8) & 0xf) ? 1 : 0;
cpu->core_c6_supported = ((sub_Cstates >> 12) & 0xf) ? 1 : 0;
cpu->core_c7_supported = ((sub_Cstates >> 16) & 0xf) ? 1 : 0;
cpu->core_c2_supported = 0;
cpu->core_c4_supported = 0;
GetMaxRatio(&cpu->max_ratio_as_mfg);
U64 platform_info = rdmsr64(MSR_PLATFORM_INFO);
cpu->max_ratio_as_cfg = (U32) ((U32)platform_info >> 8) & 0xff;
cpu->min_ratio = (U32) ((platform_info >> 40) & 0xff);
cpu->tdc_tdp_limits_for_turbo_flag = (platform_info & (1ULL << 29)) ? 1 : 0;
cpu->ratio_limits_for_turbo_flag = (platform_info & (1ULL << 28)) ? 1 : 0;
cpu->xe_available = cpu->tdc_tdp_limits_for_turbo_flag | cpu->ratio_limits_for_turbo_flag;
if (is_sandybridge() || is_jaketown())
{
cpu->package_power_limit = rdmsr64(MSR_PKG_RAPL_POWER_LIMIT);
default:
break;
}
cpu->mwait_supported = (extensions & (1UL << 0)) ? 1 : 0;
cpu->invariant_apic_timer_flag = (U32)invariant_APIC_timer;
cpu->invariant_apic_timer_flag = (U32)invariant_APIC_timer;
#if DEBUG_ACPI
printf("CPU INFO : \n");
#if BETA
#endif
printf("max_ratio_as_cfg : %d\n", cpu->max_ratio_as_cfg);
printf("max_ratio_as_mfg : %d\n", cpu->max_ratio_as_mfg);
printf("turbo_available : %d\n",cpu->turbo_available);
printf("core_c1_supported : %d\n",cpu->core_c1_supported);
printf("core_c2_supported : %d\n",cpu->core_c1_supported);
printf("core_c3_supported : %d\n",cpu->core_c3_supported);
printf("core_c6_supported : %d\n",cpu->core_c6_supported);
printf("core_c7_supported : %d\n",cpu->core_c7_supported);
printf("mwait_supported : %d\n",cpu->mwait_supported);
#if BUILD_ACPI_TSS || pstate_power_support
if (is_sandybridge() || is_jaketown())
{
printf("package_power_limit : %d\n",cpu->package_power_limit);
printf("package_power_sku_unit : %d\n",cpu->package_power_sku_unit);
}
#endif
DBG("invariant_apic_timer_flag : %d\n",cpu->invariant_apic_timer_flag);
#endif
}
//-----------------------------------------------------------------------------
static U32 BuildPstateInfo(CPU_DETAILS * cpu)
{
struct p_state p_states[32];
U8 p_states_count = 0;
if (!cpu)
{
return (0);
}
if (!cpu)
{
return (0);
}
{
#if UNUSED
struct p_state initial;
#endif
#endif
struct p_state maximum, minimum;
// Retrieving P-States, ported from code by superhai (c)
switch (Platform.CPU.Family)
{
DropTables_p = XMLCastDict(XMLGetProperty(bootInfo->chameleonConfig.dictionary, (const char*)"ACPIDropTables"));
if (DropTables_p) DropTables_tag_count = XMLTagCount(DropTables_p) ;
}
}
U32 new_table = 0ul;
U8 new_table_index = 0, table_added = 0;
branches/zenith432/i386/modules/Makefile
5757
5858
5959
60
61
62
63
6064
6165
6266
#SUBDIRS += HDAEnabler
#endif
#ifdef CONFIG_GRAPHICSENABLER_MODULE
#SUBDIRS += GraphicsEnabler
#endif
CFLAGS= -O3 $(MORECPP) -arch i386 -g -static
DEFINES=
CONFIG = hd
branches/zenith432/i386/libsa/libsa.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
......
8888
8989
9090
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108108
109109
110110
111111
112112
113
114
113
114
115115
116116
117117
118118
119119
120120
121
122
121
122
123123
124124
125125
126126
127
128
129
127
128
129
130130
131131
132132
133133
134
134
135135
136136
137137
138138
139
140
141
139
140
141
142142
143143
144144
145145
146146
147
148
149
150
147
148
149
150
151151
152152
153153
154154
155
155
156156
157157
158158
* Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
*
* Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
* Reserved. This file contains Original Code and/or Modifications of
* Original Code as defined in and that are subject to the Apple Public
* 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@
*/
#error bzero is defined.
#endif
extern void * memset(void * dst, int c, size_t n);
extern void * memcpy(void * dst, const void * src, size_t len);
extern int memcmp(const void * p1, const void * p2, size_t len);
extern int strcmp(const char * s1, const char * s2);
extern int strncmp(const char * s1, const char * s2, size_t n);
extern char * strcpy(char * s1, const char * s2);
extern char * stpcpy(char * s1, const char * s2);
extern char * strncpy(char * s1, const char * s2, size_t n);
extern char * strpcpy(char * s1, const char * s2, size_t n);
extern size_t strlcpy(char * s1, const char * s2, size_t n);
extern char * strstr(const char *in, const char *str);
extern int atoi(const char * str);
extern int ptol(const char * str);
extern size_t strlen(const char * str);
extern char * strcat(char * s1, const char * s2);
extern char * strncat(char * s1, const char * s2, size_t n);
extern char * strdup(const char *s1);
extern void*memset(void * dst, int c, size_t n);
extern void*memcpy(void * dst, const void * src, size_t len);
extern intmemcmp(const void * p1, const void * p2, size_t len);
extern intstrcmp(const char * s1, const char * s2);
extern intstrncmp(const char * s1, const char * s2, size_t n);
extern char*strcpy(char * s1, const char * s2);
extern char*stpcpy(char * s1, const char * s2);
extern char*strncpy(char * s1, const char * s2, size_t n);
extern char*strpcpy(char * s1, const char * s2, size_t n);
extern size_tstrlcpy(char * s1, const char * s2, size_t n);
extern char*strstr(const char *in, const char *str);
extern intatoi(const char * str);
extern intptol(const char * str);
extern size_tstrlen(const char * str);
extern char*strcat(char * s1, const char * s2);
extern char*strncat(char * s1, const char * s2, size_t n);
extern char*strdup(const char *s1);
#if STRNCASECMP
extern int strncasecmp(const char *s1, const char *s2, size_t n);
#endif
extern char * strchr(const char *str, int c);
extern char * strbreak(const char *str, char **next, long *len);
extern char *strchr(const char *str, int c);
extern char *strbreak(const char *str, char **next, long *len);
extern uint8_t checksum8( void * start, unsigned int length );
/*
* error.c
*/
extern int errno;
extern char * strerror(int errnum);
extern interrno;
extern char*strerror(int errnum);
/*
* strtol.c
*/
extern long strtol(const char * nptr, char ** endptr, int base);
extern unsigned long strtoul(const char * nptr, char ** endptr, int base);
extern unsigned long long strtouq(const char *nptr, char ** endptr, int base);
extern long strtol(const char *nptr, char **endptr, int base);
extern unsigned long strtoul(const char *nptr, char **endptr, int base);
extern unsigned long long strtouq(const char *nptr, char **endptr, int base);
/*
* prf.c
*/
extern void prf(const char * fmt, va_list ap, int (*putfn_p)(), void * putfn_arg);
extern void prf(const char *fmt, va_list ap, int (*putfn_p)(), void *putfn_arg);
/*
* printf.c
*/
extern int sprintf(char *s, const char * format, ...);
extern int snprintf(char *s, size_t size, const char * format, ...);
extern int slvprintf(char * buffer, int len, const char * fmt, va_list arg);
extern int sprintf(char *s, const char *format, ...);
extern int snprintf(char *s, size_t size, const char *format, ...);
extern int slvprintf(char *buffer, int len, const char *fmt, va_list arg);
/*
* zalloc.c
*/
#define malloc(size) safe_malloc(size, __FILE__, __LINE__)
extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t, const char *, int));
extern void * safe_malloc(size_t size,const char *file, int line);
extern void free(void * start);
extern void * realloc(void * ptr, size_t size);
extern voidmalloc_init(char *start, int size, int nodes, void (*malloc_error)(char *, size_t, const char *, int));
extern void*safe_malloc(size_t size,const char *file, int line);
extern voidfree(void *start);
extern void*realloc(void *ptr, size_t size);
/*
* getsegbyname.c
*/
extern struct segment_command * getsegbynamefromheader(struct mach_header * mhp, char * segname);
extern struct segment_command *getsegbynamefromheader(struct mach_header *mhp, char *segname);
/*
* interrupts.c
branches/zenith432/i386/libsa/string.c
2525
2626
2727
28
28
2929
30
31
32
33
30
31
32
33
3434
35
35
3636
3737
3838
3939
4040
41
42
43
44
41
42
43
44
4545
46
46
4747
4848
4949
......
5353
5454
5555
56
56
5757
5858
5959
6060
6161
62
63
64
65
66
67
68
69
70
71
62
63
64
65
66
67
68
69
70
71
7272
73
73
7474
7575
7676
7777
78
79
80
81
82
83
84
85
86
87
78
79
80
81
82
83
84
85
86
87
8888
8989
9090
9191
92
93
94
95
96
97
98
99
100
101
102
92
93
94
95
96
97
98
99
100
101
102
103103
104104
105105
......
157157
158158
159159
160
161
160
162161
163162
164163
......
166165
167166
168167
169
170
168
171169
172170
173171
......
176174
177175
178176
179
180
177
181178
182179
183180
......
189186
190187
191188
192
193
189
194190
195191
196192
......
201197
202198
203199
204
205
200
206201
207202
208203
......
225220
226221
227222
228
229
223
230224
231225
232226
......
238232
239233
240234
241
242
235
243236
244237
245238
......
287280
288281
289282
290
283
291284
292285
293286
......
297290
298291
299292
300
301
302
293
294
295
303296
304297
305298
......
337330
338331
339332
340
333
341334
342335
343336
344337
345338
346
339
340
347341
348342
349343
#include "libsa.h"
void * memset(void * dst, int val, size_t len)
void *memset(void * dst, int val, size_t len)
{
asm volatile ( "rep; stosb"
: "=c" (len), "=D" (dst)
: "0" (len), "1" (dst), "a" (val)
: "memory" );
asm volatile ( "rep; stosb"
: "=c" (len), "=D" (dst)
: "0" (len), "1" (dst), "a" (val)
: "memory" );
return dst;
return dst;
}
#if 0
void * memcpy(void * dst, const void * src, size_t len)
{
asm volatile ( "rep; movsb"
: "=c" (len), "=D" (dst), "=S" (src)
: "0" (len), "1" (dst), "2" (src)
: "memory" );
asm volatile ( "rep; movsb"
: "=c" (len), "=D" (dst), "=S" (src)
: "0" (len), "1" (dst), "2" (src)
: "memory" );
return dst;
return dst;
}
void bcopy(const void * src, void * dst, size_t len)
void bzero(void * dst, size_t len)
{
memset(dst, 0, len);
memset(dst, 0, len);
}
#else
void * memcpy(void * dst, const void * src, size_t len)
{
asm volatile ( "cld \n\t"
"movl %%ecx, %%edx \n\t"
"shrl $2, %%ecx \n\t"
"rep; movsl \n\t"
"movl %%edx, %%ecx \n\t"
"andl $3, %%ecx \n\t"
"rep; movsb \n\t"
: "=D" (dst)
: "c" (len), "D" (dst), "S" (src)
: "memory", "%edx" );
asm volatile ( "cld \n\t"
"movl %%ecx, %%edx \n\t"
"shrl $2, %%ecx \n\t"
"rep; movsl \n\t"
"movl %%edx, %%ecx \n\t"
"andl $3, %%ecx \n\t"
"rep; movsb \n\t"
: "=D" (dst)
: "c" (len), "D" (dst), "S" (src)
: "memory", "%edx" );
return dst;
return dst;
}
void bcopy(const void * src, void * dst, size_t len)
{
asm volatile ( "cld \n\t"
"movl %%ecx, %%edx \n\t"
"shrl $2, %%ecx \n\t"
"rep; movsl \n\t"
"movl %%edx, %%ecx \n\t"
"andl $3, %%ecx \n\t"
"rep; movsb \n\t"
:
: "c" (len), "D" (dst), "S" (src)
: "memory", "%edx" );
asm volatile ( "cld \n\t"
"movl %%ecx, %%edx \n\t"
"shrl $2, %%ecx \n\t"
"rep; movsl \n\t"
"movl %%edx, %%ecx \n\t"
"andl $3, %%ecx \n\t"
"rep; movsb \n\t"
:
: "c" (len), "D" (dst), "S" (src)
: "memory", "%edx" );
}
void bzero(void * dst, size_t len)
{
asm volatile ( "xorl %%eax, %%eax \n\t"
"cld \n\t"
"movl %%ecx, %%edx \n\t"
"shrl $2, %%ecx \n\t"
"rep; stosl \n\t"
"movl %%edx, %%ecx \n\t"
"andl $3, %%ecx \n\t"
"rep; stosb \n\t"
:
: "c" (len), "D" (dst)
: "memory", "%eax" );
asm volatile ( "xorl %%eax, %%eax \n\t"
"cld \n\t"
"movl %%ecx, %%edx \n\t"
"shrl $2, %%ecx \n\t"
"rep; stosl \n\t"
"movl %%edx, %%ecx \n\t"
"andl $3, %%ecx \n\t"
"rep; stosb \n\t"
:
: "c" (len), "D" (dst)
: "memory", "%eax" );
}
#endif
return 0;
}
char *
strcpy(char * s1, const char * s2)
char *strcpy(char *s1, const char *s2)
{
register char *ret = s1;
while ((*s1++ = *s2++))
return ret;
}
char *
stpcpy(char * s1, const char * s2)
char *stpcpy(char *s1, const char *s2)
{
while ((*s1++ = *s2++))
{
return --s1;
}
char *
strncpy(char * s1, const char * s2, size_t n)
char *strncpy(char *s1, const char *s2, size_t n)
{
register char *ret = s1;
while (n && (*s1++ = *s2++))
return ret;
}
char *
stpncpy(char * s1, const char * s2, size_t n)
char *stpncpy(char *s1, const char *s2, size_t n)
{
while (n && (*s1++ = *s2++))
--n;
return s1;
}
char *
strstr(const char *in, const char *str)
char *strstr(const char *in, const char *str)
{
char c;
size_t len;
return (char *) (in - 1);
}
int
ptol(const char *str)
int ptol(const char *str)
{
register int c = *str;
return c;
}
int
atoi(const char *str)
int atoi(const char *str)
{
register int sum = 0;
while (*str == ' ' || *str == '\t')
}
#endif
char* strchr(const char *str, int c)
char *strchr(const char *str, int c)
{
do
{
while(*(str++));
return 0;
}
char* strbreak(const char *str, char **next, long *len)
}
char *strbreak(const char *str, char **next, long *len)
{
char *start = (char*)str, *end;
bool quoted = false;
}
/* COPYRIGHT NOTICE: checksum8 from AppleSMBIOS */
uint8_t checksum8( void * start, unsigned int length )
uint8_t checksum8( void *start, unsigned int length )
{
uint8_t csum = 0;
uint8_t * cp = (uint8_t *) start;
unsigned int i;
for ( i = 0; i < length; i++) {
for ( i = 0; i < length; i++)
{
csum += *cp++;
}
return csum;
branches/zenith432/i386/util/dyldsymboltool.c
135135
136136
137137
138
139
140
138
139
140
141141
142142
143143
dylib.dylib_info.cmd = LC_ID_DYLIB;
dylib.dylib_info.cmdsize = sizeof(struct dylib_command) + sizeof(dylib.module_name);// todo: verify
dylib.dylib_info.dylib.name.offset = sizeof(struct dylib_command);
dylib.dylib_info.dylib.timestamp = 0;// TODO: populate with time
dylib.dylib_info.dylib.current_version = 0;// TODO
dylib.dylib_info.dylib.compatibility_version = 0;// TODO
dylib.dylib_info.dylib.timestamp = 0;// TODO: populate with time
dylib.dylib_info.dylib.current_version = 0;// TODO
dylib.dylib_info.dylib.compatibility_version = 0;// TODO
//int offset = dylib.dylib_info.cmdsize%4 ? 4 - (dylib.dylib_info.cmdsize % 4) : 0;
branches/zenith432/i386/util/segsize.c
103103
104104
105105
106
106
107107
108108
109109
// boolisDATA;
// unsignedvmsize;
#define lcp((struct load_command *)cp)
#define lcp((struct load_command *)cp)
switch(swap(lcp->cmd)) {
case LC_SEGMENT:
branches/zenith432/package/Scripts.templates/AddOption/postinstall
33
44
55
6
7
8
6
7
8
99
1010
1111
......
3333
3434
3535
36
36
3737
3838
39
39
4040
4141
4242
......
4949
5050
5151
52
52
5353
5454
5555
5656
57
57
5858
5959
6060
set -u
configFile='/private/tmp/InstallConfig.plist'
v_mntptDev=$( /usr/libexec/plistbuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \
| sed -e 's/^[ \t]*//' )
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//' )
key="@optionKey@"
value="@optionValue@"
case "$type" in
bool|text)
/usr/libexec/plistbuddy -c "Add :${key} string ${value}" "$bootPListFile"
/usr/libexec/PlistBuddy -c "Add :${key} string ${value}" "$bootPListFile"
;;
list)
current_values=$( /usr/libexec/plistbuddy -c "Print :${key}" \
current_values=$( /usr/libexec/PlistBuddy -c "Print :${key}" \
"$bootPListFile" 2>/dev/null )
result=$?
current_values="${current_values// /\\ }" # Escape spaces
else
new_values="${current_values}\ ${value}"
fi
/usr/libexec/plistbuddy -c "Set :${key} ${new_values}" \
/usr/libexec/PlistBuddy -c "Set :${key} ${new_values}" \
"$bootPListFile"
else
# Create a new option
new_values="${value}"
/usr/libexec/plistbuddy -c "Add :${key} string ${new_values}" \
/usr/libexec/PlistBuddy -c "Add :${key} string ${new_values}" \
"$bootPListFile"
fi
;;
branches/zenith432/package/Scripts.templates/Post/postinstall
55
66
77
8
89
910
1011
......
1920
2021
2122
22
23
23
24
2425
2526
26
27
27
28
2829
2930
3031
3132
32
33
33
34
3435
3536
36
37
37
38
39
40
41
3842
3943
44
4045
41
46
4247
4348
4449
45
46
47
48
4950
5051
5152
......
5556
5657
5758
58
59
60
61
6259
6360
6461
......
7976
8077
8178
79
80
81
82
83
8284
8385
8486
# $3 = Installation volume (mountpoint) to receive the payload
# $4 = Root directory for the system
logName="@LOG_FILENAME@"
mainLine="=============================================================================="
subLine="------------------------------------------------------------------------------"
configFile='/private/tmp/InstallConfig.plist'
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \
| sed -e 's/^[ \t]*//' )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//')
targetDevice=$( /usr/libexec/PlistBuddy -c "Print :targetdev" ${configFile} )
choicedVolume=$( LC_ALL=C diskutil info ${targetDevice} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \
| sed -e 's/^[ \t]*//' )
choicedVolume=$( LC_ALL=C diskutil info ${targetDevice} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//' )
backupRootDir="${targetVolume}/Chameleon.Backups"
backupDir=$( /usr/libexec/PlistBuddy -c "Print :backupDir" ${configFile} )
# Check target exists
if [ ! -d "${targetVolume}" ]; then
echo "Target volume does not exist !" >&2
if [ ! -d "${v_mntpt}" ]; then
echo "Ram disk volume does not exist !"
exit 1
fi
if [ ! -d "${v_mntpt}" ]; then
echo "Ram disk volume does not exist !" >&2
exec > >(tee -a "${v_mntpt}/${logName}") 2>&1
if [ ! -d "${targetVolume}" ]; then
echo "Target volume does not exist !"
exit 1
fi
if [ ! -d "${choicedVolume}" ]; then
echo "${choicedVolume} volume does not exist !" >&2
echo "${choicedVolume} volume does not exist !"
exit 1
fi
logName="@LOG_FILENAME@"
exec > >(tee -a "${v_mntpt}/${logName}") 2>&1
echo "$mainLine"
echo "Running Post postinstall script"
echo "Target volume = ${choicedVolume}"
echo "Moving Extra folder to ${choicedVolume}"
cp -R "${v_mntpt}/Extra" "${choicedVolume}"/
echo "NOTE: any Themes or modules you have must be there since this now is the boot partition,"
echo " ACPI tables, SMBios.plist and the org.chameleon.Boot.plist (with custom settings"
echo " for the target OSX must be in each partition that contanin it.)"
echo "$subLine"
echo "Post postinstall script complete"
echo "$mainLine"
# copying the installer log inside the Extra folder
if [[ $( /usr/libexec/PlistBuddy -c "Print bootloader" ${configFile} ) == "true" ]];then
# if we have installed the bootloader, this is a new log
echo "NOTE: any Themes or modules you have must be there since this now"
echo " is the boot partition. ACPI tables, SMBios.plist and the"
echo " org.chameleon.Boot.plist (with custom settings for the target"
echo " OSX must be in each partition that contain it.)"
echo "$mainLine"
cat "${v_mntpt}/${logName}" > "${choicedVolume}/Extra/${logName}"
else
# ..otherwise adding the new log to the existing one (if exist)
branches/zenith432/package/Scripts.templates/Pre/preinstall
2929
3030
3131
32
33
32
33
3434
3535
3636
......
4545
4646
4747
48
4849
4950
5051
......
5354
5455
5556
56
57
57
58
5859
5960
6061
......
6465
6566
6667
68
69
70
6771
6872
6973
}
RAM_DISK() {
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \
grep -x "${v_mntpt}" ) ]; then
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//' | grep -x "${v_mntpt}" ) ]; then
devToUmount=$( LC_ALL=C diskutil info "${v_mntpt}" | grep -i 'Device Node:' | awk '{print $3}' )
UMOUNT_VDISK $devToUmount
fi
exit 1
fi
dev=$( echo "${dev}" | tr -d " \t\n" )
rm -f $configFile
# adding the Ram disk device to InstallConfig.plist to be shared with other packages
/usr/libexec/PlistBuddy -c "Add :ramdisk string ${dev}" $configFile
RAM_DISK
# ensure that ram disk has "/Volumes/BOOTRAMDISK" mount point
v_mntpt=$( LC_ALL=C diskutil info ${dev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \
| sed -e 's/^[ \t]*//' )
v_mntpt=$( LC_ALL=C diskutil info ${dev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//' )
if [ ! -d "${v_mntpt}" ]; then
echo "Ram Disk not found!"
exit
exec > >(tee -a "${v_mntpt}/${logName}") 2>&1
echo "$mainLine"
echo "SYSTEM INFO:"
sw_vers
echo "$mainLine"
echo "Pre-Install Script"
echo "$subLine"
branches/zenith432/package/Scripts.templates/InstallTheme/postinstall
33
44
55
6
7
8
9
6
7
8
109
1110
1211
set -u
configFile='/private/tmp/InstallConfig.plist'
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \
| sed -e 's/^[ \t]*//' )
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//' )
themeName="@themeName@"
themeDir="@themeDir@"
logName="@LOG_FILENAME@"
branches/zenith432/package/Scripts.templates/InstallModule/postinstall
33
44
55
6
7
8
6
7
8
99
1010
1111
set -u
configFile='/private/tmp/InstallConfig.plist'
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \
| sed -e 's/^[ \t]*//' )
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//' )
moduleName="@moduleName@"
moduleFile="@moduleFile@"
branches/zenith432/package/Scripts/Main/ESPpostinstall
11
22
33
4
4
55
66
77
88
99
10
11
12
1013
1114
15
1216
1317
1418
......
2327
2428
2529
26
27
28
30
31
32
2933
3034
3135
3236
3337
34
35
3638
3739
3840
3941
4042
4143
42
4344
4445
4546
4647
4748
49
4850
4951
5052
......
5254
5355
5456
55
57
5658
57
59
5860
5961
6062
......
6971
7072
7173
72
74
7375
74
75
76
7677
7778
7879
......
8384
8485
8586
87
8688
8789
8890
......
9395
9496
9597
96
97
98
99
98100
99101
100102
......
102104
103105
104106
105
107
106108
107109
108110
......
116118
117119
118120
119
120
121
121
122
123
122124
123125
124126
......
128130
129131
130132
131
133
132134
133135
134136
......
144146
145147
146148
147
149
148150
149151
150
152
153
151154
152155
153
156
157
154158
155159
156160
......
159163
160164
161165
162
163
166
167
168
164169
165
170
166171
167172
168173
......
172177
173178
174179
175
176
177
178
179
180
181
182
183
184
185
180
181
182
183
184
185
186
187
188
189
190
191
186192
187193
188194
......
192198
193199
194200
201
202
203
195204
196
197
205
206
198207
199
200
201208
202209
203210
204211
205
206212
207213
208214
......
214220
215221
216222
217
218
219
220
221
222
223
224
225
226
227
228
229
230223
231224
232225
233226
234
235227
236
237
228
229
238230
239
240
241
242
243
244
245
246
247
231
248232
249
250
251
233
234
235
252236
253237
254
255
256
257
258
259
260
261
262
263
264
265
266238
267239
268240
......
275247
276248
277249
278
279
250
251
252
280253
281
282
283
284
285
286
254
255
256
257
258
259
260
261
262
263
264
265
287266
288267
289268
......
298277
299278
300279
301
280
302281
303282
304283
......
332311
333312
334313
335
314
336315
337316
338317
......
355334
356335
357336
358
337
359338
360339
361340
......
364343
365344
366345
346
367347
368348
369349
......
372352
373353
374354
375
376
377
378
379
380355
381356
382357
......
385360
386361
387362
363
388364
389365
390366
391
392
367
368
393369
394370
395371
396
397
372
373
398374
399375
400376
401
402
403
377
378
404379
405380
406381
......
408383
409384
410385
386
387
388
389
390
391
392
393
411394
412395
413396
414397
415
398
416399
417400
418401
#!/bin/bash
# --------------------------------------------------------------------------------------------------------
# Install.sh v1.3, script to install Chameleon
# Install.sh v1.5, script to install Chameleon
# Created by Miky1979 on December 8th, 2014
# --------------------------------------------------------------------------------------------------------
targetVolume="${3}"
InstallToESP="1"
InstallBootloader="0"
espmtp="/Volumes/ESP"
WINDOWS_EXIST="0"
opt="u"
configFile="/private/tmp/InstallConfig.plist"
if [ "${InstallToESP}" == "1" ]; then TYPE="ESP"; else TYPE="Standard"; fi
if [[ $( /usr/libexec/PlistBuddy -c "Print bootloader" ${configFile} ) == "true" ]];then
# installing stage 0, 1 and 2 only if user want this:
# ie only if have no selected noboot choice
choicedVolume="${targetVolume}"
ESP_MOUNTED="0"
# --------------------------------------------------------------------------------------------------------
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \
| sed -e 's/^[ \t]*//')
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//' )
backupRootDir="${targetVolume}/Chameleon.Backups"
backupDir=$( /usr/libexec/PlistBuddy -c "Print :backupDir" ${configFile} )
logName="Chameleon_Installer_Log.txt"
logFile="${v_mntpt}/${logName}"
# --------------------------------------------------------------------------------------------------------
stage0Loader="boot0"
stage0LoaderDualBoot="boot0md"
stage1LoaderHFS="boot1h"
stage1LoaderFAT="boot1f32"
stage1LoaderExFAT="boot1x"
stage2Loader="boot"
versionToInstall=$(cat "${i386Dir}/Boot" | grep -a 'Darwin/x86 boot v' )
# --------------------------------------------------------------------------------------------------------
localdd="/bin/dd"
SS="${usrLocalBin}/sectorsize"
# --------------------------------------------------------------------------------------------------------
# Scanning all Variables. We are switching to the target Volume or its ESP.
# This function is usefull to rescan the new target "at need"
SCAN() {
bootDevice=$( LC_ALL=C diskutil info / | grep -i 'Device Node:' | awk '{print $NF}' )
targetDevice=$( LC_ALL=C diskutil info "${choicedVolume}" | grep -i 'Device Node:' | awk '{print $NF}' )
targetDeviceRaw=${targetDevice/disk/rdisk}
targetDisk=${targetDevice%s*}
targetSlice=${targetDevice#*disk*s}
IOContent=$( LC_ALL=C diskutil info "${targetDisk}" | grep -i 'Content (IOContent)' | awk '{print $NF}' )
FS=$( LC_ALL=C diskutil info ${targetDevice} | grep -i 'Type (Bundle)' | \
awk '{print $NF}' | awk '{print tolower($0)}' )
awk '{print $NF}' | awk '{print tolower($0)}' )
disksignature=$( dd 2>/dev/null if="${targetDisk}" count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | \
perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $InstallBootloader = "1" ];then
blocksize=$( "${SS}" "${targetDeviceRaw}" | awk '{ print $2 }' )
# Create a folder inside the Desktop called "DebugChameleon", and the log will be full
DEBUG() {
echo "$mainLine"
echo "DEBUG: display script variables (ESPpostinstall)"
echo "DEBUG: display script variables (${TYPE}postinstall)"
echo "$mainLine"
echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader} (or boot0hfs)"
echo "DEBUG: stage0LoaderDualBoot: Disk loader is ${stage0LoaderDualBoot} (or boot0hfs)"
echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader}"
echo "DEBUG: stage1LoaderHFS: Partition loader is ${stage1LoaderHFS}"
echo "DEBUG: stage1LoaderFat: Partition loader is ${stage1LoaderFAT}"
echo "DEBUG: stage1LoaderExFAT: Partition loader is ${stage1LoaderExFAT}"
echo "DEBUG: targetDisk: Disk device is ${targetDisk}"
echo "DEBUG: targetDiskRaw: Disk raw device is ${targetDiskRaw}"
echo "DEBUG: targetSlice: Volume slice is ${targetSlice}"
echo "DEBUG: bootDevice: Current Volume device is ${bootDevice}"
echo "DEBUG: versionToInstall: version to install is ${versionToInstall}"
echo "DEBUG: IOContent: partition scheme is ${IOContent}"
echo "DEBUG: FS: file System is ${FS}"
# --------------------------------------------------------------------------------------------------------
# Checking for unsupported FAT16 filesystem
CHECK_FAT16() {
pers=$( LC_ALL=C diskutil info "${targetDeviceRaw}" | grep -i 'File System Personality' \
| awk '{print $NF}' | awk '{print tolower($0)}' )
pers=$( LC_ALL=C diskutil info "${targetDeviceRaw}" | grep -i 'File System Personality' | \
awk '{print $NF}' | awk '{print tolower($0)}' )
case $pers in
fat16)
exit 1
;;
*)
echo "First Check Passed!"
echo "First Check Passed (not Fat16)!"
;;
esac
}
CHECK_ESP_MOUNTPOINT() {
# umount the ESP by its Mount Point
# and checking it if is busy by another ESP
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \
grep -x '/Volumes/ESP' ) ]; then
umount -f /Volumes/ESP
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^ *//' | sed -e 's/ *$//' | \
grep -x "${espmtp}" ) ]; then
umount -f ${espmtp}
ESP_MOUNTED="0"
fi
}
if [ $( df | grep "${espDisk}" | awk '{print $1}' | grep -x "${espDisk}" ) ];then
# ESP is already mounted, so now we aquire the Mount Point
espmtp=$( LC_ALL=C diskutil info ${espDisk} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^[ \t]*//' )
sed -e 's/^ *//' | sed -e 's/ *$//' )
if [ -d "${espmtp}" ];then
echo "ESP Mount Point is:${espmtp}, using that as target Volume!"
choicedVolume="${espmtp}"
fi
if [ $ESP_MOUNTED = "0" ];then
mkdir -p /Volumes/ESP
mkdir -p "${espmtp}"
case $( fstyp $espDisk ) in
hfs)
mount -t hfs $espDisk /Volumes/ESP
echo "Mounting $espDisk on $espmtp as hfs Volume.."
mount -t hfs $espDisk "${espmtp}"
;;
msdos)
mount -t msdos $espDisk /Volumes/ESP
echo "Mounting $espDisk on $espmtp as msdos Volume.."
mount -t msdos $espDisk "${espmtp}"
;;
*)
echo "ESP fileSystem unsupported, Installing to ${targetVolume}!"
esac
sleep 0.3
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \
grep -x '/Volumes/ESP' ) ]; then
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^ *//' | sed -e 's/ *$//' | \
grep -x "${espmtp}" ) ]; then
echo "EFI System Partition mounted!"
ESP_MOUNTED="1"
choicedVolume="/Volumes/ESP"
choicedVolume="${espmtp}"
SCAN
else
echo "ESP can't be mounted, Installing to ${targetVolume}!"
}
# --------------------------------------------------------------------------------------------------------
PARTITION_ACTIVE_IF() {
echo -e "${mainLine}\nSET PARTITION ACTIVE:"
# if Windows was detected, don't activate the partition..
# if the stage 0 loader is boo0hfs, don't activate the partition
if [ WINDOWS_EXIST = "0" ] || [ "${stage0Loader}" != "boot0hfs" ];then
partitionactive=$( fdisk -d ${targetDiskRaw} | grep -n "*" | awk -F: '{print $1}')
if [ "${partitionactive}" ] && [ "${partitionactive}" = "${targetSlice}" ]; then
echo "${targetDiskRaw#/dev/r}, slice "${targetSlice}" is already set active. No need to change it."
else
echo "Setting ${choicedVolume} partition active."
# BadAxe requires EFI partition to be flagged active.
# but it doesn't' hurt to do it for any non-windows partition.
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nSET PARTITION ACTIVE:"
# if Windows was detected, don't activate the partition..
# if the stage 0 loader is boo0hfs, don't activate the partition
if [ WINDOWS_EXIST = "0" ] || [ "${stage0Loader}" != "boot0hfs" ];then
partitionactive=$( fdisk -d ${targetDiskRaw} | grep -n "*" | awk -F: '{print $1}')
if [ "${partitionactive}" ] && [ "${partitionactive}" = "${targetSlice}" ]; then
echo "${targetDiskRaw#/dev/r}, slice "${targetSlice}" is already set active. No need to change it."
else
echo "Setting ${choicedVolume} partition active."
# BadAxe requires EFI partition to be flagged active.
# but it doesn't' hurt to do it for any non-windows partition.
# leave left aligned the follow code:
fdisk -e ${targetDiskRaw} <<-MAKEACTIVE
y
quit
MAKEACTIVE
fi
else
echo "Partition will not activate when Windows is detected or stage 0 is boot0hfs"
fi
else
echo "Partition will not activate when Windows is detected or stage 0 is boot0hfs"
echo ""
echo "$mainLine"
fi
echo ""
echo "$mainLine"
}
# --------------------------------------------------------------------------------------------------------
# Writing stage 0
CHECK_WINDOWS() {
WINDOWS_EXIST="0"
if [ "${disksignature}" = "00000000" ]; then
echo "Windows installation not found on ${targetDisk}."
else
WRITE_STAGE0() {
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nWRITING STAGE 0:"
CHECK_WINDOWS
case "$1" in
hfs)
if [ WINDOWS_EXIST = "1" ];then stage0Loader="boo0hfs"; else stage0Loader="boot0"; fi
;;
msdos)
if [ WINDOWS_EXIST = "1" ];then stage0Loader="boo0md"; else stage0Loader="boot0";fi
;;
exfat)
stage0Loader="boot0"
;;
esac
"${usrLocalBin}/fdisk440" -u -f "${i386Dir}/${stage0Loader}" -y ${targetDisk}
echo "${stage0Loader} writed to ${targetDisk}"
fi
}
# --------------------------------------------------------------------------------------------------------
# Writing stage 1 on different filesystems
WRITE_STAGE1_HFS() {
# Writing stage 1
WRITE_STAGE1() {
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nWRITING STAGE 1 HFS:"
$localdd if="${i386Dir}/${stage1LoaderHFS}" of=${targetDeviceRaw}
echo "${stage1LoaderHFS} (hfs) writed to ${targetDeviceRaw}."
fi
}
WRITE_STAGE1_EXFAT() {
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nWRITING STAGE 1 ExFAT:"
echo -e "${mainLine}\nWRITING STAGE 1 ${2}:"
cp -R "${usrLocalBin}/boot1-install" "${v_mntpt}"/
cp -R "${i386Dir}/${stage1LoaderExFAT}" "${v_mntpt}"/
"${v_mntpt}/boot1-install" -y -u -f "${v_mntpt}/${stage1LoaderExFAT}" ${targetDeviceRaw}
echo "${stage1LoaderExFAT} (ExFAT) writed to ${targetDeviceRaw}."
cp -R "${i386Dir}/${1}" "${v_mntpt}"/
"${v_mntpt}/boot1-install" -y "-${3}" -f "${v_mntpt}/${1}" ${targetDeviceRaw}
echo "${stage1Loader} (${2}) writed to ${targetDeviceRaw}."
fi
}
WRITE_STAGE1_FAT32() {
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nWRITING STAGE 1 FAT32:"
$localdd if=${targetDeviceRaw} count=1 bs=512 of="${v_mntpt}/origbs"
cp "${i386Dir}/${stage1LoaderFAT}" "${v_mntpt}/newbs"
$localdd if="${v_mntpt}/origbs" of="${v_mntpt}/newbs" skip=3 seek=3 bs=1 count=87 conv=notrunc
$localdd if="${v_mntpt}/newbs" of="${targetDeviceRaw}" count=1 bs=512
echo "${stage1LoaderFAT} (Fat32) writed to ${targetDeviceRaw}."
fi
}
# --------------------------------------------------------------------------------------------------------
# Writing stage 2
WRITE_STAGE2() {
}
# --------------------------------------------------------------------------------------------------------
# Waiting for targhet Volume was re-mounted before proceeding..
# Note: the target Volume is umonted by boot1-install that also take the step to remount it (only waiting..)
WAIT_REMOUNT() {
# Note: the target Volume is umonted by boot1-install that also take the step to remount it (only waiting..).
# exception is the EFI partition: in Mavericks autoremount...in Yosemite not..
REMOUNT() {
if [ $InstallBootloader = "1" ];then
if [ ! -d "${choicedVolume}" ]; then
echo -e "${mainLine}\nWAITING TO RE-MOUNT ${choicedVolume}:"
until [ -d "${choicedVolume}" ]; do
sleep 0.3
done
echo "${choicedVolume} is mounted!"
if [ "${InstallToESP}" == "1" ]; then
if [ ! -d "${choicedVolume}" ]; then
MOUNT_ESP
fi
else
if [ ! -d "${choicedVolume}" ]; then
echo -e "${mainLine}\nWAITING TO RE-MOUNT ${choicedVolume}:"
until [ -d "${choicedVolume}" ]; do
sleep 0.3
done
echo "${choicedVolume} is mounted!"
fi
fi
fi
}
else
echo "Extra folder already exist on ${choicedVolume}, copying to the Ram Disk.."
cp -R "${choicedVolume}/Extra" "${v_mntpt}"/
./clean_bootplist.pl "${v_mntpt}" >/dev/null
./clean_bootplist.pl "${v_mntpt}"
fi
}
# --------------------------------------------------------------------------------------------------------
exec > >(tee -a "${logFile}") 2>&1
echo "$mainLine"
echo "Main ESP Post-Install Script"
echo "Main ${TYPE} Post-Install Script"
echo "Chameleon installer log - $( date )"
if [ $InstallBootloader = "1" ];then echo "$versionToInstall"; else echo "no boot session"; fi
echo ""
echo "GPT partition Scheme detected.."
espDisk="${targetDisk}s1"
if [ $( LC_ALL=C diskutil info ${espDisk} | grep -i 'Partition Type:' | \
awk '{print $NF}' ) = "EFI" ]; then
awk '{print $NF}' | sed -e 's/^ *//' | sed -e 's/ *$//' ) = "EFI" ]; then
echo "EFI partition found is ${espDisk}, try to mount it.."
MOUNT_ESP
else
fi
;;
*)
InstallToESP = "0"
echo "Can't install on the ESP, because does not exist.."
echo "..continue installing to ${targetVolume}"
;;
SCAN
fi
if [ -d "${HOME}/Desktop/DebugChameleon" ]; then
DEBUG
fi
# adding the chosen Volume dev id to the InstallConfig.plist
/usr/libexec/PlistBuddy -c "Add :targetdev string ${targetDevice}" $configFile
echo "${mainLine}"
CHECK_FAT16
CHECK_WINDOWS
case "$FS" in
hfs)
echo "${targetDevice} is HFS formatted"
WRITE_STAGE0 hfs
WRITE_STAGE1_HFS
if [ $WINDOWS_EXIST = "1" ];then stage0Loader="boot0hfs"; else stage0Loader="boot0"; fi
stage1Loader="${stage1LoaderHFS}"
;;
msdos)
echo "${targetDevice} is FAT32 formatted"
WRITE_STAGE0 msdos
WRITE_STAGE1_FAT32
if [ $WINDOWS_EXIST = "1" ];then stage0Loader="boot0md"; else stage0Loader="boot0"; fi
stage1Loader="${stage1LoaderFAT}"
;;
exfat)
echo "${targetDevice} is ExFAT formatted"
WRITE_STAGE0 exfat
WRITE_STAGE1_EXFAT
WAIT_REMOUNT
stage0Loader="boot0"
stage1Loader="${stage1LoaderExFAT}"
;;
*)
echo "FileSystem unsupported, aborting!"
;;
esac
# Debug mode: create a "DebugChameleon" folder on your Desktop to debug this script
if [ -d "${HOME}/Desktop/DebugChameleon" ]; then DEBUG; fi
# if the target device is equal to the boot device keep the Volume mounted using boot1-install
if [ "${bootDevice}" = "${targetDevice}" ]; then opt="M"; fi
WRITE_STAGE0 "${stage0Loader}"
WRITE_STAGE1 "${stage1Loader}" "${FS}" "${opt}"
if [ "${bootDevice}" != "${targetDevice}" ]; then REMOUNT; fi
WRITE_STAGE2
PARTITION_ACTIVE_IF
echo "$mainLine"
echo "END - ESP Post-Install Script"
echo "END - ${TYPE} Post-Install Script"
# --------------------------------------------------------------------------------------------------------
exit 0
branches/zenith432/package/Scripts/Main/Standardpostinstall
11
22
33
4
4
55
66
77
88
99
10
11
12
1013
1114
15
1216
1317
1418
......
2327
2428
2529
26
27
28
30
31
32
2933
3034
3135
3236
3337
34
35
3638
3739
3840
3941
4042
4143
42
4344
4445
4546
4647
4748
49
4850
4951
5052
......
5254
5355
5456
55
57
5658
57
59
5860
5961
6062
......
6971
7072
7173
72
74
7375
74
75
76
7677
7778
7879
......
8384
8485
8586
87
8688
8789
8890
......
9395
9496
9597
96
97
98
99
98100
99101
100102
......
102104
103105
104106
105
107
106108
107109
108110
......
116118
117119
118120
119
120
121
121
122
123
122124
123125
124126
......
128130
129131
130132
131
133
132134
133135
134136
......
144146
145147
146148
147
149
148150
149151
150
152
153
151154
152155
153
156
157
154158
155159
156160
......
159163
160164
161165
162
163
166
167
168
164169
165
170
166171
167172
168173
......
172177
173178
174179
175
176
177
178
179
180
181
182
183
184
185
180
181
182
183
184
185
186
187
188
189
190
191
186192
187193
188194
......
192198
193199
194200
201
202
203
195204
196
197
205
206
198207
199
200
201208
202209
203210
204211
205
206212
207213
208214
......
214220
215221
216222
217
218
219
220
221
222
223
224
225
226
227
228
229
230223
231224
232225
233226
234227
235
236
228
229
237230
238
239
240
241
242
243
244
245
246
231
247232
248
249
250
233
234
235
251236
252237
253
254
255
256
257
258
259
260
261
262
263
264
265238
266239
267240
......
274247
275248
276249
277
278
250
251
252
279253
280
281
282
283
284
285
254
255
256
257
258
259
260
261
262
263
264
265
286266
287267
288268
......
297277
298278
299279
300
280
301281
302282
303283
......
331311
332312
333313
334
314
335315
336316
337317
......
354334
355335
356336
357
337
358338
359339
360340
......
363343
364344
365345
346
366347
367348
368349
......
371352
372353
373354
374
375
376
377
378
379355
380356
381357
......
384360
385361
386362
363
387364
388365
389366
390
391
367
368
392369
393370
394371
395
396
372
373
397374
398375
399376
400
401
402
377
378
403379
404380
405381
......
407383
408384
409385
386
387
388
389
390
391
392
393
410394
411395
412396
413397
414
398
415399
416400
417401
#!/bin/bash
# --------------------------------------------------------------------------------------------------------
# Install.sh v1.3, script to install Chameleon
# Install.sh v1.5, script to install Chameleon
# Created by Miky1979 on December 8th, 2014
# --------------------------------------------------------------------------------------------------------
targetVolume="${3}"
InstallToESP="0"
InstallBootloader="0"
espmtp="/Volumes/ESP"
WINDOWS_EXIST="0"
opt="u"
configFile="/private/tmp/InstallConfig.plist"
if [ "${InstallToESP}" == "1" ]; then TYPE="ESP"; else TYPE="Standard"; fi
if [[ $( /usr/libexec/PlistBuddy -c "Print bootloader" ${configFile} ) == "true" ]];then
# installing stage 0, 1 and 2 only if user want this:
# ie only if have no selected noboot choice
choicedVolume="${targetVolume}"
ESP_MOUNTED="0"
# --------------------------------------------------------------------------------------------------------
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \
| sed -e 's/^[ \t]*//')
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//' )
backupRootDir="${targetVolume}/Chameleon.Backups"
backupDir=$( /usr/libexec/PlistBuddy -c "Print :backupDir" ${configFile} )
logName="Chameleon_Installer_Log.txt"
logFile="${v_mntpt}/${logName}"
# --------------------------------------------------------------------------------------------------------
stage0Loader="boot0"
stage0LoaderDualBoot="boot0md"
stage1LoaderHFS="boot1h"
stage1LoaderFAT="boot1f32"
stage1LoaderExFAT="boot1x"
stage2Loader="boot"
versionToInstall=$(cat "${i386Dir}/Boot" | grep -a 'Darwin/x86 boot v' )
# --------------------------------------------------------------------------------------------------------
localdd="/bin/dd"
SS="${usrLocalBin}/sectorsize"
# --------------------------------------------------------------------------------------------------------
# Scanning all Variables. We are switching to the target Volume or its ESP.
# This function is usefull to rescan the new target "at need"
SCAN() {
bootDevice=$( LC_ALL=C diskutil info / | grep -i 'Device Node:' | awk '{print $NF}' )
targetDevice=$( LC_ALL=C diskutil info "${choicedVolume}" | grep -i 'Device Node:' | awk '{print $NF}' )
targetDeviceRaw=${targetDevice/disk/rdisk}
targetDisk=${targetDevice%s*}
targetSlice=${targetDevice#*disk*s}
IOContent=$( LC_ALL=C diskutil info "${targetDisk}" | grep -i 'Content (IOContent)' | awk '{print $NF}' )
FS=$( LC_ALL=C diskutil info ${targetDevice} | grep -i 'Type (Bundle)' | \
awk '{print $NF}' | awk '{print tolower($0)}' )
awk '{print $NF}' | awk '{print tolower($0)}' )
disksignature=$( dd 2>/dev/null if="${targetDisk}" count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | \
perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $InstallBootloader = "1" ];then
blocksize=$( "${SS}" "${targetDeviceRaw}" | awk '{ print $2 }' )
# Create a folder inside the Desktop called "DebugChameleon", and the log will be full
DEBUG() {
echo "$mainLine"
echo "DEBUG: display script variables (Standardpostinstall)"
echo "DEBUG: display script variables (${TYPE}postinstall)"
echo "$mainLine"
echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader} (or boot0hfs)"
echo "DEBUG: stage0LoaderDualBoot: Disk loader is ${stage0LoaderDualBoot} (or boot0hfs)"
echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader}"
echo "DEBUG: stage1LoaderHFS: Partition loader is ${stage1LoaderHFS}"
echo "DEBUG: stage1LoaderFat: Partition loader is ${stage1LoaderFAT}"
echo "DEBUG: stage1LoaderExFAT: Partition loader is ${stage1LoaderExFAT}"
echo "DEBUG: targetDisk: Disk device is ${targetDisk}"
echo "DEBUG: targetDiskRaw: Disk raw device is ${targetDiskRaw}"
echo "DEBUG: targetSlice: Volume slice is ${targetSlice}"
echo "DEBUG: bootDevice: Current Volume device is ${bootDevice}"
echo "DEBUG: versionToInstall: version to install is ${versionToInstall}"
echo "DEBUG: IOContent: partition scheme is ${IOContent}"
echo "DEBUG: FS: file System is ${FS}"
# --------------------------------------------------------------------------------------------------------
# Checking for unsupported FAT16 filesystem
CHECK_FAT16() {
pers=$( LC_ALL=C diskutil info "${targetDeviceRaw}" | grep -i 'File System Personality' \
| awk '{print $NF}' | awk '{print tolower($0)}' )
pers=$( LC_ALL=C diskutil info "${targetDeviceRaw}" | grep -i 'File System Personality' | \
awk '{print $NF}' | awk '{print tolower($0)}' )
case $pers in
fat16)
exit 1
;;
*)
echo "First Check Passed!"
echo "First Check Passed (not Fat16)!"
;;
esac
}
CHECK_ESP_MOUNTPOINT() {
# umount the ESP by its Mount Point
# and checking it if is busy by another ESP
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \
grep -x '/Volumes/ESP' ) ]; then
umount -f /Volumes/ESP
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^ *//' | sed -e 's/ *$//' | \
grep -x "${espmtp}" ) ]; then
umount -f ${espmtp}
ESP_MOUNTED="0"
fi
}
if [ $( df | grep "${espDisk}" | awk '{print $1}' | grep -x "${espDisk}" ) ];then
# ESP is already mounted, so now we aquire the Mount Point
espmtp=$( LC_ALL=C diskutil info ${espDisk} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^[ \t]*//' )
sed -e 's/^ *//' | sed -e 's/ *$//' )
if [ -d "${espmtp}" ];then
echo "ESP Mount Point is:${espmtp}, using that as target Volume!"
choicedVolume="${espmtp}"
fi
if [ $ESP_MOUNTED = "0" ];then
mkdir -p /Volumes/ESP
mkdir -p "${espmtp}"
case $( fstyp $espDisk ) in
hfs)
mount -t hfs $espDisk /Volumes/ESP
echo "Mounting $espDisk on $espmtp as hfs Volume.."
mount -t hfs $espDisk "${espmtp}"
;;
msdos)
mount -t msdos $espDisk /Volumes/ESP
echo "Mounting $espDisk on $espmtp as msdos Volume.."
mount -t msdos $espDisk "${espmtp}"
;;
*)
echo "ESP fileSystem unsupported, Installing to ${targetVolume}!"
esac
sleep 0.3
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \
grep -x '/Volumes/ESP' ) ]; then
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^ *//' | sed -e 's/ *$//' | \
grep -x "${espmtp}" ) ]; then
echo "EFI System Partition mounted!"
ESP_MOUNTED="1"
choicedVolume="/Volumes/ESP"
choicedVolume="${espmtp}"
SCAN
else
echo "ESP can't be mounted, Installing to ${targetVolume}!"
}
# --------------------------------------------------------------------------------------------------------
PARTITION_ACTIVE_IF() {
echo -e "${mainLine}\nSET PARTITION ACTIVE:"
# if Windows was detected, don't activate the partition..
# if the stage 0 loader is boo0hfs, don't activate the partition
if [ WINDOWS_EXIST = "0" ] || [ "${stage0Loader}" != "boot0hfs" ];then
partitionactive=$( fdisk -d ${targetDiskRaw} | grep -n "*" | awk -F: '{print $1}')
if [ "${partitionactive}" ] && [ "${partitionactive}" = "${targetSlice}" ]; then
echo "${targetDiskRaw#/dev/r}, slice "${targetSlice}" is already set active. No need to change it."
else
echo "Setting ${choicedVolume} partition active."
# BadAxe requires EFI partition to be flagged active.
# but it doesn't' hurt to do it for any non-windows partition.
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nSET PARTITION ACTIVE:"
# if Windows was detected, don't activate the partition..
# if the stage 0 loader is boo0hfs, don't activate the partition
if [ WINDOWS_EXIST = "0" ] || [ "${stage0Loader}" != "boot0hfs" ];then
partitionactive=$( fdisk -d ${targetDiskRaw} | grep -n "*" | awk -F: '{print $1}')
if [ "${partitionactive}" ] && [ "${partitionactive}" = "${targetSlice}" ]; then
echo "${targetDiskRaw#/dev/r}, slice "${targetSlice}" is already set active. No need to change it."
else
echo "Setting ${choicedVolume} partition active."
# BadAxe requires EFI partition to be flagged active.
# but it doesn't' hurt to do it for any non-windows partition.
# leave left aligned the follow code:
fdisk -e ${targetDiskRaw} <<-MAKEACTIVE
y
quit
MAKEACTIVE
fi
else
echo "Partition will not activate when Windows is detected or stage 0 is boot0hfs"
fi
else
echo "Partition will not activate when Windows is detected or stage 0 is boot0hfs"
echo ""
echo "$mainLine"
fi
echo ""
echo "$mainLine"
}
# --------------------------------------------------------------------------------------------------------
# Writing stage 0
CHECK_WINDOWS() {
WINDOWS_EXIST="0"
if [ "${disksignature}" = "00000000" ]; then
echo "Windows installation not found on ${targetDisk}."
else
WRITE_STAGE0() {
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nWRITING STAGE 0:"
CHECK_WINDOWS
case "$1" in
hfs)
if [ WINDOWS_EXIST = "1" ];then stage0Loader="boo0hfs"; else stage0Loader="boot0"; fi
;;
msdos)
if [ WINDOWS_EXIST = "1" ];then stage0Loader="boo0md"; else stage0Loader="boot0";fi
;;
exfat)
stage0Loader="boot0"
;;
esac
"${usrLocalBin}/fdisk440" -u -f "${i386Dir}/${stage0Loader}" -y ${targetDisk}
echo "${stage0Loader} writed to ${targetDisk}"
fi
}
# --------------------------------------------------------------------------------------------------------
# Writing stage 1 on different filesystems
WRITE_STAGE1_HFS() {
# Writing stage 1
WRITE_STAGE1() {
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nWRITING STAGE 1 HFS:"
$localdd if="${i386Dir}/${stage1LoaderHFS}" of=${targetDeviceRaw}
echo "${stage1LoaderHFS} (hfs) writed to ${targetDeviceRaw}."
fi
}
WRITE_STAGE1_EXFAT() {
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nWRITING STAGE 1 ExFAT:"
echo -e "${mainLine}\nWRITING STAGE 1 ${2}:"
cp -R "${usrLocalBin}/boot1-install" "${v_mntpt}"/
cp -R "${i386Dir}/${stage1LoaderExFAT}" "${v_mntpt}"/
"${v_mntpt}/boot1-install" -y -u -f "${v_mntpt}/${stage1LoaderExFAT}" ${targetDeviceRaw}
echo "${stage1LoaderExFAT} (ExFAT) writed to ${targetDeviceRaw}."
cp -R "${i386Dir}/${1}" "${v_mntpt}"/
"${v_mntpt}/boot1-install" -y "-${3}" -f "${v_mntpt}/${1}" ${targetDeviceRaw}
echo "${stage1Loader} (${2}) writed to ${targetDeviceRaw}."
fi
}
WRITE_STAGE1_FAT32() {
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nWRITING STAGE 1 FAT32:"
$localdd if=${targetDeviceRaw} count=1 bs=512 of="${v_mntpt}/origbs"
cp "${i386Dir}/${stage1LoaderFAT}" "${v_mntpt}/newbs"
$localdd if="${v_mntpt}/origbs" of="${v_mntpt}/newbs" skip=3 seek=3 bs=1 count=87 conv=notrunc
$localdd if="${v_mntpt}/newbs" of="${targetDeviceRaw}" count=1 bs=512
echo "${stage1LoaderFAT} (Fat32) writed to ${targetDeviceRaw}."
fi
}
# --------------------------------------------------------------------------------------------------------
# Writing stage 2
WRITE_STAGE2() {
}
# --------------------------------------------------------------------------------------------------------
# Waiting for targhet Volume was re-mounted before proceeding..
# Note: the target Volume is umonted by boot1-install that also take the step to remount it (only waiting..)
WAIT_REMOUNT() {
# Note: the target Volume is umonted by boot1-install that also take the step to remount it (only waiting..).
# exception is the EFI partition: in Mavericks autoremount...in Yosemite not..
REMOUNT() {
if [ $InstallBootloader = "1" ];then
if [ ! -d "${choicedVolume}" ]; then
echo -e "${mainLine}\nWAITING TO RE-MOUNT ${choicedVolume}:"
until [ -d "${choicedVolume}" ]; do
sleep 0.3
done
echo "${choicedVolume} is mounted!"
if [ "${InstallToESP}" == "1" ]; then
if [ ! -d "${choicedVolume}" ]; then
MOUNT_ESP
fi
else
if [ ! -d "${choicedVolume}" ]; then
echo -e "${mainLine}\nWAITING TO RE-MOUNT ${choicedVolume}:"
until [ -d "${choicedVolume}" ]; do
sleep 0.3
done
echo "${choicedVolume} is mounted!"
fi
fi
fi
}
else
echo "Extra folder already exist on ${choicedVolume}, copying to the Ram Disk.."
cp -R "${choicedVolume}/Extra" "${v_mntpt}"/
./clean_bootplist.pl "${v_mntpt}" >/dev/null
./clean_bootplist.pl "${v_mntpt}"
fi
}
# --------------------------------------------------------------------------------------------------------
exec > >(tee -a "${logFile}") 2>&1
echo "$mainLine"
echo "Main Standard Post-Install Script"
echo "Main ${TYPE} Post-Install Script"
echo "Chameleon installer log - $( date )"
if [ $InstallBootloader = "1" ];then echo "$versionToInstall"; else echo "no boot session"; fi
echo ""
echo "GPT partition Scheme detected.."
espDisk="${targetDisk}s1"
if [ $( LC_ALL=C diskutil info ${espDisk} | grep -i 'Partition Type:' | \
awk '{print $NF}' ) = "EFI" ]; then
awk '{print $NF}' | sed -e 's/^ *//' | sed -e 's/ *$//' ) = "EFI" ]; then
echo "EFI partition found is ${espDisk}, try to mount it.."
MOUNT_ESP
else
fi
;;
*)
InstallToESP = "0"
echo "Can't install on the ESP, because does not exist.."
echo "..continue installing to ${targetVolume}"
;;
SCAN
fi
if [ -d "${HOME}/Desktop/DebugChameleon" ]; then
DEBUG
fi
# adding the chosen Volume dev id to the InstallConfig.plist
/usr/libexec/PlistBuddy -c "Add :targetdev string ${targetDevice}" $configFile
echo "${mainLine}"
CHECK_FAT16
CHECK_WINDOWS
case "$FS" in
hfs)
echo "${targetDevice} is HFS formatted"
WRITE_STAGE0 hfs
WRITE_STAGE1_HFS
if [ $WINDOWS_EXIST = "1" ];then stage0Loader="boot0hfs"; else stage0Loader="boot0"; fi
stage1Loader="${stage1LoaderHFS}"
;;
msdos)
echo "${targetDevice} is FAT32 formatted"
WRITE_STAGE0 msdos
WRITE_STAGE1_FAT32
if [ $WINDOWS_EXIST = "1" ];then stage0Loader="boot0md"; else stage0Loader="boot0"; fi
stage1Loader="${stage1LoaderFAT}"
;;
exfat)
echo "${targetDevice} is ExFAT formatted"
WRITE_STAGE0 exfat
WRITE_STAGE1_EXFAT
WAIT_REMOUNT
stage0Loader="boot0"
stage1Loader="${stage1LoaderExFAT}"
;;
*)
echo "FileSystem unsupported, aborting!"
;;
esac
# Debug mode: create a "DebugChameleon" folder on your Desktop to debug this script
if [ -d "${HOME}/Desktop/DebugChameleon" ]; then DEBUG; fi
# if the target device is equal to the boot device keep the Volume mounted using boot1-install
if [ "${bootDevice}" = "${targetDevice}" ]; then opt="M"; fi
WRITE_STAGE0 "${stage0Loader}"
WRITE_STAGE1 "${stage1Loader}" "${FS}" "${opt}"
if [ "${bootDevice}" != "${targetDevice}" ]; then REMOUNT; fi
WRITE_STAGE2
PARTITION_ACTIVE_IF
echo "$mainLine"
echo "END - Standard Post-Install Script"
echo "END - ${TYPE} Post-Install Script"
# --------------------------------------------------------------------------------------------------------
exit 0
branches/zenith432/package/buildpkg.sh
475475
476476
477477
478
478479
479480
480481
ditto --noextattr --noqtn ${SYMROOT}/i386/boot ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot0 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot0md ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot0hfs ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot1f32 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot1h ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot1x ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
branches/zenith432/CHANGES
1
12
23
34
- Zenith432 : Interrupt Management
- Bungo : Added ability to auto-select last booted partition as the boot volume.
- Bungo : Added MacOSVerCurrent and MacOSVer2Int function to use instead of macros.
- Bungo : Fixed bug in gDarwinBuildVerStr extracting.

Archive Download the corresponding diff file

Revision: 2594