void PBXContainerItemProxy::initFromPlist(const String& id, const Plist::dictionary_type& dict, const PBXDocument* pbxDoc) { // Call super init PBXObject::initFromPlist(id, dict, pbxDoc); // Get containerPortal getStringForKey(dict, "containerPortal", m_containerPortalId, VALUE_REQUIRED, m_parseER); // Get remoteGlobalIDString getStringForKey(dict, "remoteGlobalIDString", m_remoteGlobalIDString, VALUE_REQUIRED, m_parseER); }
void XCVersionGroup::initFromPlist(const String& id, const Plist::dictionary_type& plist, const PBXDocument* pbxDoc) { // Call super init PBXGroup::initFromPlist(id, plist, pbxDoc); // Get versionGroupType getStringForKey(plist, "versionGroupType", m_versionGroupType, VALUE_REQUIRED, m_parseER); // Get currentVersion getStringForKey(plist, "currentVersion", m_currentVersionId, VALUE_REQUIRED, m_parseER); }
void XCBuildConfiguration::initFromPlist(const String& id, const Plist::dictionary_type& plist, const PBXDocument* pbxDoc) { // Call super init PBXObject::initFromPlist(id, plist, pbxDoc); // Get name getStringForKey(plist, "name", m_name, VALUE_REQUIRED, m_parseER); // Get baseConfigurationReference getStringForKey(plist, "baseConfigurationReference", m_baseConfigurationId, VALUE_OPTIONAL, m_parseER); // Get buildSettings getStringMapForKey(plist, "buildSettings", m_buildSettings, VALUE_REQUIRED, m_parseER); }
void PBXNativeTarget::initFromPlist(const String& id, const Plist::dictionary_type& plist, const PBXDocument* pbxDoc) { // Call super init PBXTarget::initFromPlist(id, plist, pbxDoc); // Get productReference getStringForKey(plist, "productReference", m_productReferenceId, VALUE_REQUIRED, m_parseER); // Get productType getStringForKey(plist, "productType", m_productType, VALUE_REQUIRED, m_parseER); // Get buildRules getStringVectorForKey(plist, "buildRules", m_buildRuleIds, VALUE_OPTIONAL, m_parseER); }
void getSmbiosMacModel(void) { #define MAX_MODEL_LEN 32 //Slice - I want to use MacModel for ACPITables so I need char* representation const char *value = getStringForKey("SMproductname", &bootInfo->smbiosConfig); int i, n=0, first=0, rev1=0, rev2=0; for (i=0; i<8; i++) { char c = value[i]; if (isalpha(c)) { MacModel[i]=c; n++; } else if ((c) >= '0' && (c) <= '9') { if (first) { rev1 = rev1 * 10 + (int)(c) & 0xf; } else rev2 = rev2 * 10 + (int)(c) & 0xf; } else first = 1; // printf("char=%c first=%d rev1=%d rev2=%d\n", c, first, rev1, rev2); } for (i=n; i<8; i++) { MacModel[i] = 0x20; } ModelRev = (rev2 << 16) + rev1; // ModelLength = (len + 1) * 2; // printf("Model=%s %08x\n", MacModel, ModelRev); // getc(); }
void PBXFile::initFromPlist(const String& id, const Plist::dictionary_type& plist, const PBXDocument* pbxDoc) { // Call super init PBXObject::initFromPlist(id, plist, pbxDoc); // Get path getStringForKey(plist, "path", m_path, VALUE_OPTIONAL, m_parseER); // Get name getStringForKey(plist, "name", m_name, VALUE_OPTIONAL, m_parseER); if (m_name.empty()) m_name = sb_basename(m_path); // Get sourceTree getStringForKey(plist, "sourceTree", m_sourceTree, VALUE_REQUIRED, m_parseER); }
void KeyDetectorWidget::keyPressEvent(QKeyEvent* event) { event->accept(); setText(getStringForKey(event->key(), ignoreModifierKeys_)); emit keyChanged(event->key()); }
void addMiscToDeviceTree(void) { const char *hajokeys = getStringForKey("hajokeys", &bootInfo->chameleonConfig); if(!hajokeys) return; verbose("hajokeys: \"%s\" \n", hajokeys); const char* curpos = hajokeys; const char* end = curpos + strlen(hajokeys); while(curpos < end) { const char* space = strchr(curpos, ' '); const char* space2 = strchr(curpos, '\r'); const char* space3 = strchr(curpos, '\n'); if(space2 != 0 && space2 < space) space = space2; if(space3 != 0 && space3 < space) space = space3; if(!space) space = end; int len = space - curpos; char buffer[128]; strncpy(buffer, curpos, len); buffer[len] = 0; addHajoKey(buffer); curpos = space+1; } //sleep(5); }
void addHajoKey(const char* key) { if(key == 0 || strlen(key)<3) return; verbose("addHajoKey: \"%s\" \n", key); //sleep(5); const char *data = getStringForKey(key, &bootInfo->chameleonConfig); const char* colon = strchr(data, ':'); const char* equal = strchr(colon, '='); char nodePath[128]; strncpy(nodePath, data, colon-data); nodePath[colon-data] = 0; char attributeName[128]; strncpy(attributeName, colon+1, equal-colon-1); nodePath[equal-colon-1] = 0; int len = 0; const char* attributeValue = convertHexStr2Binary(equal+1, &len); verbose("in node \"%s\" set property \"%s\" to \"%s\" \n", nodePath, attributeName, attributeValue); Node* node = DT__FindNode(nodePath, true); if (node == 0) stop("Couldn't find/add node"); DT__AddProperty(node, attributeName, len + 1, (char*)attributeValue); }
int HPersistence::getIntForKey(const char* pKey,int d){ std::string tmp = getStringForKey(pKey); if(tmp.empty()){ return d; }else{ return atoi(tmp.c_str()); } }
/* * Must be called AFTER getSmbios */ void setupBoardId() { Node *node; node = DT__FindNode("/", false); if (node == 0) { stop("Couldn't get root node"); } const char *boardid = getStringForKey("SMboardproduct", &bootInfo->smbiosConfig); if (boardid) DT__AddProperty(node, BOARDID_PROP, strlen(boardid)+1, (EFI_CHAR16*)boardid); }
void PBXBuildRule::initFromPlist(const String& id, const Plist::dictionary_type& plist, const PBXDocument* pbxDoc) { // Call super init PBXObject::initFromPlist(id, plist, pbxDoc); // Get compilerSpec getStringForKey(plist, "compilerSpec", m_compilerSpec, VALUE_REQUIRED, m_parseER); // Get filePatterns getStringForKey(plist, "filePatterns", m_filePatterns, VALUE_OPTIONAL, m_parseER); // Get fileType getStringForKey(plist, "fileType", m_fileType, VALUE_REQUIRED, m_parseER); // Get outputFiles getStringVectorForKey(plist, "outputFiles", m_outputFiles, VALUE_REQUIRED, m_parseER); // Get script getStringForKey(plist, "script", m_script, VALUE_OPTIONAL, m_parseER); }
bool HPersistence::getBoolForKey(const char* pKey,bool b){ std::string tmp = getStringForKey(pKey); if(tmp.empty()){ return b; }else{ if(tmp == "true"){ return true; }else return false; } }
/* * Get an smbios option string option to convert to EFI_CHAR16 string */ static EFI_CHAR16* getSmbiosChar16(const char * key, size_t* len) { const char *src = getStringForKey(key, &bootInfo->smbiosConfig); EFI_CHAR16* dst = 0; size_t i = 0; if (!key || !(*key) || !len || !src) return 0; *len = strlen(src); dst = (EFI_CHAR16*) malloc( ((*len)+1) * 2 ); for (; i < (*len); i++) dst[i] = src[i]; dst[(*len)] = '\0'; *len = ((*len)+1)*2; // return the CHAR16 bufsize including zero terminated CHAR16 return dst; }
void HandleDataUnlock::dataFileGet() { createTypeUnlockOther(); auto userDefault = UserDefault::getInstance(); auto key = ManagerData::getInstance()->getUserDefaultKey(USER_DEFAULT_KEY_DU); auto strData = userDefault->getStringForKey(key.c_str()); auto vecData = UtilString::split(strData, ":"); _vecDataUnlock.clear(); for (int i = vecData.size() - 1; i >= 0; i--) { _vecDataUnlock.push_back(Value(vecData[i]).asInt()); } /*setIsUnlockMaid(1001);//for test setIsBuyMaid(1001);//for test*/ }
/* Load the smbios.plist override config file if any */ static void setupSmbiosConfigFile() { const char * value = getStringForKey(kSMBIOS, &bootInfo->bootConfig); extern void scan_mem(); if (!value) value = "/Extra/smbios.plist"; if (loadConfigFile(value, &bootInfo->smbiosConfig) == -1) { verbose("No SMBIOS replacement found\n"); } // get a chance to scan mem dynamically if user asks for it while having the config options loaded as well // as opposed to when it was in scan_platform(), also load the orig. smbios so that we can access dmi info without // patching the smbios yet getSmbios(SMBIOS_ORIGINAL); scan_mem(); smbios_p = (EFI_PTR32) getSmbios(SMBIOS_PATCHED); // process smbios asap }
void GameScene::publishScore() { auto userdefault = UserDefault::getInstance(); //查看路径,测试用 log(userdefault->getXMLFilePath().c_str()); //存储本次游戏分数 char score_str[100] = {0}; sprintf(score_str, "%d", m_score); userdefault->setStringForKey("LastScore", score_str); //存储最佳游戏分数 auto bestscore = userdefault->getStringForKey("BestScore"); if (m_score > atoi(bestscore.c_str())) userdefault->setStringForKey("BestScore", score_str); }
/* return a binary UUID value from the overriden SystemID and SMUUID if found, * or from the bios if not, or from a fixed value if no bios value is found */ static EFI_CHAR8* getSystemID() { // unable to determine UUID for host. Error: 35 fix // Rek: new SMsystemid option conforming to smbios notation standards, this option should // belong to smbios config only ... const char * sysId = getStringForKey(kSystemID, &bootInfo->bootConfig); EFI_CHAR8* ret = getUUIDFromString(sysId); if(!sysId || !ret) { // try bios dmi info UUID extraction ret = getSmbiosUUID(); sysId = 0; } if(!ret) // no bios dmi UUID available, set a fixed value for system-id ret=getUUIDFromString((sysId = (const char*) SYSTEM_ID)); verbose("Customizing SystemID with : %s\n", getStringFromUUID(ret)); // apply a nice formatting to the displayed output return ret; }
void PBXProject::initFromPlist(const String& id, const Plist::dictionary_type& plist, const PBXDocument* pbxDoc) { // Call super init PBXObject::initFromPlist(id, plist, pbxDoc); // Get buildConfigurationList getStringForKey(plist, "buildConfigurationList", m_buildConfigurationListId, VALUE_REQUIRED, m_parseER); // Get mainGroup getStringForKey(plist, "mainGroup", m_mainGroupId, VALUE_REQUIRED, m_parseER); // Get projectDirPath getStringForKey(plist, "projectDirPath", m_projectDirPath, VALUE_OPTIONAL, m_parseER); // Get projectRoot getStringForKey(plist, "projectRoot", m_projectRoot, VALUE_OPTIONAL, m_parseER); if (!m_projectRoot.empty()) m_parseER.reportError("Non-empty projectRoot."); // Get projectReferences const Plist::array_type& projRefArray = getContainerForKey<Plist::array_type>(plist, "projectReferences", VALUE_OPTIONAL, m_parseER); Plist::array_type::const_iterator rIt = projRefArray.begin(); Plist::array_type::const_iterator rEnd = projRefArray.end(); for (; rIt != rEnd; ++rIt) { const Plist::dictionary_type& refDict = castContainer<Plist::dictionary_type>(*rIt, VALUE_OPTIONAL, m_parseER); // Get ProjectRef and ProductGroup StringPair refPair; getStringForKey(refDict, "ProjectRef", refPair.first, VALUE_REQUIRED, m_parseER); getStringForKey(refDict, "ProductGroup", refPair.second, VALUE_REQUIRED, m_parseER); m_projectReferenceIds.push_back(refPair); } // Get targets getStringVectorForKey(plist, "targets", m_targetIds, VALUE_REQUIRED, m_parseER); }
string GameInfoSave::getNickName(int userid) { string str = "nick"; str.append(int2string(userid).c_str()); return getStringForKey(str.c_str()); }
string CCSecureUserDefault::getStringForKey(const char* pKey) { return getStringForKey(pKey, ""); }
string UserDefaultManager::getRecordeTime(){ return getStringForKey(kLoginTime); }
int processBootOptions() { const char *cp = gBootArgs; const char *val = 0; const char *kernel; int cnt; int userCnt; int cntRemaining; char *argP; char *configKernelFlags; char *valueBuffer; valueBuffer = malloc(VALUE_SIZE); skipblanks( &cp ); // Update the unit and partition number. if ( gBootVolume ) { if (!( gBootVolume->flags & kBVFlagNativeBoot )) { readBootSector( gBootVolume->biosdev, gBootVolume->part_boff, (void *) 0x7c00 ); // // Setup edx, and signal intention to chain load the // foreign booter. // chainbootdev = gBootVolume->biosdev; chainbootflag = 1; return 1; } setRootVolume(gBootVolume); } // If no boot volume fail immediately because we're just going to fail // trying to load the config file anyway. else { return -1; } // Find out which version mac os we're booting. strncpy(gMacOSVersion, gBootVolume->OSVersion, sizeof(gMacOSVersion)); // Load config table specified by the user, or use the default. if (!getValueForBootKey(cp, "config", &val, &cnt)) { val = 0; cnt = 0; } // Load com.apple.Boot.plist from the selected volume // and use its contents to override default bootConfig. loadSystemConfig(&bootInfo->bootConfig); loadChameleonConfig(&bootInfo->chameleonConfig, NULL); // Use the kernel name specified by the user, or fetch the name // in the config table, or use the default if not specified. // Specifying a kernel name on the command line, or specifying // a non-default kernel name in the config file counts as // overriding the kernel, which causes the kernelcache not // to be used. gOverrideKernel = false; if (( kernel = extractKernelName((char **)&cp) )) { strlcpy( bootInfo->bootFile, kernel, sizeof(bootInfo->bootFile) ); } else { if ( getValueForKey( kKernelNameKey, &val, &cnt, &bootInfo->bootConfig ) ) { strlcpy( bootInfo->bootFile, val, cnt+1 ); } else { if( YOSEMITE ) // is 10.10 { strlcpy( bootInfo->bootFile, kOSXKernel, sizeof(bootInfo->bootFile) ); //printf(HEADER "/System/Library/Kernels/%s\n", bootInfo->bootFile); } else { // OSX is not 10.10 strlcpy( bootInfo->bootFile, kDefaultKernel, sizeof(bootInfo->bootFile) ); //printf(HEADER "/%s\n", bootInfo->bootFile); } } } if (!YOSEMITE) // not 10.10 so 10.9 and previus { if (strcmp( bootInfo->bootFile, kDefaultKernel ) != 0) { //printf(HEADER "org.chameleon.Boot.plist found path for custom '%s' found!\n", bootInfo->bootFile); 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 { addBootArg("kext-dev-mode=1"); } cntRemaining = BOOT_STRING_LEN - 2; // save 1 for NULL, 1 for space argP = bootArgs->CommandLine; // Get config kernel flags, if not ignored. if (getValueForBootKey(cp, kIgnoreBootFileFlag, &val, &cnt) || !getValueForKey( kKernelFlagsKey, &val, &cnt, &bootInfo->bootConfig )) { val = ""; cnt = 0; } configKernelFlags = malloc(cnt + 1); strlcpy(configKernelFlags, val, cnt + 1); // boot-uuid can be set either on the command-line or in the config file if (!processBootArgument(kBootUUIDKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, gBootUUIDString, sizeof(gBootUUIDString))) { // // Try an alternate method for getting the root UUID on boot helper partitions. // if (gBootVolume->flags & kBVFlagBooter) { // Load the configuration store in the boot helper partition if (loadHelperConfig(&bootInfo->helperConfig) == 0) { val = getStringForKey(kHelperRootUUIDKey, &bootInfo->helperConfig); if (val != NULL) { strlcpy(gBootUUIDString, val, sizeof(gBootUUIDString)); } } } /* // 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, &argP, &cntRemaining, gRootDevice, ROOT_DEVICE_SIZE)) { cnt = 0; if ( getValueForKey( kBootDeviceKey, &val, &cnt, &bootInfo->chameleonConfig)) { valueBuffer[0] = '*'; cnt++; strlcpy(valueBuffer + 1, val, cnt); val = valueBuffer; } 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; /* } */ } if (cnt > 0) { copyArgument( kRootDeviceKey, val, cnt, &argP, &cntRemaining); } strlcpy( gRootDevice, val, (cnt + 1)); } /* * Removed. We don't need this anymore. * if (!processBootArgument(kPlatformKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, gPlatformName, sizeof(gCacheNameAdler))) { getPlatformName(gPlatformName); copyArgument(kPlatformKey, gPlatformName, strlen(gPlatformName), &argP, &cntRemaining); } */ if (!getValueForBootKey(cp, kSafeModeFlag, &val, &cnt) && !getValueForBootKey(configKernelFlags, kSafeModeFlag, &val, &cnt)) { if (gBootMode & kBootModeSafe) { copyArgument(0, kSafeModeFlag, strlen(kSafeModeFlag), &argP, &cntRemaining); } } // Store the merged kernel flags and boot args. cnt = strlen(configKernelFlags); if (cnt) { if (cnt > cntRemaining) { error("Warning: boot arguments too long, truncating\n"); cnt = cntRemaining; } strncpy(argP, configKernelFlags, cnt); argP[cnt++] = ' '; cntRemaining -= cnt; } userCnt = strlen(cp); if (userCnt > cntRemaining) { error("Warning: boot arguments too long, truncating\n"); userCnt = cntRemaining; } strncpy(&argP[cnt], cp, userCnt); argP[cnt+userCnt] = '\0'; if(!shouldboot) { gVerboseMode = getValueForKey( kVerboseModeFlag, &val, &cnt, &bootInfo->chameleonConfig ) || getValueForKey( kSingleUserModeFlag, &val, &cnt, &bootInfo->chameleonConfig ); gBootMode = ( getValueForKey( kSafeModeFlag, &val, &cnt, &bootInfo->chameleonConfig ) ) ? kBootModeSafe : kBootModeNormal; if ( getValueForKey( kIgnoreCachesFlag, &val, &cnt, &bootInfo->chameleonConfig ) ) { gBootMode = kBootModeSafe; } } if ( getValueForKey( kMKextCacheKey, &val, &cnt, &bootInfo->bootConfig ) ) { strlcpy(gMKextName, val, cnt + 1); } else { gMKextName[0]=0; } free(configKernelFlags); free(valueBuffer); return 0; }
BVRef selectBootVolume( BVRef chain ) { bool filteredChain = false; bool foundPrimary = false; BVRef bvr, bvr1 = 0, bvr2 = 0; if (chain->filtered) filteredChain = true; if (multiboot_partition_set) for ( bvr = chain; bvr; bvr = bvr->next ) if ( bvr->part_no == multiboot_partition && bvr->biosdev == gBIOSDev ) return bvr; /* * Checking "Default Partition" key in system configuration - use format: hd(x,y), the volume UUID or label - * to override the default selection. * We accept only kBVFlagSystemVolume or kBVFlagForeignBoot volumes. */ char *val = XMLDecode(getStringForKey(kDefaultPartitionKey, &bootInfo->bootConfig)); if (val) { for ( bvr = chain; bvr; bvr = bvr->next ) { if (matchVolumeToString(bvr, val, false)) { free(val); return bvr; } } free(val); } /* * Scannig the volume chain backwards and trying to find * a HFS+ volume with valid boot record signature. * If not found any active partition then we will * select this volume as the boot volume. */ for ( bvr = chain; bvr; bvr = bvr->next ) { if ( bvr->flags & kBVFlagPrimary && bvr->biosdev == gBIOSDev ) foundPrimary = true; // zhell -- Undo a regression that was introduced from r491 to 492. // if gBIOSBootVolume is set already, no change is required if ( bvr->flags & (kBVFlagBootable|kBVFlagSystemVolume) && gBIOSBootVolume && (!filteredChain || (filteredChain && bvr->visible)) && bvr->biosdev == gBIOSDev ) bvr2 = bvr; // zhell -- if gBIOSBootVolume is NOT set, we use the "if" statement // from r491, if ( bvr->flags & kBVFlagBootable && ! gBIOSBootVolume && bvr->biosdev == gBIOSDev ) bvr2 = bvr; } /* * Use the standrad method for selecting the boot volume. */ if (foundPrimary) { for ( bvr = chain; bvr; bvr = bvr->next ) { if ( bvr->flags & kBVFlagNativeBoot && bvr->biosdev == gBIOSDev ) bvr1 = bvr; if ( bvr->flags & kBVFlagPrimary && bvr->biosdev == gBIOSDev ) bvr2 = bvr; } } bvr = bvr2 ? bvr2 : bvr1 ? bvr1 : chain; return bvr; }
string UserDefaultManager::getRecordeTime1(){ return getStringForKey(kRecordeTime1); }
//========================================================================== // The 'main' function for the booter. Called by boot0 when booting // from a block device, or by the network booter. // // arguments: // biosdev - Value passed from boot1/NBP to specify the device // that the booter was loaded from. // // If biosdev is kBIOSDevNetwork, then this function will return if // booting was unsuccessful. This allows the PXE firmware to try the // next boot device on its list. void common_boot(int biosdev) { int status; char *bootFile; unsigned long adler32; bool quiet; bool firstRun = true; bool instantMenu; bool rescanPrompt = false; unsigned int allowBVFlags = kBVFlagSystemVolume|kBVFlagForeignBoot; unsigned int denyBVFlags = kBVFlagEFISystem; // Set reminder to unload the PXE base code. Neglect to unload // the base code will result in a hang or kernel panic. gUnloadPXEOnExit = true; // Record the device that the booter was loaded from. gBIOSDev = biosdev & kBIOSDevMask; // 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. #if DEBUG printf("before video_mode\n"); //Azi: this one is not printing... i remember it did.. check trunk. #endif video_mode( 2 ); // 80x25 mono text mode. #if DEBUG printf("after video_mode\n"); #endif // Scan and record the system's hardware information. scan_platform(); // First get info for boot volume. scanBootVolumes(gBIOSDev, 0); bvChain = getBVChainForBIOSDev(gBIOSDev); //Azi: initialising gBIOSBootVolume & gBootVolume (Startup volume) for the first time.. i think!? // also, kDefaultPartitionKey is checked here, on selectBootVolume. setBootGlobals(bvChain); msglog("setBootGlobals:\n Default: %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", gBootVolume, gBootVolume->biosdev, gBootVolume->part_no, gBootVolume->flags); msglog(" bt(0,0): %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", gBIOSBootVolume, gBIOSBootVolume->biosdev, gBIOSBootVolume->part_no, gBIOSBootVolume->flags); // Boot Volume is set as Root at this point so, pointing to Extra, /Extra or bt(0,0)/Extra // is exactly the same. Review bt(0,0)/bla bla paths...... (Reviewing...) //Azi: works as expected but... trying this because Kernel=mach_kernel doesn't work on a // override Boot.plist; this makes it impossible to override e.g. Kernel=bt(0,0)mach_kernel // on the main Boot.plist, when loading kernel from ramdisk btAliased. loadPrebootRAMDisk(); // Load boot.plist config file //Azi: on this first check, boot.plist acts as both "booter config file" // and bootargs/options "carrier".***** status = loadSystemConfig(&bootInfo->bootConfig); if (getBoolForKey(kQuietBootKey, &quiet, &bootInfo->bootConfig) && quiet) { gBootMode |= kBootModeQuiet; } // Override firstRun to get to the boot menu instantly by setting "Instant Menu"=y in system config if (getBoolForKey(kInstantMenuKey, &instantMenu, &bootInfo->bootConfig) && instantMenu) { firstRun = false; } // Loading preboot ramdisk if exists. // loadPrebootRAMDisk(); //Azi: this needs to be done before load_all_modules() // because of btAlias... (Reviewing...) // Intialize module system if (init_module_system()) { load_all_modules(); } // Disable rescan option by default gEnableCDROMRescan = false; // If we're loading the booter from optical media... (Reviewing...) if (biosDevIsCDROM(gBIOSDev)) { // ... ask the user for Rescan option by setting "Rescan Prompt"=y in system config... if (getBoolForKey(kRescanPromptKey, &rescanPrompt, &bootInfo->bootConfig) && rescanPrompt) { gEnableCDROMRescan = promptForRescanOption(); } else // ... or enable it with Rescan=y in system config. if (getBoolForKey(kRescanKey, &gEnableCDROMRescan, &bootInfo->bootConfig) && gEnableCDROMRescan) { gEnableCDROMRescan = true; } } //Azi: Is this a cdrom only thing? (Reviewing...) // Enable touching a single BIOS device only if "Scan Single Drive"=y is set in system config. if (getBoolForKey(kScanSingleDriveKey, &gScanSingleDrive, &bootInfo->bootConfig) && gScanSingleDrive) { scanBootVolumes(gBIOSDev, &bvCount); } else { //Azi: scanDisks uses scanBootVolumes. scanDisks(gBIOSDev, &bvCount); } // Create a separated bvr chain using the specified filters. bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &gDeviceCount); gBootVolume = selectBootVolume(bvChain); //#if DEBUG //printf msglog(":something...???\n Default: %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", gBootVolume, gBootVolume->biosdev, gBootVolume->part_no, gBootVolume->flags); msglog(" bt(0,0): %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", gBIOSBootVolume, gBIOSBootVolume->biosdev, gBIOSBootVolume->part_no, gBIOSBootVolume->flags); // getchar(); //#endif useGUI = true; // Override useGUI default getBoolForKey(kGUIKey, &useGUI, &bootInfo->bootConfig); // AutoResolution - Azi: default to false // http://forum.voodooprojects.org/index.php/topic,1227.0.html gAutoResolution = false; // Check if user enabled AutoResolution on Boot.plist... getBoolForKey(kAutoResolutionKey, &gAutoResolution, &bootInfo->bootConfig); // Patch the Video Bios with the extracted resolution, before initGui. if (gAutoResolution == true) { initAutoRes(); } if (useGUI && initGUI()) { // initGUI() returned with an error, disabling GUI. useGUI = false; } setBootGlobals(bvChain); msglog("setBootGlobals:\n Default: %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", gBootVolume, gBootVolume->biosdev, gBootVolume->part_no, gBootVolume->flags); msglog(" bt(0,0): %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", gBIOSBootVolume, gBIOSBootVolume->biosdev, gBIOSBootVolume->part_no, gBIOSBootVolume->flags); // Parse args, load and start kernel. while (1) { const char *val; int len; int trycache; long flags, cachetime, kerneltime, exttime, sleeptime, time; int ret = -1; void *binary = (void *)kLoadAddr; bool tryresume; bool tryresumedefault; bool forceresume; bool ignoreKC = false; // additional variable for testing alternate kernel image locations on boot helper partitions. char bootFileSpec[512]; // Initialize globals. sysConfigValid = false; gErrors = false; status = getBootOptions(firstRun); firstRun = false; if (status == -1) continue; //Azi: test (gBootVolume == NULL) - so far Ok! // test with optical media again...? // Turn off any GUI elements, draw background and update VRAM. if ( bootArgs->Video.v_display == GRAPHICS_MODE ) { gui.devicelist.draw = false; gui.bootprompt.draw = false; gui.menu.draw = false; gui.infobox.draw = false; gui.logo.draw = false; drawBackground(); updateVRAM(); } status = processBootOptions(); //Azi: AutoResolution - closing Vbios here without restoring, causes an allocation error, // if the user tries to boot, after a e.g."Can't find bla_kernel" msg. // Doing it on execKernel() instead. // Status == 1 means to chainboot if ( status == 1 ) break; // Status == -1 means that gBootVolume is NULL. Config file is not mandatory anymore! if ( status == -1 ) { // gBootVolume == NULL usually means the user hit escape. (Reviewing...) if (gBootVolume == NULL) { freeFilteredBVChain(bvChain); if (gEnableCDROMRescan) rescanBIOSDevice(gBIOSDev); bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &gDeviceCount); setBootGlobals(bvChain); setupDeviceList(&bootInfo->themeConfig); } continue; } // Other status (e.g. 0) means that we should proceed with boot. // If cpu handles 64 bit instructions... if (platformCPUFeature(CPU_FEATURE_EM64T)) { // use x86_64 kernel arch,... archCpuType = CPU_TYPE_X86_64; } else { // else use i386 kernel arch. archCpuType = CPU_TYPE_I386; } // If user override... if (getValueForKey(kArchKey, &val, &len, &bootInfo->bootConfig)) { // matches i386... if (strncmp(val, "i386", 4) == 0) { // use i386 kernel arch. archCpuType = CPU_TYPE_I386; } } if (!getBoolForKey (kWakeKey, &tryresume, &bootInfo->bootConfig)) { tryresume = true; tryresumedefault = true; } else { tryresumedefault = false; } if (!getBoolForKey (kForceWakeKey, &forceresume, &bootInfo->bootConfig)) { forceresume = false; } if (forceresume) { tryresume = true; tryresumedefault = false; } while (tryresume) { const char *tmp; BVRef bvr; if (!getValueForKey(kWakeKeyImageKey, &val, &len, &bootInfo->bootConfig)) val="/private/var/vm/sleepimage"; // Do this first to be sure that root volume is mounted ret = GetFileInfo(0, val, &flags, &sleeptime); if ((bvr = getBootVolumeRef(val, &tmp)) == NULL) break; // Can't check if it was hibernation Wake=y is required if (bvr->modTime == 0 && tryresumedefault) break; if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat)) break; if (!forceresume && ((sleeptime+3)<bvr->modTime)) { //Azi: no need for printf at this point - reminder printf ("Hibernate image is too old by %d seconds. Use ForceWake=y to override.\n",bvr->modTime-sleeptime); break; } HibernateBoot((char *)val); break; } //Azi:kernelcache stuff bool patchKernel = false; getBoolForKey(kKPatcherKey, &patchKernel, &bootInfo->bootConfig); //Azi: avoiding having to use -f to ignore kernel cache //Azi: ignore kernel cache but still use kext cache (E/E.mkext & S/L/E.mkext). - explain... getBoolForKey(kUseKCKey, &ignoreKC, &bootInfo->bootConfig); // equivalent to UseKernelCache if (ignoreKC) { verbose("KC: cache ignored by user.\n"); // make sure the damn thing get's zeroed, just in case... :)* bzero(gBootKernelCacheFile, sizeof(gBootKernelCacheFile)); } else if (patchKernel) // to be moved..? { verbose("KC: kernel patcher enabled, ignore cache.\n"); bzero(gBootKernelCacheFile, sizeof(gBootKernelCacheFile)); } else if (getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig)) { strlcpy(gBootKernelCacheFile, val, len + 1); verbose("KC: path set by user = %s\n", gBootKernelCacheFile); //Azi: bypass time check when user sets path ??? // cache is still ignored if time doesn't match... (e.g. booter on usb stick) } else { // Reset cache name. bzero(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64); // kextcache_main.c: Construct entry from UUID of boot volume...(reminder) // assemble ?string? to generate adler from... // sprintf(gCacheNameAdler + 64, "%s,%s", gRootDevice, bootInfo->bootFile); - OLD const char *ProductName = getStringForKey("SMproductname", &bootInfo->smbiosConfig); sprintf(gCacheNameAdler, ProductName); // well, at least the smbios.plist can be loaded this early... // to set/get "ProductName" this early, booter needs complete rewrite!! // see DHP's Revolution booter rework example! // verbose("KC: gCacheNameAdler 1 = %s\n", gCacheNameAdler); //Azi: check the validity of this, e.g. on Helper Partitions sprintf(gCacheNameAdler + 64, "%s", "\\System\\Library\\CoreServices\\boot.efi"); // verbose("KC: gCacheNameAdler 2 = %s\n", gCacheNameAdler + 64); sprintf(gCacheNameAdler + (64 + 38), "%s", bootInfo->bootFile); // verbose("KC: gCacheNameAdler 3 = %s\n", gCacheNameAdler + (64 + 38)); // generate adler adler32 = Adler32((unsigned char *)gCacheNameAdler, sizeof(gCacheNameAdler)); // verbose("KC: Adler32 = %08X\n", adler32); //Azi: no check for OS version here ?? - yes there is :) // append arch and/or adler (checksum) to kc path... if (gMacOSVersion[3] <= '5') { sprintf(gBootKernelCacheFile, "%s.%08lX", kCachePathTigerLeopard, adler32); // verbose("KC: adler added to path = %s\n", gBootKernelCacheFile); } else { sprintf(gBootKernelCacheFile, "%s_%s.%08X", kCachePathSnowLion, (archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64", adler32); // verbose("KC: arch & adler added to path = %s\n", gBootKernelCacheFile); } } // Check for cache file. //Azi: trycache is done if... trycache = ( ( (gBootMode & kBootModeSafe) == 0) //... we're not booting in safe mode (-x arg), && !gOverrideKernel // we're not overriding default kernel "name", && (gBootFileType == kBlockDeviceType) // we're booting from local storage device, && (gMKextName[0] == '\0') // "MKext Cache" key IS NOT in use, and && (gBootKernelCacheFile[0] != '\0') ); // gBootKernelCacheFile is populated. // we could add the use of "kernelpatcher" to this bunch..?? // verbose("Loading Darwin %s\n", gMacOSVersion); //Azi: move?? to getOSVersion? :) if (trycache) do { verbose("KC: checking kernel cache (system prelinked kernel)...\n"); // 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)) { verbose("KC: no kernel found (shouldn't happen?!?)\n"); trycache = 0; // ignore kernel cache... break; } verbose("KC: kerneltime = %d\n", kerneltime); ret = GetFileInfo(NULL, gBootKernelCacheFile, &flags, &cachetime); if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat) || (cachetime < kerneltime)) { if (cachetime <= 100) // confirm: 100 = inexistent path, -xxxxxxxxx = wrong name // not confirming... i also get -xxxxxxxxx with inexisting prelinked kernel verbose("KC: cachetime = %d, kernel cache path/adler is incorrect, ignoring it. ??? \n", cachetime); else verbose("KC: cachetime = %d, kernel cache is older than the kernel, ignoring it.\n", cachetime); trycache = 0; break; } verbose("KC: cachetime = %d\n", cachetime); ret = GetFileInfo("/System/Library/", "Extensions", &flags, &exttime); if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory) && (cachetime < exttime)) { verbose("KC: exttime = %d, kernel cache is older than S/L/E, ignoring it.\n", exttime); trycache = 0; break; } verbose("KC: exttime = %d\n", exttime); if (kerneltime > exttime) // if S/L/E is older than the kernel... { verbose("KC: S/L/E is older than the kernel, matching exttime with kerneltime...\n"); exttime = kerneltime; } verbose("KC: exttime +1 = %d\n", exttime + 1); if (cachetime != (exttime + 1)) { verbose("KC: kernel cache time is diff from S/L/E time, ignoring it.\n"); trycache = 0; break; } verbose("KC: kernel cache found and up to date, will be used.\n"); } while (0); do { // Load kernel cache if not ignored. if (trycache) { bootFile = gBootKernelCacheFile; verbose("Loading kernel cache %s\n", bootFile); ret = LoadFile(bootFile); binary = (void *)kLoadAddr; if (ret >= 0) { break; } } bootFile = bootInfo->bootFile; // Try to load kernel image from alternate locations on boot helper partitions. sprintf(bootFileSpec, "com.apple.boot.P/%s", bootFile); ret = GetFileInfo(NULL, bootFileSpec, &flags, &time); if (ret == -1) { sprintf(bootFileSpec, "com.apple.boot.R/%s", bootFile); ret = GetFileInfo(NULL, bootFileSpec, &flags, &time); if (ret == -1) { sprintf(bootFileSpec, "com.apple.boot.S/%s", bootFile); ret = GetFileInfo(NULL, bootFileSpec, &flags, &time); if (ret == -1) { // No alternate location found, using the original kernel image path. strcpy(bootFileSpec, bootFile); } } } verbose("Loading kernel %s\n", bootFileSpec); ret = LoadThinFatFile(bootFileSpec, &binary); if (ret <= 0 && archCpuType == CPU_TYPE_X86_64) { archCpuType = CPU_TYPE_I386; ret = LoadThinFatFile(bootFileSpec, &binary); } } while (0); clearActivityIndicator(); /*#if DEBUG printf("Pausing..."); sleep(8); #endif Azi: annoying stuff :P */ if (ret <= 0) { printf("Can't find %s\n", bootFile); sleep(1); if (gBootFileType == kNetworkDeviceType) { // Return control back to PXE. Don't unload PXE base code. gUnloadPXEOnExit = false; break; } } else { // Won't return if successful. ret = ExecKernel(binary); } } // while (1) // chainboot if (status==1) { if (getVideoMode() == GRAPHICS_MODE) { // if we are already in graphics-mode, setVideoMode(VGA_TEXT_MODE, 0); // switch back to text mode } } if ((gBootFileType == kNetworkDeviceType) && gUnloadPXEOnExit) { nbpUnloadBaseCode(); } }