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

📄 dmidecode.c

📁 linux环境在终端打印出所有smbios信息的代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	if(code>=0x01 && code<=0x0A)		return location[code-0x01];	if(code>=0xA0 && code<=0xA4)		return location_0xA0[code-0xA0];	return out_of_spec;}static const char *dmi_memory_array_use(u8 code){	/* 3.3.17.2 */	static const char *use[]={		"Other", /* 0x01 */		"Unknown",		"System Memory",		"Video Memory",		"Flash Memory",		"Non-volatile RAM",		"Cache Memory" /* 0x07 */	};		if(code>=0x01 && code<=0x07)		return use[code-0x01];	return out_of_spec;}static const char *dmi_memory_array_ec_type(u8 code){	/* 3.3.17.3 */	static const char *type[]={		"Other", /* 0x01 */		"Unknown",		"None",		"Parity",		"Single-bit ECC",		"Multi-bit ECC",		"CRC" /* 0x07 */	};		if(code>=0x01 && code<=0x07)		return type[code-0x01];	return out_of_spec;}static void dmi_memory_array_capacity(u32 code){	if(code==0x8000000)		printf(" Unknown");	else	{		if((code&0x000FFFFF)==0)			printf(" %u GB", code>>20);		else if((code&0x000003FF)==0)			printf(" %u MB", code>>10);		else			printf(" %u kB", code);	}}static void dmi_memory_array_error_handle(u16 code){	if(code==0xFFFE)		printf(" Not Provided");	else if(code==0xFFFF)		printf(" No Error");	else		printf(" 0x%04X", code);}/* * 3.3.18 Memory Device (Type 17) */static void dmi_memory_device_width(u16 code){	/*	 * If no memory module is present, width may be 0	 */	if(code==0xFFFF || code==0)		printf(" Unknown");	else		printf(" %u bits", code);}static void dmi_memory_device_size(u16 code){	if(code==0)		printf(" No Module Installed");	else if(code==0xFFFF)		printf(" Unknown");	else	{		if(code&0x8000)			printf(" %u kB", code&0x7FFF);		else			printf(" %u MB", code);	}}static const char *dmi_memory_device_form_factor(u8 code){	/* 3.3.18.1 */	static const char *form_factor[]={		"Other", /* 0x01 */		"Unknown",		"SIMM",		"SIP",		"Chip",		"DIP",		"ZIP",		"Proprietary Card",		"DIMM",		"TSOP",		"Row Of Chips",		"RIMM",		"SODIMM",		"SRIMM" /* 0x0E */	};		if(code>=0x01 && code<=0x0E)		return form_factor[code-0x01];	return out_of_spec;}static void dmi_memory_device_set(u8 code){	if(code==0)		printf(" None");	else if(code==0xFF)		printf(" Unknown");	else		printf(" %u", code);}static const char *dmi_memory_device_type(u8 code){	/* 3.3.18.2 */	static const char *type[]={		"Other", /* 0x01 */		"Unknown",		"DRAM",		"EDRAM",		"VRAM",		"SRAM",		"RAM",		"ROM",		"Flash",		"EEPROM",		"FEPROM",		"EPROM",		"CDRAM",		"3DRAM",		"SDRAM",		"SGRAM",		"RDRAM",		"DDR",		"DDR2" /* 0x13 */	};		if(code>=0x01 && code<=0x13)		return type[code-0x01];	return out_of_spec;}static void dmi_memory_device_type_detail(u16 code){	/* 3.3.18.3 */	static const char *detail[]={		"Other", /* 1 */		"Unknown",		"Fast-paged",		"Static Column",		"Pseudo-static",		"RAMBus",		"Synchronous",		"CMOS",		"EDO",		"Window DRAM",		"Cache DRAM",		"Non-Volatile" /* 12 */	};		if((code&0x1FFE)==0)		printf(" None");	else	{		int i;				for(i=1; i<=12; i++)			if(code&(1<<i))				printf(" %s", detail[i-1]);	}}static void dmi_memory_device_speed(u16 code){	if(code==0)		printf(" Unknown");	else		printf(" %u MHz (%.1f ns)", code, (float)1000/code);}/* * 3.3.19 32-bit Memory Error Information (Type 18) */static const char *dmi_memory_error_type(u8 code){	/* 3.3.19.1 */	static const char *type[]={		"Other", /* 0x01 */		"Unknown",		"OK",		"Bad Read",		"Parity Error",		"Single-bit Error",		"Double-bit Error",		"Multi-bit Error",		"Nibble Error",		"Checksum Error",		"CRC Error",		"Corrected Single-bit Error",		"Corrected Error",		"Uncorrectable Error" /* 0x0E */	};		if(code>=0x01 && code<=0x0E)		return type[code-0x01];	return out_of_spec;}static const char *dmi_memory_error_granularity(u8 code){	/* 3.3.19.2 */	static const char *granularity[]={		"Other", /* 0x01 */		"Unknown",		"Device Level",		"Memory Partition Level" /* 0x04 */	};		if(code>=0x01 && code<=0x04)		return granularity[code-0x01];	return out_of_spec;}static const char *dmi_memory_error_operation(u8 code){	/* 3.3.19.3 */	static const char *operation[]={		"Other", /* 0x01 */		"Unknown",		"Read",		"Write",		"Partial Write" /* 0x05 */	};		if(code>=0x01 && code<=0x05)		return operation[code-0x01];	return out_of_spec;}static void dmi_memory_error_syndrome(u32 code){	if(code==0x00000000)		printf(" Unknown");	else		printf(" 0x%08X", code);}static void dmi_32bit_memory_error_address(u32 code){	if(code==0x80000000)		printf(" Unknown");	else		printf(" 0x%08X", code);}/* * 3.3.20 Memory Array Mapped Address (Type 19) */static void dmi_mapped_address_size(u32 code){	if(code==0)		printf(" Invalid");	else if((code&0x000FFFFF)==0)		printf(" %u GB", code>>20);	else if((code&0x000003FF)==0)		printf(" %u MB", code>>10);	else		printf(" %u kB", code);}/* * 3.3.21 Memory Device Mapped Address (Type 20) */static void dmi_mapped_address_row_position(u8 code){	if(code==0)		printf(" %s", out_of_spec);	else if(code==0xFF)		printf(" Unknown");	else		printf(" %u", code);}static void dmi_mapped_address_interleave_position(u8 code, const char *prefix){	if(code!=0)	{		printf("%sInterleave Position:", prefix);		if(code==0xFF)			printf(" Unknown");		else			printf(" %u", code);		printf("\n");	}}static void dmi_mapped_address_interleaved_data_depth(u8 code, const char *prefix){	if(code!=0)	{		printf("%sInterleaved Data Depth:", prefix);		if(code==0xFF)			printf(" Unknown");		else			printf(" %u", code);		printf("\n");	}}/* * 3.3.22 Built-in Pointing Device (Type 21) */static const char *dmi_pointing_device_type(u8 code){	/* 3.3.22.1 */	static const char *type[]={		"Other", /* 0x01 */		"Unknown",		"Mouse",		"Track Ball",		"Track Point",		"Glide Point",		"Touch Pad",		"Touch Screen",		"Optical Sensor" /* 0x09 */	};		if(code>=0x01 && code<=0x09)		return type[code-0x01];	return out_of_spec;}static const char *dmi_pointing_device_interface(u8 code){	/* 3.3.22.2 */	static const char *interface[]={		"Other", /* 0x01 */		"Unknown",		"Serial",		"PS/2",		"Infrared",		"HIP-HIL",		"Bus Mouse",		"ADB (Apple Desktop Bus)" /* 0x08 */	};	static const char *interface_0xA0[]={		"Bus Mouse DB-9", /* 0xA0 */		"Bus Mouse Micro DIN",		"USB" /* 0xA2 */	};		if(code>=0x01 && code<=0x08)		return interface[code-0x01];	if(code>=0xA0 && code<=0xA2)		return interface_0xA0[code-0xA0];	return out_of_spec;}/* * 3.3.23 Portable Battery (Type 22) */static const char *dmi_battery_chemistry(u8 code){	/* 3.3.23.1 */	static const char *chemistry[]={		"Other", /* 0x01 */		"Unknown",		"Lead Acid",		"Nickel Cadmium",		"Nickel Metal Hydride",		"Lithium Ion",		"Zinc Air",		"Lithium Polymer" /* 0x08 */	};	if(code>=0x01 && code<=0x08)		return chemistry[code-0x01];	return out_of_spec;}static void dmi_battery_capacity(u16 code, u8 multiplier){	if(code==0)		printf(" Unknown");	else		printf(" %u mWh", code*multiplier);}static void dmi_battery_voltage(u16 code){	if(code==0)		printf(" Unknown");	else		printf(" %u mV", code);}static void dmi_battery_maximum_error(u8 code){	if(code==0xFF)		printf(" Unknown");	else		printf(" %u%%", code);}/* * 3.3.24 System Reset (Type 23) */static const char *dmi_system_reset_boot_option(u8 code){	static const char *option[]={		"Operating System", /* 0x1 */		"System Utilities",		"Do Not Reboot" /* 0x3 */	};		if(code>=0x1)		return option[code-0x1];	return out_of_spec;}static void dmi_system_reset_count(u16 code){	if(code==0xFFFF)		printf(" Unknown");	else		printf(" %u", code);}static void dmi_system_reset_timer(u16 code){	if(code==0xFFFF)		printf(" Unknown");	else		printf(" %u min", code);}/* * 3.3.25 Hardware Security (Type 24) */static const char *dmi_hardware_security_status(u8 code){	static const char *status[]={		"Disabled", /* 0x00 */		"Enabled",		"Not Implemented",		"Unknown" /* 0x03 */	};		return status[code];}/* * 3.3.26 System Power Controls (Type 25) */static void dmi_power_controls_power_on(u8 *p){	/* 3.3.26.1 */	if(dmi_bcd_range(p[0], 0x01, 0x12))		printf(" %02X", p[0]);	else		printf(" *");	if(dmi_bcd_range(p[1], 0x01, 0x31))		printf("-%02X", p[1]);	else		printf("-*");	if(dmi_bcd_range(p[2], 0x00, 0x23))		printf(" %02X", p[2]);	else		printf(" *");	if(dmi_bcd_range(p[3], 0x00, 0x59))		printf(":%02X", p[3]);	else		printf(":*");	if(dmi_bcd_range(p[4], 0x00, 0x59))		printf(":%02X", p[4]);	else		printf(":*");}/* * 3.3.27 Voltage Probe (Type 26) */static const char *dmi_voltage_probe_location(u8 code){	/* 3.3.27.1 */	static const char *location[]={		"Other", /* 0x01 */		"Unknown",		"Processor",		"Disk",		"Peripheral Bay",		"System Management Module",		"Motherboard",		"Memory Module",		"Processor Module",		"Power Unit",		"Add-in Card" /* 0x0B */	};		if(code>=0x01 && code<=0x0B)		return location[code-0x01];	return out_of_spec;}static const char *dmi_probe_status(u8 code){	/* 3.3.27.1 */	static const char *status[]={		"Other", /* 0x01 */		"Unknown",		"OK",		"Non-critical",		"Critical",		"Non-recoverable" /* 0x06 */	};		if(code>=0x01 && code<=0x06)		return status[code-0x01];	return out_of_spec;}static void dmi_voltage_probe_value(u16 code){	if(code==0x8000)		printf(" Unknown");	else		printf(" %.3f V", (float)(i16)code/1000);}static void dmi_voltage_probe_resolution(u16 code){	if(code==0x8000)		printf(" Unknown");	else		printf(" %.1f mV", (float)code/10);}static void dmi_probe_accuracy(u16 code){	if(code==0x8000)		printf(" Unknown");	else		printf(" %.2f%%", (float)code/100);}/* * 3.3.28 Cooling Device (Type 27) */static const char *dmi_cooling_device_type(u8 code){	/* 3.3.28.1 */	static const char *type[]={		"Other", /* 0x01 */		"Unknown",		"Fan",		"Centrifugal Blower",		"Chip Fan",		"Cabinet Fan",		"Power Supply Fan",		"Heat Pipe",		"Integrated Refrigeration" /* 0x09 */	};	static const char *type_0x10[]={		"Active Cooling", /* 0x10, master.mif says 32 */		"Passive Cooling" /* 0x11, master.mif says 33 */	};		if(code>=0x01 && code<=0x09)		return type[code-0x01];	if(code>=0x10 && code<=0x11)		return type_0x10[code-0x10];	return out_of_spec;}static void dmi_cooling_device_speed(u16 code){	if(code==0x8000)		printf(" Unknown Or Non-rotating");	else		printf(" %u rpm", code);}/* * 3.3.29 Temperature Probe (Type 28) */static const char *dmi_temperature_probe_location(u8 code){	/* 3.3.29.1 */	static const char *location[]={		"Other", /* 0x01 */		"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)

⌨️ 快捷键说明

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