⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dmidecode.c

📁 linux环境在终端打印出所有smbios信息的代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	};		if(location[code]!=NULL)		return location[code];	return out_of_spec;}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.1 */	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.2 */	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.3 */	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.4 */	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" /* 0x21 */	};	static const char *type_0xA0[]={		"PC-98", /* 0xA0 */		"PC-98 Hireso",		"PC-H98",		"PC-98 Note",		"PC-98 Full" /* 0xA4 */	};		if(code<=0x21)		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" /* 0x1F */	};	static const char *type_0xA0[]={		"8251 Compatible", /* 0xA0 */		"8251 FIFO Compatible" /* 0xA1 */	};		if(code<=0x1F)		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" /* 0xA5 */	};		if(code>=0x01 && code<=0x13)		return type[code-0x01];	if(code>=0xA0 && code<=0xA5)		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 */			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&0x7F)==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]);	}}/* * 3.3.11 On Board Devices Information (Type 10) */static const char *dmi_on_board_devices_type(u8 code){	/* 3.3.11.1 */	static const char *type[]={		"Other", /* 0x01 */		"Unknown",		"Video",		"SCSI Controller",		"Ethernet",		"Token Ring",		"Sound" /* 0x07 */	};		if(code>=0x01 && code <=0x07)		return type[code-0x01];	return out_of_spec;}static void dmi_on_board_devices(struct dmi_header *h, const char *prefix){	u8 *p=(u8 *)h+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(struct dmi_header *h, const char *prefix){	u8 *p=(u8 *)h+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(struct dmi_header *h, const char *prefix){	u8 *p=(u8 *)h+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(struct dmi_header *h, const char *prefix){	u8 *p=(u8 *)h+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, 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]));	}}/* * 3.3.16 System Event Log (Type 15) */static const char *dmi_event_log_method(u8 code){	static const char *method[]={		"Indexed I/O, one 8-bit index port, one 8-bit data port", /* 0x00 */		"Indexed I/O, two 8-bit index ports, one 8-bit data port",		"Indexed I/O, one 16-bit index port, one 8-bit data port",		"Memory-mapped physical 32-bit address",		"General-purpose non-volatile data functions" /* 0x04 */	};		if(code<=0x04)		return method[code];	if(code>=0x80)		return "OEM-specific";	return out_of_spec;}static void dmi_event_log_status(u8 code){	static const char *valid[]={		"Invalid", /* 0 */		"Valid" /* 1 */	};	static const char *full[]={		"Not Full", /* 0 */		"Full" /* 1 */	};		printf(" %s, %s",		valid[code&(1<<0)], full[code&(1<<1)]);}static void dmi_event_log_address(u8 method, u8 *p){	/* 3.3.16.3 */	switch(method)	{		case 0x00:		case 0x01:		case 0x02:			printf(" Index 0x%04X, Data 0x%04X", WORD(p), WORD(p+2));			break;		case 0x03:			printf(" 0x%08X", DWORD(p));			break;		case 0x04:			printf(" 0x%04X", WORD(p));			break;		default:			printf(" Unknown");	}}static const char *dmi_event_log_header_type(u8 code){	static const char *type[]={		"No Header", /* 0x00 */		"Type 1" /* 0x01 */	};		if(code<=0x01)		return type[code];	if(code>=0x80)		return "OEM-specific";	return out_of_spec;}static const char *dmi_event_log_descriptor_type(u8 code){	/* 3.3.16.6.1 */	static const char *type[]={		NULL, /* 0x00 */		"Single-bit ECC memory error",		"Multi-bit ECC memory error",		"Parity memory error",		"Bus timeout",		"I/O channel block",		"Software NMI",		"POST memory resize",		"POST error",		"PCI parity error",		"PCI system error",		"CPU failure",		"EISA failsafe timer timeout",		"Correctable memory log disabled",		"Logging disabled",		NULL, /* 0x0F */		"System limit exceeded",		"Asynchronous hardware timer expired",		"System configuration information",		"Hard disk information",		"System reconfigured",		"Uncorrectable CPU-complex error",		"Log area reset/cleared",		"System boot" /* 0x17 */	};		if(code<=0x17 && type[code]!=NULL)		return type[code];	if(code>=0x80 && code<=0xFE)		return "OEM-specific";	if(code==0xFF)		return "End of log";	return out_of_spec;}static const char *dmi_event_log_descriptor_format(u8 code){	/* 3.3.16.6.2 */	static const char *format[]={		"None", /* 0x00 */		"Handle",		"Multiple-event",		"Multiple-event handle",		"POST results bitmap",		"System management",		"Multiple-event system management" /* 0x06 */	};		if(code<=0x06)		return format[code];	if(code>=0x80)		return "OEM-specific";	return out_of_spec;}static void dmi_event_log_descriptors(u8 count, u8 len, u8 *p, const char *prefix){	/* 3.3.16.1 */	int i;		for(i=0; i<count; i++)	{		if(len>=0x02)		{			printf("%sDescriptor %u: %s\n",				prefix, i+1, dmi_event_log_descriptor_type(p[i*len]));			printf("%sData Format %u: %s\n",				prefix, i+1, dmi_event_log_descriptor_format(p[i*len+1]));		}	}}/* * 3.3.17 Physical Memory Array (Type 16) */static const char *dmi_memory_array_location(u8 code){	/* 3.3.17.1 */	static const char *location[]={		"Other", /* 0x01 */		"Unknown",		"System Board Or Motherboard",		"ISA Add-on Card",		"EISA Add-on Card",		"PCI Add-on Card",		"MCA Add-on Card",		"PCMCIA Add-on Card",		"Proprietary Add-on Card",		"NuBus" /* 0x0A, master.mif says 16 */	};	static const char *location_0xA0[]={		"PC-98/C20 Add-on Card", /* 0xA0 */		"PC-98/C24 Add-on Card",		"PC-98/E Add-on Card",		"PC-98/Local Bus Add-on Card",		"PC-98/Card Slot Add-on Card" /* 0xA4, from master.mif */	};	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -