Chameleon

Chameleon Commit Details

Date:2015-01-26 01:51:07 (4 years 6 months ago)
Author:ErmaC
Commit:2564
Parents: 2563
Message:Sync with trunk(r.2563)
Changes:
M/branches/ErmaC/Enoch/CHANGES
M/branches/ErmaC/Enoch/i386/libsaio/saio_internal.h
M/branches/ErmaC/Enoch/i386/libsaio/smbios.c
M/branches/ErmaC/Enoch/i386/boot2/options.c
M/branches/ErmaC/Enoch/i386/libsaio/sys.c
M/branches/ErmaC/Enoch/i386/libsaio/convert.c
M/branches/ErmaC/Enoch/i386/boot2/drivers.c
M/branches/ErmaC/Enoch/i386/libsaio/smbios.h
M/branches/ErmaC/Enoch/i386/libsaio/saio_types.h
M/branches/ErmaC/Enoch/i386/libsaio/bootargs.h
M/branches/ErmaC/Enoch/i386/boot2/boot.c
M/branches/ErmaC/Enoch/i386/libsaio/bootstruct.c
M/branches/ErmaC/Enoch/i386/libsaio/fake_efi.c
M/branches/ErmaC/Enoch/i386/boot2/boot.h

File differences

branches/ErmaC/Enoch/i386/libsaio/bootstruct.c
119119
120120
121121
122
122
123123
124124
125125
void reserveKernBootStruct(void)
{
if ( LION || MOUNTAIN_LION || MAVERICKS || YOSEMITE )
if ( MacOSVerCurrent >= MacOSVer2Int("10.7") ) // OS X 10.7 and newer
{
// for 10.7 10.8 10.9 10.10
void *oldAddr = bootArgs;
branches/ErmaC/Enoch/i386/libsaio/bootargs.h
222222
223223
224224
225
226
227225
} boot_args_pre_lion;
extern char gMacOSVersion[8];
#endif /* _PEXPERT_I386_BOOT_H */
branches/ErmaC/Enoch/i386/libsaio/sys.c
374374
375375
376376
377
377
378
379
380
381
382
383
384
378385
379
380
381
382
386
383387
384388
385389
......
953957
954958
955959
956
960
961
962
963
964
965
957966
958967
959968
......
971980
972981
973982
983
984
974985
975986
976987
......
9941005
9951006
9961007
1008
1009
9971010
9981011
9991012
10001013
10011014
10021015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
10031044
10041045
10051046
......
10691110
10701111
10711112
1072
1073
1074
1113
1114
1115
10751116
10761117
10771118
return -1;
}
// Return 0 on success, or -1 if there are no additional entries.
if (bvr->fs_getdirentry)
{
// Returns 0 on success or -1 when there are no additional entries.
return bvr->fs_getdirentry( bvr,
/* dirPath */ (char *)dirPath,
/* dirIndex */ dirIndex,
/* dirEntry */ (char **)name, flags, time, 0, 0 );
}
return bvr->fs_getdirentry( bvr,
/* dirPath */ (char *)dirPath,
/* dirIndex */ dirIndex,
/* dirEntry */ (char **)name, flags, time, 0, 0 );
return -1;
}
//==========================================================================
{
bool filteredChain = false;
bool foundPrimary = false;
BVRef bvr, bvr1 = 0, bvr2 = 0;
BVRef bvr= NULL;
BVRef bvr1= NULL;
BVRef bvr2= NULL;
char dirSpec[] = "hd(%d,%d)/", fileSpec[] = "Volumes", *label;
u_int32_t time, lasttime = 0;
long flags;
if (chain->filtered)
{
if ( (bvr->part_no == multiboot_partition) && (bvr->biosdev == gBIOSDev) )
{
label = bvr->label[0] ? bvr->label : (bvr->altlabel[0] ? bvr->altlabel : (bvr->name[0] ? bvr->name : "Untitled"));
DBG("Multiboot partition set: hd(%d,%d) '%s'\n", BIOS_DEV_UNIT(bvr), bvr->part_no, label);
return bvr;
}
}
if (matchVolumeToString(bvr, val, false))
{
free(val);
label = bvr->label[0] ? bvr->label : (bvr->altlabel[0] ? bvr->altlabel : (bvr->name[0] ? bvr->name : "Untitled"));
DBG("User default partition set: hd(%d,%d) '%s'\n", BIOS_DEV_UNIT(bvr), bvr->part_no, label);
return bvr;
}
}
free(val);
}
// Bungo: select last booted partition as the boot volume
// TODO: support other OSes (foreign boot)
for (bvr = chain; bvr; bvr = bvr->next) {
if (bvr->flags & (kBVFlagSystemVolume | kBVFlagForeignBoot))
{
time = 0;
flags = 0;
sprintf(dirSpec, "hd(%d,%d)/", BIOS_DEV_UNIT(bvr), bvr->part_no);
if ((GetFileInfo(dirSpec, fileSpec, &flags, &time) == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory))
{
if (time > lasttime)
{
lasttime = time;
bvr1 = bvr;
label = bvr1->label[0] ? bvr1->label : (bvr1->altlabel[0] ? bvr1->altlabel : (bvr1->name[0] ? bvr1->name : "Untitled"));
}
}
}
}
if (bvr1)
{
DBG("Last booted volume: hd(%d,%d) '%s' set as default partition\n\n", BIOS_DEV_UNIT(bvr1), bvr1->part_no, label);
return bvr1;
}
// Bungo: code below selects first partition in the chain (last partition on disk),
// in my case Recovery HD, as boot volume, so I would prefer last booted partition
// as default boot volume - see the code above
/*
* Scannig the volume chain backwards and trying to find
* a HFS+ volume with valid boot record signature.
}
}
bvr = bvr2 ? bvr2 :
bvr1 ? bvr1 : chain;
bvr = bvr2 ? bvr2 : (bvr1 ? bvr1 : chain);
label = bvr->label[0] ? bvr->label : (bvr->altlabel[0] ? bvr->altlabel : (bvr->name[0] ? bvr->name : "Untitled"));
DBG("Default partition set: hd(%d,%d) '%s'\n", BIOS_DEV_UNIT(bvr), bvr->part_no, label);
return bvr;
}
branches/ErmaC/Enoch/i386/libsaio/smbios.c
807807
808808
809809
810
810
811811
812812
813813
814814
815815
816816
817
817
818818
819819
820820
......
12691269
12701270
12711271
1272
1273
1272
1273
12741274
12751275
12761276
12771277
1278
1279
1280
1278
1279
1280
12811281
12821282
12831283
......
13151315
13161316
13171317
1318
1319
1318
1319
13201320
13211321
13221322
......
13981398
13991399
14001400
1401
1401
14021402
14031403
14041404
......
14491449
14501450
14511451
1452
1452
14531453
14541454
14551455
14561456
14571457
1458
1459
1460
1461
1462
1463
14641458
14651459
14661460
14671461
14681462
1469
1470
1471
1463
1464
1465
1466
1467
1468
14721469
14731470
1471
1472
1473
14741474
14751475
1476
1476
14771477
14781478
14791479
char *getSMBStringForField(SMBStructHeader *structHeader, uint8_t field)
{
if (!field)
if (!field || !structHeader)
{
return NULL;
}
uint8_t *stringPtr = (uint8_t *)structHeader + structHeader->length;
for (field--; field != 0 && strlen((char *)stringPtr) > 0;
for (field--; (field > 0) && (*stringPtr > 0) &&(*(uint16_t *)stringPtr != 0);
field--, stringPtr = (uint8_t *)((uint32_t)stringPtr + strlen((char *)stringPtr) + 1));
return (char *)stringPtr;
addSMBEndOfTable(structPtr);
}
// Bungo: does fix system uuid in SMBIOS (and EFI) instead of in EFI only
uint8_t *FixSystemUUID()
// Bungo: does fix system uuid in SMBIOS & EFI instead of in EFI (IODT/efi/platform/system-id) only
uint8_t *fixSystemUUID()
{
uint8_t *ptr = (uint8_t *)neweps->dmi.tableAddress;
SMBStructHeader *structHeader = (SMBStructHeader *)ptr;
int i, isZero, isOnes;
uint8_t FixedUUID[UUID_LEN] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
const char *sysId = getStringForKey(kSMBSystemInformationUUIDKey, SMBPlist);
uint8_t *ret = (uint8_t *)getUUIDFromString(sysId);
uint8_t fixedUUID[UUID_LEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
const char *sysId = getStringForKey(kSMBSystemInformationUUIDKey, SMBPlist); // try to get user's uuid from smbios.plist
uint8_t *ret = (uint8_t *)getUUIDFromString(sysId); // convert user's uuid from string
for (;(structHeader->type != kSMBTypeSystemInformation);) // find System Information Table (Type 1) in patched SMBIOS
{
if (isZero || isOnes) // if empty or setable...
{
verbose("No UUID present in SMBIOS System Information Table\n");
ret = FixedUUID; // ...set a fixed value for system-id = 000102030405060708090A0B0C0D0E0F
verbose("System UUID: incorrect or not present. Fixing [00112233-4455-6677-8899-AABBCCDDEEFF]\n");
ret = fixedUUID; // ...set a fixed value for system uuid: <00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF>
}
memcpy(ptr, ret, UUID_LEN); // save uuid into the patched SMBIOS Table 1
memcpy((void *)neweps->dmi.tableAddress, buffer, tableLength);
Platform.UUID = FixSystemUUID(); // Bungo: fix System UUID
Platform.UUID = fixSystemUUID(); // Bungo: fix System UUID
neweps->dmi.checksum= 0;
neweps->dmi.checksum= 0x100 - checksum8(&neweps->dmi, sizeof(DMIEntryPoint));
switch (structHeader->type)
{
case kSMBTypeSystemInformation:
Platform.UUID = ((SMBSystemInformation *)structHeader)->uuid; // get factory system uuid
Platform.UUID = ((SMBSystemInformation *)structHeader)->uuid; // save factory system uuid
break;
case kSMBTypeSystemEnclosure: // Bungo: determine platform type
switch (((SMBSystemEnclosure *)structHeader)->chassisType)
{
case kSMBchassisDesktop:
case kSMBchassisLPDesktop:
case kSMBchassisAllInOne:
case kSMBchassisLunchBox:
PlatformType = 1; // desktop (iMac, MacMini)
break;
case kSMBchassisPortable:
case kSMBchassisLaptop:
case kSMBchassisNotebook:
case kSMBchassisHandHeld:
case kSMBchassisSubNotebook:
PlatformType = 2; // notebook (Mac Books)
break;
default:
PlatformType = 2; // notebook (MacBooks/Pros)
break;
case kSMBchassisMiniTower:
case kSMBchassisTower:
case kSMBchassisBlade:
case kSMBchassisBladeEnclosing:
PlatformType = 3; // workstation (Mac Pro, Xserve)
break;
default:
PlatformType = 1; // defulting to 1 desktop (iMac, MacMini)
break;
}
break;
//
case kSMBTypePhysicalMemoryArray:
Platform.DMI.MaxMemorySlots += ((SMBPhysicalMemoryArray *)structHeader)->numMemoryDevices;
break;
branches/ErmaC/Enoch/i386/libsaio/smbios.h
239239
240240
241241
242
242243
244
243245
244246
245247
......
283285
284286
285287
286
288
287289
288290
289291
kSMBchassisSubNotebook = 0x0E,
// ... fill up if needed ;-)
kSMBchassisLunchBox = 0x10,
kSMBchassisMainServer = 0x11,
// ... fill up if needed ;-)
kSMBchassisBlade = 0x1C,
kSMBchassisBladeEnclosing = 0x1D
} MISC_CHASSIS_TYPE;
SMBByte height;// Height of the enclosure, in 'U's
SMBByte numberOfPowerCords;// Number of power cords associated with the enclosure or chassis
SMBByte containedElementCount;// Number of Contained Element record that follow, in the range 0 to 255
//SMBByte containedElementRecord;// Byte leght of each Contained Element record that follow, in the range 0 to 255
SMBByte containedElementRecord;// Byte leght of each Contained Element record that follow, in the range 0 to 255
//SMBByte containedElements;// Elements, possibly defined by other SMBIOS structures present in chassis
// 2.7+
//SMBString skuNumber;// Number of null-terminated string describing the chassis or enclosure SKU number
branches/ErmaC/Enoch/i386/libsaio/convert.c
2929
3030
3131
32
33
34
35
36
37
38
3239
33
3440
3541
3642
return 0;
}
inti = strlen(source);
if (i != 36)
{ // e.g 00112233-4455-6677-8899-AABBCCDDEEFF
verbose("[ERROR] UUID='%s' has incorrect length=%d. Use format: 00112233-4455-6677-8899-AABBCCDDEEFF.\n", source, i);
return 0;
}
char*p = (char *)source;
inti;
charbuf[3];
static EFI_CHAR8 uuid[UUID_LEN+1] = "";
branches/ErmaC/Enoch/i386/libsaio/saio_types.h
182182
183183
184184
185
185
186
186187
187188
188189
......
209210
210211
211212
212
213
213214
214
215
215216
216217
217218
BVRef dir_bvr;/* volume reference */
};
#define BVSTRLEN 32
#define BVSTRLEN 36 // changed from 32 to 36 due to gpt partition name length
#define OSVERSTRLEN 9
struct BootVolume {
BVRefnext;/* list linkage pointer */
charaltlabel[BVSTRLEN];/* alternate partition volume label */
boolfiltered;/* newFilteredBVChain() will set to TRUE */
boolvisible;/* will shown in the device list */
charOSVersion[8];
charOSVersion[OSVERSTRLEN]; /* Null terminated string from '/System/Library/CoreServices/SystemVersion.plist/ProductVersion' e.g. "10.10.10" - hope will not reach e.g. 111.222.333 soon:) If so, OSVERSTRLEN 9 change to 12 */
boolOSisServer;/* 1 = OS X server , 0 = OS X client */
boolOSisInstaller;/* 1 = OS X Install partition / recover partition , 0 = OS X Install */
boolOSisInstaller;/* 1 = OS X Install partition / recovery partition , 0 = OS X Install */
};
branches/ErmaC/Enoch/i386/libsaio/fake_efi.c
585585
586586
587587
588
588
589
589590
590
591
592
593
594
591595
592596
593597
......
602606
603607
604608
605
609
610
606611
607612
608613
609614
610615
611616
612
617
618
619
613620
614621
615622
......
717724
718725
719726
720
727
721728
722729
723730
......
729736
730737
731738
732
739
733740
734741
735742
......
895902
896903
897904
898
905
899906
900907
901908
// 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) {
if (archCpuType == CPU_TYPE_I386)
{
DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_32_PROP_VALUE), (char*)FIRMWARE_ABI_32_PROP_VALUE);
} else { */
}
else
{
*/
DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_64_PROP_VALUE), (char *)FIRMWARE_ABI_64_PROP_VALUE);
//}
// is set up. That is, name and table properties
Node *runtimeServicesNode = DT__AddChild(node, "runtime-services");
if (archCpuType == CPU_TYPE_I386) {
if (archCpuType == CPU_TYPE_I386)
{
// The value of the table property is the 32-bit physical address for the RuntimeServices table.
// Since the EFI system table already has a pointer to it, we simply use the address of that pointer
// for the pointer to the property data. Warning.. DT finalization calls free on that but we're not
// the only thing to use a non-malloc'd pointer for something in the DT
DT__AddProperty(runtimeServicesNode, "table", sizeof(uint64_t), &gST32->RuntimeServices);
} else {
}
else
{
DT__AddProperty(runtimeServicesNode, "table", sizeof(uint64_t), &gST64->RuntimeServices);
}
DT__AddProperty(chosenNode, "machine-signature", sizeof(EFI_UINT32), (EFI_UINT32 *)&MachineSig);
if(YOSEMITE)
if (MacOSVerCurrent >= MacOSVer2Int("10.10"))
{
//
// Pike R. Alpha - 12 October 2014
EFI_UINT32 rcx, rdx, rsi, rdi;
randomValue = tempValue = ecx = esi = edi = 0;// xor%ecx,%ecx
rcx = rdx = rsi = rdi = cpuTick = 0;
cpuTick = rcx = rdx = rsi = rdi = 0;
// LEAF_1 - Feature Information (Function 01h).
if (Platform.CPU.CPUID[CPUID_1][2] & 0x40000000)// Checking ecx:bit-30
*/
void setupFakeEfi(void)
{
// Generate efi device strings
// Generate efi device strings
setup_pci_devs(root_pci_dev);
readSMBIOSInfo(getSmbios(SMBIOS_ORIGINAL));
branches/ErmaC/Enoch/i386/libsaio/saio_internal.h
224224
225225
226226
227
228
229
230
231
227232
// Base64-decode.c
char *BASE64Decode(const char* src, int in_len, int* out_len);
// options.c
extern char gMacOSVersion[OSVERSTRLEN];
extern uint32_t MacOSVerCurrent;
extern uint32_t MacOSVer2Int(const char *osver);
#endif /* !__LIBSAIO_SAIO_INTERNAL_H */
branches/ErmaC/Enoch/i386/boot2/drivers.c
116116
117117
118118
119
120
119
120
121121
122122
123123
......
249249
250250
251251
252
252
253253
254254
255255
......
981981
982982
983983
984
985
986
987
984
985
986
987
988
989
988990
989
991
992
993
994
995
996
997
998
990999
9911000
9921001
static char*gFileSpec;
static char*gTempSpec;
static char*gFileName;
// Bungo
char *gDarwinBuildVerStr = "Darwin Kernel Version";
// Bungo:
char gDarwinBuildVerStr[256] = "Darwin Kernel Version";
/*static*/ unsigned long
Adler32( unsigned char *buffer, long length )
}
else
{
if ( MAVERICKS || YOSEMITE ) // issue 352
if (MacOSVerCurrent >= MacOSVer2Int("10.9")) // issue 352
{
strlcpy(gExtensionsSpec, dirSpec, 4087); /* 4096 - sizeof("Library/") */
strcat(gExtensionsSpec, "Library/");
ret = ThinFatFile(&binary, &len);
}
// Bungo: no range checking, sorry
size = 0;
while (memcmp((uint8_t *)binary + size, (uint8_t *)gDarwinBuildVerStr, 21)) {
size++;
// Bungo: scan binary for Darwin Kernel Version string
uint32_t offset = 0;
strncpy(gDarwinBuildVerStr, "Darwin Kernel Version", sizeof(gDarwinBuildVerStr));
while ((offset < 0xFFFFFFFF - (uint32_t)binary - 256) && memcmp(binary + offset, gDarwinBuildVerStr, 21))
{
offset++;
}
gDarwinBuildVerStr = (char *)binary + size;
if (offset < 0xFFFFFFFF - (uint32_t)binary - 256)
{
strncpy(gDarwinBuildVerStr, (char *)(binary + offset), sizeof(gDarwinBuildVerStr));
}
else
{
strcat(gDarwinBuildVerStr, ": Unknown");
}
// Notify modules that the kernel has been decompressed, thinned and is about to be decoded
execute_hook("DecodeKernel", (void *)binary, NULL, NULL, NULL);
branches/ErmaC/Enoch/i386/boot2/boot.c
8484
8585
8686
87
8887
8988
9089
......
220219
221220
222221
223
222
224223
225224
226
225
227226
228227
229228
......
267266
268267
269268
270
269
270
271271
272
273
274272
275
273
276274
277275
278
276
279277
280
281
278
279
280
281
282282
283283
284284
......
304304
305305
306306
307
308
309
310
311
312
307
308
309
310
311
312
313
314
313315
314316
315317
......
386388
387389
388390
389
391
390392
391393
392394
......
604606
605607
606608
607
609
608610
611
612
613
614
609615
610616
611617
......
745751
746752
747753
748
754
749755
750
756
751757
752758
753759
754
760
755761
756762
757763
......
782788
783789
784790
785
791
786792
787793
788794
......
871877
872878
873879
880
881
882
883
884
885
874886
875887
876888
chargRootDevice[ROOT_DEVICE_SIZE];
chargMKextName[512];
chargMacOSVersion[8];
intbvCount = 0;
intgDeviceCount = 0;
//intmenucount = 0;
finalizeBootStruct();
// Jump to kernel's entry point. There's no going back now.
if ( LION || MOUNTAIN_LION || MAVERICKS || YOSEMITE )
if (MacOSVerCurrent >= MacOSVer2Int("10.7"))
{
// Notify modules that the kernel is about to be started
execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgs, NULL, NULL);
execute_hook("Kernel Start", (void *)kernelEntry, (void *)bootArgs, NULL, NULL);
// Masking out so that Lion doesn't doublefault
}
else
{
if ( LION || MOUNTAIN_LION || MAVERICKS || YOSEMITE)
// Lion, Mountain Lion, Mavericks and Yosemite prelink kernel cache file
if (MacOSVerCurrent >= MacOSVer2Int("10.7")) // OSX is Lion (10.7) or newer
{
// Lion, Mountain Lion, Mavericks, and Yosemite prelink kernel cache file
// for 10.7 10.8 10.9 10.10
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", kDefaultCachePathSnow);
verbose("Kernel Cache file path (Mac OS X 10.7 and newer): %s\n", kernelCacheFile);;
verbose("Kernel Cache file path (Mac OS X 10.7 and newer): %s\n", kernelCacheFile);
}
// Snow Leopard prelink kernel cache file
else if ( SNOW_LEOPARD )
else
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "kernelcache_%s",
(archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64");
if (MacOSVerCurrent >= MacOSVer2Int("10.6")) // OSX is Snow (10.6)
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "kernelcache_%s",
(archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64");
intlnam = strlen(kernelCacheFile) + 9; //with adler32
char*name;
}
else
{
// Reset cache name.
bzero(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64);
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);
verbose("Reseted kernel cache file path: %s\n", kernelCacheFile);;
// Leopard prelink kernel cache file
// Reset cache name.
bzero(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64);
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);
verbose("Reseted kernel cache file path: %s\n", kernelCacheFile);
}
}
}
}
// Since the kernel cache file exists and is the most recent try to load it
DBG("Loading Kernel Cache from: '%s'\n", kernelCachePath);
DBG("Loading Kernel Cache from: '%s%s' (%s)\n", gBootVolume->label, gBootVolume->altlabel, gBootVolume->type_name);
ret = LoadThinFatFile(kernelCachePath, binary);
return ret; // ret contain the length of the binary
if (getValueForKey(karch, &val, &len, &bootInfo->chameleonConfig))
{
if (strncmp(val, "i386", 4) == 0)
if (strncmp(val, "x86_64", 4) == 0)
{
archCpuType = CPU_TYPE_X86_64;
}
else if (strncmp(val, "i386", 4) == 0)
{
archCpuType = CPU_TYPE_I386;
}
else
// bootFile must start with a / if it not start with a device name
if (!bootFileWithDevice && (bootInfo->bootFile)[0] != '/')
{
if ( !YOSEMITE )
if (MacOSVerCurrent >= MacOSVer2Int("10.10")) // OSX is 10.10 or newer
{
snprintf(bootFile, sizeof(bootFile), "/%s", bootInfo->bootFile); // append a leading /
snprintf(bootFile, sizeof(bootFile), kDefaultKernelPathForYos "%s", bootInfo->bootFile); // Yosemite
}
else
{
snprintf(bootFile, sizeof(bootFile), kDefaultKernelPathForYos"%s", bootInfo->bootFile); // Yosemite
snprintf(bootFile, sizeof(bootFile), "/%s", bootInfo->bootFile); // append a leading '/'
}
}
else
strlcpy(bootFilePath, bootFile, sizeof(bootFilePath));
}
DBG("Loading kernel from: '%s'\n", bootFilePath);
DBG("Loading kernel from: '%s' (%s)\n", gBootVolume->label, gBootVolume->type_name);
ret = LoadThinFatFile(bootFilePath, &binary);
if (ret <= 0 && archCpuType == CPU_TYPE_X86_64)
{
}
}
uint32_t getMacOSVerCurrent()
{
MacOSVerCurrent = MacOSVer2Int(gBootVolume->OSVersion);
return MacOSVerCurrent;
}
#define BASE 65521L /* largest prime smaller than 65536 */
#define NMAX 5000
// NMAX (was 5521) the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1
branches/ErmaC/Enoch/i386/boot2/boot.h
3030
3131
3232
33
34
35
36
37
38
39
33
34
35
36
37
38
39
4040
4141
4242
......
191191
192192
193193
194
194
195195
196196
197
197
198198
199199
200200
......
257257
258258
259259
260
260
261
262
261263
262264
263265
......
303305
304306
305307
306
307
308
309
308310
309311
310312
#include "libsaio.h"
// OS X Versions
#define YOSEMITE checkOSVersion("10.10") // Yosemite
#define MAVERICKS checkOSVersion("10.9") // Mavericks
#define MOUNTAIN_LION checkOSVersion("10.8") // Mountain Lion
#define LION checkOSVersion("10.7") // Lion
#define SNOW_LEOPARD checkOSVersion("10.6") // Snow Leopard
#define LEOPARD checkOSVersion("10.5") // Leopard
#define TIGER checkOSVersion("10.4") // Tiger
//#define YOSEMITE checkOSVersion("10.10") // Yosemite
//#define MAVERICKS checkOSVersion("10.9") // Mavericks
//#define MOUNTAIN_LION checkOSVersion("10.8") // Mountain Lion
//#define LION checkOSVersion("10.7") // Lion
//#define SNOW_LEOPARD checkOSVersion("10.6") // Snow Leopard
//#define LEOPARD checkOSVersion("10.5") // Leopard
//#define TIGER checkOSVersion("10.4") // Tiger
/*
* Paths used by chameleon
/* ErmaC: added these keys */
#define kEnableDualLink"EnableDualLink"/* ati.c && nvidia.c && gma.c*/
#define kNvidiaGeneric"NvidiaGeneric"/* nvidia.c */
#define kSkipIntelGfx"SkipIntelGfx"/* pci_setup.c */
#define kSkipIntelGfx"SkipIntelGfx"/* pci_setup.c */
#define kSkipNvidiaGfx"SkipNvidiaGfx"/* pci_setup.c */
#define kSkipAtiGfx"SkipAtiGfx"/* pci_setup.c */
//#define kUsbInject"USBInject"/* usb.c */
//#define kUsbInject"USBInject"/* usb.c */
#define kIntelCapriFB"IntelCapriFB"/* gma.c was HD4K-ig */
#define kIntelAzulFB"IntelAzulFB"/* gma.c was HD5K-ig */
#define kAAPLCustomIG"InjectIntel-ig"/* gma.c */
extern void initialize_runtime();
extern void common_boot(int biosdev);
bool checkOSVersion(const char * version);
extern bool checkOSVersion(const char * version);
extern uint32_t getMacOSVerCurrent();
/*
* usb.c
*/
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);
// Bungo
extern char *gDarwinBuildVerStr;
// Bungo:
extern char gDarwinBuildVerStr[256];
/*!
Hookable function pointer called during the driver loading phase that
branches/ErmaC/Enoch/i386/boot2/options.c
3838
3939
4040
41
42
41
42
43
44
4345
4446
4547
......
6567
6668
6769
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
68117
69118
70119
......
12301279
12311280
12321281
1233
1234
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
12351294
12361295
12371296
......
12671326
12681327
12691328
1270
1329
12711330
12721331
12731332
12741333
1275
1276
1334
1335
12771336
12781337
12791338
12801339
12811340
1282
1341
12831342
1284
1285
1286
1287
1288
1343
12891344
1290
1291
1292
1293
1294
1295
1296
1297
12981345
12991346
1300
1347
13011348
13021349
13031350
......
13491396
13501397
13511398
1352
13531399
13541400
1401
13551402
13561403
13571404
......
13631410
13641411
13651412
1413
1414
1415
1416
13661417
13671418
1368
1419
13691420
13701421
13711422
13721423
13731424
13741425
1375
1426
13761427
13771428
13781429
13791430
1380
1431
13811432
1382
1433
13831434
13841435
13851436
13861437
1438
13871439
13881440
13891441
#define DBG(x...)msglog(x)
#endif
bool showBootBanner = true; //Azi:showinfo
static bool shouldboot = false;
chargMacOSVersion[OSVERSTRLEN];
uint32_tMacOSVerCurrent = 0;
boolshowBootBanner = true; //Azi:showinfo
static boolshouldboot = false;
extern int multiboot_timeout;
extern int multiboot_timeout_set;
//==========================================================================
// MacOSVer2Int - converts OS ver. string to uint32 (e.g "10.9.5" -> 0x0A090500) for easy comparing
uint32_t MacOSVer2Int(const char *osver)
{
uint32_t result = 0;
uint8_t *resptr = (uint8_t *)&result;
uint8_t len = strlen(osver);
uint8_t i, j, m;
#define CHR2UINT(c) ((uint8_t)(c - '0'))
#define ISDIGIT(c) ((c >= '0') && (c <= '9'))
#define ISDOT(c) (c == '.')
if (!osver || (len < 4) || (len > OSVERSTRLEN - 1) || !ISDIGIT(osver[0]) || !ISDOT(osver[2]) || !ISDIGIT(osver[len - 1]))
{
verbose("ERROR: wrong Mac OS version string syntax: '%s'\n", osver);
return 0;
}
for (i = 0, j = 3, m = 1; i < len; i++)
{
if (ISDIGIT(osver[i]))
{
resptr[j] = resptr[j] * m + CHR2UINT(osver[i]);
m = 10;
}
else if (ISDOT(osver[i]))
{
if (j > 0)
{
j--;
}
else
{
return 0;
}
m = 1;
}
else
{
return 0;
}
}
return result;
}
//==========================================================================
typedef struct {
int x;
int y;
return -1;
}
// Find out which version mac os we're booting.
strncpy(gMacOSVersion, gBootVolume->OSVersion, sizeof(gMacOSVersion));
// Save a version of mac os we're booting.
MacOSVerCurrent = MacOSVer2Int(gBootVolume->OSVersion);
// so copy it and trim
gMacOSVersion[0] = 0;
if (MacOSVerCurrent >= MacOSVer2Int("10.10"))
{
strncat(gMacOSVersion, gBootVolume->OSVersion, 5);
}
else
{
strncat(gMacOSVersion, gBootVolume->OSVersion, 4);
}
// Load config table specified by the user, or use the default.
}
else
{
if( YOSEMITE ) // is 10.10
if (MacOSVerCurrent >= MacOSVer2Int("10.10")) // OS X is 10.10 or newer
{
strlcpy( bootInfo->bootFile, kOSXKernel, sizeof(bootInfo->bootFile) );
}
else
{ // OSX is not 10.10
{
// or 10.9 and previous
strlcpy( bootInfo->bootFile, kDefaultKernel, sizeof(bootInfo->bootFile) );
}
}
}
if (!YOSEMITE) // not 10.10 so 10.9 and previus
if ((strcmp( bootInfo->bootFile, kDefaultKernel ) != 0) && (strcmp( bootInfo->bootFile, kOSXKernel ) != 0))
{
if (strcmp( bootInfo->bootFile, kDefaultKernel ) != 0)
{
//printf(HEADER "org.chameleon.Boot.plist found path for custom '%s' found!\n", bootInfo->bootFile);
gOverrideKernel = true;
}
gOverrideKernel = true;
}
else
{ // OSX is 10.10
if (strcmp( bootInfo->bootFile, kOSXKernel ) != 0)
{
//printf(HEADER "org.chameleon.Boot.plist found path for custom '%s' found!\n", bootInfo->bootFile);
gOverrideKernel = true;
}
}
// Ermac : Inject "kext-dev-mode=1" if OS X 10.10 is detected
if( YOSEMITE ) // is 10.10
if (MacOSVerCurrent >= MacOSVer2Int("10.10")) // OS X is 10.10 or newer
{
addBootArg("kext-dev-mode=1");
}
if (!strlen(gBootUUIDString) && gBootVolume->fs_getuuid)
{
gBootVolume->fs_getuuid(gBootVolume, gBootUUIDString);
DBG("boot-uuid: %s\n", gBootUUIDString);
}
}
DBG("Boot UUID [%s (%s), %s]: %s\n", gBootVolume->label, gBootVolume->altlabel, gBootVolume->type_name, gBootUUIDString);
if (!processBootArgument(kRootDeviceKey, cp, configKernelFlags, bootInfo->config,
&argP, &cntRemaining, gRootDevice, ROOT_DEVICE_SIZE))
cnt++;
strlcpy(valueBuffer + 1, val, cnt);
val = valueBuffer;
if (cnt > 0)
{
copyArgument( kRootDeviceKey, val, cnt, &argP, &cntRemaining);
}
}
else
{ /*
{
if (strlen(gBootUUIDString))
{
val = "*uuid";
cnt = 5;
}
else
{ */
{
// Don't set "rd=.." if there is no boot device key
// and no UUID.
val = "";
cnt = 0;
/* } */
}
}
/* Bungo
if (cnt > 0)
{
copyArgument( kRootDeviceKey, val, cnt, &argP, &cntRemaining);
}
*/
strlcpy(gRootDevice, val, (cnt + 1));
}
branches/ErmaC/Enoch/CHANGES
1
2
3
4
15
26
37
- 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.
- Bungo : Fixed fixedUUID function (convert.c smbios.c).
- Bungo : Added Logging start time.
- Bungo : Added getRTCdatetime() Int 1Ah function 02h - RTC service.
- Zenith432 : Use caching with ExFat filesystem.

Archive Download the corresponding diff file

Revision: 2564