📄 dmidecode.c
字号:
"Other", /* 0 */
"Unknown",
"Standard",
"FPM",
"EDO",
"Parity",
"ECC",
"SIMM",
"DIMM",
"Burst EDO",
"SDRAM" /* 10 */
};
if ((code & 0x07FF) == 0)
printf(" None");
else
{
int i;
for (i = 0; i <= 10; i++)
if (code & (1 << i))
printf("%s%s", sep, types[i]);
}
}
static void dmi_memory_module_connections(u8 code)
{
if (code == 0xFF)
printf(" None");
else
{
if ((code & 0xF0) != 0xF0)
printf(" %u", code >> 4);
if ((code & 0x0F) != 0x0F)
printf(" %u", code & 0x0F);
}
}
static void dmi_memory_module_speed(u8 code)
{
if (code == 0)
printf(" Unknown");
else
printf(" %u ns", code);
}
static void dmi_memory_module_size(u8 code)
{
/* 3.3.7.2 */
switch (code & 0x7F)
{
case 0x7D:
printf(" Not Determinable");
break;
case 0x7E:
printf(" Disabled");
break;
case 0x7F:
printf(" Not Installed");
return;
default:
printf(" %u MB", 1 << (code & 0x7F));
}
if (code & 0x80)
printf(" (Double-bank Connection)");
else
printf(" (Single-bank Connection)");
}
static void dmi_memory_module_error(u8 code, const char *prefix)
{
if (code & (1 << 2))
printf(" See Event Log\n");
else
{ if ((code & 0x03) == 0)
printf(" OK\n");
if (code & (1 << 0))
printf("%sUncorrectable Errors\n", prefix);
if (code & (1 << 1))
printf("%sCorrectable Errors\n", prefix);
}
}
/*
* 3.3.8 Cache Information (Type 7)
*/
static const char *dmi_cache_mode(u8 code)
{
static const char *mode[] = {
"Write Through", /* 0x00 */
"Write Back",
"Varies With Memory Address",
"Unknown" /* 0x03 */
};
return mode[code];
}
/* code is assumed to be a 2-bit value */
static const char *dmi_cache_location(u8 code)
{
static const char *location[4] = {
"Internal", /* 0x00 */
"External",
out_of_spec, /* 0x02 */
"Unknown" /* 0x03 */
};
return location[code];
}
static void dmi_cache_size(u16 code)
{
if (code & 0x8000)
printf(" %u kB", (code & 0x7FFF) << 6);
else
printf(" %u kB", code);
}
static void dmi_cache_types(u16 code, const char *sep)
{
/* 3.3.8.2 */
static const char *types[] = {
"Other", /* 0 */
"Unknown",
"Non-burst",
"Burst",
"Pipeline Burst",
"Synchronous",
"Asynchronous" /* 6 */
};
if ((code & 0x007F) == 0)
printf(" None");
else
{
int i;
for (i = 0; i <= 6; i++)
if (code & (1 << i))
printf("%s%s", sep, types[i]);
}
}
static const char *dmi_cache_ec_type(u8 code)
{
/* 3.3.8.3 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"None",
"Parity",
"Single-bit ECC",
"Multi-bit ECC" /* 0x06 */
};
if (code >= 0x01 && code <= 0x06)
return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_cache_type(u8 code)
{
/* 3.3.8.4 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Instruction",
"Data",
"Unified" /* 0x05 */
};
if (code >= 0x01 && code <= 0x05)
return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_cache_associativity(u8 code)
{
/* 3.3.8.5 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Direct Mapped",
"2-way Set-associative",
"4-way Set-associative",
"Fully Associative",
"8-way Set-associative",
"16-way Set-associative" /* 0x08 */
};
if (code >= 0x01 && code <= 0x08)
return type[code - 0x01];
return out_of_spec;
}
/*
* 3.3.9 Port Connector Information (Type 8)
*/
static const char *dmi_port_connector_type(u8 code)
{
/* 3.3.9.2 */
static const char *type[] = {
"None", /* 0x00 */
"Centronics",
"Mini Centronics",
"Proprietary",
"DB-25 male",
"DB-25 female",
"DB-15 male",
"DB-15 female",
"DB-9 male",
"DB-9 female",
"RJ-11",
"RJ-45",
"50 Pin MiniSCSI",
"Mini DIN",
"Micro DIN",
"PS/2",
"Infrared",
"HP-HIL",
"Access Bus (USB)",
"SSA SCSI",
"Circular DIN-8 male",
"Circular DIN-8 female",
"On Board IDE",
"On Board Floppy",
"9 Pin Dual Inline (pin 10 cut)",
"25 Pin Dual Inline (pin 26 cut)",
"50 Pin Dual Inline",
"68 Pin Dual Inline",
"On Board Sound Input From CD-ROM",
"Mini Centronics Type-14",
"Mini Centronics Type-26",
"Mini Jack (headphones)",
"BNC",
"IEEE 1394",
"SAS/SATA Plug Receptacle" /* 0x22 */
};
static const char *type_0xA0[] = {
"PC-98", /* 0xA0 */
"PC-98 Hireso",
"PC-H98",
"PC-98 Note",
"PC-98 Full" /* 0xA4 */
};
if (code <= 0x22)
return type[code];
if (code >= 0xA0 && code <= 0xA4)
return type_0xA0[code - 0xA0];
if (code == 0xFF)
return "Other";
return out_of_spec;
}
static const char *dmi_port_type(u8 code)
{
/* 3.3.9.3 */
static const char *type[] = {
"None", /* 0x00 */
"Parallel Port XT/AT Compatible",
"Parallel Port PS/2",
"Parallel Port ECP",
"Parallel Port EPP",
"Parallel Port ECP/EPP",
"Serial Port XT/AT Compatible",
"Serial Port 16450 Compatible",
"Serial Port 16550 Compatible",
"Serial Port 16550A Compatible",
"SCSI Port",
"MIDI Port",
"Joystick Port",
"Keyboard Port",
"Mouse Port",
"SSA SCSI",
"USB",
"Firewire (IEEE P1394)",
"PCMCIA Type I",
"PCMCIA Type II",
"PCMCIA Type III",
"Cardbus",
"Access Bus Port",
"SCSI II",
"SCSI Wide",
"PC-98",
"PC-98 Hireso",
"PC-H98",
"Video Port",
"Audio Port",
"Modem Port",
"Network Port",
"SATA",
"SAS" /* 0x21 */
};
static const char *type_0xA0[] = {
"8251 Compatible", /* 0xA0 */
"8251 FIFO Compatible" /* 0xA1 */
};
if (code <= 0x21)
return type[code];
if (code >= 0xA0 && code <= 0xA1)
return type_0xA0[code - 0xA0];
if (code == 0xFF)
return "Other";
return out_of_spec;
}
/*
* 3.3.10 System Slots (Type 9)
*/
static const char *dmi_slot_type(u8 code)
{
/* 3.3.10.1 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"ISA",
"MCA",
"EISA",
"PCI",
"PC Card (PCMCIA)",
"VLB",
"Proprietary",
"Processor Card",
"Proprietary Memory Card",
"I/O Riser Card",
"NuBus",
"PCI-66",
"AGP",
"AGP 2x",
"AGP 4x",
"PCI-X",
"AGP 8x" /* 0x13 */
};
static const char *type_0xA0[] = {
"PC-98/C20", /* 0xA0 */
"PC-98/C24",
"PC-98/E",
"PC-98/Local Bus",
"PC-98/Card",
"PCI Express",
"PCI Express x1",
"PCI Express x2",
"PCI Express x4",
"PCI Express x8",
"PCI Express x16" /* 0xAA */
};
if (code >= 0x01 && code <= 0x13)
return type[code - 0x01];
if (code >= 0xA0 && code <= 0xAA)
return type_0xA0[code - 0xA0];
return out_of_spec;
}
static const char *dmi_slot_bus_width(u8 code)
{
/* 3.3.10.2 */
static const char *width[] = {
"", /* 0x01, "Other" */
"", /* "Unknown" */
"8-bit ",
"16-bit ",
"32-bit ",
"64-bit ",
"128-bit ",
"x1 ",
"x2 ",
"x4 ",
"x8 ",
"x12 ",
"x16 ",
"x32 " /* 0x0E */
};
if (code >= 0x01 && code <= 0x0E)
return width[code - 0x01];
return out_of_spec;
}
static const char *dmi_slot_current_usage(u8 code)
{
/* 3.3.10.3 */
static const char *usage[] = {
"Other", /* 0x01 */
"Unknown",
"Available",
"In Use" /* 0x04 */
};
if (code >= 0x01 && code <= 0x04)
return usage[code - 0x01];
return out_of_spec;
}
static const char *dmi_slot_length(u8 code)
{
/* 3.3.1O.4 */
static const char *length[] = {
"Other", /* 0x01 */
"Unknown",
"Short",
"Long" /* 0x04 */
};
if (code >= 0x01 && code <= 0x04)
return length[code - 0x01];
return out_of_spec;
}
static void dmi_slot_id(u8 code1, u8 code2, u8 type, const char *prefix)
{
/* 3.3.10.5 */
switch (type)
{
case 0x04: /* MCA */
printf("%sID: %u\n", prefix, code1);
break;
case 0x05: /* EISA */
printf("%sID: %u\n", prefix, code1);
break;
case 0x06: /* PCI */
case 0x0E: /* PCI */
case 0x0F: /* AGP */
case 0x10: /* AGP */
case 0x11: /* AGP */
case 0x12: /* PCI-X */
case 0x13: /* AGP */
case 0xA5: /* PCI Express */
printf("%sID: %u\n", prefix, code1);
break;
case 0x07: /* PCMCIA */
printf("%sID: Adapter %u, Socket %u\n", prefix, code1, code2);
break;
}
}
static void dmi_slot_characteristics(u8 code1, u8 code2, const char *prefix)
{
/* 3.3.10.6 */
static const char *characteristics1[] = {
"5.0 V is provided", /* 1 */
"3.3 V is provided",
"Opening is shared",
"PC Card-16 is supported",
"Cardbus is supported",
"Zoom Video is supported",
"Modem ring resume is supported" /* 7 */
};
/* 3.3.10.7 */
static const char *characteristics2[] = {
"PME signal is supported", /* 0 */
"Hot-plug devices are supported",
"SMBus signal is supported" /* 2 */
};
if (code1 & (1 << 0))
printf(" Unknown\n");
else if ((code1 & 0xFE) == 0 && (code2 & 0x07) == 0)
printf(" None\n");
else
{
int i;
printf("\n");
for (i = 1; i <= 7; i++)
if (code1 & (1 << i))
printf("%s%s\n", prefix, characteristics1[i - 1]);
for (i = 0; i <= 2; i++)
if (code2 & (1 << i))
printf("%s%s\n", prefix, characteristics2[i]);
}
}
static void dmi_slot_segment_bus_func(u16 code1, u8 code2, u8 code3, const char *prefix)
{
/* 3.3.10.8 */
if (!(code1 == 0xFFFF && code2 == 0xFF && code3 == 0xFF))
printf("%sBus Address: %04x:%02x:%02x.%x\n",
prefix, code1, code2, code3 >> 3, code3 & 0x7);
}
/*
* 3.3.11 On Board Devices Information (Type 10)
*/
static const char *dmi_on_board_devices_type(u8 code)
{
/* 3.3.11.1 and 3.3.42.2 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Video",
"SCSI Controller",
"Ethernet",
"Token Ring",
"Sound",
"PATA Controller",
"SATA Controller",
"SAS Controller" /* 0x0A */
};
if (code >= 0x01 && code <= 0x0A)
return type[code - 0x01];
return out_of_spec;
}
static void dmi_on_board_devices(const struct dmi_header *h, const char *prefix)
{
u8 *p = h->data + 4;
u8 count = (h->length - 0x04) / 2;
int i;
for (i = 0; i < count; i++)
{
if (count == 1)
printf("%sOn Board Device Information\n",
prefix);
else
printf("%sOn Board Device %d Information\n",
prefix, i + 1);
printf("%s\tType: %s\n",
prefix, dmi_on_board_devices_type(p[2 * i] & 0x7F));
printf("%s\tStatus: %s\n",
prefix, p[2 * i] & 0x80 ? "Enabled" : "Disabled");
printf("%s\tDescription: %s\n",
prefix, dmi_string(h, p[2 * i + 1]));
}
}
/*
* 3.3.12 OEM Strings (Type 11)
*/
static void dmi_oem_strings(const struct dmi_header *h, const char *prefix)
{
u8 *p = h->data + 4;
u8 count = p[0x00];
int i;
for (i = 1; i <= count; i++)
printf("%sString %d: %s\n",
prefix, i, dmi_string(h, i));
}
/*
* 3.3.13 System Configuration Options (Type 12)
*/
static void dmi_system_configuration_options(const struct dmi_header *h, const char *prefix)
{
u8 *p = h->data + 4;
u8 count = p[0x00];
int i;
for (i = 1; i <= count; i++)
printf("%sOption %d: %s\n",
prefix, i, dmi_string(h, i));
}
/*
* 3.3.14 BIOS Language Information (Type 13)
*/
static void dmi_bios_languages(const struct dmi_header *h, const char *prefix)
{
u8 *p = h->data + 4;
u8 count = p[0x00];
int i;
for (i = 1; i <= count; i++)
printf("%s%s\n",
prefix, dmi_string(h, i));
}
/*
* 3.3.15 Group Associations (Type 14)
*/
static void dmi_group_associations_items(u8 count, const u8 *p, const char *prefix)
{
int i;
for (i = 0; i < count; i++)
{
printf("%s0x%04X (%s)\n",
prefix, WORD(p + 3 * i + 1),
dmi_smbios_structure_type(p[3 * i]));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -