Index: trunk/i386/libsaio/sys.c =================================================================== --- trunk/i386/libsaio/sys.c (revision 1102) +++ trunk/i386/libsaio/sys.c (revision 1103) @@ -335,6 +335,7 @@ for (idx = len; idx && (name[idx] != '/' && name[idx] != '\\'); idx--) {} if (idx == 0) { + if(name[idx] == '/' || name[idx] == '\\') ++name; // todo: ensure other functions handel \ properly gMakeDirSpec[0] = '/'; gMakeDirSpec[1] = '\0'; } else { Index: trunk/i386/libsaio/stringTable.c =================================================================== --- trunk/i386/libsaio/stringTable.c (revision 1102) +++ trunk/i386/libsaio/stringTable.c (revision 1103) @@ -28,6 +28,7 @@ #include "bootstruct.h" #include "libsaio.h" +#include "boot.h" #include "xml.h" extern char *Language; @@ -607,12 +608,7 @@ int loadSystemConfig(config_file_t *config) { char *dirspec[] = { - "/Extra/com.apple.Boot.plist", - "bt(0,0)/Extra/com.apple.Boot.plist", "/Library/Preferences/SystemConfiguration/com.apple.Boot.plist", - "/com.apple.boot.P/Library/Preferences/SystemConfiguration/com.apple.Boot.plist", - "/com.apple.boot.R/Library/Preferences/SystemConfiguration/com.apple.Boot.plist", - "/com.apple.boot.S/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" }; int i, fd, count, ret=-1; @@ -639,20 +635,16 @@ return ret; } -/* loadOverrideConfig +/* loadChameleonConfig * * Returns 0 - successful. * -1 - unsuccesful. */ -int loadOverrideConfig(config_file_t *config) +int loadChameleonConfig(config_file_t *config) { char *dirspec[] = { "rd(0,0)/Extra/com.apple.Boot.plist", "/Extra/com.apple.Boot.plist", - "/Library/Preferences/SystemConfiguration/com.apple.Boot.plist", - "/com.apple.boot.P/Library/Preferences/SystemConfiguration/com.apple.Boot.plist", - "/com.apple.boot.R/Library/Preferences/SystemConfiguration/com.apple.Boot.plist", - "/com.apple.boot.S/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" }; int i, fd, count, ret=-1; Index: trunk/i386/libsaio/saio_internal.h =================================================================== --- trunk/i386/libsaio/saio_internal.h (revision 1102) +++ trunk/i386/libsaio/saio_internal.h (revision 1103) @@ -162,7 +162,7 @@ extern int loadConfigFile(const char *configFile, config_file_t *configBuff); extern int loadSystemConfig(config_file_t *configBuff); extern int loadHelperConfig(config_file_t *configBuff); -extern int loadOverrideConfig(config_file_t *configBuff); +extern int loadChameleonConfig(config_file_t *configBuff); extern char * newString(const char *oldString); extern char * getNextArg(char ** ptr, char * val); extern int ParseXMLFile( char * buffer, TagPtr * dict ); Index: trunk/i386/boot2/drivers.c =================================================================== --- trunk/i386/boot2/drivers.c (revision 1102) +++ trunk/i386/boot2/drivers.c (revision 1103) @@ -209,37 +209,45 @@ } } } - - // Also try to load Extensions from boot helper partitions. - if (gBootVolume->flags & kBVFlagBooter) + if(!gHaveKernelCache) { - strcpy(dirSpecExtra, "/com.apple.boot.P/System/Library/"); - if (FileLoadDrivers(dirSpecExtra, 0) != 0) + // Don't load main driver (from /System/Library/Extentions) if gHaveKernelCache is set. + // since these drivers will already be in the kernel cache. + // NOTE: when gHaveKernelCache, xnu cannot (by default) load *any* extra kexts from the bootloader. + // The /Extra code is not disabled in this case due to a kernel patch that allows for this to happen. + + // Also try to load Extensions from boot helper partitions. + if (gBootVolume->flags & kBVFlagBooter) { - strcpy(dirSpecExtra, "/com.apple.boot.R/System/Library/"); + strcpy(dirSpecExtra, "/com.apple.boot.P/System/Library/"); if (FileLoadDrivers(dirSpecExtra, 0) != 0) { - strcpy(dirSpecExtra, "/com.apple.boot.S/System/Library/"); - FileLoadDrivers(dirSpecExtra, 0); + strcpy(dirSpecExtra, "/com.apple.boot.R/System/Library/"); + if (FileLoadDrivers(dirSpecExtra, 0) != 0) + { + strcpy(dirSpecExtra, "/com.apple.boot.S/System/Library/"); + FileLoadDrivers(dirSpecExtra, 0); + } } } - } - - if (gMKextName[0] != '\0') - { - verbose("LoadDrivers: Loading from [%s]\n", gMKextName); - if ( LoadDriverMKext(gMKextName) != 0 ) + + if (gMKextName[0] != '\0') { - error("Could not load %s\n", gMKextName); - return -1; + verbose("LoadDrivers: Loading from [%s]\n", gMKextName); + if ( LoadDriverMKext(gMKextName) != 0 ) + { + error("Could not load %s\n", gMKextName); + return -1; + } } + else + { + strcpy(gExtensionsSpec, dirSpec); + strcat(gExtensionsSpec, "System/Library/"); + FileLoadDrivers(gExtensionsSpec, 0); + } + } - else - { - strcpy(gExtensionsSpec, dirSpec); - strcat(gExtensionsSpec, "System/Library/"); - FileLoadDrivers(gExtensionsSpec, 0); - } } else { Index: trunk/i386/boot2/boot.c =================================================================== --- trunk/i386/boot2/boot.c (revision 1102) +++ trunk/i386/boot2/boot.c (revision 1103) @@ -93,12 +93,6 @@ */ #define kBootErrorTimeout 5 -/* - * Default path to kernel cache file - */ -//Slice - first one for Leopard -#define kDefaultCachePathLeo "/System/Library/Caches/com.apple.kernelcaches/" -#define kDefaultCachePathSnow "/System/Library/Caches/com.apple.kext.caches/Startup/" //========================================================================== // Zero the BSS. @@ -155,8 +149,8 @@ execute_hook("DecodedKernel", (void*)binary, NULL, NULL, NULL); // Load boot drivers from the specifed root path. - if (!gHaveKernelCache) - LoadDrivers("/"); + //if (!gHaveKernelCache) + LoadDrivers("/"); clearActivityIndicator(); @@ -265,7 +259,7 @@ bool firstRun = true; bool instantMenu; bool rescanPrompt; - unsigned int allowBVFlags = kBVFlagSystemVolume|kBVFlagForeignBoot; + unsigned int allowBVFlags = kBVFlagSystemVolume | kBVFlagForeignBoot; unsigned int denyBVFlags = kBVFlagEFISystem; // Set reminder to unload the PXE base code. Neglect to unload @@ -300,7 +294,7 @@ setBootGlobals(bvChain); // Load boot.plist config file - status = loadSystemConfig(&bootInfo->bootConfig); + status = loadChameleonConfig(&bootInfo->overrideConfig); if (getBoolForKey(kQuietBootKey, &quiet, &bootInfo->bootConfig) && quiet) { gBootMode |= kBootModeQuiet; @@ -438,7 +432,8 @@ archCpuType = CPU_TYPE_I386; } } - + //archCpuType = CPU_TYPE_I386; + // Notify moduals that we are attempting to boot execute_hook("PreBoot", NULL, NULL, NULL, NULL); @@ -489,9 +484,12 @@ getBoolForKey(kUseKernelCache, &usecache, &bootInfo->bootConfig); if(usecache) { if (getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig)) { - //ugly hack. FIX THIS - if(strcmp(val, "\\kernelcache") == 0) strlcpy(gBootKernelCacheFile, "kernelcache", sizeof("kernelcache")); - else strlcpy(gBootKernelCacheFile, val, len+1); + if(val[0] == '\\') + { + len--; + val++; + } + strlcpy(gBootKernelCacheFile, val, len+1); } else { //Lion @@ -550,13 +548,13 @@ verbose("Loading Darwin %s\n", gMacOSVersion); if (trycache) do { - - // if we haven't found the kernel yet, don't use the cache ret = GetFileInfo(NULL, bootInfo->bootFile, &flags, &kerneltime); - if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat)) { + if(ret != 0) kerneltime = 0; + else if ((flags & kFileTypeMask) != kFileTypeFlat) { trycache = 0; break; } + ret = GetFileInfo(NULL, gBootKernelCacheFile, &flags, &cachetime); if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat) || (cachetime < kerneltime)) { @@ -595,7 +593,7 @@ if (ret >= 0) break; - verbose("Kernel cache did not loaded %s\n ", bootFile); + verbose("Kernel cache did not load %s\n ", bootFile); } bootFile = bootInfo->bootFile; Index: trunk/i386/boot2/boot.h =================================================================== --- trunk/i386/boot2/boot.h (revision 1102) +++ trunk/i386/boot2/boot.h (revision 1103) @@ -30,7 +30,18 @@ #define __BOOT2_BOOT_H #include "libsaio.h" +/* + * Paths used by chameleon + */ +//kernel cache +#define kDefaultCachePathLeo "/System/Library/Caches/com.apple.kernelcaches/" +#define kDefaultCachePathSnow "/System/Library/Caches/com.apple.kext.caches/Startup/" + +// Lion installer +#define kLionInstallerDataFolder "/Mac OS X Install Data/" +#define kLionInstallerPlist kLionInstallerDataFolder "com.apple.Boot.plist" + /* * Keys used in system Boot.plist */ Index: trunk/i386/boot2/modules.c =================================================================== --- trunk/i386/boot2/modules.c (revision 1102) +++ trunk/i386/boot2/modules.c (revision 1103) @@ -177,7 +177,7 @@ if(module_start && module_start != (void*)0xFFFFFFFF) { // Notify the system that it was laoded - module_loaded(module, NULL, NULL, 0, 0 /*moduleName, moduleVersion, moduleCompat*/); + module_loaded(module, NULL, NULL, 0, 0 /*moduleName, NULL, moduleVersion, moduleCompat*/); (*module_start)(); // Start the module DBG("Module %s Loaded.\n", module); DBGPAUSE(); } @@ -455,6 +455,7 @@ case LC_LOAD_DYLIB: case LC_LOAD_WEAK_DYLIB ^ LC_REQ_DYLD: + // Required modules dylibCommand = binary + binaryIndex; char* module = binary + binaryIndex + ((UInt32)*((UInt32*)&dylibCommand->dylib.name)); // Possible enhancments: verify version @@ -475,7 +476,7 @@ break; case LC_ID_DYLIB: - dylibCommand = binary + binaryIndex; + //dylibCommand = binary + binaryIndex; /*moduleName = binary + binaryIndex + ((UInt32)*((UInt32*)&dylibCommand->dylib.name)); moduleVersion = dylibCommand->dylib.current_version; moduleCompat = dylibCommand->dylib.compatibility_version; Index: trunk/i386/boot2/options.c =================================================================== --- trunk/i386/boot2/options.c (revision 1102) +++ trunk/i386/boot2/options.c (revision 1103) @@ -1183,9 +1183,8 @@ // Load com.apple.Boot.plist from the selected volume // and use its contents to override default bootConfig. - // This is not a mandatory opeartion anymore. - loadOverrideConfig(&bootInfo->overrideConfig); + loadSystemConfig(&bootInfo->overrideConfig); // Use the kernel name specified by the user, or fetch the name // in the config table, or use the default if not specified. @@ -1240,12 +1239,13 @@ uuidSet = true; } } - + if (!uuidSet && gBootVolume->fs_getuuid && gBootVolume->fs_getuuid (gBootVolume, uuidStr) == 0) { verbose("Setting boot-uuid to: %s\n", uuidStr); copyArgument(kBootUUIDKey, uuidStr, strlen(uuidStr), &argP, &cntRemaining); uuidSet = true; } + } if (!processBootArgument(kRootDeviceKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, gRootDevice)) {