blob: c46fdb36700bc2d83115245e660853ffc5a47141 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef __DMI_H__
3#define __DMI_H__
4
Andrey Paninebad6a42005-09-06 15:18:29 -07005#include <linux/list.h>
Ivan Khoronzhukd7f96f972015-06-25 09:06:56 +02006#include <linux/kobject.h>
David Woodhoused945b692008-09-16 16:23:28 -07007#include <linux/mod_devicetable.h>
Andrey Paninebad6a42005-09-06 15:18:29 -07008
David Woodhoused945b692008-09-16 16:23:28 -07009/* enum dmi_field is in mod_devicetable.h */
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
Andrey Paninebad6a42005-09-06 15:18:29 -070011enum 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,
Wim Van Sebroeckb4bd7d52008-02-08 04:20:58 -080020 DMI_DEV_TYPE_PATA,
21 DMI_DEV_TYPE_SATA,
22 DMI_DEV_TYPE_SAS,
Shem Multinymous2e0c1f62006-09-29 01:59:37 -070023 DMI_DEV_TYPE_IPMI = -1,
Wim Van Sebroeckb4bd7d52008-02-08 04:20:58 -080024 DMI_DEV_TYPE_OEM_STRING = -2,
Narendra K911e1c92010-07-26 05:56:50 -050025 DMI_DEV_TYPE_DEV_ONBOARD = -3,
Jordan Hargravee5b6c152016-01-15 22:08:45 +010026 DMI_DEV_TYPE_DEV_SLOT = -4,
Andrey Paninebad6a42005-09-06 15:18:29 -070027};
28
Mike Waychison93c890d2011-02-22 17:53:15 -080029enum 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_MGMT_DEV,
64 DMI_ENTRY_MGMT_DEV_COMPONENT,
65 DMI_ENTRY_MGMT_DEV_THRES,
66 DMI_ENTRY_MEM_CHANNEL,
67 DMI_ENTRY_IPMI_DEV,
68 DMI_ENTRY_SYS_POWER_SUPPLY,
69 DMI_ENTRY_ADDITIONAL,
70 DMI_ENTRY_ONBOARD_DEV_EXT,
71 DMI_ENTRY_MGMT_CONTROLLER_HOST,
72 DMI_ENTRY_INACTIVE = 126,
73 DMI_ENTRY_END_OF_TABLE = 127,
74};
75
Andrey Paninebad6a42005-09-06 15:18:29 -070076struct dmi_header {
77 u8 type;
78 u8 length;
79 u16 handle;
Jean Delvare9ea650c82015-06-25 09:06:57 +020080} __packed;
Andrey Paninebad6a42005-09-06 15:18:29 -070081
Andrey Paninebad6a42005-09-06 15:18:29 -070082struct dmi_device {
83 struct list_head list;
84 int type;
85 const char *name;
86 void *device_data; /* Type specific data */
87};
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
Andi Kleene9928672006-01-11 22:43:33 +010089#ifdef CONFIG_DMI
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
Narendra K911e1c92010-07-26 05:56:50 -050091struct dmi_dev_onboard {
92 struct dmi_device dev;
93 int instance;
94 int segment;
95 int bus;
96 int devfn;
97};
98
Ivan Khoronzhukd7f96f972015-06-25 09:06:56 +020099extern struct kobject *dmi_kobj;
Jeff Garzik18552562007-10-03 15:15:40 -0400100extern int dmi_check_system(const struct dmi_system_id *list);
Rafael J. Wysockid7b19562009-01-19 20:55:50 +0100101const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list);
Jeff Garzik18552562007-10-03 15:15:40 -0400102extern const char * dmi_get_system_info(int field);
103extern const struct dmi_device * dmi_find_device(int type, const char *name,
104 const struct dmi_device *from);
Andi Kleene9928672006-01-11 22:43:33 +0100105extern void dmi_scan_machine(void);
Chen, Gongdd6dad42013-10-18 14:29:25 -0700106extern void dmi_memdev_walk(void);
Tejun Heo98e5e1b2013-04-30 15:27:15 -0700107extern void dmi_set_dump_stack_arch_desc(void);
Tejun Heo3e5cd1f2009-08-16 21:02:36 +0900108extern bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp);
Andy Shevchenko3af34522018-03-20 20:07:59 +0200109extern int dmi_get_bios_year(void);
Jeff Garzik18552562007-10-03 15:15:40 -0400110extern int dmi_name_in_vendors(const char *str);
Alok Katariafd8cd7e2008-11-03 15:50:38 -0800111extern int dmi_name_in_serial(const char *str);
Len Brown81b4e1f2008-01-16 17:20:37 -0500112extern int dmi_available;
Jean Delvaree7a19c562009-03-30 21:46:44 +0200113extern int dmi_walk(void (*decode)(const struct dmi_header *, void *),
114 void *private_data);
Jiri Slabyd61c72e2008-12-10 14:07:21 +0100115extern bool dmi_match(enum dmi_field f, const char *str);
Chen, Gongdd6dad42013-10-18 14:29:25 -0700116extern void dmi_memdev_name(u16 handle, const char **bank, const char **device);
Tony Luck6deae962018-03-12 11:24:29 -0700117extern u64 dmi_memdev_size(u16 handle);
Andi Kleene9928672006-01-11 22:43:33 +0100118
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119#else
120
Jeff Garzik18552562007-10-03 15:15:40 -0400121static inline int dmi_check_system(const struct dmi_system_id *list) { return 0; }
122static inline const char * dmi_get_system_info(int field) { return NULL; }
123static inline const struct dmi_device * dmi_find_device(int type, const char *name,
124 const struct dmi_device *from) { return NULL; }
Thomas Petazzoni7ae93922008-04-28 02:14:14 -0700125static inline void dmi_scan_machine(void) { return; }
Chen, Gongdd6dad42013-10-18 14:29:25 -0700126static inline void dmi_memdev_walk(void) { }
Tejun Heo98e5e1b2013-04-30 15:27:15 -0700127static inline void dmi_set_dump_stack_arch_desc(void) { }
Tejun Heo3e5cd1f2009-08-16 21:02:36 +0900128static inline bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp)
129{
130 if (yearp)
131 *yearp = 0;
132 if (monthp)
133 *monthp = 0;
134 if (dayp)
135 *dayp = 0;
136 return false;
137}
Andy Shevchenko3af34522018-03-20 20:07:59 +0200138static inline int dmi_get_bios_year(void) { return -ENXIO; }
Jeff Garzik18552562007-10-03 15:15:40 -0400139static inline int dmi_name_in_vendors(const char *s) { return 0; }
Alok Katariafd8cd7e2008-11-03 15:50:38 -0800140static inline int dmi_name_in_serial(const char *s) { return 0; }
Len Brown81b4e1f2008-01-16 17:20:37 -0500141#define dmi_available 0
Jean Delvaree7a19c562009-03-30 21:46:44 +0200142static inline int dmi_walk(void (*decode)(const struct dmi_header *, void *),
Andy Lutomirskic9268202017-06-15 13:46:00 +0200143 void *private_data) { return -ENXIO; }
Jiri Slabyd61c72e2008-12-10 14:07:21 +0100144static inline bool dmi_match(enum dmi_field f, const char *str)
145 { return false; }
Chen, Gongdd6dad42013-10-18 14:29:25 -0700146static inline void dmi_memdev_name(u16 handle, const char **bank,
147 const char **device) { }
Tony Luck6deae962018-03-12 11:24:29 -0700148static inline u64 dmi_memdev_size(u16 handle) { return ~0ul; }
Kumar Galad8204ee2009-01-28 00:07:20 -0600149static inline const struct dmi_system_id *
150 dmi_first_match(const struct dmi_system_id *list) { return NULL; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151
152#endif
153
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154#endif /* __DMI_H__ */