📄 dmidecode.c
字号:
"Unknown", "Processor", "Disk", "Peripheral Bay", "System Management Module", /* master.mif says SMB MAster */ "Motherboard", "Memory Module", "Processor Module", "Power Unit", "Add-in Card", "Front Panel Board", "Back Panel Board", "Power System Board", "Drive Back Plane" /* 0x0F */ }; if(code>=0x01 && code<=0x0F) return location[code-0x01]; return out_of_spec;}static void dmi_temperature_probe_value(u16 code){ if(code==0x8000) printf(" Unknown"); else printf(" %.1f deg C", (float)(i16)code/10);}static void dmi_temperature_probe_resolution(u16 code){ if(code==0x8000) printf(" Unknown"); else printf(" %.3f deg C", (float)code/1000);}/* * 3.3.30 Electrical Current Probe (Type 29) */static void dmi_current_probe_value(u16 code){ if(code==0x8000) printf(" Unknown"); else printf(" %.3f A", (float)(i16)code/1000);}static void dmi_current_probe_resolution(u16 code){ if(code==0x8000) printf(" Unknown"); else printf(" %.1f mA", (float)code/10);}/* * 3.3.33 System Boot Information (Type 32) */static const char *dmi_system_boot_status(u8 code){ static const char *status[]={ "No errors detected", /* 0 */ "No bootable media", "Operating system failed to load", "Firmware-detected hardware failure", "Operating system-detected hardware failure", "User-requested boot", "System security violation", "Previously-requested image", "System watchdog timer expired" /* 8 */ }; if(code<=8) return status[code]; if(code>=128 && code<=191) return "OEM-specific"; if(code>=192 && code<=255) return "Product-specific"; return out_of_spec;}/* * 3.3.34 64-bit Memory Error Information (Type 33) */static void dmi_64bit_memory_error_address(u64 code){ if(code.h==0x80000000 && code.l==0x00000000) printf(" Unknown"); else printf(" 0x%08X%08X", code.h, code.l);}/* * 3.3.35 Management Device (Type 34) */static const char *dmi_management_device_type(u8 code){ /* 3.3.35.1 */ static const char *type[]={ "Other", /* 0x01 */ "Unknown", "LM75", "LM78", "LM79", "LM80", "LM81", "ADM9240", "DS1780", "MAX1617", "GL518SM", "W83781D", "HT82H791" /* 0x0D */ }; if(code>=0x01 && code<=0x0D) return type[code-0x01]; return out_of_spec;}static const char *dmi_management_device_address_type(u8 code){ /* 3.3.35.2 */ static const char *type[]={ "Other", /* 0x01 */ "Unknown", "I/O Port", "Memory", "SMBus" /* 0x05 */ }; if(code>=0x01 && code<=0x05) return type[code-0x01]; return out_of_spec;}/* * 3.3.38 Memory Channel (Type 37) */static const char *dmi_memory_channel_type(u8 code){ /* 3.3.38.1 */ static const char *type[]={ "Other", /* 0x01 */ "Unknown", "RAMBus", "Synclink" /* 0x04 */ }; if(code>=0x01 && code<=0x04) return type[code-0x01]; return out_of_spec;}static void dmi_memory_channel_devices(u8 count, u8 *p, const char *prefix){ int i; for(i=1; i<=count; i++) { printf("%sDevice %u Load: %u\n", prefix, i, p[3*i]); printf("%sDevice %u Handle: 0x%04X\n", prefix, i, WORD(p+3*i+1)); }}/* * 3.3.39 IPMI Device Information (Type 38) */static const char *dmi_ipmi_interface_type(u8 code){ /* 3.3.39.1 */ static const char *type[]={ "Unknown", /* 0x00 */ "KCS (Keyboard Control Style)", "SMIC (Server Management Interface Chip)", "BT (Block Transfer)" /* 0x03 */ }; if(code<=0x03) return type[code]; return out_of_spec;}static const char *dmi_ipmi_register_spacing(u8 code){ /* IPMI 1.5 */ static const char *spacing[]={ "Successive Byte Boundaries", /* 0x00 */ "32-bit Boundaries", "16-byte Boundaries" /* 0x02 */ }; if(code<=0x02) return spacing[code]; return out_of_spec;}/* * 3.3.40 System Power Supply (Type 39) */static void dmi_power_supply_power(u16 code){ if(code==0x8000) printf(" Unknown"); else printf(" %.3f W", (float)code/1000);}static const char *dmi_power_supply_type(u8 code){ /* 3.3.40.1 */ static const char *type[]={ "Other", /* 0x01 */ "Unknown", "Linear", "Switching", "Battery", "UPS", "Converter", "Regulator" /* 0x08 */ }; if(code>=0x01 && code<=0x08) return type[code-0x01]; return out_of_spec;}static const char *dmi_power_supply_status(u8 code){ /* 3.3.40.1 */ static const char *status[]={ "Other", /* 0x01 */ "Unknown", "OK", "Non-critical" "Critical" /* 0x05 */ }; if(code>=0x01 && code<=0x05) return status[code-0x01]; return out_of_spec;}static const char *dmi_power_supply_range_switching(u8 code){ /* 3.3.40.1 */ static const char *switching[]={ "Other", /* 0x01 */ "Unknown", "Manual", "Auto-switch", "Wide Range", "N/A" /* 0x06 */ }; if(code>=0x01 && code<=0x06) return switching[code-0x01]; return out_of_spec;}/* * Main */static void dmi_decode(u8 *data, u16 ver){ struct dmi_header *h=(struct dmi_header *)data; /* * Note: DMI types 31, 37, 38 and 39 are untested */ switch(h->type) { case 0: /* 3.3.1 BIOS Information */ printf("\tBIOS Information\n"); if(h->length<0x12) break; printf("\t\tVendor: %s\n", dmi_string(h, data[0x04])); printf("\t\tVersion: %s\n", dmi_string(h, data[0x05])); printf("\t\tRelease Date: %s\n", dmi_string(h, data[0x08])); printf("\t\tAddress: 0x%04X0\n", WORD(data+0x06)); printf("\t\tRuntime Size:"); dmi_bios_runtime_size((0x10000-WORD(data+0x06))<<4); printf("\n"); printf("\t\tROM Size: %u kB\n", (data[0x09]+1)<<6); printf("\t\tCharacteristics:\n"); dmi_bios_characteristics(QWORD(data+0x0A), "\t\t\t"); if(h->length<0x13) break; dmi_bios_characteristics_x1(data[0x12], "\t\t\t"); if(h->length<0x14) break; dmi_bios_characteristics_x2(data[0x13], "\t\t\t"); break; case 1: /* 3.3.2 System Information */ printf("\tSystem Information\n"); if(h->length<0x08) break; printf("\t\tManufacturer: %s\n", dmi_string(h, data[0x04])); printf("\t\tProduct Name: %s\n", dmi_string(h, data[0x05])); printf("\t\tVersion: %s\n", dmi_string(h, data[0x06])); printf("\t\tSerial Number: %s\n", dmi_string(h, data[0x07])); if(h->length<0x19) break; printf("\t\tUUID:"); dmi_system_uuid(data+0x08); printf("\n"); printf("\t\tWake-up Type: %s\n", dmi_system_wake_up_type(data[0x18])); break; case 2: /* 3.3.3 Base Board Information */ printf("\tBase Board Information\n"); if(h->length<0x08) break; printf("\t\tManufacturer: %s\n", dmi_string(h, data[0x04])); printf("\t\tProduct Name: %s\n", dmi_string(h, data[0x05])); printf("\t\tVersion: %s\n", dmi_string(h, data[0x06])); printf("\t\tSerial Number: %s\n", dmi_string(h, data[0x07])); if(h->length<0x0F) break; printf("\t\tAsset Tag: %s\n", dmi_string(h, data[0x08])); printf("\t\tFeatures:"); dmi_base_board_features(data[0x09], "\t\t"); printf("\t\tLocation In Chassis: %s\n", dmi_string(h, data[0x0A])); printf("\t\tChassis Handle: 0x%04X\n", WORD(data+0x0B)); printf("\t\tType: %s\n", dmi_base_board_type(data[0x0D])); if(h->length<0x0F+data[0x0E]*sizeof(u16)) break; dmi_base_board_handlers(data[0x0E], data+0x0F, "\t\t"); break; case 3: /* 3.3.4 Chassis Information */ printf("\tChassis Information\n"); if(h->length<0x09) break; printf("\t\tManufacturer: %s\n", dmi_string(h, data[0x04])); printf("\t\tType: %s\n", dmi_chassis_type(data[0x05]&0x7F)); printf("\t\tLock: %s\n", dmi_chassis_lock(data[0x05]>>7)); printf("\t\tVersion: %s\n", dmi_string(h, data[0x06])); printf("\t\tSerial Number: %s\n", dmi_string(h, data[0x07])); printf("\t\tAsset Tag: %s\n", dmi_string(h, data[0x08])); if(h->length<0x0D) break; printf("\t\tBoot-up State: %s\n", dmi_chassis_state(data[0x09])); printf("\t\tPower Supply State: %s\n", dmi_chassis_state(data[0x0A])); printf("\t\tThermal State: %s\n", dmi_chassis_state(data[0x0B])); printf("\t\tSecurity Status: %s\n", dmi_chassis_security_status(data[0x0C])); if(h->length<0x11) break; printf("\t\tOEM Information: 0x%08X\n", DWORD(data+0x0D)); if(h->length<0x15) break; printf("Heigth:"); dmi_chassis_height(data[0x11]); printf("\n"); printf("Number Of Power Cords:"); dmi_chassis_power_cords(data[0x12]); printf("\n"); if(h->length<0x15+data[0x13]*data[0x14]) break; dmi_chassis_elements(data[0x13], data[0x14], data+0x15, "\t\t"); break; case 4: /* 3.3.5 Processor Information */ printf("\tProcessor Information\n"); if(h->length<0x1A) break; printf("\t\tSocket Designation: %s\n", dmi_string(h, data[0x04])); printf("\t\tType: %s\n", dmi_processor_type(data[0x05])); printf("\t\tFamily: %s\n", dmi_processor_family(data[0x06])); printf("\t\tManufacturer: %s\n", dmi_string(h, data[0x07])); dmi_processor_id(data[0x06], data+8, dmi_string(h, data[0x10]), "\t\t"); printf("\t\tVersion: %s\n", dmi_string(h, data[0x10])); printf("\t\tVoltage:"); dmi_processor_voltage(data[0x11]); printf("\n"); printf("\t\tExternal Clock:"); dmi_processor_frequency(WORD(data+0x12)); printf("\n"); printf("\t\tMax Speed:"); dmi_processor_frequency(WORD(data+0x14)); printf("\n"); printf("\t\tCurrent Speed:"); dmi_processor_frequency(WORD(data+0x16)); printf("\n"); if(data[0x18]&(1<<6)) printf("\t\tStatus: Populated, %s\n", dmi_processor_status(data[0x18]&0x07)); else printf("\t\tStatus: Unpopulated\n"); printf("\t\tUpgrade: %s\n", dmi_processor_upgrade(data[0x19])); if(h->length<0x20) break; printf("\t\tL1 Cache Handle:"); dmi_processor_cache(WORD(data+0x1A), "L1", ver); printf("\n"); printf("\t\tL2 Cache Handle:"); dmi_processor_cache(WORD(data+0x1C), "L2", ver); printf("\n"); printf("\t\tL3 Cache Handle:"); dmi_processor_cache(WORD(data+0x1E), "L3", ver); printf("\n"); if(h->length<0x23) break; printf("\t\tSerial Number: %s\n", dmi_string(h, data[0x20])); printf("\t\tAsset Tag: %s\n", dmi_string(h, data[0x21])); printf("\t\tPart Number: %s\n", dmi_string(h, data[0x22])); break; case 5: /* 3.3.6 Memory Controller Information */ printf("\tMemory Controller Information\n"); if(h->length<0x0F) break; printf("\t\tError Detecting Method: %s\n", dmi_memory_controller_ed_method(data[0x04])); printf("\t\tError Correcting Capabilities:"); dmi_memory_controller_ec_capabilities(data[0x05], "\t\t\t"); printf("\t\tSupported Interleave: %s\n", dmi_memory_controller_interleave(data[0x06])); printf("\t\tCurrent Interleave: %s\n", dmi_memory_controller_interleave(data[0x07])); printf("\t\tMaximum Memory Module Size: %u MB\n", 1<<data[0x08]); printf("\t\tMaximum Total Memory Size: %u MB\n", data[0x0E]*(1<<data[0x08])); printf("\t\tSupported Speeds:"); dmi_memory_controller_speeds(WORD(data+0x09), "\t\t\t"); printf("\t\tSupported Memory Types:"); dmi_memory_module_types(WORD(data+0x0B), "\n\t\t\t"); printf("\n"); printf("\t\tMemory Module Voltage:"); dmi_processor_voltage(data[0x0D]); printf("\n"); if(h->length<0x0F+data[0x0E]*sizeof(u16)) break; dmi_memory_controller_slots(data[0x0E], data+0x0F, "\t\t"); if(h->length<0x10+data[0x0E]*sizeof(u16)) break; printf("\t\tEnabled Error Correcting Capabilities:"); dmi_memory_controller_ec_capabilities(data[0x0F+data[0x0E]*sizeof(u16)], "\t\t\t"); break; case 6: /* 3.3.7 Memory Module Information */ printf("\tMemory Module Information\n"); if(h->length<0x0C) break; printf("\t\tSocket Designation: %s\n", dmi_string(h, data[0x04])); printf("\t\tBank Connections:"); dmi_memory_module_connections(data[0x05]); printf("\n"); printf("\t\tCurrent Speed:"); dmi_memory_module_speed(data[0x06]); printf("\n"); printf("\t\tType:"); dmi_memory_module_types(WORD(data+0x07), " "); printf("\n"); printf("\t\tInstalled Size:"); dmi_memory_module_size(data[0x09]); printf("\n"); printf("\t\tEnabled Size:"); dmi_memory_module_size(data[0x0A]); printf("\n"); printf("\t\tError Status:"); dmi_memory_module_error(data[0x0B], "\t\t\t"); break; case 7: /* 3.3.8 Cache Information */ printf("\tCache Information\n"); if(h->length<0x0F) break; printf("\t\tSocket Designation: %s\n", dmi_string(h, data[0x04])); printf("\t\tConfiguration: %s, %s, Level %u\n", WORD(data+0x05)&0x0080?"Enabled":"Disabled", WORD(data+0x05)&0x0008?"Socketed":"Not Socketed", (WORD(data+0x05)&0x0007)+1); printf("\t\tOperational Mode: %s\n", dmi_cache_mode((WORD(data+0x05)>>8)&0x0003)); printf("\t\tLocation: %s\n", dmi_cache_location((WORD(data+0x05)>>5)&0x0003)); printf("\t\tInstalled Size:"); dmi_cache_size(WORD(data+0x09)); printf("\n"); printf("\t\tMaximum Size:"); dmi_cache_size(WORD(data+0x07)); printf("\n"); printf("\t\tSupported SRAM Types:"); dmi_cache_types(WORD(data+0x0B), "\n\t\t\t"); printf("\n"); printf("\t\tInstalled SRAM Type:"); dmi_cache_types(WORD(data+0x0D), " "); printf("\n"); if(h->length<0x13) break; printf("\t\tSpeed:"); dmi_memory_module_speed(data[0x0F]); printf("\n"); printf("\t\tError Correction Type: %s\n", dmi_cache_ec_type(data[0x10])); printf("\t\tSystem Type: %s\n", dmi_cache_type(data[0x11])); printf("\t\tAssociativity: %s\n", dmi_cache_associativity(data[0x12])); break; case 8: /* 3.3.9 Port Connector Information */ printf("\tPort Connector Information\n"); if(h->length<0x09) break; printf("\t\tInternal Reference Designator: %s\n", dmi_string(h, data[0x04])); printf("\t\tInternal Connector Type: %s\n", dmi_port_connector_type(data[0x05])); printf("\t\tExternal Reference Designator: %s\n", dmi_string(h, data[0x06])); printf("\t\tExternal Connector Type: %s\n", dmi_port_connector_type(data[0x07])); printf("\t\tPort Type: %s\n", dmi_port_type(data[0x08])); break; case 9: /* 3.3.10 System Slots */ printf("\tSystem Slot Information\n"); if(h->length<0x0C) break; printf("\t\tDesignation: %s\n", dmi_string(h, data[0x04])); printf("\t\tType: %s%s\n", dmi_slot_bus_width(data[0x06]), dmi_slot_type(data[0x05])); printf("\t\tCurrent Usage: %s\n", dmi_slot_current_usage(data[0x07])); printf("\t\tLength: %s\n", dmi_slot_length(data[0x08])); dmi_slot_id(data[0x09], data[0x0A], data[0x05], "\t\t"); printf("\t\tCharacteristics:"); if(h->length<0x0D) dmi_slot_characteristics(data[0x0B], 0x00, "\t\t\t"); else dmi_slot_characteristics(data[0x0B], data[0x0C], "\t\t\t"); break; case 10: /* 3.3.11 On Board Devices Information */ dmi_on_board_devices(h, "\t"); break; case 11: /* 3.3.12 OEM Strings */ printf("\tOEM Strings\n"); if(h->length<0x05) break; dmi_oem_strings(h, "\t\t"); break; case 12: /* 3.3.13 System Configuration Options */ printf("\tSystem Configuration Options\n"); if(h->length<0x05) break; dmi_system_configuration_options(h, "\t\t"); break; case 13: /* 3.3.14 BIOS Language Information */ printf("\tBIOS Language Information\n"); if(h->length<0x16) break; printf("\t\tInstallable Languages: %u\n", data[0x04]); dmi_bios_languages(h, "\t\t\t"); printf("\t\tCurrently Installed Language: %s\n", dmi_string(h, data[0x15])); break; case 14: /* 3.3.15 Group Associations */ printf("\tGroup Associations\n"); if(h->length<0x05) break; printf("\t\tName: %s\n", dmi_string(h, data[0x04])); printf("\t\tItems: %u\n", (h->length-0x05)/3); dmi_group_associations_items((h->length-0x05)/3, data+0x05, "\t\t\t"); break; case 15: /* 3.3.16 System Event Log */ printf("\tSystem Event Log\n"); if(h->length<0x14) break; printf("\t\tArea Length: %u bytes\n", WORD(data+0x04)); printf("\t\tHeader Start Offset: 0x%04X\n", WORD(data+0x06)); if(WORD(data+0x08)-WORD(data+0x06)) printf("\t\tHeader Length: %u byte%s\n", WORD(data+0x08)-WORD(data+0x06), WORD(data+0x08)-WORD(data+0x06)>1?"s":""); printf("\t\tData Start Offset: 0x%04X\n", WORD(data+0x08)); printf("\t\tAccess Method: %s\n", dmi_event_log_method(data[0x0A])); printf("\t\tAccess Address:"); dmi_event_log_address(data[0x0A], data+0x10); printf("\n"); printf("\t\tStatus:"); dmi_event_log_status(data[0x0B]); printf("\n"); printf("\t\tChange Token: 0x%08X\n", DWORD(data+0x0C)); if(h->length<0x17) break; printf("\t\tHeader Format: %s\n", dmi_event_log_header_type(data[0x14])); printf("\t\tSupported Log Type Descriptors: %u\n", data[0x15]); if(h->length<0x17+data[0x15]*data[0x16]) break; dmi_event_log_descriptors(data[0x15], data[0x16], data+0x17, "\t\t"); break; case 16: /* 3.3.17 Physical Memory Array */ printf("\tPhysical Memory Array\n"); if(h->length<0x0F) br
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -