Index: trunk/i386/libsaio/smbios_getters.h =================================================================== --- trunk/i386/libsaio/smbios_getters.h (revision 2381) +++ trunk/i386/libsaio/smbios_getters.h (revision 2382) @@ -17,8 +17,8 @@ kSMBString, kSMBByte, kSMBWord, - kSMBDWord -// kSMBQWord + kSMBDWord, + kSMBQWord } SMBValueType; typedef union @@ -27,7 +27,7 @@ uint8_t byte; uint16_t word; uint32_t dword; -// uint64_t qword; + uint64_t qword; } returnType; extern bool getProcessorInformationExternalClock(returnType *value); Index: trunk/i386/libsaio/console.c =================================================================== --- trunk/i386/libsaio/console.c (revision 2381) +++ trunk/i386/libsaio/console.c (revision 2382) @@ -246,6 +246,25 @@ } else { vprf(fmt, ap); } + + { + // Kabyl: BooterLog + struct putc_info pi; + + if (!msgbuf) { + return 0; + } + + if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) { + return 0; + } + + pi.str = cursor; + pi.last_str = 0; + prf(fmt, ap, sputc, &pi); + cursor += strlen((char *)cursor); + } + va_end(ap); return(0); } Index: trunk/i386/libsaio/bootstruct.c =================================================================== --- trunk/i386/libsaio/bootstruct.c (revision 2381) +++ trunk/i386/libsaio/bootstruct.c (revision 2382) @@ -29,6 +29,16 @@ #include "libsaio.h" #include "bootstruct.h" +#ifndef DEBUG_BOOTSTRUCT +#define DEBUG_BOOTSTRUCT 0 +#endif + +#if DEBUG_BOOTSTRUCT +#define DBG(x...) printf(x) +#else +#define DBG(x...) msglog(x) +#endif + /*========================================================================== * Initialize the structure of parameters passed to * the kernel by the booter. @@ -52,7 +62,7 @@ bootArgs = (boot_args *)malloc(sizeof(boot_args)); bootArgsPreLion = (boot_args_pre_lion *)malloc(sizeof(boot_args_pre_lion)); bootInfo = (PrivateBootInfo_t *)malloc(sizeof(PrivateBootInfo_t)); - if (bootArgs == 0 || bootInfo == 0) + if (bootArgs == 0 || bootArgsPreLion == 0 || bootInfo == 0) stop("Couldn't allocate boot info\n"); bzero(bootArgs, sizeof(boot_args)); Index: trunk/i386/libsaio/device_tree.c =================================================================== --- trunk/i386/libsaio/device_tree.c (revision 2381) +++ trunk/i386/libsaio/device_tree.c (revision 2382) @@ -398,7 +398,25 @@ } //============================================================================== +// Bungo +Property * +DT__GetProperty(Node *node, const char *name) +{ + Property *prop; + + for (prop = node->properties; prop; prop = prop->next) + { + if (strcmp(prop->name, name) == 0) + { + return prop; + } + } + + return NULL; +} +//============================================================================== + Node * DT__FindNode(const char *path, bool createIfMissing) { Index: trunk/i386/libsaio/hfs.c =================================================================== --- trunk/i386/libsaio/hfs.c (revision 2381) +++ trunk/i386/libsaio/hfs.c (revision 2382) @@ -304,7 +304,7 @@ } dirID = kHFSRootFolderID; - // Skip a lead '\'. Start in the system folder if there are two. + // Skip a lead '/'. Start in the system folder if there are two. if (filePath[0] == '/') { if (filePath[1] == '/') @@ -370,7 +370,7 @@ if (*dirIndex == -1) return -1; dirID = kHFSRootFolderID; - // Skip a lead '\'. Start in the system folder if there are two. + // Skip a lead '/'. Start in the system folder if there are two. if (dirPath[0] == '/') { if (dirPath[1] == '/') { if (gIsHFSPlus) dirID = SWAP_BE32(((long *)gHFSPlus->finderInfo)[5]); @@ -435,7 +435,7 @@ if (HFSInitPartition(ih) == -1) return -1; dirID = kHFSRootFolderID; - // Skip a lead '\'. Start in the system folder if there are two. + // Skip a lead '/'. Start in the system folder if there are two. if (filePath[0] == '/') { if (filePath[1] == '/') { if (gIsHFSPlus) dirID = SWAP_BE32(((long *)gHFSPlus->finderInfo)[5]); Index: trunk/i386/libsaio/acpi_patcher.c =================================================================== --- trunk/i386/libsaio/acpi_patcher.c (revision 2381) +++ trunk/i386/libsaio/acpi_patcher.c (revision 2382) @@ -23,7 +23,7 @@ #elif DEBUG_ACPI==1 #define DBG(x...) printf(x) #else -#define DBG(x...) +#define DBG(x...) msglog(x) #endif // Slice: New signature compare function @@ -112,7 +112,7 @@ fd = open(dirSpec, 0); if (fd < 0) { // NOT FOUND: - verbose("ACPI Table not found: %s\n", filename); + DBG("ACPI Table not found: %s\n", filename); *dirSpec = '\0'; } } @@ -136,7 +136,7 @@ { if (read (fd, tableAddr, file_size (fd))!=file_size (fd)) { - printf("Couldn't read table %s\n",dirspec); + DBG("Couldn't read table %s\n",dirspec); free (tableAddr); close (fd); return NULL; @@ -147,7 +147,7 @@ return tableAddr; } close (fd); - printf("Couldn't allocate memory for table \n", dirspec); + DBG("Couldn't allocate memory for table \n", dirspec); } //printf("Couldn't find table %s\n", filename); return NULL; @@ -161,13 +161,13 @@ { uint32_t i; - DBG("start finding cpu names. length %d\n", length); + DBG("Start finding cpu names. length %d\n", length); for (i=0; i> 6); @@ -182,7 +182,7 @@ if (!aml_isvalidchar(c)) { add_name = false; - verbose("Invalid character found in ProcessorOP 0x%x!\n", c); + DBG("Invalid character found in ProcessorOP 0x%x!\n", c); break; } } @@ -196,7 +196,7 @@ if (acpi_cpu_count == 0) acpi_cpu_p_blk = dsdt[i] | (dsdt[i+1] << 8); - verbose("Found ACPI CPU: %c%c%c%c\n", acpi_cpu_name[acpi_cpu_count][0], acpi_cpu_name[acpi_cpu_count][1], acpi_cpu_name[acpi_cpu_count][2], acpi_cpu_name[acpi_cpu_count][3]); + DBG("Found ACPI CPU: %c%c%c%c\n", acpi_cpu_name[acpi_cpu_count][0], acpi_cpu_name[acpi_cpu_count][1], acpi_cpu_name[acpi_cpu_count][2], acpi_cpu_name[acpi_cpu_count][3]); if (++acpi_cpu_count == 32) { return; @@ -205,7 +205,7 @@ } } - DBG("end finding cpu names: cpu names found: %d\n", acpi_cpu_count); + DBG("End finding cpu names: cpu names found: %d\n", acpi_cpu_count); } struct acpi_2_ssdt *generate_cst_ssdt(struct acpi_2_fadt* fadt) @@ -234,19 +234,19 @@ }; if (Platform.CPU.Vendor != 0x756E6547) { - verbose ("Not an Intel platform: C-States will not be generated !!!\n"); + DBG("Not an Intel platform: C-States will not be generated !!!\n"); return NULL; } if (fadt == NULL) { - verbose ("FACP not exists: C-States will not be generated !!!\n"); + DBG("FACP not exists: C-States will not be generated !!!\n"); return NULL; } struct acpi_2_dsdt* dsdt = (void*)fadt->DSDT; if (dsdt == NULL) { - verbose ("DSDT not found: C-States will not be generated !!!\n"); + DBG("DSDT not found: C-States will not be generated !!!\n"); return NULL; } @@ -397,11 +397,11 @@ // dumpPhysAddr("C-States SSDT content: ", ssdt, ssdt->Length); - verbose ("SSDT with CPU C-States generated successfully\n"); + DBG("SSDT with CPU C-States generated successfully\n"); return ssdt; } else { - verbose ("ACPI CPUs not found: C-States not generated !!!\n"); + DBG("ACPI CPUs not found: C-States not generated !!!\n"); } return NULL; @@ -419,12 +419,12 @@ }; if (Platform.CPU.Vendor != 0x756E6547) { - verbose ("Not an Intel platform: P-States will not be generated !!!\n"); + DBG("Not an Intel platform: P-States will not be generated !!!\n"); return NULL; } if (!(Platform.CPU.Features & CPU_FEATURE_MSR)) { - verbose ("Unsupported CPU: P-States will not be generated !!! No MSR support\n"); + DBG("Unsupported CPU: P-States will not be generated !!! No MSR support\n"); return NULL; } @@ -587,7 +587,7 @@ minimum.Control = (rdmsr64(MSR_PLATFORM_INFO) >> 40) & 0xff; - verbose("P-States: min 0x%x, max 0x%x\n", minimum.Control, maximum.Control); + DBG("P-States: min 0x%x, max 0x%x\n", minimum.Control, maximum.Control); // Sanity check if (maximum.Control < minimum.Control) { @@ -608,7 +608,7 @@ break; } default: - verbose ("Unsupported CPU (0x%X): P-States not generated !!!\n", Platform.CPU.Family); + DBG("Unsupported CPU (0x%X): P-States not generated !!!\n", Platform.CPU.Family); break; } } @@ -658,12 +658,12 @@ //dumpPhysAddr("P-States SSDT content: ", ssdt, ssdt->Length); - verbose ("SSDT with CPU P-States generated successfully\n"); + DBG("SSDT with CPU P-States generated successfully\n"); return ssdt; } } else { - verbose ("ACPI CPUs not found: P-States not generated !!!\n"); + DBG("ACPI CPUs not found: P-States not generated !!!\n"); } return NULL; @@ -677,7 +677,7 @@ bool fadt_rev2_needed = false; bool fix_restart; bool fix_restart_ps2; - const char * value; + int value = 1; // Restart Fix if (Platform.CPU.Vendor == 0x756E6547) { /* Intel */ @@ -689,7 +689,7 @@ getBoolForKey(kRestartFix, &fix_restart, &bootInfo->chameleonConfig); } } else { - verbose ("Not an Intel platform: Restart Fix not applied !!!\n"); + DBG("Not an Intel platform: Restart Fix not applied !!!\n"); fix_restart = false; } @@ -708,33 +708,30 @@ fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(fadt->Length); memcpy(fadt_mod, fadt, fadt->Length); } - // Determine system type / PM_Model - if ( (value=getStringForKey(kSystemType, &bootInfo->chameleonConfig))!=NULL) - { - if (Platform.Type > 6) { - if(fadt_mod->PM_Profile<=6) { - Platform.Type = fadt_mod->PM_Profile; // get the fadt if correct - } else { - Platform.Type = 1; /* Set a fixed value (Desktop) */ - } - verbose("Error: system-type must be 0..6. Defaulting to %d !\n", Platform.Type); - } else { - Platform.Type = (unsigned char) strtoul(value, NULL, 10); - } + + // Determine PM Profile + if (getIntForKey(kSystemType, &value, &bootInfo->chameleonConfig)) { + DBG("FADT: changing PM Profile from 0x%02x to 0x%02x\n", fadt_mod->PM_Profile, (unsigned char)value); + // user has overriden the PM Profile so take care of it in FACP + fadt_mod->PM_Profile = (unsigned char)value; + } else { + DBG("FADT: PM Profile=0x%02x\n", fadt_mod->PM_Profile); } - // Set PM_Profile from System-type if only user wanted this value to be forced - if (fadt_mod->PM_Profile != Platform.Type) { - if (value) { - // user has overriden the SystemType so take care of it in FACP - verbose("FADT: changing PM_Profile from 0x%02x to 0x%02x\n", fadt_mod->PM_Profile, Platform.Type); - fadt_mod->PM_Profile = Platform.Type; - } else { - // PM_Profile has a different value and no override has been set, so reflect the user value to ioregs - Platform.Type = fadt_mod->PM_Profile <= 6 ? fadt_mod->PM_Profile : 1; - } + // Check if PM Profile is correct (1..3), otherwise set it to value + switch (fadt_mod->PM_Profile) { + case 1: break; + case 2: break; + case 3: break; + default: + value = 1; + DBG("FADT: wrong PM Profile (0x%02x), must be 1..3. Defaulting to 0x%02x!\n", fadt_mod->PM_Profile, (unsigned char)value); + fadt_mod->PM_Profile = (unsigned char)value; } + // Setup system-type + Platform.Type = fadt_mod->PM_Profile; + // We now have to write the systemm-type in ioregs: we cannot do it before in setupDeviceTree() - // because we need to take care of facp original content, if it is correct. + // because we need to take care of FACP original content, if it is correct. setupSystemType(); // Patch FADT to fix restart @@ -747,7 +744,7 @@ fadt_mod->Reset_AccessWidth = 0x01; // Byte access fadt_mod->Reset_Address = 0x64; // Address of the register fadt_mod->Reset_Value = 0xfe; // Value to write to reset the system - msglog("FADT: PS2 Restart Fix applied!\n"); + DBG("FADT: PS2 Restart Fix applied!\n"); } else { fadt_mod->Flags|= 0x400; fadt_mod->Reset_SpaceID = 0x01; // System I/O @@ -756,7 +753,7 @@ fadt_mod->Reset_AccessWidth = 0x01; // Byte access fadt_mod->Reset_Address = 0x0cf9; // Address of the register fadt_mod->Reset_Value = 0x06; // Value to write to reset the system - verbose("FADT: ACPI Restart Fix applied!\n"); + DBG("FADT: ACPI Restart Fix applied!\n"); } } @@ -772,7 +769,7 @@ DBG("New @%x,%x\n",fadt_mod->DSDT,fadt_mod->X_DSDT); - verbose("FADT: Using custom DSDT!\n"); + DBG("FADT: Using custom DSDT!\n"); } // Correct the checksum @@ -794,7 +791,7 @@ if(acpi20_p) { addConfigurationTable(&gEfiAcpi20TableGuid, &acpi20_p, "ACPI_20"); } else { - verbose("No ACPI 2.\n"); + DBG("No ACPI 2.\n"); } return 1; } @@ -803,7 +800,8 @@ int setupAcpi(void) { int version; - void *new_dsdt; + void *new_dsdt = NULL; // DSDT.aml DSDT + void *new_table; const char *filename; @@ -823,6 +821,7 @@ // Load replacement DSDT new_dsdt = loadACPITable(dirSpec); + // Mozodojo: going to patch FACP and load SSDT's even if DSDT.aml is not present /*if (!new_dsdt) { @@ -840,8 +839,9 @@ getBoolForKey(kGeneratePStates, &generate_pstates, &bootInfo->chameleonConfig); getBoolForKey(kGenerateCStates, &generate_cstates, &bootInfo->chameleonConfig); - DBG("Generating P-States config: %d\n", generate_pstates); - DBG("Generating C-States config: %d\n", generate_cstates); + DBG("Generating P-States config: %s\n", generate_pstates ? "YES" : "NO"); + DBG("Generating C-States config: %s\n", generate_cstates ? "YES" : "NO"); + //DBG("Generating T-States config: %s\n", generate_tstates ? "YES" : "NO"); { int i; @@ -849,7 +849,7 @@ for (i = 0; i < 30; i++) { char filename[512]; - sprintf(filename, i > 0?"SSDT-%d.aml":"SSDT.aml", i); + sprintf(filename, i > 0 ? "SSDT-%d.aml" : "SSDT.aml", i); if ( (new_ssdt[ssdt_count] = loadACPITable(filename)) ) { ssdt_count++; @@ -859,6 +859,10 @@ } } + // Load new table + sprintf(dirSpec, "ECDT.aml"); + new_table = loadACPITable(dirSpec); + // Do the same procedure for both versions of ACPI for (version = 0; version < 2; version++) { struct acpi_2_rsdp *rsdp, *rsdp_mod; @@ -866,7 +870,7 @@ int rsdplength; // Find original rsdp - rsdp=(struct acpi_2_rsdp *)(version?getAddressOfAcpi20Table():getAddressOfAcpiTable()); + rsdp=(struct acpi_2_rsdp *)(version ? getAddressOfAcpi20Table() : getAddressOfAcpiTable()); if (!rsdp) { DBG("No ACPI version %d found. Ignoring\n", version+1); if (version) { @@ -876,7 +880,7 @@ } continue; } - rsdplength=version?rsdp->Length:20; + rsdplength=version ? rsdp->Length : 20; DBG("RSDP version %d found @%x. Length=%d\n",version+1,rsdp,rsdplength); @@ -895,7 +899,7 @@ if (rsdt && (uint32_t)rsdt !=0xffffffff && rsdt->Length<0x10000) { uint32_t *rsdt_entries; int rsdt_entries_num; - int dropoffset=0, i; + int dropoffset=0, i, j; // mozo: using malloc cos I didn't found how to free already allocated kernel memory rsdt_mod=(struct acpi_2_rsdt *)malloc(rsdt->Length); @@ -909,22 +913,21 @@ continue; } - DBG("TABLE %c%c%c%c,",table[0],table[1],table[2],table[3]); + DBG("TABLE %c%c%c%c@%x: ", table[0],table[1],table[2],table[3],rsdt_entries[i]); rsdt_entries[i-dropoffset]=rsdt_entries[i]; if (drop_ssdt && tableSign(table, "SSDT")) { - verbose("OEM SSDT tables was dropped\n"); + DBG("dropped (OEM)\n"); dropoffset++; continue; } + if (tableSign(table, "DSDT")) { - DBG("DSDT found\n"); - verbose("Custom DSDT table was found\n"); if(new_dsdt) { rsdt_entries[i-dropoffset]=(uint32_t)new_dsdt; + DBG("custom table added\n"); } - continue; } @@ -932,10 +935,10 @@ struct acpi_2_fadt *fadt, *fadt_mod; fadt=(struct acpi_2_fadt *)rsdt_entries[i]; - DBG("FADT found @%x, Length %d\n",fadt, fadt->Length); + DBG("found, Length %d\n",fadt->Length); if (!fadt || (uint32_t)fadt == 0xffffffff || fadt->Length>0x10000) { - printf("FADT incorrect. Not modified\n"); + DBG("FADT incorrect. Not modified\n"); continue; } @@ -955,33 +958,34 @@ generate_pstates = false; // Generate SSDT only once! ssdt_count++; } - continue; } + DBG("copied (OEM)\n"); } - DBG("\n"); + // Mozodojo: Insert additional SSDTs into RSDT + if(ssdt_count > 0) { + for (j=0; jLength += 4*ssdt_count - 4*dropoffset; + rsdt_mod->Length += 4*ssdt_count + 4 - 4*dropoffset; struct acpi_2_rsdt *rsdt_copy = (struct acpi_2_rsdt *)AllocateKernelMemory(rsdt_mod->Length); memcpy (rsdt_copy, rsdt_mod, rsdt_mod->Length); - free(rsdt_mod); rsdt_mod = rsdt_copy; + free(rsdt_mod); + rsdt_mod = rsdt_copy; rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod; rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4; rsdt_entries=(uint32_t *)(rsdt_mod+1); - // Mozodojo: Insert additional SSDTs into RSDT - if(ssdt_count>0) { - int j; - - for (j=0; jChecksum); @@ -991,8 +995,9 @@ DBG("New checksum %d at %x\n", rsdt_mod->Checksum,rsdt_mod); } else { rsdp_mod->RsdtAddress=0; - printf("RSDT not found or RSDT incorrect\n"); + DBG("RSDT not found or RSDT incorrect\n"); } + DBG("\n"); if (version) { struct acpi_2_xsdt *xsdt, *xsdt_mod; @@ -1004,7 +1009,7 @@ if (xsdt && (uint64_t)rsdp->XsdtAddress<0xffffffff && xsdt->Length<0x10000) { uint64_t *xsdt_entries; - int xsdt_entries_num, i; + int xsdt_entries_num, i, j; int dropoffset=0; // mozo: using malloc cos I didn't found how to free already allocated kernel memory @@ -1019,62 +1024,75 @@ if (!table) { continue; } + + DBG("TABLE %c%c%c%c@%x: ", table[0],table[1],table[2],table[3],xsdt_entries[i]); + xsdt_entries[i-dropoffset]=xsdt_entries[i]; if (drop_ssdt && tableSign(table, "SSDT")) { - verbose("OEM SSDT tables was dropped\n"); + DBG("dropped (OEM)\n"); dropoffset++; continue; } + if (tableSign(table, "DSDT")) { - DBG("DSDT found\n"); - if (new_dsdt) { xsdt_entries[i-dropoffset]=(uint32_t)new_dsdt; + DBG("custom table added\n"); } - - DBG("TABLE %c%c%c%c@%x \n", table[0],table[1],table[2],table[3],xsdt_entries[i]); - continue; } if (tableSign(table, "FACP")) { struct acpi_2_fadt *fadt, *fadt_mod; fadt=(struct acpi_2_fadt *)(uint32_t)xsdt_entries[i]; - DBG("FADT found @%x%x, Length %d\n",(uint32_t)(xsdt_entries[i]>>32),fadt, - fadt->Length); + DBG("found, Length %d\n",(uint32_t)(xsdt_entries[i]>>32), fadt->Length); if (!fadt || (uint64_t)xsdt_entries[i] >= 0xffffffff || fadt->Length>0x10000) { - verbose("FADT incorrect or after 4GB. Dropping XSDT\n"); + DBG("FADT incorrect or after 4GB. Dropping XSDT\n"); goto drop_xsdt; } fadt_mod = patch_fadt(fadt, new_dsdt); xsdt_entries[i-dropoffset]=(uint32_t)fadt_mod; - DBG("TABLE %c%c%c%c@%x \n", table[0],table[1],table[2],table[3],xsdt_entries[i]); + // DBG("TABLE %c%c%c%c@%x \n", table[0],table[1],table[2],table[3],xsdt_entries[i]); // Generate _CST SSDT if (generate_cstates && (new_ssdt[ssdt_count] = generate_cst_ssdt(fadt_mod))) { + DBG("C-States generated\n"); generate_cstates = false; // Generate SSDT only once! ssdt_count++; } // Generating _PSS SSDT if (generate_pstates && (new_ssdt[ssdt_count] = generate_pss_ssdt((void*)fadt_mod->DSDT))) { + DBG("P-States generated\n"); generate_pstates = false; // Generate SSDT only once! ssdt_count++; } continue; } + DBG("copied (OEM)\n"); + // DBG("TABLE %c%c%c%c@%x \n", table[0],table[1],table[2],table[3],xsdt_entries[i]); + } - DBG("TABLE %c%c%c%c@%x \n", table[0],table[1],table[2],table[3],xsdt_entries[i]); + // Mozodojo: Insert additional SSDTs into XSDT + if(ssdt_count > 0) { + for (j=0; jLength += 8*ssdt_count - 8*dropoffset; + xsdt_mod->Length += 8*ssdt_count + 8 - 8*dropoffset; struct acpi_2_xsdt *xsdt_copy = (struct acpi_2_xsdt *)AllocateKernelMemory(xsdt_mod->Length); memcpy(xsdt_copy, xsdt_mod, xsdt_mod->Length); free(xsdt_mod); xsdt_mod = xsdt_copy; @@ -1082,53 +1100,36 @@ xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8; xsdt_entries=(uint64_t *)(xsdt_mod+1); - // Mozodojo: Insert additional SSDTs into XSDT - if(ssdt_count > 0) { - int j; - - for (j=0; jChecksum); xsdt_mod->Checksum=0; xsdt_mod->Checksum=256-checksum8(xsdt_mod,xsdt_mod->Length); + DBG("New checksum %d\n", xsdt_mod->Checksum); } else { drop_xsdt: - DBG("About to drop XSDT\n"); - /*FIXME: Now we just hope that if MacOS doesn't find XSDT it reverts to RSDT. * A Better strategy would be to generate */ - rsdp_mod->XsdtAddress=0xffffffffffffffffLL; verbose("XSDT not found or XSDT incorrect\n"); } } + DBG("\n"); - // Correct the checksum of RSDP - + // Correct the checksum of RSDP DBG("RSDP: Original checksum %d, ", rsdp_mod->Checksum); - rsdp_mod->Checksum=0; rsdp_mod->Checksum=256-checksum8(rsdp_mod,20); - DBG("New checksum %d\n", rsdp_mod->Checksum); if (version) { - DBG("RSDP: Original extended checksum %d", rsdp_mod->ExtendedChecksum); - + DBG("RSDP: Original extended checksum %d, ", rsdp_mod->ExtendedChecksum); rsdp_mod->ExtendedChecksum=0; rsdp_mod->ExtendedChecksum=256-checksum8(rsdp_mod,rsdp_mod->Length); - DBG("New extended checksum %d\n", rsdp_mod->ExtendedChecksum); } - //verbose("Patched ACPI version %d DSDT\n", version+1); if (version) { /* XXX aserebln why uint32 cast if pointer is uint64 ? */ acpi20_p = (uint64_t)(uint32_t)rsdp_mod; @@ -1138,6 +1139,7 @@ acpi10_p = (uint64_t)(uint32_t)rsdp_mod; addConfigurationTable(&gEfiAcpiTableGuid, &acpi10_p, "ACPI"); } + DBG("ACPI version %d patching finished\n\n", version+1); } #if DEBUG_ACPI printf("Press a key to continue... (DEBUG_ACPI)\n"); Index: trunk/i386/libsaio/device_tree.h =================================================================== --- trunk/i386/libsaio/device_tree.h (revision 2381) +++ trunk/i386/libsaio/device_tree.h (revision 2382) @@ -67,6 +67,9 @@ extern char * DT__GetName(Node *node); +extern Property * +DT__GetProperty(Node *node, const char *name); + void DT__Initialize(void); Index: trunk/i386/libsaio/bootargs.h =================================================================== --- trunk/i386/libsaio/bootargs.h (revision 2381) +++ trunk/i386/libsaio/bootargs.h (revision 2382) @@ -116,7 +116,7 @@ uint16_t Revision; /* Revision of boot_args structure */ uint16_t Version; /* Version of boot_args structure */ - uint8_t efiMode; /* 32 = 32-bit, 64 = 64-bit */ + uint8_t efiMode; /* 32 means 32-bit mode, 64 means 64-bit mode */ uint8_t debugMode; /* Bit field with behavior changes */ uint8_t __reserved1[2]; @@ -178,7 +178,7 @@ uint32_t efiRuntimeServicesPageCount; uint32_t efiSystemTable; /* physical address of system table in runtime area */ - uint8_t efiMode; /* 32 = 32-bit, 64 = 64-bit */ + uint8_t efiMode; /* 32 means 32-bit mode, 64 means 64-bit mode */ uint8_t __reserved1[3]; uint32_t __reserved2[1]; uint32_t performanceDataStart; /* physical address of log */ Index: trunk/i386/libsaio/device_inject.c =================================================================== --- trunk/i386/libsaio/device_inject.c (revision 2381) +++ trunk/i386/libsaio/device_inject.c (revision 2382) @@ -20,7 +20,7 @@ #if DEBUG_INJECT #define DBG(x...) printf(x) #else -#define DBG(x...) +#define DBG(x...) msglog(x) #endif uint32_t devices_number = 1; Index: trunk/i386/libsaio/sys.c =================================================================== --- trunk/i386/libsaio/sys.c (revision 2381) +++ trunk/i386/libsaio/sys.c (revision 2382) @@ -65,6 +65,7 @@ #include "disk.h" #include "ramdisk.h" #include "xml.h" +#include "sl.h" #include //#include @@ -76,6 +77,12 @@ static unsigned char kFSUUIDNamespaceSHA1[] = {0xB3,0xE2,0x0F,0x39,0xF2,0x92,0x11,0xD6,0x97,0xA4,0x00,0x30,0x65,0x43,0xEC,0xAC}; #endif +#if DEBUG +#define DBG(x...) printf(x) +#else +#define DBG(x...) msglog(x) +#endif + extern int multiboot_partition; extern int multiboot_partition_set; extern int multiboot_skip_partition; @@ -203,21 +210,27 @@ readFile = bvr->fs_readfile; - if (readFile != NULL) { + if (readFile != NULL) + { // Read the first 4096 bytes (fat header) length = readFile(bvr, (char *)filePath, *binary, 0, 0x1000); - if (length > 0) { - if (ThinFatFile(binary, &length) == 0) { - if (length == 0) { + if (length > 0) + { + if (ThinFatFile(binary, &length) == 0) + { + if (length == 0) + { return 0; } // We found a fat binary; read only the thin part + DBG("Fat Binary found. Reading thin part only...\n"); length = readFile(bvr, (char *)filePath, (void *)kLoadAddr, (unsigned long)(*binary) - kLoadAddr, length); *binary = (void *)kLoadAddr; } else { // Not a fat binary; read the rest of the file + DBG("Thin Binary found. Reading rest of the file...\n"); length2 = readFile(bvr, (char *)filePath, (void *)(kLoadAddr + length), length, 0); if (length2 == -1) { @@ -230,7 +243,8 @@ } else { length = bvr->fs_loadfile(bvr, (char *)filePath); - if (length > 0) { + if (length > 0) + { ThinFatFile(binary, &length); } } Index: trunk/i386/libsaio/load.c =================================================================== --- trunk/i386/libsaio/load.c (revision 2381) +++ trunk/i386/libsaio/load.c (revision 2382) @@ -32,6 +32,12 @@ #include +#if DEBUG +#define DBG(x...) printf(x) +#else +#define DBG(x...) msglog(x) +#endif + static long DecodeSegment(long cmdBase, unsigned int*load_addr, unsigned int *load_size); static long DecodeUnixThread(long cmdBase, unsigned int *entry); static long DecodeSymbolTable(long cmdBase); @@ -54,10 +60,10 @@ uint32_t fapoffset; uint32_t fapsize; - if (fhp->magic == FAT_MAGIC) { + if (fhp->magic == FAT_MAGIC)/* 0xcafebabe */{ nfat = fhp->nfat_arch; swapped = 0; - } else if (fhp->magic == FAT_CIGAM) { + } else if (fhp->magic == FAT_CIGAM)/* 0xbebafeca */{ nfat = OSSwapInt32(fhp->nfat_arch); swapped = 1; } else { @@ -107,17 +113,18 @@ mH = (struct mach_header *)(gBinaryAddress); -#if DEBUG - printf("magic: %x\n", (unsigned)mH->magic); - printf("cputype: %x\n", (unsigned)mH->cputype); - printf("cpusubtype: %x\n", (unsigned)mH->cpusubtype); - printf("filetype: %x\n", (unsigned)mH->filetype); - printf("ncmds: %x\n", (unsigned)mH->ncmds); - printf("sizeofcmds: %x\n", (unsigned)mH->sizeofcmds); - printf("flags: %x\n", (unsigned)mH->flags); - getchar(); -#endif - + /*#if DEBUG + DBG("magic: 0x%x\n", (unsigned)mH->magic); + DBG("cputype: 0x%x\n", (unsigned)mH->cputype); + DBG("cpusubtype: 0x%x\n", (unsigned)mH->cpusubtype); + DBG("filetype: 0x%x\n", (unsigned)mH->filetype); + DBG("ncmds: 0x%x\n", (unsigned)mH->ncmds); + DBG("sizeofcmds: 0x%x\n", (unsigned)mH->sizeofcmds); + DBG("flags: 0x%x\n", (unsigned)mH->flags); + DBG("archCpuType: 0x%x\n", archCpuType); + //getchar(); + #endif*/ + switch (archCpuType) { case CPU_TYPE_I386: @@ -131,11 +138,11 @@ break; case CPU_TYPE_X86_64: - +/* if (mH->magic != MH_MAGIC_64 && mH->magic == MH_MAGIC) { return -1; } - +*/ if (mH->magic != MH_MAGIC_64) { error("Mach-O file has bad magic number\n"); return -1; @@ -201,17 +208,17 @@ cmdBase = cmdstart; for (cnt = 0; cnt < ncmds; cnt++) { - cmd = ((long *)cmdBase)[0]; - cmdsize = ((long *)cmdBase)[1]; - - if (cmd == LC_SYMTAB) { - if (DecodeSymbolTable(cmdBase) != 0) { - return -1; + cmd = ((long *)cmdBase)[0]; + cmdsize = ((long *)cmdBase)[1]; + + if (cmd == LC_SYMTAB) { + if (DecodeSymbolTable(cmdBase) != 0) { + return -1; + } } - } cmdBase += cmdsize; - } + } return ret; } Index: trunk/i386/libsaio/platform.c =================================================================== --- trunk/i386/libsaio/platform.c (revision 2381) +++ trunk/i386/libsaio/platform.c (revision 2382) @@ -20,7 +20,7 @@ #if DEBUG_PLATFORM #define DBG(x...) printf(x) #else -#define DBG(x...) +#define DBG(x...) msglog(x) #endif PlatformInfo_t Platform; Index: trunk/i386/libsaio/cpu.c =================================================================== --- trunk/i386/libsaio/cpu.c (revision 2381) +++ trunk/i386/libsaio/cpu.c (revision 2382) @@ -261,17 +261,17 @@ do_cpuid(0x80000001, p->CPU.CPUID[CPUID_81]); } -#if DEBUG_CPU +// #if DEBUG_CPU { int i; - printf("CPUID Raw Values:\n"); - for (i=0; iCPU.CPUID[i][0], p->CPU.CPUID[i][1], p->CPU.CPUID[i][2], p->CPU.CPUID[i][3]); } } -#endif +// #endif /* EAX (Intel): Index: trunk/i386/libsaio/platform.h =================================================================== --- trunk/i386/libsaio/platform.h (revision 2381) +++ trunk/i386/libsaio/platform.h (revision 2382) @@ -31,14 +31,14 @@ #define CPUID_MAX 10 #define CPU_MODEL_PRESCOTT 0x03 // Celeron D, Pentium 4 (90nm) -#define CPU_MODEL_NOCONA 0x04 // Xeon Nocona, Irwindale (90nm) +#define CPU_MODEL_NOCONA 0x04 // Xeon Nocona/Paxville, Irwindale (90nm) #define CPU_MODEL_PRESLER 0x06 // Pentium 4, Pentium D (65nm) -#define CPU_MODEL_PENTIUM_M 0x09 // Banias -#define CPU_MODEL_DOTHAN 0x0D // Dothan +#define CPU_MODEL_PENTIUM_M 0x09 // Banias Pentium M (130nm) +#define CPU_MODEL_DOTHAN 0x0D // Dothan Pentium M, Celeron M (90nm) #define CPU_MODEL_YONAH 0x0E // Sossaman, Yonah #define CPU_MODEL_MEROM 0x0F // Allendale, Conroe, Kentsfield, Woodcrest, Clovertown, Tigerton, Merom #define CPU_MODEL_CONROE 0x0F // -#define CPU_MODEL_CELERON 0x16 // +#define CPU_MODEL_CELERON 0x16 // Merom, Conroe (65nm) #define CPU_MODEL_PENRYN 0x17 // Wolfdale, Yorkfield, Harpertown, Penryn #define CPU_MODEL_WOLFDALE 0x17 // #define CPU_MODEL_NEHALEM 0x1A // Bloomfield. Nehalem-EP, Nehalem-WS, Gainestown @@ -177,7 +177,7 @@ int DIMM[MAX_RAM_SLOTS]; // Information and SPD mapping for each slot } DMI; - uint8_t Type; // System Type: 1=Desktop, 2=Portable... according ACPI2.0 (FACP: PM_Profile) + uint8_t Type; // System Type: 1=Desktop, 2=Portable, 3=Workstation... according ACPI2.0 (FACP: PM_Profile) uint8_t *UUID; } PlatformInfo_t; Index: trunk/i386/libsaio/smbios.c =================================================================== --- trunk/i386/libsaio/smbios.c (revision 2381) +++ trunk/i386/libsaio/smbios.c (revision 2382) @@ -125,7 +125,7 @@ /* ============================================== OEM Platform Feature (Apple Specific - Type 133) ================================================ */ -//#define kSMBOemPlatformFeatureKey +//#define kSMBOemPlatformFeatureKey "SMoemplatformfeature" /* ==================================================*/ #define getFieldOffset(struct, field) ((uint8_t)(uint32_t)&(((struct *)0)->field)) @@ -186,8 +186,8 @@ uint8_t chassisType; char *version; char *serialNumber; - char *assetTag; // Bungo: renamed folowing convention - //char *skuNumber; + char *assetTag; + char *skuNumber; } defaultChassis_t; defaultChassis_t defaultChassis; @@ -421,7 +421,7 @@ //#define KDefaultBoardSerialNumber "C02140302D5DMT31M" // new C07019501PLDCVHAD - C02032101R5DC771H //=========== Mac mini =========== -#define kDefaultMacMiniFamily "Mac mini" +#define kDefaultMacMiniFamily "Napa Mac" // Macmini2,1 family = "Napa Mac" not "Mac mini" //#define kDefaultMacMiniBoardAssetTagNumber "Mini-Aluminum" #define kDefaultMacMini "Macmini2,1" @@ -500,6 +500,7 @@ #define kDefaultiMacBIOSVersion " IM81.88Z.00C1.B00.0903051113" #define kDefaultiMacBIOSReleaseDate "02/09/08" #define kDefaultiMacBoardProduct "Mac-F227BEC8" +#define kDefaultMacFamily "Mac" // iMac8,1 family = "Mac" not "iMac" // iMac10,1 // iMac11,1 core i3/i5/i7 @@ -534,7 +535,7 @@ //#define kDefaultiMacIvyBoardProduct "Mac-FC02E91DDD3FA6A4" //=========== MacPro =========== -#define kDefaultMacProFamily "Mac Pro" +#define kDefaultMacProFamily "MacPro" // MacPro's family = "MacPro" not "Mac Pro" //#define KDefauktMacProBoardAssetTagNumber "Pro-Enclosure" //#define kDefaultMacProBoardType "0xB" // 11 @@ -546,12 +547,16 @@ //#define KDefaultMacProBoardSerialNumber "J593902RA4MFE" // Mac Pro 4,1 core i7/Xeon +#define kDefaultMacProNahWestSystemVersion "0.0" + #define kDefaultMacProNehalem "MacPro4,1" #define kDefaultMacProNehalemBIOSVersion " MP41.88Z.0081.B07.0910130729" #define kDefaultMacProNehalemBIOSReleaseDate "10/13/09" //#define kDefaultMacProNehalemSystemVersion "1.4" #define kDefaultMacProNehalemBoardProduct "Mac-F221BEC8" //#define KDefaultMacProNehalemBoardSerialNumber "J593004RB1LUE" +// "J591302R61LUC " // 2-cpu board +// "J591002JV4MFB " // 1-cpu board // Mac Pro 5,1 core i7/Xeon #define kDefaultMacProWestmere "MacPro5,1" @@ -560,16 +565,20 @@ //#define kDefaultMacProWestmereSystemVersion "1.2" #define kDefaultMacProWestmereBoardProduct "Mac-F221BEC8" //#define KDefaultMacProWestmereBoardSerialNumber "J522700H7BH8C" +// "J503104H1BH8A " // 2-cpu board // Mac Pro 6,1 #define kDefaultMacProHaswell "MacPro6,1" -#define kDefaultMacProHaswellBIOSVersion " MP61.88Z.0116.B04.1312061508" +#define kDefaultMacProHaswellBIOSVersion "MP61.88Z.0116.B04.1312061508" #define kDefaultMacProHaswellBIOSReleaseDate "12/06/2013" //#define kDefaultMacProHaswellSystemVersion "1.?" #define kDefaultMacProHaswellBoardProduct "Mac-F60DEB81FF30ACF6" -//#define KDefaultMacProHaswellBoardSerialNumber "?????????????" +//#define KDefaultMacProHaswellBoardSerialNumber "F5K3474008JFNN215" -//#define KDefaultBoardSerialNumber "C02140302D5DMT31M" // new C07019501PLDCVHAD - C02032101R5DC771H +//#define KDefaultBoardSerialNumber "C02140302D5DMT31M" +// "C07019501PLDCVHAD" +// "C02032101R5DC771H" + // J593902RA4MFE 3,1 // J5031046RCZJA 5,1 // J521101A5CZJC 3,1 @@ -584,7 +593,7 @@ bool useSMBIOSdefaults = true; // Bungo -SMBByte PlatformType = 3; // Bungo: same as Platfom.Type in platform.h +SMBByte PlatformType = 1; // Bungo: same as Platfom.Type in platform.h. Because can't get from ACPI FADT PM profile and platformCPUFeature(CPU_FEATURE_MOBILE)) doesn't work as expect, FIXING NEEDED. /* Rewrite this function */ void setDefaultSMBData(void) // Bungo: setting data from real Macs @@ -604,12 +613,13 @@ defaultChassis.manufacturer = kDefaultVendorManufacturer; defaultChassis.serialNumber = kDefaultSerialNumber; defaultChassis.assetTag = kDefaultAssetTag; -// defaultChassis.skuNumber = kDefaultSkuNumber; + defaultChassis.skuNumber = kDefaultSkuNumber; // if (platformCPUFeature(CPU_FEATURE_MOBILE)) Bungo: doesn't recognise correctly, need fixing - if (PlatformType == 2) // this method works but it's a substitute + if (PlatformType == 2) // this works but it's a substitute { - if (Platform.CPU.NoCores > 1) { + if (Platform.CPU.NoCores > 1) + { defaultSystemInfo.productName = kDefaultMacBookPro; defaultBIOSInfo.version = kDefaultMacBookProBIOSVersion; defaultBIOSInfo.releaseDate = kDefaultMacBookProBIOSReleaseDate; @@ -643,7 +653,7 @@ defaultBIOSInfo.version = kDefaultiMacBIOSVersion; defaultBIOSInfo.releaseDate = kDefaultiMacBIOSReleaseDate; defaultSystemInfo.productName = kDefaultiMac; - defaultSystemInfo.family = kDefaultiMacFamily; + defaultSystemInfo.family = kDefaultMacFamily; // iMac8,1 family = Mac defaultBaseBoard.product = kDefaultiMacBoardProduct; defaultBaseBoard.boardType = kSMBBaseBoardMotherboard; defaultChassis.chassisType = kSMBchassisAllInOne; @@ -685,6 +695,7 @@ defaultBIOSInfo.version = kDefaultMacProNehalemBIOSVersion; defaultBIOSInfo.releaseDate = kDefaultMacProNehalemBIOSReleaseDate; defaultSystemInfo.productName = kDefaultMacProNehalem; + defaultSystemInfo.version = kDefaultMacProNahWestSystemVersion; defaultSystemInfo.family = kDefaultMacProFamily; defaultBaseBoard.product = kDefaultMacProNehalemBoardProduct; defaultBaseBoard.boardType = kSMBBaseBoardProcessorMemoryModule; @@ -697,6 +708,7 @@ defaultBIOSInfo.version = kDefaultMacProWestmereBIOSVersion; defaultBIOSInfo.releaseDate = kDefaultMacProWestmereBIOSReleaseDate; defaultSystemInfo.productName = kDefaultMacProWestmere; + defaultSystemInfo.version = kDefaultMacProNahWestSystemVersion; defaultSystemInfo.family = kDefaultMacProFamily; defaultBaseBoard.product = kDefaultMacProWestmereBoardProduct; defaultBaseBoard.boardType = kSMBBaseBoardProcessorMemoryModule; @@ -852,7 +864,7 @@ case kSMBByte: case kSMBWord: case kSMBDWord: - //case kSMBQWord: + case kSMBQWord: if (SMBSetters[idx].keyString) { parsed = getIntForKey(SMBSetters[idx].keyString, &val, SMBPlist); if (!parsed) @@ -869,9 +881,9 @@ case kSMBWord: value->word = (uint16_t)val; break; - //case kSMBQWord: - // value->qword = (uint64_t)val; - // break; + case kSMBQWord: + value->qword = (uint64_t)val; + break; case kSMBDWord: default: value->dword = (uint32_t)val; @@ -897,9 +909,9 @@ case kSMBWord: value->word = *(uint16_t *)(SMBSetters[idx].defaultValue); break; - //case kSMBQWord: - // value->qword = *(uint32_t *)(SMBSetters[idx].defaultValue); - // break; + case kSMBQWord: + value->qword = *(uint64_t *)(SMBSetters[idx].defaultValue); + break; case kSMBDWord: default: value->dword = *(uint32_t *)(SMBSetters[idx].defaultValue); @@ -1071,7 +1083,7 @@ structSize = sizeof(SMBMemoryDevice); break; default: - structSize = structPtr->orig->length; // don't change if not to patch + structSize = structPtr->orig->length; // doesn't change a length for unpatched break; } Index: trunk/i386/libsaio/smbios_decode.c =================================================================== --- trunk/i386/libsaio/smbios_decode.c (revision 2381) +++ trunk/i386/libsaio/smbios_decode.c (revision 2382) @@ -170,6 +170,25 @@ "Socket LGA1356-3" /* 2Ch */ }; +static const char *SMBMemoryDeviceFormFactors[] = // Bungo: strings for form factor (Table Type 17 - Memory Device) +{ + "Other", /* 01h */ + "Unknown", /* 02h */ + "SIMM", /* 03h */ + "SIP", /* 04h */ + "Chip", /* 05h */ + "DIP", /* 06h */ + "ZIP", /* 07h */ + "Proprietary Card", /* 08h */ + "DIMM", /* 09h */ + "TSOP", /* 0Ah */ + "Row of chips", /* 0Bh */ + "RIMM", /* 0Ch */ + "SODIMM", /* 0Dh */ + "SRIMM", /* 0Eh */ + "FB-DIMM" /* 0Fh */ +}; + /*===== 7.18.2 ====*/ @@ -421,11 +440,32 @@ printHeader(structHeader); DBG("Memory Device\n"); // Aray Handle - DBG("\tError Information Handle: 0x%x\n", ((SMBMemoryDevice *)structHeader)->errorHandle); + if (((SMBMemoryDevice *)structHeader)->errorHandle == 0xFFFF) { + DBG("\tError Information Handle: No Error\n"); + } else { + DBG("\tError Information Handle: 0x%x\n", ((SMBMemoryDevice *)structHeader)->errorHandle); + } // Total Width: // Data Width: -// Size: -// Form Factor: + switch (((SMBMemoryDevice *)structHeader)->memorySize) { + case 0: + DBG("\tSize: No Module Installed\n"); + break; + case 0x7FFF: + DBG("\tSize: 32GB or more\n"); + break; + case 0xFFFF: + DBG("\tSize: Unknown\n"); + break; + default: + DBG("\tSize: %d %s\n", ((SMBMemoryDevice *)structHeader)->memorySize & 0x7FFF, ((((SMBMemoryDevice *)structHeader)->memorySize & 0x8000) == 0x8000) ? "kB" : "MB"); + break; + } + if ((((SMBMemoryDevice *)structHeader)->formFactor < 0x01) || (((SMBMemoryDevice *)structHeader)->formFactor > 0x0F)) { + DBG("\tForm Factor: %s\n", OutOfSpecStr); + } else { + DBG("\tForm Factor: %s\n", SMBMemoryDeviceFormFactors[((SMBMemoryDevice *)structHeader)->formFactor - 1]); + } // Set: DBG("\tLocator: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->deviceLocator, neverMask)); DBG("\tBank Locator: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->bankLocator, neverMask)); @@ -480,7 +520,7 @@ //} //------------------------------------------------------------------------------------------------------------------------- -// Specific (Type 134) +// Specific (Type 134) //------------------------------------------------------------------------------------------------------------------------- //void decodeOem(SMBStructHeader *structHeader) //{ Index: trunk/i386/libsaio/smbios.h =================================================================== --- trunk/i386/libsaio/smbios.h (revision 2381) +++ trunk/i386/libsaio/smbios.h (revision 2382) @@ -24,8 +24,8 @@ #define __LIBSAIO_SMBIOS_H -/* Based on System Management BIOS Reference Specification v2.5 */ -// http://dmtf.org/sites/default/files/standards/documents/DSP0134_2.8.0.pdf +/* Based on System Management BIOS Reference Specification v2.4 */ +// http://dmtf.org/standards/smbios typedef uint8_t SMBString; typedef uint8_t SMBByte; @@ -81,10 +81,7 @@ #define SMB_ANCHOR_RESET(x) \ bzero(x, sizeof(typedef struct SMBAnchor)); -/* - ======================= - SMBIOS structure types. - ======================= */ +/* ======================= SMBIOS structure types. ======================= */ enum { kSMBTypeBIOSInformation = 0, // BIOS information (Type 0) @@ -138,13 +135,12 @@ kSMBTypeFirmwareVolume = 128, // FirmwareVolume (TYPE 128) kSMBTypeMemorySPD = 130, // MemorySPD (TYPE 130) kSMBTypeOemProcessorType = 131, // Processor Type (Type 131) - kSMBTypeOemProcessorBusSpeed = 132 // Processor Bus Speed (Type 132) - //kSMBTypeOemPlatformFeature = 133 // Platform Feature (Type 133) + kSMBTypeOemProcessorBusSpeed = 132, // Processor Bus Speed (Type 132) + kSMBTypeOemPlatformFeature = 133 // Platform Feature (Type 133) }; -/* ======================= - BIOS Information (Type 0) - ========================= */ +//---------------------------------------------------------------------------------------------------------- +// Struct - BIOS Information (Type 0) typedef struct SMBBIOSInformation { SMB_STRUCT_HEADER @@ -163,9 +159,8 @@ SMBByte ECreleaseMinor; // Embedded Controller firmware release (minor) } __attribute__((packed)) SMBBIOSInformation; -/* ========================= - System Information (Type 1) - =========================== */ +//---------------------------------------------------------------------------------------------------------- +// Struct - System Information (Type 1) typedef struct SMBSystemInformation { // 2.0+ spec (8 bytes) @@ -182,9 +177,29 @@ SMBString family; } __attribute__((packed)) SMBSystemInformation; -/* ========================================= - Base Board (or Module) Information (Type 2) - =========================================== */ +//---------------------------------------------------------------------------------------------------------- +// Base Board (or Module) Information (Type 2) + +// Base Board - Board Type. +// Values for SMBBaseBoard.boardType +typedef enum +{ + kSMBBaseBoardUnknown = 0x01, // Unknow + kSMBBaseBoardOther = 0x02, // Other + kSMBBaseBoardServerBlade = 0x03, // Server Blade + kSMBBaseBoardConnectivitySwitch = 0x04, // Connectivity Switch + kSMBBaseBoardSystemMgmtModule = 0x05, // System Management Module + kSMBBaseBoardProcessorModule = 0x06, // Processor Module + kSMBBaseBoardIOModule = 0x07, // I/O Module + kSMBBaseBoardMemoryModule = 0x08, // Memory Module + kSMBBaseBoardDaughter = 0x09, // Daughter Board + kSMBBaseBoardMotherboard = 0x0A, // Motherboard (includes processor, memory, and I/O) + kSMBBaseBoardProcessorMemoryModule = 0x0B, // Processor/Memory Module + kSMBBaseBoardProcessorIOModule = 0x0C, // Processor/IO Module + kSMBBaseBoardInterconnect = 0x0D // Interconnect board +} BASE_BOARD_TYPE; + +// Struct - Base Board (or Module) Information (Type 2) typedef struct SMBBaseBoard { SMB_STRUCT_HEADER // Type 2 @@ -196,61 +211,20 @@ SMBByte featureFlags; // Collection of flag that identify features of this baseboard SMBString locationInChassis; SMBWord chassisHandle; - SMBByte boardType; // Type of board + SMBByte boardType; // Type of board, numeration value from BASE_BOARD_TYPE. SMBByte numberOfContainedHandles; -// SMBWord containedObjectHandles[1]; // 0 - 255 contained handles go here but we do not include // them in our structure. Be careful to use numberOfContainedHandles // times sizeof(SMBWord) when computing the actual record size, // if you need it. + SMBByte containedObjectHandles; } __attribute__((packed)) SMBBaseBoard; -/* ==================================== - Values for boardType in Type 2 records - ====================================== */ -enum -{ - kSMBBaseBoardUnknown = 0x01, // Unknow - kSMBBaseBoardOther = 0x02, // Other - kSMBBaseBoardServerBlade = 0x03, // Server Blade - kSMBBaseBoardConnectivitySwitch = 0x04, // Connectivity Switch - kSMBBaseBoardSystemMgmtModule = 0x05, // System Management Module - kSMBBaseBoardProcessorModule = 0x06, // Processor Module - kSMBBaseBoardIOModule = 0x07, // I/O Module - kSMBBaseBoardMemoryModule = 0x08, // Memory Module - kSMBBaseBoardDaughter = 0x09, // Daughter Board - kSMBBaseBoardMotherboard = 0x0A, // Motherboard (includes processor, memory, and I/O) - kSMBBaseBoardProcessorMemoryModule = 0x0B, // Processor/Memory Module - kSMBBaseBoardProcessorIOModule = 0x0C, // Processor/IO Module - kSMBBaseBoardInterconnect = 0x0D // Interconnect board -}; +//---------------------------------------------------------------------------------------------------------- +// System Enclosure (Type 3) -/* ======================= - System Enclosure (Type 3) - ========================= */ -typedef struct SMBSystemEnclosure -{ - SMB_STRUCT_HEADER // Type 3 - SMBString manufacturer; - SMBByte chassisType; // System Enclosure Indicator - SMBString version; // Board Number? - SMBString serialNumber; - SMBString assetTag; // Bungo: renamed from assetTagNumber folowing convention - SMBByte bootupState; // State of enclosure when when it was last booted - SMBByte powerSupplyState; // State of enclosure's power supply when last booted - SMBByte thermalState; // Thermal state of the enclosure when last booted - SMBByte securityStatus; // Physical security status of the enclosure when last booted - SMBDWord oemDefined; // OEM- or BIOS vendor-specific information - SMBByte height; // Height of the enclosure, in 'U's - SMBByte numberOfPowerCords; // Number of power cords associated with the enclosure or chassis - SMBByte containedElementCount; // Number of Contained Element record that follow, in the range 0 to 255 -// SMBByte containedElementRecord; // Byte leght of each Contained Element record that follow, in the range 0 to 255 -// SMBByte containedElements; // Elements, possibly defined by other SMBIOS structures present in chassis -// SMBString skuNumber; // Number of null-terminated string describing the chassis or enclosure SKU number (2.7+) -} __attribute__((packed)) SMBSystemEnclosure; - // Bungo: values for SMBSystemEnclosure.chassisType -enum { +typedef enum { kSMBchassisOther = 0x01, kSMBchassisUnknown = 0x02, kSMBchassisDesktop = 0x03, @@ -269,18 +243,313 @@ kSMBchassisLunchBox = 0x10, // ... fill up if needed ;-) kSMBchassisBladeEnclosing = 0x1D -}; +} MISC_CHASSIS_TYPE; -/* ============================ - Processor Information (Type 4) - ============================== */ +// System Enclosure or Chassis States. +// values for SMBSystemEnclosure.bootupState +// values for SMBSystemEnclosure.powerSupplyState +// values for SMBSystemEnclosure.thermalState +typedef enum { + kSMBChassisStateOther = 0x01, + kSMBChassisStateUnknown = 0x02, + kSMBChassisStateSafe = 0x03, + kSMBChassisStateWarning = 0x04, + kSMBChassisStateCritical = 0x05, + kSMBChassisStateNonRecoverable = 0x06 +} MISC_CHASSIS_STATE; + +// System Enclosure or Chassis Security Status. +// values for SMBSystemEnclosure.securityStatus +typedef enum { + kSMBChassisSecurityStatusOther = 0x01, + kSMBChassisSecurityStatusUnknown = 0x02, + kSMBChassisSecurityStatusNone = 0x03, + kSMBChassisSecurityStatusExternalInterfaceLockedOut = 0x04, + kSMBChassisSecurityStatusExternalInterfaceLockedEnabled = 0x05 +} MISC_CHASSIS_SECURITY_STATE; + +// Struct - System Enclosure (Type 3) +typedef struct SMBSystemEnclosure +{ + SMB_STRUCT_HEADER // Type 3 + SMBString manufacturer; + SMBByte chassisType; // System Enclosure Indicator + SMBString version; // Board Number? + SMBString serialNumber; + SMBString assetTag; // Bungo: renamed from assetTagNumber folowing convention + SMBByte bootupState; // State of enclosure when when it was last booted + SMBByte powerSupplyState; // State of enclosure's power supply when last booted + SMBByte thermalState; // Thermal state of the enclosure when last booted + SMBByte securityStatus; // Physical security status of the enclosure when last booted + SMBDWord oemDefined; // OEM- or BIOS vendor-specific information + SMBByte height; // Height of the enclosure, in 'U's + SMBByte numberOfPowerCords; // Number of power cords associated with the enclosure or chassis + SMBByte containedElementCount; // Number of Contained Element record that follow, in the range 0 to 255 + // SMBByte containedElementRecord; // Byte leght of each Contained Element record that follow, in the range 0 to 255 + // SMBByte containedElements; // Elements, possibly defined by other SMBIOS structures present in chassis + // SMBString skuNumber; // Number of null-terminated string describing the chassis or enclosure SKU number (2.7+) +} __attribute__((packed)) SMBSystemEnclosure; + +//---------------------------------------------------------------------------------------------------------- +// Processor Information (Type 4) +#define kSMBProcessorInformationMinSize 26 + +// Processor Information - Processor Type. +// Values for SMBProcessorInformation.processorType +typedef enum +{ + kSMBprocessorTypeOther = 0x01, + kSMBprocessorTypeUnknown = 0x02, + kSMBprocessorTypeCPU = 0x03, + kSMBprocessorTypeMPU = 0x04, + kSMBprocessorTypeDSP = 0x05, + kSMBprocessorTypeGPU = 0x06 +} PROCESSOR_TYPE_DATA; + +// Processor Information - Processor Family. +// Values for SMBProcessorInformation.processorFamily +typedef enum { + kSMBprocessorFamilyOther = 0x01, + kSMBprocessorFamilyUnknown = 0x02, + kSMBprocessorFamily8086 = 0x03, + kSMBprocessorFamily80286 = 0x04, + kSMBprocessorFamilyIntel386 = 0x05, + kSMBprocessorFamilyIntel486 = 0x06, + kSMBprocessorFamily8087 = 0x07, + kSMBprocessorFamily80287 = 0x08, + kSMBprocessorFamily80387 = 0x09, + kSMBprocessorFamily80487 = 0x0A, + kSMBprocessorFamilyPentium = 0x0B, + kSMBprocessorFamilyPentiumPro = 0x0C, + kSMBprocessorFamilyPentiumII = 0x0D, + kSMBprocessorFamilyPentiumMMX = 0x0E, + kSMBprocessorFamilyCeleron = 0x0F, + kSMBprocessorFamilyPentiumIIXeon = 0x10, + kSMBprocessorFamilyPentiumIII = 0x11, + kSMBprocessorFamilyM1 = 0x12, + kSMBprocessorFamilyM2 = 0x13, + kSMBprocessorFamilyIntelCeleronM = 0x14, + kSMBprocessorFamilyIntelPentium4Ht = 0x15, + kSMBprocessorFamilyM1Reserved4 = 0x16, + kSMBprocessorFamilyM1Reserved5 = 0x17, + kSMBprocessorFamilyAmdDuron = 0x18, + kSMBprocessorFamilyK5 = 0x19, + kSMBprocessorFamilyK6 = 0x1A, + kSMBprocessorFamilyK6_2 = 0x1B, + kSMBprocessorFamilyK6_3 = 0x1C, + kSMBprocessorFamilyAmdAthlon = 0x1D, + kSMBprocessorFamilyAmd29000 = 0x1E, + kSMBprocessorFamilyK6_2Plus = 0x1F, + kSMBprocessorFamilyPowerPC = 0x20, + kSMBprocessorFamilyPowerPC601 = 0x21, + kSMBprocessorFamilyPowerPC603 = 0x22, + kSMBprocessorFamilyPowerPC603Plus = 0x23, + kSMBprocessorFamilyPowerPC604 = 0x24, + kSMBprocessorFamilyPowerPC620 = 0x25, + kSMBprocessorFamilyPowerPCx704 = 0x26, + kSMBprocessorFamilyPowerPC750 = 0x27, + kSMBprocessorFamilyIntelCoreDuo = 0x28, + kSMBprocessorFamilyIntelCoreDuoMobile = 0x29, + kSMBprocessorFamilyIntelCoreSoloMobile = 0x2A, + kSMBprocessorFamilyIntelAtom = 0x2B, + kSMBprocessorFamilyAlpha3 = 0x30, + kSMBprocessorFamilyAlpha21064 = 0x31, + kSMBprocessorFamilyAlpha21066 = 0x32, + kSMBprocessorFamilyAlpha21164 = 0x33, + kSMBprocessorFamilyAlpha21164PC = 0x34, + kSMBprocessorFamilyAlpha21164a = 0x35, + kSMBprocessorFamilyAlpha21264 = 0x36, + kSMBprocessorFamilyAlpha21364 = 0x37, + kSMBprocessorFamilyAmdTurionIIUltraDualCoreMobileM = 0x38, + kSMBprocessorFamilyAmdTurionIIDualCoreMobileM = 0x39, + kSMBprocessorFamilyAmdAthlonIIDualCoreM = 0x3A, + kSMBprocessorFamilyAmdOpteron6100Series = 0x3B, + kSMBprocessorFamilyAmdOpteron4100Series = 0x3C, + kSMBprocessorFamilyAmdOpteron6200Series = 0x3D, + kSMBprocessorFamilyAmdOpteron4200Series = 0x3E, + kSMBprocessorFamilyMips = 0x40, + kSMBprocessorFamilyMIPSR4000 = 0x41, + kSMBprocessorFamilyMIPSR4200 = 0x42, + kSMBprocessorFamilyMIPSR4400 = 0x43, + kSMBprocessorFamilyMIPSR4600 = 0x44, + kSMBprocessorFamilyMIPSR10000 = 0x45, + kSMBprocessorFamilyAmdCSeries = 0x46, + kSMBprocessorFamilyAmdESeries = 0x47, + kSMBprocessorFamilyAmdSSeries = 0x48, + kSMBprocessorFamilyAmdGSeries = 0x49, + kSMBprocessorFamilySparc = 0x50, + kSMBprocessorFamilySuperSparc = 0x51, + kSMBprocessorFamilymicroSparcII = 0x52, + kSMBprocessorFamilymicroSparcIIep = 0x53, + kSMBprocessorFamilyUltraSparc = 0x54, + kSMBprocessorFamilyUltraSparcII = 0x55, + kSMBprocessorFamilyUltraSparcIIi = 0x56, + kSMBprocessorFamilyUltraSparcIII = 0x57, + kSMBprocessorFamilyUltraSparcIIIi = 0x58, + kSMBprocessorFamily68040 = 0x60, + kSMBprocessorFamily68xxx = 0x61, + kSMBprocessorFamily68000 = 0x62, + kSMBprocessorFamily68010 = 0x63, + kSMBprocessorFamily68020 = 0x64, + kSMBprocessorFamily68030 = 0x65, + kSMBprocessorFamilyHobbit = 0x70, + kSMBprocessorFamilyCrusoeTM5000 = 0x78, + kSMBprocessorFamilyCrusoeTM3000 = 0x79, + kSMBprocessorFamilyEfficeonTM8000 = 0x7A, + kSMBprocessorFamilyWeitek = 0x80, + kSMBprocessorFamilyItanium = 0x82, + kSMBprocessorFamilyAmdAthlon64 = 0x83, + kSMBprocessorFamilyAmdOpteron = 0x84, + kSMBprocessorFamilyAmdSempron = 0x85, + kSMBprocessorFamilyAmdTurion64Mobile = 0x86, + kSMBprocessorFamilyDualCoreAmdOpteron = 0x87, + kSMBprocessorFamilyAmdAthlon64X2DualCore = 0x88, + kSMBprocessorFamilyAmdTurion64X2Mobile = 0x89, + kSMBprocessorFamilyQuadCoreAmdOpteron = 0x8A, + kSMBprocessorFamilyThirdGenerationAmdOpteron = 0x8B, + kSMBprocessorFamilyAmdPhenomFxQuadCore = 0x8C, + kSMBprocessorFamilyAmdPhenomX4QuadCore = 0x8D, + kSMBprocessorFamilyAmdPhenomX2DualCore = 0x8E, + kSMBprocessorFamilyAmdAthlonX2DualCore = 0x8F, + kSMBprocessorFamilyPARISC = 0x90, + kSMBprocessorFamilyPaRisc8500 = 0x91, + kSMBprocessorFamilyPaRisc8000 = 0x92, + kSMBprocessorFamilyPaRisc7300LC = 0x93, + kSMBprocessorFamilyPaRisc7200 = 0x94, + kSMBprocessorFamilyPaRisc7100LC = 0x95, + kSMBprocessorFamilyPaRisc7100 = 0x96, + kSMBprocessorFamilyV30 = 0xA0, + kSMBprocessorFamilyQuadCoreIntelXeon3200Series = 0xA1, + kSMBprocessorFamilyDualCoreIntelXeon3000Series = 0xA2, + kSMBprocessorFamilyQuadCoreIntelXeon5300Series = 0xA3, + kSMBprocessorFamilyDualCoreIntelXeon5100Series = 0xA4, + kSMBprocessorFamilyDualCoreIntelXeon5000Series = 0xA5, + kSMBprocessorFamilyDualCoreIntelXeonLV = 0xA6, + kSMBprocessorFamilyDualCoreIntelXeonULV = 0xA7, + kSMBprocessorFamilyDualCoreIntelXeon7100Series = 0xA8, + kSMBprocessorFamilyQuadCoreIntelXeon5400Series = 0xA9, + kSMBprocessorFamilyQuadCoreIntelXeon = 0xAA, + kSMBprocessorFamilyDualCoreIntelXeon5200Series = 0xAB, + kSMBprocessorFamilyDualCoreIntelXeon7200Series = 0xAC, + kSMBprocessorFamilyQuadCoreIntelXeon7300Series = 0xAD, + kSMBprocessorFamilyQuadCoreIntelXeon7400Series = 0xAE, + kSMBprocessorFamilyMultiCoreIntelXeon7400Series = 0xAF, + kSMBprocessorFamilyPentiumIIIXeon = 0xB0, + kSMBprocessorFamilyPentiumIIISpeedStep = 0xB1, + kSMBprocessorFamilyPentium4 = 0xB2, + kSMBprocessorFamilyIntelXeon = 0xB3, + kSMBprocessorFamilyAS400 = 0xB4, + kSMBprocessorFamilyIntelXeonMP = 0xB5, + kSMBprocessorFamilyAMDAthlonXP = 0xB6, + kSMBprocessorFamilyAMDAthlonMP = 0xB7, + kSMBprocessorFamilyIntelItanium2 = 0xB8, + kSMBprocessorFamilyIntelPentiumM = 0xB9, + kSMBprocessorFamilyIntelCeleronD = 0xBA, + kSMBprocessorFamilyIntelPentiumD = 0xBB, + kSMBprocessorFamilyIntelPentiumEx = 0xBC, + kSMBprocessorFamilyIntelCoreSolo = 0xBD, ///< SMBIOS spec 2.6 correct this value + kSMBprocessorFamilyReserved = 0xBE, + kSMBprocessorFamilyIntelCore2 = 0xBF, + kSMBprocessorFamilyIntelCore2Solo = 0xC0, + kSMBprocessorFamilyIntelCore2Extreme = 0xC1, + kSMBprocessorFamilyIntelCore2Quad = 0xC2, + kSMBprocessorFamilyIntelCore2ExtremeMobile = 0xC3, + kSMBprocessorFamilyIntelCore2DuoMobile = 0xC4, + kSMBprocessorFamilyIntelCore2SoloMobile = 0xC5, + kSMBprocessorFamilyIntelCoreI7 = 0xC6, + kSMBprocessorFamilyDualCoreIntelCeleron = 0xC7, + kSMBprocessorFamilyIBM390 = 0xC8, + kSMBprocessorFamilyG4 = 0xC9, + kSMBprocessorFamilyG5 = 0xCA, + kSMBprocessorFamilyG6 = 0xCB, + kSMBprocessorFamilyzArchitectur = 0xCC, + kSMBprocessorFamilyIntelCoreI5 = 0xCD, + kSMBprocessorFamilyIntelCoreI3 = 0xCE, + kSMBprocessorFamilyViaC7M = 0xD2, + kSMBprocessorFamilyViaC7D = 0xD3, + kSMBprocessorFamilyViaC7 = 0xD4, + kSMBprocessorFamilyViaEden = 0xD5, + kSMBprocessorFamilyMultiCoreIntelXeon = 0xD6, + kSMBprocessorFamilyDualCoreIntelXeon3Series = 0xD7, + kSMBprocessorFamilyQuadCoreIntelXeon3Series = 0xD8, + kSMBprocessorFamilyViaNano = 0xD9, + kSMBprocessorFamilyDualCoreIntelXeon5Series = 0xDA, + kSMBprocessorFamilyQuadCoreIntelXeon5Series = 0xDB, + kSMBprocessorFamilyDualCoreIntelXeon7Series = 0xDD, + kSMBprocessorFamilyQuadCoreIntelXeon7Series = 0xDE, + kSMBprocessorFamilyMultiCoreIntelXeon7Series = 0xDF, + kSMBprocessorFamilyMultiCoreIntelXeon3400Series = 0xE0, + kSMBprocessorFamilyEmbeddedAmdOpteronQuadCore = 0xE6, + kSMBprocessorFamilyAmdPhenomTripleCore = 0xE7, + kSMBprocessorFamilyAmdTurionUltraDualCoreMobile = 0xE8, + kSMBprocessorFamilyAmdTurionDualCoreMobile = 0xE9, + kSMBprocessorFamilyAmdAthlonDualCore = 0xEA, + kSMBprocessorFamilyAmdSempronSI = 0xEB, + kSMBprocessorFamilyAmdPhenomII = 0xEC, + kSMBprocessorFamilyAmdAthlonII = 0xED, + kSMBprocessorFamilySixCoreAmdOpteron = 0xEE, + kSMBprocessorFamilyAmdSempronM = 0xEF, + kSMBprocessorFamilyi860 = 0xFA, + kSMBprocessorFamilyi960 = 0xFB, + kSMBprocessorFamilyIndicatorFamily2 = 0xFE, + kSMBprocessorFamilyReserved1 = 0xFF +} PROCESSOR_FAMILY_DATA; + +// Processor Information - Processor Upgrade. +// Values for SMBProcessorInformation.processorUpgrade +typedef enum { + kSMBprocessorUpgradeOther = 0x01, + kSMBprocessorUpgradeUnknown = 0x02, + kSMBprocessorUpgradeDaughterBoard = 0x03, + kSMBprocessorUpgradeZIFSocket = 0x04, + kSMBprocessorUpgradePiggyBack = 0x05, ///< Replaceable. + kSMBprocessorUpgradeNone = 0x06, + kSMBprocessorUpgradeLIFSocket = 0x07, + kSMBprocessorUpgradeSlot1 = 0x08, + kSMBprocessorUpgradeSlot2 = 0x09, + kSMBprocessorUpgrade370PinSocket = 0x0A, + kSMBprocessorUpgradeSlotA = 0x0B, + kSMBprocessorUpgradeSlotM = 0x0C, + kSMBprocessorUpgradeSocket423 = 0x0D, + kSMBprocessorUpgradeSocketA = 0x0E, ///< Socket 462. + kSMBprocessorUpgradeSocket478 = 0x0F, + kSMBprocessorUpgradeSocket754 = 0x10, + kSMBprocessorUpgradeSocket940 = 0x11, + kSMBprocessorUpgradeSocket939 = 0x12, + kSMBprocessorUpgradeSocketmPGA604 = 0x13, + kSMBprocessorUpgradeSocketLGA771 = 0x14, + kSMBprocessorUpgradeSocketLGA775 = 0x15, + kSMBprocessorUpgradeSocketS1 = 0x16, + kSMBprocessorUpgradeAM2 = 0x17, + kSMBprocessorUpgradeF1207 = 0x18, + kSMBprocessorUpgradeSocketLGA1366 = 0x19, + kSMBprocessorUpgradeSocketG34 = 0x1A, + kSMBprocessorUpgradeSocketAM3 = 0x1B, + kSMBprocessorUpgradeSocketC32 = 0x1C, + kSMBprocessorUpgradeSocketLGA1156 = 0x1D, + kSMBprocessorUpgradeSocketLGA1567 = 0x1E, + kSMBprocessorUpgradeSocketPGA988A = 0x1F, + kSMBprocessorUpgradeSocketBGA1288 = 0x20, + kSMBprocessorUpgradeSocketrPGA988B = 0x21, + kSMBprocessorUpgradeSocketBGA1023 = 0x22, + kSMBprocessorUpgradeSocketBGA1224 = 0x23, + kSMBprocessorUpgradeSocketBGA1155 = 0x24, + kSMBprocessorUpgradeSocketLGA1356 = 0x25, + kSMBprocessorUpgradeSocketLGA2011 = 0x26, + kSMBprocessorUpgradeSocketFS1 = 0x27, + kSMBprocessorUpgradeSocketFS2 = 0x28, + kSMBprocessorUpgradeSocketFM1 = 0x29, + kSMBprocessorUpgradeSocketFM2 = 0x2A +} PROCESSOR_UPGRADE; + +// Struct - Processor Information (Type 4). typedef struct SMBProcessorInformation { // 2.0+ spec (26 bytes) SMB_STRUCT_HEADER // Type 4 SMBString socketDesignation; - SMBByte processorType; // CPU = 3 - SMBByte processorFamily; // processor family enum + SMBByte processorType; // The enumeration value from PROCESSOR_TYPE_DATA. + SMBByte processorFamily; // The enumeration value from PROCESSOR_FAMILY_DATA. SMBString manufacturer; SMBQWord processorID; // based on CPUID SMBString processorVersion; @@ -289,7 +558,7 @@ SMBWord maximumClock; // max internal clock in MHz SMBWord currentClock; // current internal clock in MHz SMBByte status; - SMBByte processorUpgrade; // processor upgrade enum + SMBByte processorUpgrade; // The enumeration value from PROCESSOR_UPGRADE. // 2.1+ spec (32 bytes) SMBWord L1CacheHandle; SMBWord L2CacheHandle; @@ -307,24 +576,8 @@ // SMBWord processorFamily2; } __attribute__((packed)) SMBProcessorInformation; -#define kSMBProcessorInformationMinSize 26 - -/* ======================================== - Values for processorType in Type 4 records - ======================================== */ -enum -{ - kSMBprocessorTypeOther = 0x01, - kSMBprocessorTypeUnknown = 0x02, - kSMBprocessorTypeCPU = 0x03, - kSMBprocessorTypeMPU = 0x04, - kSMBprocessorTypeDSP = 0x05, - kSMBprocessorTypeGPU = 0x06 -}; - -/* ====================================================================== - Memory Controller Information (Type 5) Obsolete since SMBIOS version 2.1 - ======================================================================== */ +//---------------------------------------------------------------------------------------------------------- +// Struct - Memory Controller Information (Type 5) Obsolete since SMBIOS version 2.1 typedef struct SMBMemoryControllerInfo { SMB_STRUCT_HEADER SMBByte errorDetectingMethod; @@ -338,9 +591,8 @@ SMBByte numberOfMemorySlots; } __attribute__((packed)) SMBMemoryControllerInfo; -/* ================================================================== - Memory Module Information (Type 6) Obsolete since SMBIOS version 2.1 - ==================================================================== */ +//---------------------------------------------------------------------------------------------------------- +// Struct - Memory Module Information (Type 6) Obsolete since SMBIOS version 2.1 typedef struct SMBMemoryModule { SMB_STRUCT_HEADER // Type 6 @@ -357,9 +609,8 @@ #define kSMBMemoryModuleSizeNotEnabled 0x7E #define kSMBMemoryModuleSizeNotInstalled 0x7F -/* ======================== - Cache Information (Type 7) - ========================== */ +//---------------------------------------------------------------------------------------------------------- +// Struct - Cache Information (Type 7) typedef struct SMBCacheInformation { SMB_STRUCT_HEADER // Type 7 @@ -375,9 +626,8 @@ SMBByte associativity; } __attribute__((packed)) SMBCacheInformation; -/* =================== - System Slots (Type 9) - ===================== */ +//---------------------------------------------------------------------------------------------------------- +// Struct - System Slots (Type 9) typedef struct SMBSystemSlot { // 2.0+ spec (12 bytes) @@ -397,36 +647,20 @@ // SMBByte deviceFunctionNumber; } __attribute__((packed)) SMBSystemSlot; -/* =================== - OEM Strings (Type 11) - ===================== */ +//---------------------------------------------------------------------------------------------------------- +// Struct - OEM Strings (Type 11) typedef struct SMBOEMStrings { SMB_STRUCT_HEADER // Type 11 SMBByte count; // number of strings } __attribute__((packed)) SMBOEMStrings; -/* ============================= - Physical Memory Array (Type 16) - =============================== */ -typedef struct SMBPhysicalMemoryArray -{ - // 2.1+ spec (15 bytes) - SMB_STRUCT_HEADER // Type 16 - SMBByte physicalLocation; // physical location - SMBByte arrayUse; // the use for the memory array - SMBByte errorCorrection; // error correction/detection method - SMBDWord maximumCapacity; // maximum memory capacity in kilobytes - SMBWord errorHandle; // handle of a previously detected error - SMBWord numMemoryDevices; // number of memory slots or sockets - // 2.7+ spec -// SMBQWord extMaximumCapacity; // maximum memory capacity in bytes -} __attribute__((packed)) SMBPhysicalMemoryArray; +//---------------------------------------------------------------------------------------------------------- +// Physical Memory Array (Type 16) -/* ================ - Memory Array - Use - ================== */ -enum +// Physical Memory Array - Use. +// Values for SMBPhysicalMemoryArray.arrayUse +typedef enum { kSMBMemoryArrayUseOther = 0x01, kSMBMemoryArrayUseUnknown = 0x02, @@ -435,12 +669,11 @@ kSMBMemoryArrayUseFlashMemory = 0x05, kSMBMemoryArrayUseNonVolatileMemory = 0x06, kSMBMemoryArrayUseCacheMemory = 0x07 -}; +} MEMORY_ARRAY_USE; -/* =================================== - Memory Array - Error Correction Types - ===================================== */ -enum +// Physical Memory Array - Error Correction Types. +// Values for SMBPhysicalMemoryArray.errorCorrection +typedef enum { kSMBMemoryArrayErrorCorrectionTypeOther = 0x01, kSMBMemoryArrayErrorCorrectionTypeUnknown = 0x02, @@ -449,11 +682,25 @@ kSMBMemoryArrayErrorCorrectionTypeSingleBitECC = 0x05, kSMBMemoryArrayErrorCorrectionTypeMultiBitECC = 0x06, kSMBMemoryArrayErrorCorrectionTypeCRC = 0x07 -}; +} MEMORY_ERROR_CORRECTION; -/* ===================== - Memory Device (Type 17) - ======================= */ +// Struct - Physical Memory Array (Type 16) +typedef struct SMBPhysicalMemoryArray +{ + // 2.1+ spec (15 bytes) + SMB_STRUCT_HEADER // Type 16 + SMBByte physicalLocation; // physical location + SMBByte arrayUse; // the use for the memory array, The enumeration value from MEMORY_ARRAY_USE. + SMBByte errorCorrection; // error correction/detection method, The enumeration value from MEMORY_ERROR_CORRECTION. + SMBDWord maximumCapacity; // maximum memory capacity in kilobytes + SMBWord errorHandle; // handle of a previously detected error + SMBWord numMemoryDevices; // number of memory slots or sockets + // 2.7+ spec + // SMBQWord extMaximumCapacity; // maximum memory capacity in bytes +} __attribute__((packed)) SMBPhysicalMemoryArray; + +//---------------------------------------------------------------------------------------------------------- +// Struct - Memory Device (Type 17) typedef struct SMBMemoryDevice { // 2.1+ spec (21 bytes) @@ -486,9 +733,9 @@ // SMBWord configuredVolt; } __attribute__((packed)) SMBMemoryDevice; -/* =================================== - Memory Array Mapped Address (Type 19) - ===================================== */ +//---------------------------------------------------------------------------------------------------------- + +// Struct - Memory Array Mapped Address (Type 19) //typedef struct SMBMemoryArrayMappedAddress //{ // 2.1+ spec @@ -502,9 +749,9 @@ // SMBQWord extEndAddress; //} __attribute__((packed)) SMBMemoryArrayMappedAddress; -/* ==================================== - Memory Device Mapped Address (Type 20) - ====================================== */ +//---------------------------------------------------------------------------------------------------------- + +// Struct - Memory Device Mapped Address (Type 20) //typedef struct SMBMemoryDeviceMappedAddress //{ // 2.1+ spec @@ -520,9 +767,8 @@ // SMBQWord extEndAddress; //} __attribute__((packed)) SMBMemoryDeviceMappedAddress; -/* ===================================================== - Firmware Volume Description (Apple Specific - Type 128) - ======================================================= */ +//---------------------------------------------------------------------------------------------------------- +// Firmware Volume Description (Apple Specific - Type 128) enum { FW_REGION_RESERVED = 0, @@ -541,9 +787,7 @@ SMBDWord EndAddress; } __attribute__((packed)) FW_REGION_INFO; -/* ======== - (Type 128) - ========== */ +// Struct - Firmware Volume Description (Apple Specific - Type 128) typedef struct SMBFirmwareVolume { SMB_STRUCT_HEADER // Type 128 @@ -555,6 +799,8 @@ FW_REGION_INFO FlashMap[ NUM_FLASHMAP_ENTRIES ]; } __attribute__((packed)) SMBFirmwareVolume; +//---------------------------------------------------------------------------------------------------------- + /* =========================================== Memory SPD Data (Apple Specific - Type 130) ============================================= */ @@ -564,9 +810,11 @@ SMBWord Type17Handle; SMBWord Offset; SMBWord Size; - SMBWord Data[]; + SMBWord Data[1]; } __attribute__((packed)) SMBMemorySPD; +//---------------------------------------------------------------------------------------------------------- + /* ============================================ OEM Processor Type (Apple Specific - Type 131) ============================================== */ @@ -576,6 +824,8 @@ SMBWord ProcessorType; } __attribute__((packed)) SMBOemProcessorType; +//---------------------------------------------------------------------------------------------------------- + /* ================================================= OEM Processor Bus Speed (Apple Specific - Type 132) =================================================== */ @@ -585,6 +835,8 @@ SMBWord ProcessorBusSpeed; // MT/s unit } __attribute__((packed)) SMBOemProcessorBusSpeed; +//---------------------------------------------------------------------------------------------------------- + /* ============================================== OEM Platform Feature (Apple Specific - Type 133) ================================================ */ Index: trunk/i386/libsaio/stringTable.c =================================================================== --- trunk/i386/libsaio/stringTable.c (revision 2381) +++ trunk/i386/libsaio/stringTable.c (revision 2382) @@ -60,7 +60,7 @@ break; } } else if (c == '\"') { - /* Premature end of key */ + // Premature end of key return 1; } if (c != *str++) { Index: trunk/i386/libsaio/fake_efi.c =================================================================== --- trunk/i386/libsaio/fake_efi.c (revision 2381) +++ trunk/i386/libsaio/fake_efi.c (revision 2382) @@ -74,9 +74,10 @@ /* Identify ourselves as the EFI firmware vendor */ static EFI_CHAR16 const FIRMWARE_VENDOR[] = {'C','h','a','m','e','l','e','o','n','_','2','.','2', 0}; -static EFI_UINT32 const FIRMWARE_REVISION = 132; /* FIXME: Find a constant for this. */ - // Bungo +//static EFI_UINT32 const FIRMWARE_REVISION = 132; /* FIXME: Find a constant for this. */ +static EFI_UINT32 const FIRMWARE_REVISION = 0x0001000a; // got from real MBP6,1 +// Bungo /* Default platform system_id (fix by IntVar) static EFI_CHAR8 const SYSTEM_ID[] = "0123456789ABCDEF"; //random value gen by uuidgen */ @@ -438,13 +439,15 @@ static const char FIRMWARE_VENDOR_PROP[] = "firmware-vendor"; static const char FIRMWARE_ABI_32_PROP_VALUE[] = "EFI32"; static const char FIRMWARE_ABI_64_PROP_VALUE[] = "EFI64"; +static const char EFI_MODE_PROP[] = "efi-mode"; //Bungo static const char SYSTEM_ID_PROP[] = "system-id"; static const char SYSTEM_SERIAL_PROP[] = "SystemSerialNumber"; static const char SYSTEM_TYPE_PROP[] = "system-type"; static const char MODEL_PROP[] = "Model"; static const char BOARDID_PROP[] = "board-id"; static const char DEV_PATH_SUP[] = "DevicePathsSupported"; -static uint32_t DevPathSup = 1; +static EFI_UINT32 DevPathSup = 1; +static EFI_UINT32 MachineSig = 0; //Bungo /* * Get an smbios option string option to convert to EFI_CHAR16 string */ @@ -567,16 +570,18 @@ // But I think eventually we want to fill stuff in the efi node // too so we might as well create it so we have a pointer for it too. node = DT__AddChild(node, "efi"); - +/* Bungo if (archCpuType == CPU_TYPE_I386) { DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_32_PROP_VALUE), (char*)FIRMWARE_ABI_32_PROP_VALUE); - } else { - DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_64_PROP_VALUE), (char*)FIRMWARE_ABI_64_PROP_VALUE); - } + } else { */ + DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_64_PROP_VALUE), (char *)FIRMWARE_ABI_64_PROP_VALUE); +// } - DT__AddProperty(node, FIRMWARE_REVISION_PROP, sizeof(FIRMWARE_REVISION), (EFI_UINT32*)&FIRMWARE_REVISION); - DT__AddProperty(node, FIRMWARE_VENDOR_PROP, sizeof(FIRMWARE_VENDOR), (EFI_CHAR16*)FIRMWARE_VENDOR); + DT__AddProperty(node, EFI_MODE_PROP, sizeof(EFI_UINT8), (EFI_UINT8 *)&bootArgs->efiMode); + DT__AddProperty(node, FIRMWARE_REVISION_PROP, sizeof(FIRMWARE_REVISION), (EFI_UINT32 *)&FIRMWARE_REVISION); + DT__AddProperty(node, FIRMWARE_VENDOR_PROP, sizeof(FIRMWARE_VENDOR), (EFI_CHAR16 *)FIRMWARE_VENDOR); + // TODO: Fill in other efi properties if necessary // Set up the /efi/runtime-services table node similar to the way a child node of configuration-table @@ -598,6 +603,11 @@ // all of the configuration tables needed by various kernel extensions. gEfiConfigurationTableNode = DT__AddChild(node, "configuration-table"); + // New node: /efi/kernel-compatibility + Node *efiKernelComNode = DT__AddChild(node, "kernel-compatibility"); + len = 1; + DT__AddProperty(efiKernelComNode, "x86_64", sizeof(uint32_t), (EFI_UINT32 *)&len); + // Now fill in the /efi/platform Node Node *efiPlatformNode = DT__AddChild(node, "platform"); @@ -618,7 +628,7 @@ DT__AddProperty(efiPlatformNode, CPU_Frequency_prop, sizeof(uint64_t), &Platform.CPU.CPUFrequency); } - DT__AddProperty(efiPlatformNode,DEV_PATH_SUP, sizeof(uint32_t), &DevPathSup); + DT__AddProperty(efiPlatformNode,DEV_PATH_SUP, sizeof(EFI_UINT32), &DevPathSup); // Bungo /* Export system-id. Can be disabled with SystemId=No in com.apple.Boot.plist @@ -674,11 +684,19 @@ stop("Couldn't get chosen node"); } - int bootUUIDLength = strlen(gBootUUIDString); - if (bootUUIDLength) + int length = strlen(gBootUUIDString); + if (length) { - DT__AddProperty(chosenNode, "boot-uuid", bootUUIDLength + 1, gBootUUIDString); + DT__AddProperty(chosenNode, "boot-uuid", length + 1, gBootUUIDString); } + + length = strlen(bootArgs->CommandLine); + DT__AddProperty(chosenNode, "boot-args", length + 1, bootArgs->CommandLine); + + length = strlen(bootInfo->bootFile); + DT__AddProperty(chosenNode, "boot-file", length + 1, bootInfo->bootFile); + + DT__AddProperty(chosenNode, "machine-signature", sizeof(EFI_UINT32), (EFI_UINT32 *)&MachineSig); } /* Index: trunk/i386/libsaio/smbios_getters.c =================================================================== --- trunk/i386/libsaio/smbios_getters.c (revision 2381) +++ trunk/i386/libsaio/smbios_getters.c (revision 2382) @@ -30,6 +30,7 @@ // set external clock to 0 for SANDY // removes FSB info from system profiler as on real mac's. case CPU_MODEL_SANDYBRIDGE: + case CPU_MODEL_JAKETOWN: case CPU_MODEL_IVYBRIDGE_XEON: case CPU_MODEL_IVYBRIDGE: case CPU_MODEL_HASWELL: @@ -85,10 +86,10 @@ case CPU_MODEL_NEHALEM_EX: // Intel Xeon X75xx, Xeon X65xx, Xeon E75xx, Xeon E65x case CPU_MODEL_WESTMERE_EX: // Intel Xeon E7 case CPU_MODEL_SANDYBRIDGE: // Intel Core i3, i5, i7 LGA1155 (32nm) + case CPU_MODEL_JAKETOWN: // Intel Core i7, Xeon E5 LGA2011 (32nm) case CPU_MODEL_IVYBRIDGE: // Intel Core i3, i5, i7 LGA1155 (22nm) case CPU_MODEL_IVYBRIDGE_XEON: case CPU_MODEL_HASWELL: - case CPU_MODEL_JAKETOWN: // Intel Core i7, Xeon E5 LGA2011 (32nm) { // thanks to dgobe for i3/i5/i7 bus speed detection int nhm_bus = 0x3F; @@ -138,7 +139,7 @@ if (Platform.CPU.NoCores >= 4) { return 0x501; // 1281 - Quad-Core Xeon } else if (Platform.CPU.NoCores == 1) { - return 0x201; // 513 - Core Solo + return 0x201; // 513 - Core Duo }; return 0x301; // 769 - Core 2 Duo @@ -155,31 +156,41 @@ verbose("CPU is %s, family 0x%x, model 0x%x\n", Platform.CPU.BrandString, (uint32_t)Platform.CPU.Family, (uint32_t)Platform.CPU.Model); done = true; } - // Bungo: fixes Oem Processor Type - better matching IMHO + // Bungo: fixes Oem Processor Type - better matching IMHO, needs testing switch (Platform.CPU.Family) { + case 0x0F: case 0x06: { switch (Platform.CPU.Model) { - + case CPU_MODEL_PENTIUM_M: case CPU_MODEL_DOTHAN: // 0x0D - Intel Pentium M model D - value->word = 0x101; // 257 + case CPU_MODEL_PRESCOTT: + case CPU_MODEL_NOCONA: + if (strstr(Platform.CPU.BrandString, "Xeon")) { + value->word = 0x402; // 1026 - Xeon + } return true; + case CPU_MODEL_PRESLER: + case CPU_MODEL_CELERON: case CPU_MODEL_YONAH: // 0x0E - Intel Mobile Core Solo, Duo - case CPU_MODEL_CELERON: value->word = 0x201; // 513 return true; + case CPU_MODEL_MEROM: // 0x0F - Intel Mobile Core 2 Solo, Duo, Xeon 30xx, Xeon 51xx, Xeon X53xx, Xeon E53xx, Xeon X32xx case CPU_MODEL_XEON_MP: // 0x1D - Six-Core Xeon 7400, "Dunnington", 45nm - value->word = 0x401; // 1025 + case CPU_MODEL_PENRYN: // 0x17 - Intel Core 2 Solo, Duo, Quad, Extreme, Xeon X54xx, Xeon X33xx + if (strstr(Platform.CPU.BrandString, "Xeon")) { + value->word = 0x402; // 1026 - Xeon return true; + } + if (Platform.CPU.NoCores <= 2) { + value->word = 0x301; // 769 - Core 2 Duo + } else { + value->word = 0x402; // 1026 - Core 2 Quad as Xeon + } + return true; - case CPU_MODEL_MEROM: // 0x0F - Intel Mobile Core 2 Solo, Duo, Xeon 30xx, Xeon 51xx, Xeon X53xx, Xeon E53xx, Xeon X32xx - case CPU_MODEL_PENRYN: // 0x17 - Intel Core 2 Solo, Duo, Quad, Extreme, Xeon X54xx, Xeon X33xx - if (strstr(Platform.CPU.BrandString, "Xeon(R)")) { - value->word = 0x402; // 1026 - Xeon - } - case CPU_MODEL_PENTIUM_M: // 0x09 - Banias case CPU_MODEL_LINCROFT: // 0x27 - Intel Atom, "Lincroft", 45nm case CPU_MODEL_ATOM: // 0x1C - Intel Atom (45nm) return true; @@ -188,7 +199,7 @@ case CPU_MODEL_NEHALEM: // 0x1A - Intel Core i7, Xeon W35xx, Xeon X55xx, Xeon E55xx LGA1366 (45nm) case CPU_MODEL_FIELDS: // 0x1E - Intel Core i5, i7, Xeon X34xx LGA1156 (45nm) case CPU_MODEL_DALES: // 0x1F - Intel Core i5, i7 LGA1156 (45nm) (Havendale, Auburndale) - if (strstr(Platform.CPU.BrandString, "Xeon(R)")) { + if (strstr(Platform.CPU.BrandString, "Xeon")) { value->word = 0x501; // 1281 - Lynnfiled Quad-Core Xeon return true; } @@ -205,14 +216,14 @@ return true; } if (Platform.CPU.NoCores <= 2) { - value->word = 0x601; // 1537 - Core i5 + value->word = 0x901; // - Core i3 } return true; case CPU_MODEL_DALES_32NM: // 0x25 - Intel Core i3, i5 LGA1156 (32nm) (Clarkdale, Arrandale) case CPU_MODEL_WESTMERE: // 0x2C - Intel Core i7, Xeon X56xx, Xeon E56xx, Xeon W36xx LGA1366 (32nm) 6 Core case CPU_MODEL_WESTMERE_EX: // 0x2F - Intel Xeon E7 - if (strstr(Platform.CPU.BrandString, "Xeon(R)")) { + if (strstr(Platform.CPU.BrandString, "Xeon")) { value->word = 0x501; // 1281 - Xeon return true; } @@ -229,13 +240,13 @@ return true; } if (Platform.CPU.NoCores <= 2) { - value->word = 0x602; // 1538 - Core i5 + value->word = 0x901; // - Core i3 } return true; case CPU_MODEL_JAKETOWN: // 0x2D - Intel Core i7, Xeon E5-xxxx LGA2011 (32nm) case CPU_MODEL_SANDYBRIDGE: // 0x2A - Intel Core i3, i5, i7 LGA1155 (32nm) - if (strstr(Platform.CPU.BrandString, "Xeon(R)")) { + if (strstr(Platform.CPU.BrandString, "Xeon")) { value->word = 0x501; // 1281 - Xeon return true; } @@ -252,12 +263,12 @@ return true; } if (Platform.CPU.NoCores <= 2) { - value->word = 0x603; // 1539 - Core i5 + value->word = 0x902; // - Core i5 } return true; case CPU_MODEL_IVYBRIDGE: // 0x3A - Intel Core i3, i5, i7 LGA1155 (22nm) - if (strstr(Platform.CPU.BrandString, "Xeon(R)")) { + if (strstr(Platform.CPU.BrandString, "Xeon")) { value->word = 0xA01; // 2561 - Xeon return true; } @@ -274,19 +285,19 @@ return true; } if (Platform.CPU.NoCores <= 2) { - value->word = 0x604; // 1540 - Core i5 + value->word = 0x903; // - Core i5 } return true; case CPU_MODEL_IVYBRIDGE_XEON: // 0x3E - Mac Pro 6,1 - value->word = 0xA01; // 2561 + value->word = 0xA01; // 2561 - Xeon return true; case CPU_MODEL_HASWELL: // 0x3C - case CPU_MODEL_HASWELL_SVR: // 0x3F - case CPU_MODEL_HASWELL_ULT: // 0x45 - case CPU_MODEL_CRYSTALWELL: // 0x46 - if (strstr(Platform.CPU.BrandString, "Xeon(R)")) { + if (strstr(Platform.CPU.BrandString, "Xeon")) { value->word = 0xA01; // 2561 - Xeon return true; } @@ -303,7 +314,7 @@ return true; } if (Platform.CPU.NoCores <= 2) { - value->word = 0x605; // 1541 - Core i5 + value->word = 0x904; // - Core i3 } return true; @@ -332,6 +343,10 @@ static int idx = -1; int map; + if (!bootInfo->memDetect) { + return false; + } + idx++; if (idx < MAX_RAM_SLOTS) { map = Platform.DMI.DIMM[idx]; @@ -342,7 +357,8 @@ } } - return false; + value->byte = 2; // means Unknown + return true; // value->byte = SMB_MEM_TYPE_DDR2; // return true; } @@ -358,6 +374,10 @@ static int idx = -1; int map; + if (!bootInfo->memDetect) { + return false; + } + idx++; if (idx < MAX_RAM_SLOTS) { map = Platform.DMI.DIMM[idx]; @@ -368,7 +388,8 @@ } } - return false; + value->dword = 0; // means Unknown + return true; // value->dword = 800; // return true; } @@ -378,6 +399,10 @@ static int idx = -1; int map; + if (!bootInfo->memDetect) { + return false; + } + idx++; if (idx < MAX_RAM_SLOTS) { map = Platform.DMI.DIMM[idx]; @@ -388,9 +413,6 @@ } } - if (!bootInfo->memDetect) { - return false; - } value->string = NOT_AVAILABLE; return true; } @@ -400,9 +422,13 @@ static int idx = -1; int map; + if (!bootInfo->memDetect) { + return false; + } + idx++; - DBG("getSMBMemoryDeviceSerialNumber index: %d, MAX_RAM_SLOTS: %d\n",idx,MAX_RAM_SLOTS); + //DBG("getSMBMemoryDeviceSerialNumber index: %d, MAX_RAM_SLOTS: %d\n",idx,MAX_RAM_SLOTS); if (idx < MAX_RAM_SLOTS) { map = Platform.DMI.DIMM[idx]; @@ -413,9 +439,6 @@ } } - if (!bootInfo->memDetect) { - return false; - } value->string = NOT_AVAILABLE; return true; } @@ -425,6 +448,10 @@ static int idx = -1; int map; + if (!bootInfo->memDetect) { + return false; + } + idx++; if (idx < MAX_RAM_SLOTS) { map = Platform.DMI.DIMM[idx]; @@ -435,9 +462,6 @@ } } - if (!bootInfo->memDetect) { - return false; - } value->string = NOT_AVAILABLE; return true; } Index: trunk/i386/boot2/drivers.c =================================================================== --- trunk/i386/boot2/drivers.c (revision 2381) +++ trunk/i386/boot2/drivers.c (revision 2382) @@ -40,8 +40,14 @@ #include "ramdisk.h" #include "modules.h" -//extern char gMacOSVersion[8]; +#if DEBUG +#define DBG(x...) printf(x) +#else +#define DBG(x...) msglog(x) +#endif +// extern char gMacOSVersion[8]; + struct Module { struct Module *nextModule; long willLoad; @@ -837,16 +843,18 @@ static char gPlatformName[64]; #endif +char *gDarwinBuildVerStr = "Darwin Kernel Version"; // Bungo + long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize) { - long ret; + long ret = 0; compressed_kernel_header * kernel_header = (compressed_kernel_header *) binary; - u_int32_t uncompressed_size, size; - void *buffer; - unsigned long len; + u_int32_t uncompressed_size = 0, size = 0, adler32 = 0; + void *buffer = NULL; + unsigned long len = 0; -#if 0 +/*#if 0 printf("kernel header:\n"); printf("signature: 0x%x\n", kernel_header->signature); printf("compress_type: 0x%x\n", kernel_header->compress_type); @@ -854,13 +862,15 @@ printf("uncompressed_size: 0x%x\n", kernel_header->uncompressed_size); printf("compressed_size: 0x%x\n", kernel_header->compressed_size); getchar(); -#endif +#endif*/ if (kernel_header->signature == OSSwapBigToHostConstInt32('comp')) { + DBG("Decompressing Kernel: "); + if (kernel_header->compress_type != OSSwapBigToHostConstInt32('lzss')) { - error("kernel compression is bad\n"); + error("ERROR: kernel compression is bad!\n"); return -1; } #if NOTDEF @@ -873,23 +883,23 @@ return -1; } #endif - uncompressed_size = OSSwapBigToHostInt32(kernel_header->uncompressed_size); binary = buffer = malloc(uncompressed_size); - - size = decompress_lzss((u_int8_t *) binary, &kernel_header->data[0], - OSSwapBigToHostInt32(kernel_header->compressed_size)); + + size = decompress_lzss((u_int8_t *)binary, &kernel_header->data[0], OSSwapBigToHostInt32(kernel_header->compressed_size)); if (uncompressed_size != size) { - error("size mismatch from lzss: %x\n", size); + error("ERROR: size mismatch from lzss (found: %x, expected: %x).\n", size, uncompressed_size); return -1; } - - if (OSSwapBigToHostInt32(kernel_header->adler32) != - Adler32(binary, uncompressed_size)) + + adler32 = Adler32(binary, uncompressed_size); + if (OSSwapBigToHostInt32(kernel_header->adler32) != adler32) { - printf("adler mismatch\n"); + error("ERROR: adler mismatch (found: %x, expected: %x).\n", adler32, OSSwapBigToHostInt32(kernel_header->adler32)); return -1; } + + DBG("OK.\n"); } ret = ThinFatFile(&binary, &len); @@ -899,6 +909,13 @@ ret = ThinFatFile(&binary, &len); } + // Bungo: no range checking, sorry + size = 0; + while (memcmp((uint8_t *)binary + size, (uint8_t *)gDarwinBuildVerStr, 21)) { + size++; + } + gDarwinBuildVerStr = (char *)binary + size; + // Notify modules that the kernel has been decompressed, thinned and is about to be decoded execute_hook("DecodeKernel", (void*)binary, NULL, NULL, NULL); Index: trunk/i386/boot2/boot.c =================================================================== --- trunk/i386/boot2/boot.c (revision 2381) +++ trunk/i386/boot2/boot.c (revision 2382) @@ -59,7 +59,18 @@ #include "gui.h" #include "platform.h" #include "modules.h" +#include "device_tree.h" +#ifndef DEBUG_BOOT2 +#define DEBUG_BOOT2 0 +#endif + +#if DEBUG_BOOT2 +#define DBG(x...) printf(x) +#else +#define DBG(x...) msglog(x) +#endif + /* * How long to wait (in seconds) to load the * kernel after displaying the "boot:" prompt. @@ -165,9 +176,6 @@ md0Ramdisk(); - verbose("Starting Darwin %s\n",( archCpuType == CPU_TYPE_I386 ) ? "x86" : "x86_64"); - verbose("Boot Args: %s\n", bootArgs->CommandLine); - // Cleanup the PXE base code. if ( (gBootFileType == kNetworkDeviceType) && gUnloadPXEOnExit ) { @@ -192,6 +200,10 @@ } else { drawBootGraphics(); } + + DBG("Starting Darwin/%s [%s]\n",( archCpuType == CPU_TYPE_I386 ) ? "x86" : "x86_64", gDarwinBuildVerStr); + DBG("Boot Args: %s\n", bootArgs->CommandLine); + setupBooterLog(); finalizeBootStruct(); @@ -231,7 +243,7 @@ unsigned long adler32; if((gBootMode & kBootModeSafe) != 0) { - verbose("Kernel Cache ignored.\n"); + DBG("Kernel Cache ignored.\n"); return -1; } @@ -251,12 +263,13 @@ else if (checkOSVersion("10.6")) { snprintf(kernelCacheFile, sizeof(kernelCacheFile), "kernelcache_%s", (archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64"); - int lnam = strlen(kernelCacheFile) + 9; //with adler32 - char* name; - long prev_time = 0; + int lnam = strlen(kernelCacheFile) + 9; //with adler32 + char *name; + long prev_time = 0; - struct dirstuff* cacheDir = opendir(kDefaultCachePathSnow); + struct dirstuff* cacheDir = opendir(kDefaultCachePathSnow); + /* TODO: handle error? */ if (cacheDir) { while(readdir(cacheDir, (const char**)&name, &flags, &time) >= 0) { @@ -309,7 +322,7 @@ // Exit if kernel cache file wasn't found if (ret == -1) { - verbose("No Kernel Cache File '%s' found\n", kernelCacheFile); + DBG("No Kernel Cache File '%s' found\n", kernelCacheFile); return -1; } @@ -319,7 +332,7 @@ // Check if the kernel file is more recent than the cache file if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeFlat) && (kerneltime > cachetime)) { - verbose("Kernel file (%s) is more recent than KernelCache (%s), ignoring KernelCache\n", + DBG("Kernel file (%s) is more recent than Kernel Cache (%s)! Ignoring Kernel Cache.\n", bootInfo->bootFile, kernelCacheFile); return -1; } @@ -328,13 +341,13 @@ // Check if the S/L/E directory time is more recent than the cache file if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory) && (exttime > cachetime)) { - verbose("/System/Library/Extensions is more recent than KernelCache (%s), ignoring KernelCache\n", + DBG("Folder: '/System/Library/Extensions' is more recent than Kernel Cache file (%s)! Ignoring Kernel Cache.\n", kernelCacheFile); return -1; } // Since the kernel cache file exists and is the most recent try to load it - verbose("Loading kernel cache %s\n", kernelCachePath); + DBG("Loading kernel cache: '%s'\n", kernelCachePath); ret = LoadThinFatFile(kernelCachePath, binary); return ret; // ret contain the length of the binary @@ -380,11 +393,12 @@ // Record the device that the booter was loaded from. gBIOSDev = biosdev & kBIOSDevMask; + // Initialize boot-log + initBooterLog(); + // 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. @@ -454,7 +468,7 @@ gBootVolume = selectBootVolume(bvChain); - // Intialize module system + // Intialize module system init_module_system(); #if DEBUG @@ -508,10 +522,10 @@ if (gBootVolume == NULL) { freeFilteredBVChain(bvChain); - + if (gEnableCDROMRescan) rescanBIOSDevice(gBIOSDev); - + bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &gDeviceCount); setBootGlobals(bvChain); setupDeviceList(&bootInfo->themeConfig); @@ -603,8 +617,6 @@ HibernateBoot((char *)val); break; } - - verbose("Loading Darwin %s\n", gMacOSVersion); getBoolForKey(kUseKernelCache, &useKernelCache, &bootInfo->chameleonConfig); if (useKernelCache) do { @@ -623,13 +635,12 @@ } if (gOverrideKernel && kernelCacheFile[0] == 0) { - verbose("Using a non default kernel (%s) without specifying 'Kernel Cache' path, KernelCache will not be used\n", - bootInfo->bootFile); + DBG("Using a non default kernel (%s) without specifying 'Kernel Cache' path, KernelCache will not be used\n", bootInfo->bootFile); useKernelCache = false; break; } if (gMKextName[0] != 0) { - verbose("Using a specific MKext Cache (%s), KernelCache will not be used\n", + DBG("Using a specific MKext Cache (%s), KernelCache will not be used\n", gMKextName); useKernelCache = false; break; @@ -680,7 +691,7 @@ strlcpy(bootFilePath, bootFile, sizeof(bootFilePath)); } - verbose("Loading kernel %s\n", bootFilePath); + DBG("Loading kernel: '%s'\n", bootFilePath); ret = LoadThinFatFile(bootFilePath, &binary); if (ret <= 0 && archCpuType == CPU_TYPE_X86_64) { @@ -712,7 +723,7 @@ ret = ExecKernel(binary); } } - + // chainboot if (status == 1) { // if we are already in graphics-mode, @@ -720,7 +731,7 @@ setVideoMode(VGA_TEXT_MODE, 0); // switch back to text mode. } } - + if ((gBootFileType == kNetworkDeviceType) && gUnloadPXEOnExit) { nbpUnloadBaseCode(); } @@ -736,9 +747,9 @@ CacheReset(); diskFreeMap(oldMap); oldMap = NULL; - + int dev = selectAlternateBootDevice(gBIOSDev); - + BVRef bvchain = scanBootVolumes(dev, 0); BVRef bootVol = selectBootVolume(bvchain); gBootVolume = bootVol; Index: trunk/i386/boot2/boot.h =================================================================== --- trunk/i386/boot2/boot.h (revision 2381) +++ trunk/i386/boot2/boot.h (revision 2382) @@ -248,6 +248,7 @@ /* * drivers.c */ +extern char *gDarwinBuildVerStr; // Bungo extern long LoadExtraDrivers(char * dirSpec); extern long LoadDrivers(char * dirSpec); extern long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize); Index: trunk/i386/boot2/options.c =================================================================== --- trunk/i386/boot2/options.c (revision 2381) +++ trunk/i386/boot2/options.c (revision 2382) @@ -32,6 +32,12 @@ #include "pci.h" #include "modules.h" +#if DEBUG +#define DBG(x...) printf(x) +#else +#define DBG(x...) msglog(x) +#endif + bool showBootBanner = true; //Azi:showinfo static bool shouldboot = false; @@ -1203,7 +1209,7 @@ // Load com.apple.Boot.plist from the selected volume // and use its contents to override default bootConfig. - loadSystemConfig(&bootInfo->bootConfig); + loadSystemConfig(&bootInfo->bootConfig); loadChameleonConfig(&bootInfo->chameleonConfig, NULL); // Use the kernel name specified by the user, or fetch the name @@ -1254,16 +1260,21 @@ } } } - +/* // 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, @@ -1274,17 +1285,18 @@ cnt++; strlcpy(valueBuffer + 1, val, cnt); val = valueBuffer; - } else { + } else { /* if (strlen(gBootUUIDString)) { val = "*uuid"; cnt = 5; - } else { + } 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); }