xref: /linux/include/linux/dmi.h (revision 0972ba5605a0a0cd8a9e74558b97a9c9626adfb5)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __DMI_H__
3 #define __DMI_H__
4 
5 #include <linux/list.h>
6 #include <linux/kobject.h>
7 #include <linux/mod_devicetable.h>
8 
9 /* enum dmi_field is in mod_devicetable.h */
10 
11 enum dmi_device_type {
12 	DMI_DEV_TYPE_ANY = 0,
13 	DMI_DEV_TYPE_OTHER,
14 	DMI_DEV_TYPE_UNKNOWN,
15 	DMI_DEV_TYPE_VIDEO,
16 	DMI_DEV_TYPE_SCSI,
17 	DMI_DEV_TYPE_ETHERNET,
18 	DMI_DEV_TYPE_TOKENRING,
19 	DMI_DEV_TYPE_SOUND,
20 	DMI_DEV_TYPE_PATA,
21 	DMI_DEV_TYPE_SATA,
22 	DMI_DEV_TYPE_SAS,
23 	DMI_DEV_TYPE_IPMI = -1,
24 	DMI_DEV_TYPE_OEM_STRING = -2,
25 	DMI_DEV_TYPE_DEV_ONBOARD = -3,
26 	DMI_DEV_TYPE_DEV_SLOT = -4,
27 };
28 
29 enum dmi_entry_type {
30 	DMI_ENTRY_BIOS = 0,
31 	DMI_ENTRY_SYSTEM,
32 	DMI_ENTRY_BASEBOARD,
33 	DMI_ENTRY_CHASSIS,
34 	DMI_ENTRY_PROCESSOR,
35 	DMI_ENTRY_MEM_CONTROLLER,
36 	DMI_ENTRY_MEM_MODULE,
37 	DMI_ENTRY_CACHE,
38 	DMI_ENTRY_PORT_CONNECTOR,
39 	DMI_ENTRY_SYSTEM_SLOT,
40 	DMI_ENTRY_ONBOARD_DEVICE,
41 	DMI_ENTRY_OEMSTRINGS,
42 	DMI_ENTRY_SYSCONF,
43 	DMI_ENTRY_BIOS_LANG,
44 	DMI_ENTRY_GROUP_ASSOC,
45 	DMI_ENTRY_SYSTEM_EVENT_LOG,
46 	DMI_ENTRY_PHYS_MEM_ARRAY,
47 	DMI_ENTRY_MEM_DEVICE,
48 	DMI_ENTRY_32_MEM_ERROR,
49 	DMI_ENTRY_MEM_ARRAY_MAPPED_ADDR,
50 	DMI_ENTRY_MEM_DEV_MAPPED_ADDR,
51 	DMI_ENTRY_BUILTIN_POINTING_DEV,
52 	DMI_ENTRY_PORTABLE_BATTERY,
53 	DMI_ENTRY_SYSTEM_RESET,
54 	DMI_ENTRY_HW_SECURITY,
55 	DMI_ENTRY_SYSTEM_POWER_CONTROLS,
56 	DMI_ENTRY_VOLTAGE_PROBE,
57 	DMI_ENTRY_COOLING_DEV,
58 	DMI_ENTRY_TEMP_PROBE,
59 	DMI_ENTRY_ELECTRICAL_CURRENT_PROBE,
60 	DMI_ENTRY_OOB_REMOTE_ACCESS,
61 	DMI_ENTRY_BIS_ENTRY,
62 	DMI_ENTRY_SYSTEM_BOOT,
63 	DMI_ENTRY_64_MEM_ERROR,
64 	DMI_ENTRY_MGMT_DEV,
65 	DMI_ENTRY_MGMT_DEV_COMPONENT,
66 	DMI_ENTRY_MGMT_DEV_THRES,
67 	DMI_ENTRY_MEM_CHANNEL,
68 	DMI_ENTRY_IPMI_DEV,
69 	DMI_ENTRY_SYS_POWER_SUPPLY,
70 	DMI_ENTRY_ADDITIONAL,
71 	DMI_ENTRY_ONBOARD_DEV_EXT,
72 	DMI_ENTRY_MGMT_CONTROLLER_HOST,
73 	DMI_ENTRY_TPM_DEVICE,
74 	DMI_ENTRY_PROCESSOR_ADDITIONAL,
75 	DMI_ENTRY_FIRMWARE_INVENTORY,
76 	DMI_ENTRY_STRING_PROPERTY,
77 	DMI_ENTRY_INACTIVE = 126,
78 	DMI_ENTRY_END_OF_TABLE = 127,
79 };
80 
81 struct dmi_header {
82 	u8 type;
83 	u8 length;
84 	u16 handle;
85 } __packed;
86 
87 struct dmi_device {
88 	struct list_head list;
89 	int type;
90 	const char *name;
91 	void *device_data;	/* Type specific data */
92 };
93 
94 #define DMI_A_INFO_ENT_MIN_SIZE 0x6
95 struct dmi_a_info_entry {
96 	u8 length;
97 	u16 handle;
98 	u8 offset;
99 	u8 str_num;
100 	u8 value[];
101 } __packed;
102 
103 #define DMI_A_INFO_MIN_SIZE	0xB
104 struct dmi_a_info {
105 	struct dmi_header header;
106 	u8 count;
107 } __packed;
108 
109 #ifdef CONFIG_DMI
110 
111 struct dmi_dev_onboard {
112 	struct dmi_device dev;
113 	int instance;
114 	int segment;
115 	int bus;
116 	int devfn;
117 };
118 
119 extern struct kobject *dmi_kobj;
120 extern int dmi_check_system(const struct dmi_system_id *list);
121 const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list);
122 extern const char * dmi_get_system_info(int field);
123 extern const struct dmi_device * dmi_find_device(int type, const char *name,
124 	const struct dmi_device *from);
125 extern void dmi_setup(void);
126 extern bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp);
127 extern int dmi_get_bios_year(void);
128 extern int dmi_name_in_vendors(const char *str);
129 extern int dmi_name_in_serial(const char *str);
130 extern int dmi_available;
131 extern int dmi_walk(void (*decode)(const struct dmi_header *, void *),
132 	void *private_data);
133 extern bool dmi_match(enum dmi_field f, const char *str);
134 extern void dmi_memdev_name(u16 handle, const char **bank, const char **device);
135 extern u64 dmi_memdev_size(u16 handle);
136 extern u8 dmi_memdev_type(u16 handle);
137 extern u16 dmi_memdev_handle(int slot);
138 const char *dmi_string_nosave(const struct dmi_header *dm, u8 s);
139 
140 #else
141 
dmi_check_system(const struct dmi_system_id * list)142 static inline int dmi_check_system(const struct dmi_system_id *list) { return 0; }
dmi_get_system_info(int field)143 static inline const char * dmi_get_system_info(int field) { return NULL; }
dmi_find_device(int type,const char * name,const struct dmi_device * from)144 static inline const struct dmi_device * dmi_find_device(int type, const char *name,
145 	const struct dmi_device *from) { return NULL; }
dmi_setup(void)146 static inline void dmi_setup(void) { }
dmi_get_date(int field,int * yearp,int * monthp,int * dayp)147 static inline bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp)
148 {
149 	if (yearp)
150 		*yearp = 0;
151 	if (monthp)
152 		*monthp = 0;
153 	if (dayp)
154 		*dayp = 0;
155 	return false;
156 }
dmi_get_bios_year(void)157 static inline int dmi_get_bios_year(void) { return -ENXIO; }
dmi_name_in_vendors(const char * s)158 static inline int dmi_name_in_vendors(const char *s) { return 0; }
dmi_name_in_serial(const char * s)159 static inline int dmi_name_in_serial(const char *s) { return 0; }
160 #define dmi_available 0
dmi_walk(void (* decode)(const struct dmi_header *,void *),void * private_data)161 static inline int dmi_walk(void (*decode)(const struct dmi_header *, void *),
162 	void *private_data) { return -ENXIO; }
dmi_match(enum dmi_field f,const char * str)163 static inline bool dmi_match(enum dmi_field f, const char *str)
164 	{ return false; }
dmi_memdev_name(u16 handle,const char ** bank,const char ** device)165 static inline void dmi_memdev_name(u16 handle, const char **bank,
166 		const char **device) { }
dmi_memdev_size(u16 handle)167 static inline u64 dmi_memdev_size(u16 handle) { return ~0ul; }
dmi_memdev_type(u16 handle)168 static inline u8 dmi_memdev_type(u16 handle) { return 0x0; }
dmi_memdev_handle(int slot)169 static inline u16 dmi_memdev_handle(int slot) { return 0xffff; }
170 static inline const struct dmi_system_id *
dmi_first_match(const struct dmi_system_id * list)171 	dmi_first_match(const struct dmi_system_id *list) { return NULL; }
172 static inline const char *
dmi_string_nosave(const struct dmi_header * dm,u8 s)173 	dmi_string_nosave(const struct dmi_header *dm, u8 s) { return ""; }
174 
175 #endif
176 
177 #endif	/* __DMI_H__ */
178