📄 dmidecode.c
字号:
{ 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) 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]); if(!(opt.flags & FLAG_QUIET)) 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 37, 38 and 39 are untested */ switch(h->type) { case 0: /* 3.3.1 BIOS Information */ printf("BIOS Information\n"); if(h->length<0x12) break; printf("\tVendor: %s\n", dmi_string(h, data[0x04])); printf("\tVersion: %s\n", dmi_string(h, data[0x05])); printf("\tRelease Date: %s\n", dmi_string(h, data[0x08])); printf("\tAddress: 0x%04X0\n", WORD(data+0x06)); printf("\tRuntime Size:"); dmi_bios_runtime_size((0x10000-WORD(data+0x06))<<4); printf("\n"); printf("\tROM Size: %u kB\n", (data[0x09]+1)<<6); printf("\tCharacteristics:\n"); dmi_bios_characteristics(QWORD(data+0x0A), "\t\t"); if(h->length<0x13) break; dmi_bios_characteristics_x1(data[0x12], "\t\t"); if(h->length<0x14) break; dmi_bios_characteristics_x2(data[0x13], "\t\t"); if(h->length<0x18) break; if(data[0x14]!=0xFF && data[0x15]!=0xFF) printf("\tBIOS Revision: %u.%u\n", data[0x14], data[0x15]); if(data[0x16]!=0xFF && data[0x17]!=0xFF) printf("\tFirmware Revision: %u.%u\n", data[0x16], data[0x17]); break; case 1: /* 3.3.2 System Information */ printf("System Information\n"); if(h->length<0x08) break; printf("\tManufacturer: %s\n", dmi_string(h, data[0x04])); printf("\tProduct Name: %s\n", dmi_string(h, data[0x05])); printf("\tVersion: %s\n", dmi_string(h, data[0x06])); printf("\tSerial Number: %s\n", dmi_string(h, data[0x07])); if(h->length<0x19) break; printf("\tUUID:"); dmi_system_uuid(data+0x08); printf("\n"); printf("\tWake-up Type: %s\n", dmi_system_wake_up_type(data[0x18])); if(h->length<0x1B) break; printf("\tSKU Number: %s\n", dmi_string(h, data[0x19])); printf("\tFamily: %s\n", dmi_string(h, data[0x1A])); break; case 2: /* 3.3.3 Base Board Information */ printf("Base Board Information\n"); if(h->length<0x08) break; printf("\tManufacturer: %s\n", dmi_string(h, data[0x04])); printf("\tProduct Name: %s\n", dmi_string(h, data[0x05])); printf("\tVersion: %s\n", dmi_string(h, data[0x06])); printf("\tSerial Number: %s\n", dmi_string(h, data[0x07])); if(h->length<0x0F) break; printf("\tAsset Tag: %s\n", dmi_string(h, data[0x08])); printf("\tFeatures:"); dmi_base_board_features(data[0x09], "\t\t"); printf("\tLocation In Chassis: %s\n", dmi_string(h, data[0x0A])); if(!(opt.flags & FLAG_QUIET)) printf("\tChassis Handle: 0x%04X\n", WORD(data+0x0B)); printf("\tType: %s\n", dmi_base_board_type(data[0x0D])); if(h->length<0x0F+data[0x0E]*sizeof(u16)) break; if(!(opt.flags & FLAG_QUIET)) dmi_base_board_handles(data[0x0E], data+0x0F, "\t"); break; case 3: /* 3.3.4 Chassis Information */ printf("Chassis Information\n"); if(h->length<0x09) break; printf("\tManufacturer: %s\n", dmi_string(h, data[0x04])); printf("\tType: %s\n", dmi_chassis_type(data[0x05]&0x7F)); printf("\tLock: %s\n", dmi_chassis_lock(data[0x05]>>7)); printf("\tVersion: %s\n", dmi_string(h, data[0x06])); printf("\tSerial Number: %s\n", dmi_string(h, data[0x07])); printf("\tAsset Tag: %s\n", dmi_string(h, data[0x08])); if(h->length<0x0D) break; printf("\tBoot-up State: %s\n", dmi_chassis_state(data[0x09])); printf("\tPower Supply State: %s\n", dmi_chassis_state(data[0x0A])); printf("\tThermal State: %s\n", dmi_chassis_state(data[0x0B])); printf("\tSecurity Status: %s\n", dmi_chassis_security_status(data[0x0C])); if(h->length<0x11) break; printf("\tOEM Information: 0x%08X\n", DWORD(data+0x0D)); if(h->length<0x15) break; printf("\tHeigth:"); dmi_chassis_height(data[0x11]); printf("\n"); printf("\tNumber 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"); break; case 4: /* 3.3.5 Processor Information */ printf("Processor Information\n"); if(h->length<0x1A) break; printf("\tSocket Designation: %s\n", dmi_string(h, data[0x04])); printf("\tType: %s\n", dmi_processor_type(data[0x05])); printf("\tFamily: %s\n", dmi_processor_family(data[0x06])); printf("\tManufacturer: %s\n", dmi_string(h, data[0x07])); dmi_processor_id(data[0x06], data+8, dmi_string(h, data[0x10]), "\t"); printf("\tVersion: %s\n", dmi_string(h, data[0x10])); printf("\tVoltage:"); dmi_processor_voltage(data[0x11]); printf("\n"); printf("\tExternal Clock:"); dmi_processor_frequency(WORD(data+0x12)); printf("\n"); printf("\tMax Speed:"); dmi_processor_frequency(WORD(data+0x14)); printf("\n"); printf("\tCurrent Speed:"); dmi_processor_frequency(WORD(data+0x16)); printf("\n"); if(data[0x18]&(1<<6)) printf("\tStatus: Populated, %s\n", dmi_processor_status(data[0x18]&0x07)); else printf("\tStatus: Unpopulated\n"); printf("\tUpgrade: %s\n", dmi_processor_upgrade(data[0x19])); if(h->length<0x20) break; if(!(opt.flags & FLAG_QUIET)) { printf("\tL1 Cache Handle:"); dmi_processor_cache(WORD(data+0x1A), "L1", ver); printf("\n"); printf("\tL2 Cache Handle:"); dmi_processor_cache(WORD(data+0x1C), "L2", ver); printf("\n"); printf("\tL3 Cache Handle:"); dmi_processor_cache(WORD(data+0x1E), "L3", ver); printf("\n"); } if(h->length<0x23) break; printf("\tSerial Number: %s\n", dmi_string(h, data[0x20])); printf("\tAsset Tag: %s\n", dmi_string(h, data[0x21])); printf("\tPart Number: %s\n", dmi_string(h, data[0x22])); break; case 5: /* 3.3.6 Memory Controller Information */ printf("Memory Controller Information\n"); if(h->length<0x0F) break; printf("\tError Detecting Method: %s\n", dmi_memory_controller_ed_method(data[0x04])); printf("\tError Correcting Capabilities:"); dmi_memory_controller_ec_capabilities(data[0x05], "\t\t"); printf("\tSupported Interleave: %s\n", dmi_memory_controller_interleave(data[0x06])); printf("\tCurrent Interleave: %s\n", dmi_memory_controller_interleave(data[0x07])); printf("\tMaximum Memory Module Size: %u MB\n", 1<<data[0x08]); printf("\tMaximum Total Memory Size: %u MB\n", data[0x0E]*(1<<data[0x08])); printf("\tSupported Speeds:"); dmi_memory_controller_speeds(WORD(data+0x09), "\t\t"); printf("\tSupported Memory Types:"); dmi_memory_module_types(WORD(data+0x0B), "\n\t\t"); printf("\n"); printf("\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"); if(h->length<0x10+data[0x0E]*sizeof(u16)) break; printf("\tEnabled Error Correcting Capabilities:"); dmi_memory_controller_ec_capabilities(data[0x0F+data[0x0E]*sizeof(u16)], "\t\t"); break; case 6: /* 3.3.7 Memory Module Information */ printf("Memory Module Information\n"); if(h->length<0x0C) break; printf("\tSocket Designation: %s\n", dmi_string(h, data[0x04])); printf("\tBank Connections:"); dmi_memory_module_connections(data[0x05]); printf("\n"); printf("\tCurrent Speed:"); dmi_memory_module_speed(data[0x06]); printf("\n"); printf("\tType:"); dmi_memory_module_types(WORD(data+0x07), " "); printf("\n"); printf("\tInstalled Size:"); dmi_memory_module_size(data[0x09]); printf("\n"); printf("\tEnabled Size:"); dmi_memory_module_size(data[0x0A]); printf("\n"); printf("\tError Status:"); dmi_memory_module_error(data[0x0B], "\t\t"); break; case 7: /* 3.3.8 Cache Information */ printf("Cache Information\n"); if(h->length<0x0F) break; printf("\tSocket Designation: %s\n", dmi_string(h, data[0x04])); printf("\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("\tOperational Mode: %s\n", dmi_cache_mode((WORD(data+0x05)>>8)&0x0003)); printf("\tLocation: %s\n", dmi_cache_location((WORD(data+0x05)>>5)&0x0003)); printf("\tInstalled Size:"); dmi_cache_size(WORD(data+0x09)); printf("\n"); printf("\tMaximum Size:"); dmi_cache_size(WORD(data+0x07)); printf("\n"); printf("\tSupported SRAM Types:"); dmi_cache_types(WORD(data+0x0B), "\n\t\t"); printf("\n"); printf("\tInstalled SRAM Type:"); dmi_cache_types(WORD(data+0x0D), " "); printf("\n"); if(h->length<0x13) break; printf("\tSpeed:"); dmi_memory_module_speed(data[0x0F]); printf("\n"); printf("\tError Correction Type: %s\n", dmi_cache_ec_type(data[0x10])); printf("\tSystem Type: %s\n", dmi_cache_type(data[0x11])); printf("\tAssociativity: %s\n", dmi_cache_associativity(data[0x12])); break; case 8: /* 3.3.9 Port Connector Information */ printf("Port Connector Information\n"); if(h->length<0x09) break; printf("\tInternal Reference Designator: %s\n", dmi_string(h, data[0x04])); printf("\tInternal Connector Type: %s\n", dmi_port_connector_type(data[0x05])); printf("\tExternal Reference Designator: %s\n", dmi_string(h, data[0x06])); printf("\tExternal Connector Type: %s\n", dmi_port_connector_type(data[0x07])); printf("\tPort Type: %s\n", dmi_port_type(data[0x08])); break; case 9: /* 3.3.10 System Slots */ printf("System Slot Information\n"); if(h->length<0x0C) break; printf("\tDesignation: %s\n", dmi_string(h, data[0x04])); printf("\tType: %s%s\n", dmi_slot_bus_width(data[0x06]), dmi_slot_type(data[0x05])); printf("\tCurrent Usage: %s\n", dmi_slot_current_usage(data[0x07])); printf("\tLength: %s\n", dmi_slot_length(data[0x08])); dmi_slot_id(data[0x09], data[0x0A], data[0x05], "\t"); printf("\tCharacteristics:"); if(h->length<0x0D) dmi_slot_characteristics(data[0x0B], 0x00, "\t\t"); else dmi_slot_characteristics(data[0x0B], data[0x0C], "\t\t"); break; case 10: /* 3.3.11 On Board Devices Information */ dmi_on_board_devices(h, ""); break; case 11: /* 3.3.12 OEM Strings */ printf("OEM Strings\n"); if(h->length<0x05) break; dmi_oem_strings(h, "\t"); break; case 12: /* 3.3.13 System Configuration Options */ printf("System Configuration Options\n"); if(h->length<0x05) break; dmi_system_configuration_options(h, "\t"); break; case 13: /* 3.3.14 BIOS Language Information */ printf("BIOS Language Information\n"); if(h->length<0x16) break; printf("\tInstallable Languages: %u\n", data[0x04]); dmi_bios_languages(h, "\t\t"); printf("\tCurrently Installed Language: %s\n", dmi_string(h, data[0x15])); break; case 14: /* 3.3.15 Group Associations */ printf("Group Associations\n"); if(h->length<0x05) break; printf("\tName: %s\n", dmi_string(h, data[0x04])); printf("\tItems: %u\n", (h->length-0x05)/3); dmi_group_associations_items((h->length-0x05)/3, data+0x05, "\t\t"); break; case 15: /* 3.3.16 System Event Log */ printf("System Event Log\n"); if(h->length<0x14) break; printf("\tArea Length: %u bytes\n", WORD(data+0x04)); printf("\tHeader Start Offset: 0x%04X\n", WORD(data+0x06)); if(WORD(data+0x08)-WORD(data+0x06)) printf("\tHeader Length: %u byte%s\n", WORD(data+0x08)-WORD(data+0x06), WORD(data+0x08)-WORD(data+0x06)>1?"s":""); printf("\tData Start Offset: 0x%04X\n", WORD(data+0x08)); printf("\tAccess Method: %s\n", dmi_event_log_method(data[0x0A])); printf("\tAccess Address:"); dmi_event_log_address(data[0x0A], data+0x10); printf("\n"); printf("\tStatus:"); dmi_event_log_status(data[0x0B]); printf("\n"); printf("\tChange Token: 0x%08X\n", DWORD(data+0x0C)); if(h->length<0x17) break; printf("\tHeader Format: %s\n", dmi_event_log_header_type(data[0x14])); printf("\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"); break; case 16: /* 3.3.17 Physical Memory Array */ printf("Physical Memory Array\n"); if(h->length<0x0F) break; printf("\tLocation: %s\n", dmi_memory_array_location(data[0x04])); printf("\tUse: %s\n", dmi_memory_array_use(data[0x05])); printf("\tError Correction Type: %s\n", dmi_memory_array_ec_type(data[0x06])); printf("\tMaximum Capacity:"); dmi_memory_array_ca
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -