inline struct SMBEntryPoint * getSmbios() { const char *smbios_filename; char dirSpec[512]; int len; struct SMBEntryPoint *orig_address; struct SMBEntryPoint *new_address; orig_address=getAddressOfSmbiosTable(); if (!getValueForKey("SMBIOS", &smbios_filename, &len, &bootInfo->bootConfig)) smbios_filename = "smbios.plist"; sprintf(dirSpec, "%s", smbios_filename); if (loadConfigFile(dirSpec, &bootInfo->smbiosConfig) == -1) { sprintf(dirSpec, "/Extra/%s", smbios_filename); if (loadConfigFile(dirSpec, &bootInfo->smbiosConfig) == -1) { sprintf(dirSpec, "bt(0,0)/Extra/%s", smbios_filename); if (loadConfigFile(dirSpec, &bootInfo->smbiosConfig) == -1) { verbose("No SMBIOS replacement found.\n"); } } } // if( (loadConfigFile("/Extra/smbios.plist", &bootInfo->smbiosConfig)) == -1 ) // loadConfigFile("bt(0,0)/Extra/smbios.plist", &bootInfo->smbiosConfig); // TODO: do we need this ? new_address = smbios_dry_run(orig_address); smbios_real_run(orig_address, new_address); return new_address; }
/** Get original or new smbios entry point, if sucessful, the adresses are cached for next time */ struct SMBEntryPoint *getSmbios(int which) { static struct SMBEntryPoint *orig = NULL; // cached static struct SMBEntryPoint *patched = NULL; // cached // whatever we are called with orig or new flag, initialize asap both structures switch (which) { case SMBIOS_ORIGINAL: if (orig==NULL) { orig = getAddressOfSmbiosTable(); getSmbiosTableStructure(orig); // generate tables entry list for fast table finding } return orig; case SMBIOS_PATCHED: if (orig==NULL && (orig = getAddressOfSmbiosTable())==NULL ) { printf("Could not find original SMBIOS !!\n"); pause(); } else { patched = smbios_dry_run(orig); if(patched==NULL) { printf("Could not create new SMBIOS !!\n"); pause(); } else { smbios_real_run(orig, patched); } } return patched; default: printf("ERROR: invalid option for getSmbios() !!\n"); break; } return NULL; }