Index: trunk/Chameleon.xcodeproj/project.pbxproj =================================================================== --- trunk/Chameleon.xcodeproj/project.pbxproj (revision 759) +++ trunk/Chameleon.xcodeproj/project.pbxproj (revision 760) @@ -11,6 +11,7 @@ 0172D0DD11FB66820030222E /* dram_controllers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dram_controllers.c; sourceTree = ""; }; 019DFBAF11FB94090013E8CC /* MEMTEST86_LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MEMTEST86_LICENSE; sourceTree = ""; }; 1D145307137073F40050C0CD /* bootargs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bootargs.h; sourceTree = ""; }; + 1D2A1AF513743A2600787720 /* bootargs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bootargs.h; sourceTree = ""; }; 65ED53931204B83200B22507 /* disk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = disk.h; sourceTree = ""; }; B0056CD611F3868000754B65 /* boot */ = {isa = PBXFileReference; lastKnownFileType = text; path = boot; sourceTree = ""; }; B0056CD711F3868000754B65 /* boot.sys */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.preload"; path = boot.sys; sourceTree = ""; }; @@ -561,6 +562,7 @@ B0056D7311F3868000754B65 /* vbe.h */, B0056D7411F3868000754B65 /* xml.c */, B0056D7511F3868000754B65 /* xml.h */, + 1D2A1AF513743A2600787720 /* bootargs.h */, ); path = libsaio; sourceTree = ""; Index: trunk/i386/libsaio/bootstruct.c =================================================================== --- trunk/i386/libsaio/bootstruct.c (revision 759) +++ trunk/i386/libsaio/bootstruct.c (revision 760) @@ -41,11 +41,6 @@ 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; @@ -115,7 +110,7 @@ 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)); Index: trunk/i386/libsaio/saio_internal.h =================================================================== --- trunk/i386/libsaio/saio_internal.h (revision 759) +++ trunk/i386/libsaio/saio_internal.h (revision 760) @@ -75,7 +75,6 @@ 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); Index: trunk/i386/boot2/boot.c =================================================================== --- trunk/i386/boot2/boot.c (revision 759) +++ trunk/i386/boot2/boot.c (revision 760) @@ -81,7 +81,8 @@ //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; @@ -149,7 +150,6 @@ reserveKernBootStruct(); // Load boot drivers from the specifed root path. - if (!gHaveKernelCache) LoadDrivers("/"); @@ -362,6 +362,7 @@ bool tryresume; bool tryresumedefault; bool forceresume; + bool usecache; // additional variable for testing alternate kernel image locations on boot helper partitions. char bootFileSpec[512]; @@ -411,7 +412,7 @@ } // Find out which version mac os we're booting. - getOSVersion(gMacOSVersion); + getOSVersion(); if (platformCPUFeature(CPU_FEATURE_EM64T)) { archCpuType = CPU_TYPE_X86_64; @@ -467,51 +468,56 @@ 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') && @@ -547,9 +553,6 @@ break; } } while (0); - - if (getValueForKey("-usecache", &val, &len, &bootInfo->bootConfig)) - trycache=1; do { if (trycache) { @@ -673,13 +676,18 @@ } */ -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; @@ -688,20 +696,20 @@ { 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; } Index: trunk/i386/boot2/boot.h =================================================================== --- trunk/i386/boot2/boot.h (revision 759) +++ trunk/i386/boot2/boot.h (revision 760) @@ -65,6 +65,7 @@ #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 */