Chameleon

Chameleon Commit Details

Date:2014-06-17 12:36:58 (9 years 9 months ago)
Author:Bungo
Commit:2379
Parents: 2378
Message:Loading custom ECDT.aml, Darwin version string printing, clean boot-args, change firmware rev. to real Mac (0x0001000a), added kernel-compatibility, boot-file, boot-args, machine-signature, random-seed DT properties & some minor changes.
Changes:
M/branches/Bungo/i386/boot2/boot.c
M/branches/Bungo/i386/libsaio/bootstruct.c
M/branches/Bungo/i386/boot2/boot.h
M/branches/Bungo/i386/libsaio/bootstruct.h
M/branches/Bungo/i386/libsaio/device_tree.c
M/branches/Bungo/i386/libsaio/stringTable.c
M/branches/Bungo/i386/libsaio/sys.c
M/branches/Bungo/i386/libsaio/load.c
M/branches/Bungo/i386/libsaio/hfs.c
M/branches/Bungo/i386/boot2/drivers.c
M/branches/Bungo/i386/libsaio/acpi_patcher.c
M/branches/Bungo/i386/libsaio/device_tree.h
M/branches/Bungo/i386/libsaio/platform.c
M/branches/Bungo/Chameleon.xcodeproj/project.pbxproj
M/branches/Bungo/i386/libsaio/bootargs.h
M/branches/Bungo/i386/libsaio/cpu.c
M/branches/Bungo/i386/libsaio/smbios_getters.c
M/branches/Bungo/i386/libsaio/platform.h
M/branches/Bungo/i386/libsaio/fake_efi.c
M/branches/Bungo/i386/libsaio/device_inject.c
M/branches/Bungo/i386/libsaio/smbios.c
M/branches/Bungo/i386/libsaio/cpu.h
M/branches/Bungo/i386/boot2/options.c
M/branches/Bungo/i386/libsaio/console.c

File differences

