Chameleon

Chameleon Commit Details

Date:2011-05-06 18:27:14 (12 years 11 months ago)
Author:mozo
Commit:760
Parents: 759
Message:Added UseKernelCache (=No, by default) in boot.plist or command line option. UseKernelCache=Yes will load pre-linked kernel and will ignore E/E and S/L/E/Extensions.mkext.
Changes:
M/trunk/Chameleon.xcodeproj/project.pbxproj
M/trunk/i386/boot2/boot.c
M/trunk/i386/libsaio/bootstruct.c
M/trunk/i386/boot2/boot.h
M/trunk/i386/libsaio/saio_internal.h

File differences

trunk/Chameleon.xcodeproj/project.pbxproj
1111
1212
1313
14
1415
1516
1617
......
561562
562563
563564
565
564566
565567
566568
0172D0DD11FB66820030222E /* dram_controllers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dram_controllers.c; sourceTree = "<group>"; };
019DFBAF11FB94090013E8CC /* MEMTEST86_LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MEMTEST86_LICENSE; sourceTree = "<group>"; };
1D145307137073F40050C0CD /* bootargs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bootargs.h; sourceTree = "<group>"; };
1D2A1AF513743A2600787720 /* bootargs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bootargs.h; sourceTree = "<group>"; };
65ED53931204B83200B22507 /* disk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = disk.h; sourceTree = "<group>"; };
B0056CD611F3868000754B65 /* boot */ = {isa = PBXFileReference; lastKnownFileType = text; path = boot; sourceTree = "<group>"; };
B0056CD711F3868000754B65 /* boot.sys */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.preload"; path = boot.sys; sourceTree = "<group>"; };
B0056D7311F3868000754B65 /* vbe.h */,
B0056D7411F3868000754B65 /* xml.c */,
B0056D7511F3868000754B65 /* xml.h */,
1D2A1AF513743A2600787720 /* bootargs.h */,
);
path = libsaio;
sourceTree = "<group>";
trunk/i386/libsaio/bootstruct.c
4141
4242
4343
44
45
46
47
48
4944
5045
5146
......
115110
116111
117112
118
113
119114
120115
121116
static char platformName[64];
bool checkOSVersion(const char * version)
{
return ((gMacOSVersion[0] == version[0]) && (gMacOSVersion[1] == version[1]) && (gMacOSVersion[2] == version[2]) && (gMacOSVersion[3] == version[3]));
}
void initKernBootStruct( void )
{
Node *node;
void
reserveKernBootStruct(void)
{
if (checkOSVersion("10.7"))
if ((gMacOSVersion[0] == '1') && (gMacOSVersion[1] == '0') && (gMacOSVersion[2] == '.') && (gMacOSVersion[3] == '7'))
{
void *oldAddr = bootArgs;
bootArgs = (boot_args *)AllocateKernelMemory(sizeof(boot_args));
trunk/i386/libsaio/saio_internal.h
7575
7676
7777
78
7978
8079
8180
extern void sleep(int n);
/* bootstruct.c */
extern bool checkOSVersion(const char * version);
extern void initKernBootStruct(void);
extern void reserveKernBootStruct(void);
extern void copyKernBootStruct(void);
trunk/i386/boot2/boot.c
8181
8282
8383
84
84
85
8586
8687
8788
......
149150
150151
151152
152
153153
154154
155155
......
362362
363363
364364
365
365366
366367
367368
......
411412
412413
413414
414
415
415416
416417
417418
......
467468
468469
469470
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
471
472
473
474
485475
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
504497
505
506
498
499
500
501
502
507503
508504
505
506
507
508
509
510
511
512
513
514
509515
510
511516
512
517
513518
514
519
520
515521
516522
517523
......
547553
548554
549555
550
551
552
553556
554557
555558
......
673676
674677
675678
676
679
677680
681
682
683
684
685
678686
679687
680688
681689
682
690
683691
684692
685693
......
688696
689697
690698
691
699
692700
693701
694702
695703
696704
697705
698
699
706
707
700708
701709
702710
703711
704
712
705713
706714
707715
//static void selectBiosDevice(void);
static unsigned long Adler32(unsigned char *buffer, long length);
static bool getOSVersion(char *str);
static bool checkOSVersion(const char * version);
static bool getOSVersion();
static bool gUnloadPXEOnExit = false;
reserveKernBootStruct();
// Load boot drivers from the specifed root path.
if (!gHaveKernelCache)
LoadDrivers("/");
bool tryresume;
bool tryresumedefault;
bool forceresume;
bool usecache;
// additional variable for testing alternate kernel image locations on boot helper partitions.
char bootFileSpec[512];
}
// Find out which version mac os we're booting.
getOSVersion(gMacOSVersion);
getOSVersion();
if (platformCPUFeature(CPU_FEATURE_EM64T)) {
archCpuType = CPU_TYPE_X86_64;
HibernateBoot((char *)val);
break;
}
// Reset cache name.
bzero(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64);
sprintf(gCacheNameAdler + 64, "%s,%s", gRootDevice, bootInfo->bootFile);
adler32 = Adler32((unsigned char *)gCacheNameAdler, sizeof(gCacheNameAdler));
if (getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig)) {
strlcpy(gBootKernelCacheFile, val, len+1);
}
else {
//Lion
if (checkOSVersion("10.7")) {
sprintf(gBootKernelCacheFile, "%skernelcache", kDefaultCachePathSnow);
if(getBoolForKey(kUseKernelCache, &usecache, &bootInfo->bootConfig)) {
if (getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig)) {
strlcpy(gBootKernelCacheFile, val, len+1);
}
// Snow Leopard
else if (checkOSVersion("10.6")) {
sprintf(gBootKernelCacheFile, "kernelcache_%s", (archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64"); //, adler32);
int lnam = sizeof(gBootKernelCacheFile) + 9; //with adler32
//Slice - TODO
/*
- but the name is longer .adler32 and more...
kernelcache_i386.E102928C.qSs0
so will opendir and scan for some files
*/
char* name;
long prev_time = 0;
struct dirstuff* cacheDir = opendir(kDefaultCachePathSnow);
while(readdir(cacheDir, (const char**)&name, &flags, &time) >= 0)
{
if(((flags & kFileTypeMask) != kFileTypeDirectory) && time > prev_time && strstr(name, gBootKernelCacheFile) && (name[lnam] != '.'))
else {
//Lion
if (checkOSVersion("10.7")) {
sprintf(gBootKernelCacheFile, "%skernelcache", kDefaultCachePathSnow);
}
// Snow Leopard
else if (checkOSVersion("10.6")) {
sprintf(gBootKernelCacheFile, "kernelcache_%s", (archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64");
int lnam = sizeof(gBootKernelCacheFile) + 9; //with adler32
//Slice - TODO
/*
- but the name is longer .adler32 and more...
kernelcache_i386.E102928C.qSs0
so will opendir and scan for some files
*/
char* name;
long prev_time = 0;
struct dirstuff* cacheDir = opendir(kDefaultCachePathSnow);
while(readdir(cacheDir, (const char**)&name, &flags, &time) >= 0)
{
sprintf(gBootKernelCacheFile, "%s%s", kDefaultCachePathSnow, name);
prev_time = time;
if(((flags & kFileTypeMask) != kFileTypeDirectory) && time > prev_time && strstr(name, gBootKernelCacheFile) && (name[lnam] != '.'))
{
sprintf(gBootKernelCacheFile, "%s%s", kDefaultCachePathSnow, name);
prev_time = time;
}
}
}
else {
// Reset cache name.
bzero(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64);
sprintf(gCacheNameAdler + 64, "%s,%s", gRootDevice, bootInfo->bootFile);
adler32 = Adler32((unsigned char *)gCacheNameAdler, sizeof(gCacheNameAdler));
sprintf(gBootKernelCacheFile, "%s.%08lX", kDefaultCachePathLeo, adler32);
}
}
else sprintf(gBootKernelCacheFile, "%s.%08lX", kDefaultCachePathLeo, adler32);
}
// Check for cache file.
trycache = (((gBootMode & kBootModeSafe) == 0) &&
trycache = (usecache &&
((gBootMode & kBootModeSafe) == 0) &&
!gOverrideKernel &&
(gBootFileType == kBlockDeviceType) &&
(gMKextName[0] == '\0') &&
break;
}
} while (0);
if (getValueForKey("-usecache", &val, &len, &bootInfo->bootConfig))
trycache=1;
do {
if (trycache) {
}
*/
static bool getOSVersion(char *str)
bool checkOSVersion(const char * version)
{
return ((gMacOSVersion[0] == version[0]) && (gMacOSVersion[1] == version[1]) && (gMacOSVersion[2] == version[2]) && (gMacOSVersion[3] == version[3]));
}
bool getOSVersion()
{
bool valid = false;
config_file_t systemVersion;
const char *val;
int len;
if (!loadConfigFile("System/Library/CoreServices/SystemVersion.plist", &systemVersion))
{
valid = true;
{
valid = true;
}
if (valid)
{
if (getValueForKey(kProductVersion, &val, &len, &systemVersion))
{
// getValueForKey uses const char for val
// so copy it and trim
*str = '\0';
strncat(str, val, MIN(len, 4));
*gMacOSVersion = '\0';
strncat(gMacOSVersion, val, MIN(len, 4));
}
else
valid = false;
}
return valid;
}
trunk/i386/boot2/boot.h
6565
6666
6767
68
6869
6970
7071
#define kWakeImage"WakeImage"/* boot.c */
#define kProductVersion"ProductVersion"/* boot.c */
#define karch"arch"/* boot.c */
#define kUseKernelCache"UseKernelCache"/* boot.c */
#define kDSDT"DSDT"/* acpi_patcher.c */
#define kDropSSDT"DropSSDT"/* acpi_patcher.c */
#define kRestartFix"RestartFix"/* acpi_patcher.c */

Archive Download the corresponding diff file

Revision: 760