branches/Bungo/Chameleon.xcodeproj/project.pbxproj
38723872
38733873
38743874
3875
3875
38763876
38773877
38783878
......
41194119
41204120
41214121
4122
4123
4122
4123
41244124
41254125
41264126
......
41304130
41314131
41324132
4133
4133
41344134
41354135
41364136
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0460;
LastUpgradeCheck = 0500;
};
buildConfigurationList = 1DEB919308733D9F0010E9CD /* Build configuration list for PBXProject "Chameleon" */;
compatibilityVersion = "Xcode 3.2";
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
GCC_WARN_UNUSED_VARIABLE = NO;
ONLY_ACTIVE_ARCH = NO;
SDKROOT = macosx;
};
name = Debug;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
GCC_WARN_UNUSED_VARIABLE = NO;
SDKROOT = macosx;
};
name = Release;
branches/Bungo/i386/libsaio/console.c
246246
247247
248248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
249267
250268
251269
} else {
vprf(fmt, ap);
}
{
// Kabyl: BooterLog
struct putc_info pi;
if (!msgbuf) {
return 0;
}
if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) {
return 0;
}
pi.str = cursor;
pi.last_str = 0;
prf(fmt, ap, sputc, &pi);
cursor += strlen((char *)cursor);
}
va_end(ap);
return(0);
}
branches/Bungo/i386/libsaio/bootstruct.c
2929
3030
3131
32
33
34
35
36
37
38
39
40
41
3242
3343
3444
......
5262
5363
5464
55
65
5666
5767
5868
#include "libsaio.h"
#include "bootstruct.h"
#ifndef DEBUG_BOOTSTRUCT
#define DEBUG_BOOTSTRUCT 0
#endif
#if DEBUG_BOOTSTRUCT
#define DBG(x...)printf(x)
#else
#define DBG(x...)msglog(x)
#endif
/*==========================================================================
* Initialize the structure of parameters passed to
* the kernel by the booter.
bootArgs = (boot_args *)malloc(sizeof(boot_args));
bootArgsPreLion = (boot_args_pre_lion *)malloc(sizeof(boot_args_pre_lion));
bootInfo = (PrivateBootInfo_t *)malloc(sizeof(PrivateBootInfo_t));
if (bootArgs == 0 || bootInfo == 0)
if (bootArgs == 0 || bootArgsPreLion == 0 || bootInfo == 0)
stop("Couldn't allocate boot info\n");
bzero(bootArgs, sizeof(boot_args));
branches/Bungo/i386/libsaio/bootstruct.h
3333
3434
3535
36
37
38
36
37
38
3939
4040
4141
/*
* Kernel boot args global also used by booter for its own data.
*/
extern boot_args *bootArgs;
extern boot_args_pre_lion *bootArgsPreLion;
extern Node *gMemoryMapNode;
extern boot_args*bootArgs;
extern boot_args_pre_lion*bootArgsPreLion;
extern Node*gMemoryMapNode;
#define VGA_TEXT_MODE 0
//defined in /usr/../boot.h
branches/Bungo/i386/libsaio/device_tree.c
398398
399399
400400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
401417
418
419
402420
403421
404422
}
//==============================================================================
// Bungo
Property *
DT__GetProperty(Node *node, const char *name)
{
Property *prop;
for (prop = node->properties; prop; prop = prop->next)
{
if (strcmp(prop->name, name) == 0)
{
return prop;
}
}
return NULL;
}
//==============================================================================
Node *
DT__FindNode(const char *path, bool createIfMissing)
{
branches/Bungo/i386/libsaio/hfs.c
304304
305305
306306
307
307
308308
309309
310310
......
370370
371371
372372
373
373
374374
375375
376376
......
435435
436436
437437
438
438
439439
440440
441441
}
dirID = kHFSRootFolderID;
// Skip a lead '\'. Start in the system folder if there are two.
// Skip a lead '/'. Start in the system folder if there are two.
if (filePath[0] == '/')
{
if (filePath[1] == '/')
if (*dirIndex == -1) return -1;
dirID = kHFSRootFolderID;
// Skip a lead '\'. Start in the system folder if there are two.
// Skip a lead '/'. Start in the system folder if there are two.
if (dirPath[0] == '/') {
if (dirPath[1] == '/') {
if (gIsHFSPlus) dirID = SWAP_BE32(((long *)gHFSPlus->finderInfo)[5]);
if (HFSInitPartition(ih) == -1) return -1;
dirID = kHFSRootFolderID;
// Skip a lead '\'. Start in the system folder if there are two.
// Skip a lead '/'. Start in the system folder if there are two.
if (filePath[0] == '/') {
if (filePath[1] == '/') {
if (gIsHFSPlus) dirID = SWAP_BE32(((long *)gHFSPlus->finderInfo)[5]);
branches/Bungo/i386/libsaio/acpi_patcher.c
2323
2424
2525
26
26
2727
2828
2929
......
112112
113113
114114
115
115
116116
117117
118118
......
136136
137137
138138
139
139
140140
141141
142142
......
147147
148148
149149
150
150
151151
152152
153153
......
161161
162162
163163
164
164
165165
166166
167167
168168
169169
170
170
171171
172172
173173
......
182182
183183
184184
185
185
186186
187187
188188
......
196196
197197
198198
199
199
200200
201201
202202
......
205205
206206
207207
208
208
209209
210210
211211
......
234234
235235
236236
237
237
238238
239239
240240
241241
242
242
243243
244244
245245
246246
247247
248248
249
249
250250
251251
252252
......
397397
398398
399399
400
400
401401
402402
403403
404
404
405405
406406
407407
......
419419
420420
421421
422
422
423423
424424
425425
426426
427
427
428428
429429
430430
......
587587
588588
589589
590
590
591591
592592
593593
......
608608
609609
610610
611
611
612612
613613
614614
......
658658
659659
660660
661
661
662662
663663
664664
665665
666
666
667667
668668
669669
......
677677
678678
679679
680
680
681681
682682
683683
......
689689
690690
691691
692
692
693693
694694
695695
......
708708
709709
710710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
736733
737
734
738735
739736
740737
......
747744
748745
749746
750
747
751748
752749
753750
......
756753
757754
758755
759
756
760757
761758
762759
......
771768
772769
773770
774
775
771
776772
777773
778774
......
794790
795791
796792
797
793
798794
799795
800796
......
803799
804800
805801
806
802
807803
808804
809805
......
823819
824820
825821
822
826823
827824
828825
......
840837
841838
842839
843
844
840
841
845842
846843
847844
......
849846
850847
851848
852
849
853850
854851
855852
......
858855
859856
860857
858
859
860
861
861862
862863
863864
......
866867
867868
868869
869
870
870871
871872
872873
......
876877
877878
878879
879
880
880881
881882
882883
......
895896
896897
897898
898
899
899900
900901
901902
......
909910
910911
911912
912
913
914
913915
914916
915917
916918
917
919
918920
919921
920922
923
921924
922
923
924925
925926
927
926928
927
928929
929930
930931
......
932933
933934
934935
935
936
936937
937938
938
939
939940
940941
941942
......
955956
956957
957958
958
959959
960960
961
961962
962
963963
964
965
966
967
968
969
970
971
972
973
974
975
976
964977
965
978
966979
967980
968
981
982
969983
970984
971985
972
973
974
975
976
977
978
979
980
981
982
983
984
986
985987
986988
987
988989
989990
990
991991
992992
993993
994
994
995995
996
996997
997998
998999
9991000
10001001
1001
10021002
10031003
10041004
10051005
10061006
1007
1007
10081008
10091009
10101010
......
10191019
10201020
10211021
1022
1023
1024
10221025
10231026
10241027
1025
1028
10261029
10271030
10281031
1032
10291033
1030
1031
10321034
10331035
1036
10341037
1035
1036
1037
10381038
10391039
10401040
10411041
10421042
10431043
1044
1045
1044
10461045
10471046
1048
1047
10491048
10501049
10511050
10521051
10531052
10541053
1055
1054
10561055
10571056
10581057
1058
10591059
10601060
10611061
10621062
10631063
10641064
1065
10651066
10661067
10671068
10681069
10691070
10701071
1071
1072
1073
1072
1073
10741074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
10751088
10761089
1077
1090
10781091
10791092
10801093
......
10821095
10831096
10841097
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
10961098
1099
10971100
10981101
1102
10991103
11001104
1101
11021105
1103
11041106
11051107
11061108
1107
11081109
11091110
11101111
11111112
1113
11121114
1113
1114
1115
11151116
1116
11171117
11181118
1119
11201119
11211120
11221121
1123
1124
1122
11251123
11261124
1127
11281125
11291126
11301127
1131
11321128
11331129
11341130
......
11381134
11391135
11401136
1137
11411138
11421139
11431140
#elif DEBUG_ACPI==1
#define DBG(x...) printf(x)
#else
#define DBG(x...)
#define DBG(x...) msglog(x)
#endif
// Slice: New signature compare function
fd = open(dirSpec, 0);
if (fd < 0) {
// NOT FOUND:
verbose("ACPI Table not found: %s\n", filename);
DBG("ACPI Table not found: %s\n", filename);
*dirSpec = '\0';
}
}
{
if (read (fd, tableAddr, file_size (fd))!=file_size (fd))
{
printf("Couldn't read table %s\n",dirspec);
DBG("Couldn't read table %s\n",dirspec);
free (tableAddr);
close (fd);
return NULL;
return tableAddr;
}
close (fd);
printf("Couldn't allocate memory for table \n", dirspec);
DBG("Couldn't allocate memory for table \n", dirspec);
}
//printf("Couldn't find table %s\n", filename);
return NULL;
{
uint32_t i;
DBG("start finding cpu names. length %d\n", length);
DBG("Start finding cpu names. length %d\n", length);
for (i=0; i<length-7; i++)
{
if (dsdt[i] == 0x5B && dsdt[i+1] == 0x83) // ProcessorOP
{
DBG("dsdt: %x%x\n", dsdt[i], dsdt[i+1]);
DBG("DSDT: %x%x\n", dsdt[i], dsdt[i+1]);
uint32_t offset = i + 3 + (dsdt[i+2] >> 6);
if (!aml_isvalidchar(c))
{
add_name = false;
verbose("Invalid character found in ProcessorOP 0x%x!\n", c);
DBG("Invalid character found in ProcessorOP 0x%x!\n", c);
break;
}
}
if (acpi_cpu_count == 0)
acpi_cpu_p_blk = dsdt[i] | (dsdt[i+1] << 8);
verbose("Found ACPI CPU: %c%c%c%c\n", acpi_cpu_name[acpi_cpu_count][0], acpi_cpu_name[acpi_cpu_count][1], acpi_cpu_name[acpi_cpu_count][2], acpi_cpu_name[acpi_cpu_count][3]);
DBG("Found ACPI CPU: %c%c%c%c\n", acpi_cpu_name[acpi_cpu_count][0], acpi_cpu_name[acpi_cpu_count][1], acpi_cpu_name[acpi_cpu_count][2], acpi_cpu_name[acpi_cpu_count][3]);
if (++acpi_cpu_count == 32) {
return;
}
}
DBG("end finding cpu names: cpu names found: %d\n", acpi_cpu_count);
DBG("End finding cpu names: cpu names found: %d\n", acpi_cpu_count);
}
struct acpi_2_ssdt *generate_cst_ssdt(struct acpi_2_fadt* fadt)
};
if (Platform.CPU.Vendor != 0x756E6547) {
verbose ("Not an Intel platform: C-States will not be generated !!!\n");
DBG("Not an Intel platform: C-States will not be generated !!!\n");
return NULL;
}
if (fadt == NULL) {
verbose ("FACP not exists: C-States will not be generated !!!\n");
DBG("FACP not exists: C-States will not be generated !!!\n");
return NULL;
}
struct acpi_2_dsdt* dsdt = (void*)fadt->DSDT;
if (dsdt == NULL) {
verbose ("DSDT not found: C-States will not be generated !!!\n");
DBG("DSDT not found: C-States will not be generated !!!\n");
return NULL;
}
// dumpPhysAddr("C-States SSDT content: ", ssdt, ssdt->Length);
verbose ("SSDT with CPU C-States generated successfully\n");
DBG("SSDT with CPU C-States generated successfully\n");
return ssdt;
} else {
verbose ("ACPI CPUs not found: C-States not generated !!!\n");
DBG("ACPI CPUs not found: C-States not generated !!!\n");
}
return NULL;
};
if (Platform.CPU.Vendor != 0x756E6547) {
verbose ("Not an Intel platform: P-States will not be generated !!!\n");
DBG("Not an Intel platform: P-States will not be generated !!!\n");
return NULL;
}
if (!(Platform.CPU.Features & CPU_FEATURE_MSR)) {
verbose ("Unsupported CPU: P-States will not be generated !!! No MSR support\n");
DBG("Unsupported CPU: P-States will not be generated !!! No MSR support\n");
return NULL;
}
minimum.Control = (rdmsr64(MSR_PLATFORM_INFO) >> 40) & 0xff;
verbose("P-States: min 0x%x, max 0x%x\n", minimum.Control, maximum.Control);
DBG("P-States: min 0x%x, max 0x%x\n", minimum.Control, maximum.Control);
// Sanity check
if (maximum.Control < minimum.Control) {
break;
}
default:
verbose ("Unsupported CPU (0x%X): P-States not generated !!!\n", Platform.CPU.Family);
DBG("Unsupported CPU (0x%X): P-States not generated !!!\n", Platform.CPU.Family);
break;
}
}
//dumpPhysAddr("P-States SSDT content: ", ssdt, ssdt->Length);
verbose ("SSDT with CPU P-States generated successfully\n");
DBG("SSDT with CPU P-States generated successfully\n");
return ssdt;
}
} else {
verbose ("ACPI CPUs not found: P-States not generated !!!\n");
DBG("ACPI CPUs not found: P-States not generated !!!\n");
}
return NULL;
bool fadt_rev2_needed = false;
bool fix_restart;
bool fix_restart_ps2;
const char * value;
int value = 1;
// Restart Fix
if (Platform.CPU.Vendor == 0x756E6547) { /* Intel */
getBoolForKey(kRestartFix, &fix_restart, &bootInfo->chameleonConfig);
}
} else {
verbose ("Not an Intel platform: Restart Fix not applied !!!\n");
DBG("Not an Intel platform: Restart Fix not applied !!!\n");
fix_restart = false;
}
fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(fadt->Length);
memcpy(fadt_mod, fadt, fadt->Length);
}
// Determine system type / PM_Model
if ( (value=getStringForKey(kSystemType, &bootInfo->chameleonConfig))!=NULL)
{
if (Platform.Type > 6) {
if(fadt_mod->PM_Profile<=6) {
Platform.Type = fadt_mod->PM_Profile; // get the fadt if correct
} else {
Platform.Type = 1;/* Set a fixed value (Desktop) */
}
verbose("Error: system-type must be 0..6. Defaulting to %d !\n", Platform.Type);
} else {
Platform.Type = (unsigned char) strtoul(value, NULL, 10);
}
}
// Set PM_Profile from System-type if only user wanted this value to be forced
if (fadt_mod->PM_Profile != Platform.Type) {
if (value) {
// user has overriden the SystemType so take care of it in FACP
verbose("FADT: changing PM_Profile from 0x%02x to 0x%02x\n", fadt_mod->PM_Profile, Platform.Type);
fadt_mod->PM_Profile = Platform.Type;
} else {
// PM_Profile has a different value and no override has been set, so reflect the user value to ioregs
Platform.Type = fadt_mod->PM_Profile <= 6 ? fadt_mod->PM_Profile : 1;
}
}
// Determine PM Profile
if (getIntForKey(kSystemType, &value, &bootInfo->chameleonConfig)) {
DBG("FADT: changing PM Profile from 0x%02x to 0x%02x\n", fadt_mod->PM_Profile, (unsigned char)value);
// user has overriden the PM Profile so take care of it in FACP
fadt_mod->PM_Profile = (unsigned char)value;
} else {
DBG("FADT: PM Profile=0x%02x\n", fadt_mod->PM_Profile);
}
// Check if PM Profile is correct (1..3), otherwise set it to value
switch (fadt_mod->PM_Profile) {
case 1: break;
case 2: break;
case 3: break;
default:
value = 1;
DBG("FADT: wrong PM Profile (0x%02x), must be 1..3. Defaulting to 0x%02x!\n", fadt_mod->PM_Profile, (unsigned char)value);
fadt_mod->PM_Profile = (unsigned char)value;
}
// Setup system-type
Platform.Type = fadt_mod->PM_Profile;
// We now have to write the systemm-type in ioregs: we cannot do it before in setupDeviceTree()
// because we need to take care of facp original content, if it is correct.
// because we need to take care of FACP original content, if it is correct.
setupSystemType();
// Patch FADT to fix restart
fadt_mod->Reset_AccessWidth= 0x01; // Byte access
fadt_mod->Reset_Address= 0x64; // Address of the register
fadt_mod->Reset_Value= 0xfe; // Value to write to reset the system
msglog("FADT: PS2 Restart Fix applied!\n");
DBG("FADT: PS2 Restart Fix applied!\n");
} else {
fadt_mod->Flags|= 0x400;
fadt_mod->Reset_SpaceID= 0x01; // System I/O
fadt_mod->Reset_AccessWidth= 0x01; // Byte access
fadt_mod->Reset_Address= 0x0cf9; // Address of the register
fadt_mod->Reset_Value= 0x06; // Value to write to reset the system
verbose("FADT: ACPI Restart Fix applied!\n");
DBG("FADT: ACPI Restart Fix applied!\n");
}
}
}
DBG("New @%x,%x\n",fadt_mod->DSDT,fadt_mod->X_DSDT);
verbose("FADT: Using custom DSDT!\n");
DBG("FADT: Using custom DSDT!\n");
}
// Correct the checksum
if(acpi20_p) {
addConfigurationTable(&gEfiAcpi20TableGuid, &acpi20_p, "ACPI_20");
} else {
verbose("No ACPI 2.\n");
DBG("No ACPI 2.\n");
}
return 1;
}
int setupAcpi(void)
{
int version;
void *new_dsdt;
void *new_dsdt, *new_table;
const char *filename;
// Load replacement DSDT
new_dsdt = loadACPITable(dirSpec);
// Mozodojo: going to patch FACP and load SSDT's even if DSDT.aml is not present
/*if (!new_dsdt)
{
getBoolForKey(kGeneratePStates, &generate_pstates, &bootInfo->chameleonConfig);
getBoolForKey(kGenerateCStates, &generate_cstates, &bootInfo->chameleonConfig);
DBG("Generating P-States config: %d\n", generate_pstates);
DBG("Generating C-States config: %d\n", generate_cstates);
DBG("Generating P-States config: %s\n", generate_pstates ? "YES" : "NO");
DBG("Generating C-States config: %s\n", generate_cstates ? "YES" : "NO");
{
int i;
for (i = 0; i < 30; i++) {
char filename[512];
sprintf(filename, i > 0?"SSDT-%d.aml":"SSDT.aml", i);
sprintf(filename, i > 0 ? "SSDT-%d.aml" : "SSDT.aml", i);
if ( (new_ssdt[ssdt_count] = loadACPITable(filename)) ) {
ssdt_count++;
}
}
}
// Load new table
sprintf(dirSpec, "ECDT.aml");
new_table = loadACPITable(dirSpec);
// Do the same procedure for both versions of ACPI
for (version = 0; version < 2; version++) {
int rsdplength;
// Find original rsdp
rsdp=(struct acpi_2_rsdp *)(version?getAddressOfAcpi20Table():getAddressOfAcpiTable());
rsdp=(struct acpi_2_rsdp *)(version ? getAddressOfAcpi20Table() : getAddressOfAcpiTable());
if (!rsdp) {
DBG("No ACPI version %d found. Ignoring\n", version+1);
if (version) {
}
continue;
}
rsdplength=version?rsdp->Length:20;
rsdplength=version ? rsdp->Length : 20;
DBG("RSDP version %d found @%x. Length=%d\n",version+1,rsdp,rsdplength);
if (rsdt && (uint32_t)rsdt !=0xffffffff && rsdt->Length<0x10000) {
uint32_t *rsdt_entries;
int rsdt_entries_num;
int dropoffset=0, i;
int dropoffset=0, i, j;
// mozo: using malloc cos I didn't found how to free already allocated kernel memory
rsdt_mod=(struct acpi_2_rsdt *)malloc(rsdt->Length);
continue;
}
DBG("TABLE %c%c%c%c,",table[0],table[1],table[2],table[3]);
//DBG("TABLE %c%c%c%c,",table[0],table[1],table[2],table[3]);
DBG("TABLE %c%c%c%c@%x: ", table[0],table[1],table[2],table[3],rsdt_entries[i]);
rsdt_entries[i-dropoffset]=rsdt_entries[i];
if (drop_ssdt && tableSign(table, "SSDT")) {
verbose("OEM SSDT tables was dropped\n");
DBG("dropped (OEM)\n");
dropoffset++;
continue;
}
if (tableSign(table, "DSDT")) {
DBG("DSDT found\n");
verbose("Custom DSDT table was found\n");
if(new_dsdt) {
rsdt_entries[i-dropoffset]=(uint32_t)new_dsdt;
DBG("custom table added\n");
}
continue;
}
struct acpi_2_fadt *fadt, *fadt_mod;
fadt=(struct acpi_2_fadt *)rsdt_entries[i];
DBG("FADT found @%x, Length %d\n",fadt, fadt->Length);
DBG("found, Length %d\n",fadt->Length);
if (!fadt || (uint32_t)fadt == 0xffffffff || fadt->Length>0x10000) {
printf("FADT incorrect. Not modified\n");
DBG("FADT incorrect. Not modified\n");
continue;
}
generate_pstates = false; // Generate SSDT only once!
ssdt_count++;
}
continue;
}
DBG("coppied (OEM)\n");
}
DBG("\n");
// Mozodojo: Insert additional SSDTs into RSDT
if(ssdt_count > 0) {
for (j=0; j<ssdt_count; j++) {
rsdt_entries[i-dropoffset+j]=(uint32_t)new_ssdt[j];
}
DBG("RSDT: Added %d SSDT table(s)\n", ssdt_count);
}
if (new_table) {
rsdt_entries[i-dropoffset+j]=(uint32_t)new_table;
DBG("RSDT: Added custom table %s @%x\n", "ECDT", new_table);
}
// Allocate rsdt in Kernel memory area
rsdt_mod->Length += 4*ssdt_count - 4*dropoffset;
rsdt_mod->Length += 4*ssdt_count + 4 - 4*dropoffset;
struct acpi_2_rsdt *rsdt_copy = (struct acpi_2_rsdt *)AllocateKernelMemory(rsdt_mod->Length);
memcpy (rsdt_copy, rsdt_mod, rsdt_mod->Length);
free(rsdt_mod); rsdt_mod = rsdt_copy;
free(rsdt_mod);
rsdt_mod = rsdt_copy;
rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod;
rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4;
rsdt_entries=(uint32_t *)(rsdt_mod+1);
// Mozodojo: Insert additional SSDTs into RSDT
if(ssdt_count>0) {
int j;
for (j=0; j<ssdt_count; j++) {
rsdt_entries[i-dropoffset+j]=(uint32_t)new_ssdt[j];
}
verbose("RSDT: Added %d SSDT table(s)\n", ssdt_count);
}
// Correct the checksum of RSDT
DBG("RSDT: Original checksum %d, ", rsdt_mod->Checksum);
rsdt_mod->Checksum=0;
rsdt_mod->Checksum=256-checksum8(rsdt_mod,rsdt_mod->Length);
DBG("New checksum %d at %x\n", rsdt_mod->Checksum,rsdt_mod);
} else {
rsdp_mod->RsdtAddress=0;
printf("RSDT not found or RSDT incorrect\n");
DBG("RSDT not found or RSDT incorrect\n");
}
DBG("\n");
if (version) {
struct acpi_2_xsdt *xsdt, *xsdt_mod;
// FIXME: handle 64-bit address correctly
xsdt=(struct acpi_2_xsdt*) ((uint32_t)rsdp->XsdtAddress);
DBG("XSDT @%x;%x, Length=%d\n", (uint32_t)(rsdp->XsdtAddress>>32),(uint32_t)rsdp->XsdtAddress, xsdt->Length);
if (xsdt && (uint64_t)rsdp->XsdtAddress<0xffffffff && xsdt->Length<0x10000) {
uint64_t *xsdt_entries;
int xsdt_entries_num, i;
int xsdt_entries_num, i, j;
int dropoffset=0;
// mozo: using malloc cos I didn't found how to free already allocated kernel memory
if (!table) {
continue;
}
DBG("TABLE %c%c%c%c@%x: ", table[0],table[1],table[2],table[3],xsdt_entries[i]);
xsdt_entries[i-dropoffset]=xsdt_entries[i];
if (drop_ssdt && tableSign(table, "SSDT")) {
verbose("OEM SSDT tables was dropped\n");
DBG("dropped (OEM)\n");
dropoffset++;
continue;
}
if (tableSign(table, "DSDT")) {
DBG("DSDT found\n");
if (new_dsdt) {
xsdt_entries[i-dropoffset]=(uint32_t)new_dsdt;
DBG("custom table added\n");
}
DBG("TABLE %c%c%c%c@%x \n", table[0],table[1],table[2],table[3],xsdt_entries[i]);
continue;
}
if (tableSign(table, "FACP")) {
struct acpi_2_fadt *fadt, *fadt_mod;
fadt=(struct acpi_2_fadt *)(uint32_t)xsdt_entries[i];
DBG("FADT found @%x%x, Length %d\n",(uint32_t)(xsdt_entries[i]>>32),fadt,
fadt->Length);
DBG("found, Length %d\n",(uint32_t)(xsdt_entries[i]>>32), fadt->Length);
if (!fadt || (uint64_t)xsdt_entries[i] >= 0xffffffff || fadt->Length>0x10000) {
verbose("FADT incorrect or after 4GB. Dropping XSDT\n");
DBG("FADT incorrect or after 4GB. Dropping XSDT\n");
goto drop_xsdt;
}
fadt_mod = patch_fadt(fadt, new_dsdt);
xsdt_entries[i-dropoffset]=(uint32_t)fadt_mod;
DBG("TABLE %c%c%c%c@%x \n", table[0],table[1],table[2],table[3],xsdt_entries[i]);
// DBG("TABLE %c%c%c%c@%x \n", table[0],table[1],table[2],table[3],xsdt_entries[i]);
// Generate _CST SSDT
if (generate_cstates && (new_ssdt[ssdt_count] = generate_cst_ssdt(fadt_mod))) {
DBG("C-States generated\n");
generate_cstates = false; // Generate SSDT only once!
ssdt_count++;
}
// Generating _PSS SSDT
if (generate_pstates && (new_ssdt[ssdt_count] = generate_pss_ssdt((void*)fadt_mod->DSDT))) {
DBG("P-States generated\n");
generate_pstates = false; // Generate SSDT only once!
ssdt_count++;
}
continue;
}
DBG("TABLE %c%c%c%c@%x \n", table[0],table[1],table[2],table[3],xsdt_entries[i]);
DBG("coppied (OEM)\n");
// DBG("TABLE %c%c%c%c@%x \n", table[0],table[1],table[2],table[3],xsdt_entries[i]);
}
// Mozodojo: Insert additional SSDTs into XSDT
if(ssdt_count > 0) {
for (j=0; j<ssdt_count; j++) {
xsdt_entries[i-dropoffset+j]=(uint32_t)new_ssdt[j];
}
DBG("Added %d SSDT table(s) into XSDT\n", ssdt_count);
}
if (new_table) {
xsdt_entries[i-dropoffset+j]=(uint32_t)new_table;
DBG("XSDT: Added custom table %s @%x\n", "ECDT", new_table);
}
// Allocate xsdt in Kernel memory area
xsdt_mod->Length += 8*ssdt_count - 8*dropoffset;
xsdt_mod->Length += 8*ssdt_count + 8 - 8*dropoffset;
struct acpi_2_xsdt *xsdt_copy = (struct acpi_2_xsdt *)AllocateKernelMemory(xsdt_mod->Length);
memcpy(xsdt_copy, xsdt_mod, xsdt_mod->Length);
free(xsdt_mod); xsdt_mod = xsdt_copy;
xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8;
xsdt_entries=(uint64_t *)(xsdt_mod+1);
// Mozodojo: Insert additional SSDTs into XSDT
if(ssdt_count > 0) {
int j;
for (j=0; j<ssdt_count; j++) {
xsdt_entries[i-dropoffset+j]=(uint32_t)new_ssdt[j];
}
verbose("Added %d SSDT table(s) into XSDT\n", ssdt_count);
}
// Correct the checksum of XSDT
DBG("XSDT: Original checksum %d, ", xsdt_mod->Checksum);
xsdt_mod->Checksum=0;
xsdt_mod->Checksum=256-checksum8(xsdt_mod,xsdt_mod->Length);
DBG("New checksum %d\n", xsdt_mod->Checksum);
} else {
drop_xsdt:
DBG("About to drop XSDT\n");
/*FIXME: Now we just hope that if MacOS doesn't find XSDT it reverts to RSDT.
* A Better strategy would be to generate
*/
rsdp_mod->XsdtAddress=0xffffffffffffffffLL;
verbose("XSDT not found or XSDT incorrect\n");
}
}
DBG("\n");
// Correct the checksum of RSDP
// Correct the checksum of RSDP
DBG("RSDP: Original checksum %d, ", rsdp_mod->Checksum);
rsdp_mod->Checksum=0;
rsdp_mod->Checksum=256-checksum8(rsdp_mod,20);
DBG("New checksum %d\n", rsdp_mod->Checksum);
if (version) {
DBG("RSDP: Original extended checksum %d", rsdp_mod->ExtendedChecksum);
DBG("RSDP: Original extended checksum %d, ", rsdp_mod->ExtendedChecksum);
rsdp_mod->ExtendedChecksum=0;
rsdp_mod->ExtendedChecksum=256-checksum8(rsdp_mod,rsdp_mod->Length);
DBG("New extended checksum %d\n", rsdp_mod->ExtendedChecksum);
}
//verbose("Patched ACPI version %d DSDT\n", version+1);
if (version) {
/* XXX aserebln why uint32 cast if pointer is uint64 ? */
acpi20_p = (uint64_t)(uint32_t)rsdp_mod;
acpi10_p = (uint64_t)(uint32_t)rsdp_mod;
addConfigurationTable(&gEfiAcpiTableGuid, &acpi10_p, "ACPI");
}
DBG("ACPI version %d patching finished\n\n", version+1);
}
#if DEBUG_ACPI
printf("Press a key to continue... (DEBUG_ACPI)\n");
branches/Bungo/i386/libsaio/device_tree.h
6767
6868
6969
70
71
72
7073
7174
7275
extern char *
DT__GetName(Node *node);
extern Property *
DT__GetProperty(Node *node, const char *name);
void
DT__Initialize(void);
branches/Bungo/i386/libsaio/bootargs.h
116116
117117
118118
119
119
120120
121121
122122
......
178178
179179
180180
181
181
182182
183183
184184
uint16_t Revision;/* Revision of boot_args structure */
uint16_t Version;/* Version of boot_args structure */
uint8_t efiMode; /* 32 = 32-bit, 64 = 64-bit */
uint8_t efiMode; /* 32 means 32-bit mode, 64 means 64-bit mode */
uint8_t debugMode; /* Bit field with behavior changes */
uint8_t __reserved1[2];
uint32_t efiRuntimeServicesPageCount;
uint32_t efiSystemTable; /* physical address of system table in runtime area */
uint8_t efiMode; /* 32 = 32-bit, 64 = 64-bit */
uint8_t efiMode; /* 32 means 32-bit mode, 64 means 64-bit mode */
uint8_t __reserved1[3];
uint32_t __reserved2[1];
uint32_t performanceDataStart; /* physical address of log */
branches/Bungo/i386/libsaio/device_inject.c
2020
2121
2222
23
23
2424
2525
2626
#if DEBUG_INJECT
#define DBG(x...)printf(x)
#else
#define DBG(x...)
#define DBG(x...)msglog(x)
#endif
uint32_t devices_number = 1;
branches/Bungo/i386/libsaio/sys.c
6565
6666
6767
68
6869
6970
7071
......
7677
7778
7879
80
81
82
83
84
85
7986
8087
8188
......
206213
207214
208215
209
216
210217
211218
212219
213220
214221
215222
216
223
224
217225
218226
219227
220228
229
221230
222231
223232
......
234243
235244
236245
237
246
238247
239248
240249
#include "disk.h"
#include "ramdisk.h"
#include "xml.h"
#include "sl.h"
#include <libkern/crypto/md5.h>
//#include <uuid/uuid.h>
static unsigned char kFSUUIDNamespaceSHA1[] = {0xB3,0xE2,0x0F,0x39,0xF2,0x92,0x11,0xD6,0x97,0xA4,0x00,0x30,0x65,0x43,0xEC,0xAC};
#endif
#if DEBUG
#define DBG(x...)printf(x)
#else
#define DBG(x...)msglog(x)
#endif
extern int multiboot_partition;
extern int multiboot_partition_set;
extern int multiboot_skip_partition;
if (readFile != NULL) {
// Read the first 4096 bytes (fat header)
length = readFile(bvr, (char *)filePath, *binary, 0, 0x1000);
if (length > 0) {
if (ThinFatFile(binary, &length) == 0) {
if (length == 0) {
return 0;
}
// We found a fat binary; read only the thin part
// We found a fat binary; read only the thin part
DBG("Fat Binary found. Reading thin part only...\n");
length = readFile(bvr, (char *)filePath, (void *)kLoadAddr, (unsigned long)(*binary) - kLoadAddr, length);
*binary = (void *)kLoadAddr;
} else {
// Not a fat binary; read the rest of the file
DBG("Thin Binary found. Reading rest of the file...\n");
length2 = readFile(bvr, (char *)filePath, (void *)(kLoadAddr + length), length, 0);
if (length2 == -1) {
ThinFatFile(binary, &length);
}
}
return length;
}
branches/Bungo/i386/libsaio/load.c
3232
3333
3434
35
36
37
38
39
40
3541
3642
3743
......
5460
5561
5662
57
63
5864
5965
60
66
6167
6268
6369
......
102108
103109
104110
105
111
106112
107113
108114
109115
110
111
112
113
114
115
116
117
118
119
120
116
117
118
119
120
121
122
123
124
125
126
127
121128
122129
123130
......
131138
132139
133140
134
141
135142
136143
137144
138
145
139146
140147
141148
......
201208
202209
203210
204
205
211
212
206213
207
208
214
215
209216
210
217
211218
212219
213220
#include <sl.h>
#if DEBUG
#define DBG(x...)printf(x)
#else
#define DBG(x...)msglog(x)
#endif
static long DecodeSegment(long cmdBase, unsigned int*load_addr, unsigned int *load_size);
static long DecodeUnixThread(long cmdBase, unsigned int *entry);
static long DecodeSymbolTable(long cmdBase);
uint32_t fapoffset;
uint32_t fapsize;
if (fhp->magic == FAT_MAGIC) {
if (fhp->magic == FAT_MAGIC)/* 0xcafebabe */{
nfat = fhp->nfat_arch;
swapped = 0;
} else if (fhp->magic == FAT_CIGAM) {
} else if (fhp->magic == FAT_CIGAM)/* 0xbebafeca */{
nfat = OSSwapInt32(fhp->nfat_arch);
swapped = 1;
} else {
unsigned long cnt;
long ret = -1;
unsigned int entry = 0;
gBinaryAddress = (unsigned long)binary;
mH = (struct mach_header *)(gBinaryAddress);
#if DEBUG
printf("magic: %x\n", (unsigned)mH->magic);
printf("cputype: %x\n", (unsigned)mH->cputype);
printf("cpusubtype: %x\n", (unsigned)mH->cpusubtype);
printf("filetype: %x\n", (unsigned)mH->filetype);
printf("ncmds: %x\n", (unsigned)mH->ncmds);
printf("sizeofcmds: %x\n", (unsigned)mH->sizeofcmds);
printf("flags: %x\n", (unsigned)mH->flags);
getchar();
#endif
/*#if DEBUG
DBG("magic: 0x%x\n", (unsigned)mH->magic);
DBG("cputype: 0x%x\n", (unsigned)mH->cputype);
DBG("cpusubtype: 0x%x\n", (unsigned)mH->cpusubtype);
DBG("filetype: 0x%x\n", (unsigned)mH->filetype);
DBG("ncmds: 0x%x\n", (unsigned)mH->ncmds);
DBG("sizeofcmds: 0x%x\n", (unsigned)mH->sizeofcmds);
DBG("flags: 0x%x\n", (unsigned)mH->flags);
DBG("archCpuType: 0x%x\n", archCpuType);
//getchar();
#endif*/
switch (archCpuType)
{
case CPU_TYPE_I386:
break;
case CPU_TYPE_X86_64:
/*
if (mH->magic != MH_MAGIC_64 && mH->magic == MH_MAGIC) {
return -1;
}
*/
if (mH->magic != MH_MAGIC_64) {
error("Mach-O file has bad magic number\n");
return -1;
cmdBase = cmdstart;
for (cnt = 0; cnt < ncmds; cnt++) {
cmd = ((long *)cmdBase)[0];
cmdsize = ((long *)cmdBase)[1];
cmd = ((long *)cmdBase)[0];
cmdsize = ((long *)cmdBase)[1];
if (cmd == LC_SYMTAB) {
if (DecodeSymbolTable(cmdBase) != 0) {
if (cmd == LC_SYMTAB) {
if (DecodeSymbolTable(cmdBase) != 0) {
return -1;
}
}
}
cmdBase += cmdsize;
branches/Bungo/i386/libsaio/platform.c
2020
2121
2222
23
23
2424
2525
2626
#if DEBUG_PLATFORM
#define DBG(x...)printf(x)
#else
#define DBG(x...)
#define DBG(x...)msglog(x)
#endif
PlatformInfo_t Platform;
branches/Bungo/i386/libsaio/cpu.c
261261
262262
263263
264
264
265265
266266
267
267
268268
269
269
270270
271271
272272
273273
274
274
275275
276276
277277
do_cpuid(0x80000001, p->CPU.CPUID[CPUID_81]);
}
#if DEBUG_CPU
// #if DEBUG_CPU
{
inti;
printf("CPUID Raw Values:\n");
DBG("CPUID Raw Values:\n");
for (i=0; i<CPUID_MAX; i++) {
printf("%02d: %08x-%08x-%08x-%08x\n", i,
DBG("%02d: %08x-%08x-%08x-%08x\n", i,
p->CPU.CPUID[i][0], p->CPU.CPUID[i][1],
p->CPU.CPUID[i][2], p->CPU.CPUID[i][3]);
}
}
#endif
// #endif
/*
EAX (Intel):
branches/Bungo/i386/libsaio/platform.h
3232
3333
3434
35
36
35
36
3737
3838
3939
......
177177
178178
179179
180
180
181181
182182
183183
#define CPU_MODEL_PENTIUM_M 0x09// Banias Pentium M (130nm)
#define CPU_MODEL_DOTHAN 0x0D// Dothan Pentium M, Celeron M (90nm)
#define CPU_MODEL_PRESCOTT 0x03// Celeron D, Pentium 4 (90nm)
#define CPU_MODEL_NOCONA 0x04// Xeon Nocona, Irwindale (90nm)
#define CPU_MODEL_NOCONA 0x03// Celeron D, Pentium 4 (90nm)
#define CPU_MODEL_IRWINDALE 0x04// Xeon Nocona, Irwindale (90nm)
#define CPU_MODEL_PRESLER 0x06// Pentium 4, Pentium D (65nm)
#define CPU_MODEL_CELERON 0x16// Merom, Conroe (65nm)
#define CPU_MODEL_YONAH 0x0E// Sossaman, Yonah
intDIMM[MAX_RAM_SLOTS];// Information and SPD mapping for each slot
} DMI;
uint8_tType;// System Type: 1=Desktop, 2=Portable... according ACPI2.0 (FACP: PM_Profile)
uint8_tType;// System Type: 1=Desktop, 2=Portable, 3=Workstation... according ACPI2.0 (FACP: PM_Profile)
uint8_t*UUID;
} PlatformInfo_t;
branches/Bungo/i386/libsaio/cpu.h
1010
1111
1212
13
13
1414
1515
1616
......
102102
103103
104104
105
106
105
106
107107
108
109
110
108
109
110
111111
112
112
113113
114114
115115
116116
117117
118
118
119119
120120
121121
122
123
122
123
124124
125125
126126
......
155155
156156
157157
158
158
159159
160160
161161
162162
163
163
164164
165
165
166166
167167
168
168
169169
170
170
171171
172172
173173
......
219219
220220
221221
222
223
224
225
222
223
224
225
226226
227227
228228
229229
230230
231231
232
233
234
235
232
233
234
235
236
236237
237238
238239
extern void scan_cpu(PlatformInfo_t *);
#define bit(n)(1ULL << (n))
#define bit(n)(1ULL << (n))
#define bitmask(h,l)((bit(h)|(bit(h)-1)) & ~(bit(l)-1))
#define bitfield(x,h,l)(((x) & bitmask(h,l)) >> l)
* The CPUID_EXTFEATURE_XXX values define 64-bit values
* returned in %ecx:%edx to a CPUID request with %eax of 0x80000001:
*/
#define CPUID_EXTFEATURE_SYSCALL _Bit(11)/* SYSCALL/sysret */
#define CPUID_EXTFEATURE_XD _Bit(20)/* eXecute Disable */
#define CPUID_EXTFEATURE_SYSCALL _Bit(11)/* SYSCALL/sysret */
#define CPUID_EXTFEATURE_XD _Bit(20)/* eXecute Disable */
#define CPUID_EXTFEATURE_1GBPAGE _Bit(26)/* 1GB pages */
#define CPUID_EXTFEATURE_RDTSCP _Bit(27)/* RDTSCP */
#define CPUID_EXTFEATURE_EM64T _Bit(29)/* Extended Mem 64 Technology */
#define CPUID_EXTFEATURE_1GBPAGE _Bit(26)/* 1GB pages */
#define CPUID_EXTFEATURE_RDTSCP _Bit(27)/* RDTSCP */
#define CPUID_EXTFEATURE_EM64T _Bit(29)/* Extended Mem 64 Technology */
#define CPUID_EXTFEATURE_LAHF _HBit(0)/* LAFH/SAHF instructions */
#define CPUID_EXTFEATURE_LAHF _HBit(0)/* LAFH/SAHF instructions */
/*
* The CPUID_EXTFEATURE_XXX values define 64-bit values
* returned in %ecx:%edx to a CPUID request with %eax of 0x80000007:
*/
#define CPUID_EXTFEATURE_TSCI _Bit(8)/* TSC Invariant */
#define CPUID_EXTFEATURE_TSCI _Bit(8)/* TSC Invariant */
#defineCPUID_CACHE_SIZE16/* Number of descriptor values */
#define CPUID_MWAIT_EXTENSION_Bit(0)/* enumeration of WMAIT extensions */
#define CPUID_MWAIT_BREAK_Bit(1)/* interrupts are break events */
#define CPUID_MWAIT_EXTENSION _Bit(0)/* enumeration of WMAIT extensions */
#define CPUID_MWAIT_BREAK _Bit(1)/* interrupts are break events */
//-- processor type -> p_type:
#define PT_OEM0x00// Intel Original OEM Processor;
#define IA32_ENERGY_PERF_BIAS0x01B0
#define MSR_PACKAGE_THERM_STATUS0x01B1
#define IA32_PLATFORM_DCA_CAP0x01F8
#define MSR_POWER_CTL0x01FC // MSR 000001FC 0000-0000-0004-005F
#define MSR_POWER_CTL0x01FC // MSR 000001FC 0000-0000-0004-005F
// Sandy Bridge & JakeTown specific 'Running Average Power Limit' MSR's.
#define MSR_RAPL_POWER_UNIT0x606 /* R/O */
//MSR 00000606 0000-0000-000A-1003
#define MSR_PKGC3_IRTL 0x60A /* RW time limit to go C3 */
#define MSR_PKGC3_IRTL0x60A /* RW time limit to go C3 */
// bit 15 = 1 -- the value valid for C-state PM
#define MSR_PKGC6_IRTL 0x60B /* RW time limit to go C6 */
#define MSR_PKGC6_IRTL0x60B /* RW time limit to go C6 */
//MSR 0000060B 0000-0000-0000-8854
//Valid + 010=1024ns + 0x54=84mks
#define MSR_PKGC7_IRTL 0x60C /* RW time limit to go C7 */
#define MSR_PKGC7_IRTL0x60C /* RW time limit to go C7 */
//MSR 0000060C 0000-0000-0000-8854
#define MSR_PKG_C2_RESIDENCY 0x60D /* same as TSC but in C2 only */
#define MSR_PKG_C2_RESIDENCY0x60D /* same as TSC but in C2 only */
#define MSR_PKG_RAPL_POWER_LIMIT0x610 //MSR 00000610 0000-A580-0000-8960
#define MSR_PKG_ENERGY_STATUS0x611 //MSR 00000611 0000-0000-3212-A857
{
asm volatile ("cpuid"
: "=a" (data[0]),
"=b" (data[1]),
"=c" (data[2]),
"=d" (data[3])
: "a" (selector));
"=b" (data[1]),
"=c" (data[2]),
"=d" (data[3])
: "a" (selector));
}
static inline void do_cpuid2(uint32_t selector, uint32_t selector2, uint32_t *data)
{
asm volatile ("cpuid"
: "=a" (data[0]),
"=b" (data[1]),
"=c" (data[2]),
"=d" (data[3])
: "a" (selector), "c" (selector2));
"=b" (data[1]),
"=c" (data[2]),
"=d" (data[3])
: "a" (selector),
"c" (selector2));
}
// DFE: enable_PIT2 and disable_PIT2 come from older xnu
branches/Bungo/i386/libsaio/smbios.c
127127
128128
129129
130
130
131131
132132
133133
================================================ */
//#define kSMBOemPlatformFeatureKey "SMoemplatformfeature"
/* ==================================================*/
/* =================================================*/
#define getFieldOffset(struct, field)((uint8_t)(uint32_t)&(((struct *)0)->field))
typedef struct
branches/Bungo/i386/libsaio/stringTable.c
6060
6161
6262
63
63
6464
6565
6666
......
254254
255255
256256
257
258
257
259258
260259
261260
break;
}
} else if (c == '\"') {
/* Premature end of key */
// Premature end of key
return 1;
}
if (c != *str++) {
#endif
char *
newStringForKey(char *key, config_file_t *config)
char *newStringForKey(char *key, config_file_t *config)
{
const char *val;
char *newstr;
branches/Bungo/i386/libsaio/fake_efi.c
7474
7575
7676
77
78
7977
78
79
80
8081
8182
8283
......
438439
439440
440441
442
441443
442444
443445
444446
445447
446448
447
449
450
451
452
453
454
455
456
457
458
448459
449460
450461
......
567578
568579
569580
570
581
571582
572583
573
574
575
584
585
586
576587
577
578
588
589
590
591
579592
580593
581594
......
598611
599612
600613
601
614
615
616
617
618
619
602620
603621
604622
......
618636
619637
620638
621
639
622640
623641
624642
......
674692
675693
676694
677
678
695
696
679697
680
698
681699
700
701
702
703
704
705
706
707
708
709
710
711
682712
683713
684714
......
776806
777807
778808
779
809
780810
781811
782812
/* Identify ourselves as the EFI firmware vendor */
static EFI_CHAR16 const FIRMWARE_VENDOR[] = {'C','h','a','m','e','l','e','o','n','_','2','.','2', 0};
static EFI_UINT32 const FIRMWARE_REVISION = 132; /* FIXME: Find a constant for this. */
// Bungo
//static EFI_UINT32 const FIRMWARE_REVISION = 132; /* FIXME: Find a constant for this. */
static EFI_UINT32 const FIRMWARE_REVISION = 0x0001000a; // got from real MBP6,1
// Bungo
/* Default platform system_id (fix by IntVar)
static EFI_CHAR8 const SYSTEM_ID[] = "0123456789ABCDEF"; //random value gen by uuidgen
*/
static const char FIRMWARE_VENDOR_PROP[] = "firmware-vendor";
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";
static const char SYSTEM_SERIAL_PROP[] = "SystemSerialNumber";
static const char SYSTEM_TYPE_PROP[] = "system-type";
static const char MODEL_PROP[] = "Model";
static const char BOARDID_PROP[] = "board-id";
static const char DEV_PATH_SUP[] = "DevicePathsSupported";
static uint32_t DevPathSup = 1;
static EFI_UINT32 DevPathSup = 1;
static EFI_UINT32 MachineSig = 0; //Bungo
static EFI_UINT8 const RANDOM_SEED[] =
{
0x40, 0x00, 0x50, 0x00, 0x5c, 0x00, 0x53, 0x00, 0x79, 0x00, 0x73, 0x00, 0x74, 0x00, 0x65, 0x00,
0x6d, 0x00, 0x5c, 0x00, 0x4c, 0x00, 0x69, 0x00, 0x62, 0x00, 0x72, 0x00, 0x61, 0x00, 0x72, 0x00,
0x79, 0x00, 0x5c, 0x00, 0x43, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x65, 0x00, 0x53, 0x00, 0x65, 0x00,
0x72, 0x00, 0x76, 0x00, 0x69, 0x00, 0x63, 0x00, 0x65, 0x00, 0x73, 0x00, 0x5c, 0x00, 0x62, 0x00
};
/*
* Get an smbios option string option to convert to EFI_CHAR16 string
*/
// 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);
} else {
DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_64_PROP_VALUE), (char*)FIRMWARE_ABI_64_PROP_VALUE);
}
} else { */
DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_64_PROP_VALUE), (char *)FIRMWARE_ABI_64_PROP_VALUE);
//}
DT__AddProperty(node, FIRMWARE_REVISION_PROP, sizeof(FIRMWARE_REVISION), (EFI_UINT32*)&FIRMWARE_REVISION);
DT__AddProperty(node, FIRMWARE_VENDOR_PROP, sizeof(FIRMWARE_VENDOR), (EFI_CHAR16*)FIRMWARE_VENDOR);
DT__AddProperty(node, EFI_MODE_PROP, sizeof(EFI_UINT8), (EFI_UINT8 *)&bootArgs->efiMode);
DT__AddProperty(node, FIRMWARE_REVISION_PROP, sizeof(FIRMWARE_REVISION), (EFI_UINT32 *)&FIRMWARE_REVISION);
DT__AddProperty(node, FIRMWARE_VENDOR_PROP, sizeof(FIRMWARE_VENDOR), (EFI_CHAR16 *)FIRMWARE_VENDOR);
// TODO: Fill in other efi properties if necessary
// all of the configuration tables needed by various kernel extensions.
gEfiConfigurationTableNode = DT__AddChild(node, "configuration-table");
// Now fill in the /efi/platform Node
// New node: /efi/kernel-compatibility
Node *efiKernelComNode = DT__AddChild(node, "kernel-compatibility");
len = 1;
DT__AddProperty(efiKernelComNode, "x86_64", sizeof(uint32_t), (EFI_UINT32 *)&len);
// Now fill in the /efi/platform Node
Node *efiPlatformNode = DT__AddChild(node, "platform");
// NOTE WELL: If you do add FSB Frequency detection, make sure to store
DT__AddProperty(efiPlatformNode, CPU_Frequency_prop, sizeof(uint64_t), &Platform.CPU.CPUFrequency);
}
DT__AddProperty(efiPlatformNode,DEV_PATH_SUP, sizeof(uint32_t), &DevPathSup);
DT__AddProperty(efiPlatformNode,DEV_PATH_SUP, sizeof(EFI_UINT32), &DevPathSup);
// Bungo
/* Export system-id. Can be disabled with SystemId=No in com.apple.Boot.plist
stop("Couldn't get chosen node");
}
int bootUUIDLength = strlen(gBootUUIDString);
if (bootUUIDLength)
int length = strlen(gBootUUIDString);
if (length)
{
DT__AddProperty(chosenNode, "boot-uuid", bootUUIDLength + 1, gBootUUIDString);
DT__AddProperty(chosenNode, "boot-uuid", length + 1, gBootUUIDString);
}
length = strlen(bootArgs->CommandLine);
DT__AddProperty(chosenNode, "boot-args", length + 1, bootArgs->CommandLine);
length = strlen(bootInfo->bootFile);
DT__AddProperty(chosenNode, "boot-file", length + 1, bootInfo->bootFile);
// DT__AddProperty(chosenNode, "boot-device-path", bootDPsize, gBootDP);
// DT__AddProperty(chosenNode, "boot-file-path", bootFPsize, gBootFP);
// DT__AddProperty(chosenNode, "boot-kernelchache-adler32", sizeof(adler32), adler32);
DT__AddProperty(chosenNode, "machine-signature", sizeof(EFI_UINT32), (EFI_UINT32 *)&MachineSig);
DT__AddProperty(chosenNode, "random-seed", sizeof(RANDOM_SEED), (EFI_UINT8*) &RANDOM_SEED);
}
/*
}
memcpy(tableAddress, (void *)origeps->dmi.tableAddress, origeps->dmi.tableLength);
DT__AddProperty(node, "SMBIOS-ORIG", origeps->dmi.tableLength, tableAddress); // Bungo: changed from SMBIOS to SMBIOS-ORIG to differentiate
DT__AddProperty(node, "SMBIOS", origeps->dmi.tableLength, tableAddress);
}
/*
branches/Bungo/i386/libsaio/smbios_getters.c
3030
3131
3232
33
3334
3435
3536
......
8586
8687
8788
89
8890
8991
9092
91
9293
9394
9495
......
163164
164165
165166
166
167
167168
169
170
171
168172
169173
170174
......
176180
177181
178182
179
183
180184
181185
182186
......
195199
196200
197201
198
202
199203
200204
201205
......
219223
220224
221225
222
226
223227
224228
225229
......
242246
243247
244248
245
249
246250
247251
248252
......
264268
265269
266270
267
271
268272
269273
270274
......
293297
294298
295299
296
300
297301
298302
299303
// set external clock to 0 for SANDY
// removes FSB info from system profiler as on real mac's.
case CPU_MODEL_SANDYBRIDGE:
case CPU_MODEL_JAKETOWN:
case CPU_MODEL_IVYBRIDGE_XEON:
case CPU_MODEL_IVYBRIDGE:
case CPU_MODEL_HASWELL:
case CPU_MODEL_NEHALEM_EX:// Intel Xeon X75xx, Xeon X65xx, Xeon E75xx, Xeon E65x
case CPU_MODEL_WESTMERE_EX:// Intel Xeon E7
case CPU_MODEL_SANDYBRIDGE:// Intel Core i3, i5, i7 LGA1155 (32nm)
case CPU_MODEL_JAKETOWN:// Intel Core i7, Xeon E5 LGA2011 (32nm)
case CPU_MODEL_IVYBRIDGE:// Intel Core i3, i5, i7 LGA1155 (22nm)
case CPU_MODEL_IVYBRIDGE_XEON:
case CPU_MODEL_HASWELL:
case CPU_MODEL_JAKETOWN:// Intel Core i7, Xeon E5 LGA2011 (32nm)
{
// thanks to dgobe for i3/i5/i7 bus speed detection
int nhm_bus = 0x3F;
switch (Platform.CPU.Model) {
case CPU_MODEL_PENTIUM_M:
case CPU_MODEL_DOTHAN:// 0x0D - Intel Pentium M model D
case CPU_MODEL_PRESCOTT:
case CPU_MODEL_IRWINDALE:
case CPU_MODEL_NOCONA:
if (strstr(Platform.CPU.BrandString, "Xeon")) {
value->word = 0x402;// 1026 - Xeon
}
return true;
case CPU_MODEL_PRESLER:
case CPU_MODEL_MEROM:// 0x0F - Intel Mobile Core 2 Solo, Duo, Xeon 30xx, Xeon 51xx, Xeon X53xx, Xeon E53xx, Xeon X32xx
case CPU_MODEL_XEON_MP:// 0x1D - Six-Core Xeon 7400, "Dunnington", 45nm
case CPU_MODEL_PENRYN:// 0x17 - Intel Core 2 Solo, Duo, Quad, Extreme, Xeon X54xx, Xeon X33xx
if (strstr(Platform.CPU.BrandString, "Xeon(R)")) {
if (strstr(Platform.CPU.BrandString, "Xeon")) {
value->word = 0x402;// 1026 - Xeon
return true;
}
case CPU_MODEL_NEHALEM:// 0x1A - Intel Core i7, Xeon W35xx, Xeon X55xx, Xeon E55xx LGA1366 (45nm)
case CPU_MODEL_FIELDS:// 0x1E - Intel Core i5, i7, Xeon X34xx LGA1156 (45nm)
case CPU_MODEL_DALES:// 0x1F - Intel Core i5, i7 LGA1156 (45nm) (Havendale, Auburndale)
if (strstr(Platform.CPU.BrandString, "Xeon(R)")) {
if (strstr(Platform.CPU.BrandString, "Xeon")) {
value->word = 0x501;// // 1281 - Lynnfiled Quad-Core Xeon
return true;
}
case CPU_MODEL_DALES_32NM:// 0x25 - Intel Core i3, i5 LGA1156 (32nm) (Clarkdale, Arrandale)
case CPU_MODEL_WESTMERE:// 0x2C - Intel Core i7, Xeon X56xx, Xeon E56xx, Xeon W36xx LGA1366 (32nm) 6 Core
case CPU_MODEL_WESTMERE_EX:// 0x2F - Intel Xeon E7
if (strstr(Platform.CPU.BrandString, "Xeon(R)")) {
if (strstr(Platform.CPU.BrandString, "Xeon")) {
value->word = 0x501;// Xeon
return true;
}
case CPU_MODEL_JAKETOWN:// 0x2D - Intel Core i7, Xeon E5-xxxx LGA2011 (32nm)
case CPU_MODEL_SANDYBRIDGE:// 0x2A - Intel Core i3, i5, i7 LGA1155 (32nm)
if (strstr(Platform.CPU.BrandString, "Xeon(R)")) {
if (strstr(Platform.CPU.BrandString, "Xeon")) {
value->word = 0x501;// Xeon
return true;
}
return true;
case CPU_MODEL_IVYBRIDGE:// 0x3A - Intel Core i3, i5, i7 LGA1155 (22nm)
if (strstr(Platform.CPU.BrandString, "Xeon(R)")) {
if (strstr(Platform.CPU.BrandString, "Xeon")) {
value->word = 0xA01;// 2561 - Xeon
return true;
}
case CPU_MODEL_HASWELL_SVR:// 0x3F -
case CPU_MODEL_HASWELL_ULT:// 0x45 -
case CPU_MODEL_CRYSTALWELL:// 0x46
if (strstr(Platform.CPU.BrandString, "Xeon(R)")) {
if (strstr(Platform.CPU.BrandString, "Xeon")) {
value->word = 0xA01;// 2561 - Xeon
return true;
}
branches/Bungo/i386/boot2/drivers.c
4040
4141
4242
43
43
44
45
46
47
4448
49
50
4551
4652
4753
......
837843
838844
839845
846
847
840848
841849
842850
843
851
844852
845
846
847
853
854
855
848856
849
857
850858
851859
852860
......
854862
855863
856864
857
865
858866
859867
860868
869
870
861871
862872
863
873
864874
865875
866876
......
873883
874884
875885
876
877886
878887
879888
880
881
889
882890
883
891
884892
885893
886894
887
888
895
896
889897
890
898
891899
892900
901
902
893903
894904
895905
......
898908
899909
900910
911
912
913
914
915
916
917
901918
902919
903920
......
908925
909926
910927
911
928
912929
913930
#include "ramdisk.h"
#include "modules.h"
//extern char gMacOSVersion[8];
#if DEBUG
#define DBG(x...)printf(x)
#else
#define DBG(x...)msglog(x)
#endif
// extern char gMacOSVersion[8];
struct Module {
struct Module *nextModule;
long willLoad;
static char gPlatformName[64];
#endif
char *gDarwinBuildVerStr = "Darwin Kernel Version"; // Bungo
long
DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize)
{
long ret;
long ret = 0;
compressed_kernel_header * kernel_header = (compressed_kernel_header *) binary;
u_int32_t uncompressed_size, size;
void *buffer;
unsigned long len;
u_int32_t uncompressed_size = 0, size = 0, adler32 = 0;
void *buffer = NULL;
unsigned long len = 0;
#if 0
/*#if 0
printf("kernel header:\n");
printf("signature: 0x%x\n", kernel_header->signature);
printf("compress_type: 0x%x\n", kernel_header->compress_type);
printf("uncompressed_size: 0x%x\n", kernel_header->uncompressed_size);
printf("compressed_size: 0x%x\n", kernel_header->compressed_size);
getchar();
#endif
#endif*/
if (kernel_header->signature == OSSwapBigToHostConstInt32('comp'))
{
DBG("Decompressing Kernel: ");
if (kernel_header->compress_type != OSSwapBigToHostConstInt32('lzss'))
{
error("kernel compression is bad\n");
error("ERROR: kernel compression is bad!\n");
return -1;
}
#if NOTDEF
return -1;
}
#endif
uncompressed_size = OSSwapBigToHostInt32(kernel_header->uncompressed_size);
binary = buffer = malloc(uncompressed_size);
size = decompress_lzss((u_int8_t *) binary, &kernel_header->data[0],
OSSwapBigToHostInt32(kernel_header->compressed_size));
size = decompress_lzss((u_int8_t *)binary, &kernel_header->data[0], OSSwapBigToHostInt32(kernel_header->compressed_size));
if (uncompressed_size != size) {
error("size mismatch from lzss: %x\n", size);
error("ERROR: size mismatch from lzss (found: %x, expected: %x).\n", size, uncompressed_size);
return -1;
}
if (OSSwapBigToHostInt32(kernel_header->adler32) !=
Adler32(binary, uncompressed_size))
adler32 = Adler32(binary, uncompressed_size);
if (OSSwapBigToHostInt32(kernel_header->adler32) != adler32)
{
printf("adler mismatch\n");
error("ERROR: adler mismatch (found: %x, expected: %x).\n", adler32, OSSwapBigToHostInt32(kernel_header->adler32));
return -1;
}
DBG("OK.\n");
}
ret = ThinFatFile(&binary, &len);
archCpuType=CPU_TYPE_I386;
ret = ThinFatFile(&binary, &len);
}
// Bungo: no range checking, sorry
size = 0;
while (memcmp((uint8_t *)binary + size, (uint8_t *)gDarwinBuildVerStr, 21)) {
size++;
}
gDarwinBuildVerStr = (char *)binary + size;
// Notify modules that the kernel has been decompressed, thinned and is about to be decoded
execute_hook("DecodeKernel", (void*)binary, NULL, NULL, NULL);
archCpuType=CPU_TYPE_I386;
ret = DecodeMachO(binary, rentry, raddr, rsize);
}
return ret;
}
branches/Bungo/i386/boot2/boot.c
5959
6060
6161
62
6263
64
65
66
67
68
69
70
71
72
73
6374
6475
6576
......
7586
7687
7788
78
89
7990
8091
8192
......
165176
166177
167178
168
169
170
171179
172180
173181
......
192200
193201
194202
203
204
205
206
195207
196208
197209
......
231243
232244
233245
234
246
235247
236248
237249
......
251263
252264
253265
254
255
256
257
258
259
266
267
268
269
270
271
260272
261273
262274
......
271283
272284
273285
274
275
276
286
277287
278288
279289
......
309319
310320
311321
312
322
313323
314324
315325
......
319329
320330
321331
322
332
323333
324334
325335
......
328338
329339
330340
331
341
332342
333343
334344
335345
336346
337
347
338348
339349
340350
......
379389
380390
381391
392
393
394
382395
383396
384397
385398
386
387
388399
389400
390401
......
603614
604615
605616
606
607
608617
609618
610619
......
623632
624633
625634
626
627
635
628636
629637
630638
631639
632
640
633641
634642
635643
......
679687
680688
681689
682
683
690
691
684692
685693
686694
#include "gui.h"
#include "platform.h"
#include "modules.h"
#include "device_tree.h"
#ifndef DEBUG_BOOT2
#define DEBUG_BOOT2 0
#endif
#if DEBUG_BOOT2
#define DBG(x...)printf(x)
#else
#define DBG(x...)msglog(x)
#endif
/*
* How long to wait (in seconds) to load the
* kernel after displaying the "boot:" prompt.
chargRootDevice[ROOT_DEVICE_SIZE];
chargMKextName[512];
chargMacOSVersion[8];
intbvCount = 0, gDeviceCount = 0;
intbvCount = 0, gDeviceCount = 0;
//intmenucount = 0;
longgBootMode; /* defaults to 0 == kBootModeNormal */
BVRefbvr, menuBVR, bvChain;
md0Ramdisk();
verbose("Starting Darwin %s\n",( archCpuType == CPU_TYPE_I386 ) ? "x86" : "x86_64");
verbose("Boot Args: %s\n", bootArgs->CommandLine);
// Cleanup the PXE base code.
if ( (gBootFileType == kNetworkDeviceType) && gUnloadPXEOnExit ) {
} else {
drawBootGraphics();
}
DBG("Starting Darwin/%s [%s]\n",( archCpuType == CPU_TYPE_I386 ) ? "x86" : "x86_64", gDarwinBuildVerStr);
DBG("Boot Args: %s\n", bootArgs->CommandLine);
setupBooterLog();
finalizeBootStruct();
unsigned long adler32;
if((gBootMode & kBootModeSafe) != 0) {
verbose("Kernel Cache ignored.\n");
DBG("Kernel Cache ignored.\n");
return -1;
}
else if (checkOSVersion("10.6")) {
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "kernelcache_%s",
(archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64");
int lnam = strlen(kernelCacheFile) + 9; //with adler32
char* name;
long prev_time = 0;
struct dirstuff* cacheDir = opendir(kDefaultCachePathSnow);
intlnam = strlen(kernelCacheFile) + 9; //with adler32
char*name;
longprev_time = 0;
structdirstuff* cacheDir = opendir(kDefaultCachePathSnow);
/* TODO: handle error? */
if (cacheDir) {
while(readdir(cacheDir, (const char**)&name, &flags, &time) >= 0) {
} else {
// Reset cache name.
bzero(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64);
snprintf(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64,
"%s,%s",
gRootDevice, bootInfo->bootFile);
snprintf(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64, "%s,%s", gRootDevice, bootInfo->bootFile);
adler32 = Adler32((unsigned char *)gCacheNameAdler, sizeof(gCacheNameAdler));
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%s.%08lX", kDefaultCachePathLeo, adler32);
}
// Exit if kernel cache file wasn't found
if (ret == -1) {
verbose("No Kernel Cache File '%s' found\n", kernelCacheFile);
DBG("No Kernel Cache File '%s' found\n", kernelCacheFile);
return -1;
}
// Check if the kernel file is more recent than the cache file
if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeFlat)
&& (kerneltime > cachetime)) {
verbose("Kernel file (%s) is more recent than KernelCache (%s), ignoring KernelCache\n",
DBG("Kernel file (%s) is more recent than Kernel Cache (%s)! Ignoring Kernel Cache.\n",
bootInfo->bootFile, kernelCacheFile);
return -1;
}
// Check if the S/L/E directory time is more recent than the cache file
if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory)
&& (exttime > cachetime)) {
verbose("/System/Library/Extensions is more recent than KernelCache (%s), ignoring KernelCache\n",
DBG("Folder: '/System/Library/Extensions' is more recent than Kernel Cache file (%s)! Ignoring Kernel Cache.\n",
kernelCacheFile);
return -1;
}
// Since the kernel cache file exists and is the most recent try to load it
verbose("Loading kernel cache %s\n", kernelCachePath);
DBG("Loading kernel cache: '%s'\n", kernelCachePath);
ret = LoadThinFatFile(kernelCachePath, binary);
return ret; // ret contain the length of the binary
// Record the device that the booter was loaded from.
gBIOSDev = biosdev & kBIOSDevMask;
// Initialize boot-log
initBooterLog();
// Initialize boot info structure.
initKernBootStruct();
initBooterLog();
// Setup VGA text mode.
// Not sure if it is safe to call setVideoMode() before the
// config table has been loaded. Call video_mode() instead.
HibernateBoot((char *)val);
break;
}
verbose("Loading Darwin %s\n", gMacOSVersion);
getBoolForKey(kUseKernelCache, &useKernelCache, &bootInfo->chameleonConfig);
if (useKernelCache) do {
}
if (gOverrideKernel && kernelCacheFile[0] == 0) {
verbose("Using a non default kernel (%s) without specifying 'Kernel Cache' path, KernelCache will not be used\n",
bootInfo->bootFile);
DBG("Using a non default kernel (%s) without specifying 'Kernel Cache' path, KernelCache will not be used\n", bootInfo->bootFile);
useKernelCache = false;
break;
}
if (gMKextName[0] != 0) {
verbose("Using a specific MKext Cache (%s), KernelCache will not be used\n",
DBG("Using a specific MKext Cache (%s), KernelCache will not be used\n",
gMKextName);
useKernelCache = false;
break;
// No alternate location found, using the original kernel image path.
strlcpy(bootFilePath, bootFile, sizeof(bootFilePath));
}
verbose("Loading kernel %s\n", bootFilePath);
DBG("Loading kernel: '%s'\n", bootFilePath);
ret = LoadThinFatFile(bootFilePath, &binary);
if (ret <= 0 && archCpuType == CPU_TYPE_X86_64)
{
branches/Bungo/i386/boot2/boot.h
5353
5454
5555
56
56
5757
5858
5959
6060
61
61
6262
6363
6464
65
65
6666
6767
6868
69
69
7070
7171
7272
7373
7474
75
76
77
78
75
76
77
78
7979
80
81
82
80
81
82
8383
8484
8585
86
87
88
86
87
88
8989
90
91
90
91
9292
9393
94
94
9595
9696
97
97
9898
99
100
99
100
101101
102102
103103
104
104
105105
106106
107107
108108
109109
110
110
111111
112112
113113
114114
115
115
116116
117117
118118
......
125125
126126
127127
128
129
130
128
129
130
131131
132132
133133
134134
135135
136
137
136
137
138138
139139
140140
......
147147
148148
149149
150
150
151151
152152
153153
154
154
155155
156156
157157
......
159159
160160
161161
162
162
163163
164164
165165
......
248248
249249
250250
251
251252
252253
253254
254
255255
256256
257257
#define kKernelCacheKey"Kernel Cache"
#define kUseKernelCache"UseKernelCache"/* boot.c */
#define kBootDeviceKey"Boot Device"
#define kTimeoutKey"Timeout"
#define kTimeoutKey"Timeout"
#define kRootDeviceKey"rd"
#define kBootUUIDKey"boot-uuid"
#define kHelperRootUUIDKey"Root UUID"
#define kPlatformKey"platform"
#define kACPIKey"acpi"
#define kACPIKey"acpi"
#define kCDROMPromptKey"CD-ROM Prompt"
#define kCDROMOptionKey"CD-ROM Option Key"
#define kRescanPromptKey"Rescan Prompt"
#define kRescanKey"Rescan"
#define kRescanKey"Rescan"
#define kScanSingleDriveKey"Scan Single Drive"
#define kInstantMenuKey"Instant Menu"
#define kDefaultKernel"mach_kernel"
#define kGUIKey"GUI"
#define kGUIKey"GUI"
#define kBootBannerKey"Boot Banner"
#define kShowInfoKey"ShowInfo"// gui.c
#define kWaitForKeypressKey"Wait"
/* AsereBLN: added these keys */
#define kUseAtiROM"UseAtiROM"/* ati.c */
#define kWake"Wake"/* boot.c */
#define kForceWake"ForceWake"/* boot.c */
#define kWakeImage"WakeImage"/* boot.c */
#define kUseAtiROM"UseAtiROM"/* ati.c */
#define kWake"Wake"/* boot.c */
#define kForceWake"ForceWake"/* boot.c */
#define kWakeImage"WakeImage"/* boot.c */
#define kProductVersion"ProductVersion"/* boot.c */
#define karch"arch"/* boot.c */
#define kDSDT"DSDT"/* acpi_patcher.c */
#define kDropSSDT"DropSSDT"/* acpi_patcher.c */
#define karch"arch"/* boot.c */
#define kDSDT"DSDT"/* acpi_patcher.c */
#define kDropSSDT"DropSSDT"/* acpi_patcher.c */
#define kDeviceProperties"device-properties"/* device_inject.c */
#define kHidePartition"Hide Partition"/* disk.c */
#define kRenamePartition"Rename Partition"/* disk.c */
#define kSMBIOSKey"SMBIOS"/* fake_efi.c */
#define kSystemID"SystemId"/* fake_efi.c */
#define kSystemType"SystemType"/* fake_efi.c */
#define kSMBIOSKey"SMBIOS"/* fake_efi.c */
#define kSystemID"SystemId"/* fake_efi.c */
#define kSystemType"SystemType"/* fake_efi.c */
#define kUseNvidiaROM"UseNvidiaROM"/* nvidia.c */
#define kVBIOS"VBIOS"/* nvidia.c && ati.c */
#define kPCIRootUID"PCIRootUID"/* pci_root.c */
#define kVBIOS"VBIOS"/* nvidia.c && ati.c */
#define kPCIRootUID"PCIRootUID"/* pci_root.c */
#define kEthernetBuiltIn"EthernetBuiltIn"/* pci_setup.c */
#define kGraphicsEnabler"GraphicsEnabler"/* pci_setup.c */
#define kForceHPET"ForceHPET"/* pci_setup.c */
#define kForceHPET"ForceHPET"/* pci_setup.c */
#define kUseMemDetect"UseMemDetect"/* platform.c */
#define kSMBIOSdefaults"SMBIOSdefaults"/* smbios_patcher.c */
#define kUSBBusFix"USBBusFix"/* usb.c */
#define kUSBBusFix"USBBusFix"/* usb.c */
#define kEHCIacquire"EHCIacquire"/* usb.c */
#define kUHCIreset"UHCIreset"/* usb.c */
#define kEHCIhard"EHCIhard"/* usb.c */
#define kUHCIreset"UHCIreset"/* usb.c */
#define kEHCIhard"EHCIhard"/* usb.c */
#define kDefaultPartition"Default Partition"/* sys.c */
/* Duvel300: added this */
#define kRestartFix"RestartFix"/* acpi_patcher.c */
#define kRestartFix"RestartFix"/* acpi_patcher.c */
/* Slice: added this */
#define kPS2RestartFix"PS2RestartFix"/* acpi_patcher.c */
/* Signal64: added this key */
#define kLegacyOff"USBLegacyOff"/* usb.c */
#define kLegacyOff"USBLegacyOff"/* usb.c */
/* Lebidou: added this key */
/* Meklort: added this key */
#define kMD0Image"md0"/* ramdisk.h */
#define kMD0Image"md0"/* ramdisk.h */
/* Andyvand: added these keys */
#define kEnableC4State"EnableC4State"/* acpi_patcher.c */
/* valv: added these keys */
#define kbusratio"busratio"/* cpu.c */
#define kDcfg0"display_0"/* nvidia.c */
#define kDcfg1"display_1"/* nvidia.c */
#define kbusratio"busratio"/* cpu.c */
#define kDcfg0"display_0"/* nvidia.c */
#define kDcfg1"display_1"/* nvidia.c */
/* Marchrius: added these keys */
#define kEnableBacklight"EnableBacklight"/* nvidia.c */
/* Kabyl: added these keys */
#define kAtiConfig"AtiConfig"/* ati.c */
#define kAtiPorts"AtiPorts"/* ati.c */
#define kAtiConfig"AtiConfig"/* ati.c */
#define kAtiPorts"AtiPorts"/* ati.c */
#define kATYbinimage"ATYbinimage"/* ati.c */
/* cosmo1: added these keys */
#define kNvidiaGeneric"NvidiaGeneric"/* nvidia.c */
#define kSkipIntelGfx"SkipIntelGfx"/* pci_setup.c */
#define kSkipNvidiaGfx"SkipNvidiaGfx"/* pci_setup.c */
#define kSkipAtiGfx"SkipAtiGfx"/* pci_setup.c */
#define kSkipAtiGfx"SkipAtiGfx"/* pci_setup.c */
#define kIntelCapriFB"IntelCapriFB"/* gma.c was HD4K-ig */
#define kIntelAzulFB"IntelAzulFB"/* gma.c was HD5K-ig */
#define kAAPLCustomIG"InjectIntel-ig"/* gma.c */
#define kHDAEnabler"HDAEnabler"/* pci_setup.c */
#define kHDAEnabler"HDAEnabler"/* pci_setup.c */
#define kHDEFLayoutID"HDEFLayoutID"/* hda.c */
#define kHDAULayoutID"HDAULayoutID"/* hda.c */
#define kMemFullInfo"ForceFullMemInfo"/* smbios.c */
/* Bungo: added these keys */
// mask private data or no
// mask private data
#define kPrivateData"PrivateData"/* smbios_decode.c */
/*
/*
* drivers.c
*/
extern char *gDarwinBuildVerStr; // Bungo
extern long LoadExtraDrivers(char * dirSpec);
extern long LoadDrivers(char * dirSpec);
extern long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize);
typedef long (*FileLoadDrivers_t)(char *dirSpec, long plugin);
/*!
Hookable function pointer called during the driver loading phase that
branches/Bungo/i386/boot2/options.c
3232
3333
3434
35
36
37
38
39
40
3541
3642
3743
......
12541260
12551261
12561262
1257
1263
12581264
12591265
12601266
12611267
1262
1268
12631269
12641270
12651271
12661272
1273
1274
1275
1276
1277
1278
12671279
12681280
12691281
......
12741286
12751287
12761288
1277
1289
12781290
12791291
12801292
1281
1293
12821294
12831295
12841296
12851297
1286
1287
1298
1299
1300
12881301
12891302
12901303
#include "pci.h"
#include "modules.h"
#if DEBUG
#define DBG(x...)printf(x)
#else
#define DBG(x...)msglog(x)
#endif
bool showBootBanner = true; //Azi:showinfo
static bool shouldboot = false;
}
}
}
/*
// Try to get the volume uuid string
if (!strlen(gBootUUIDString) && gBootVolume->fs_getuuid) {
gBootVolume->fs_getuuid(gBootVolume, gBootUUIDString);
}
*/
// If we have the volume uuid add it to the commandline arguments
if (strlen(gBootUUIDString)) {
copyArgument(kBootUUIDKey, gBootUUIDString, strlen(gBootUUIDString), &argP, &cntRemaining);
}
// Try to get the volume uuid string
if (!strlen(gBootUUIDString) && gBootVolume->fs_getuuid) {
gBootVolume->fs_getuuid(gBootVolume, gBootUUIDString);
DBG("boot-uuid: %s\n", gBootUUIDString);
}
}
if (!processBootArgument(kRootDeviceKey, cp, configKernelFlags, bootInfo->config,
cnt++;
strlcpy(valueBuffer + 1, val, cnt);
val = valueBuffer;
} else {
} else { /*
if (strlen(gBootUUIDString)) {
val = "*uuid";
cnt = 5;
} else {
} else { */
// Don't set "rd=.." if there is no boot device key
// and no UUID.
val = "";
cnt = 0;
}
}
/* } */
}
if (cnt > 0) {
copyArgument( kRootDeviceKey, val, cnt, &argP, &cntRemaining);
}

Archive Download the corresponding diff file

Revision: 2379