Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __DMI_H__
0003 #define __DMI_H__
0004 
0005 #include <linux/list.h>
0006 #include <linux/kobject.h>
0007 #include <linux/mod_devicetable.h>
0008 
0009 /* enum dmi_field is in mod_devicetable.h */
0010 
0011 enum dmi_device_type {
0012     DMI_DEV_TYPE_ANY = 0,
0013     DMI_DEV_TYPE_OTHER,
0014     DMI_DEV_TYPE_UNKNOWN,
0015     DMI_DEV_TYPE_VIDEO,
0016     DMI_DEV_TYPE_SCSI,
0017     DMI_DEV_TYPE_ETHERNET,
0018     DMI_DEV_TYPE_TOKENRING,
0019     DMI_DEV_TYPE_SOUND,
0020     DMI_DEV_TYPE_PATA,
0021     DMI_DEV_TYPE_SATA,
0022     DMI_DEV_TYPE_SAS,
0023     DMI_DEV_TYPE_IPMI = -1,
0024     DMI_DEV_TYPE_OEM_STRING = -2,
0025     DMI_DEV_TYPE_DEV_ONBOARD = -3,
0026     DMI_DEV_TYPE_DEV_SLOT = -4,
0027 };
0028 
0029 enum dmi_entry_type {
0030     DMI_ENTRY_BIOS = 0,
0031     DMI_ENTRY_SYSTEM,
0032     DMI_ENTRY_BASEBOARD,
0033     DMI_ENTRY_CHASSIS,
0034     DMI_ENTRY_PROCESSOR,
0035     DMI_ENTRY_MEM_CONTROLLER,
0036     DMI_ENTRY_MEM_MODULE,
0037     DMI_ENTRY_CACHE,
0038     DMI_ENTRY_PORT_CONNECTOR,
0039     DMI_ENTRY_SYSTEM_SLOT,
0040     DMI_ENTRY_ONBOARD_DEVICE,
0041     DMI_ENTRY_OEMSTRINGS,
0042     DMI_ENTRY_SYSCONF,
0043     DMI_ENTRY_BIOS_LANG,
0044     DMI_ENTRY_GROUP_ASSOC,
0045     DMI_ENTRY_SYSTEM_EVENT_LOG,
0046     DMI_ENTRY_PHYS_MEM_ARRAY,
0047     DMI_ENTRY_MEM_DEVICE,
0048     DMI_ENTRY_32_MEM_ERROR,
0049     DMI_ENTRY_MEM_ARRAY_MAPPED_ADDR,
0050     DMI_ENTRY_MEM_DEV_MAPPED_ADDR,
0051     DMI_ENTRY_BUILTIN_POINTING_DEV,
0052     DMI_ENTRY_PORTABLE_BATTERY,
0053     DMI_ENTRY_SYSTEM_RESET,
0054     DMI_ENTRY_HW_SECURITY,
0055     DMI_ENTRY_SYSTEM_POWER_CONTROLS,
0056     DMI_ENTRY_VOLTAGE_PROBE,
0057     DMI_ENTRY_COOLING_DEV,
0058     DMI_ENTRY_TEMP_PROBE,
0059     DMI_ENTRY_ELECTRICAL_CURRENT_PROBE,
0060     DMI_ENTRY_OOB_REMOTE_ACCESS,
0061     DMI_ENTRY_BIS_ENTRY,
0062     DMI_ENTRY_SYSTEM_BOOT,
0063     DMI_ENTRY_MGMT_DEV,
0064     DMI_ENTRY_MGMT_DEV_COMPONENT,
0065     DMI_ENTRY_MGMT_DEV_THRES,
0066     DMI_ENTRY_MEM_CHANNEL,
0067     DMI_ENTRY_IPMI_DEV,
0068     DMI_ENTRY_SYS_POWER_SUPPLY,
0069     DMI_ENTRY_ADDITIONAL,
0070     DMI_ENTRY_ONBOARD_DEV_EXT,
0071     DMI_ENTRY_MGMT_CONTROLLER_HOST,
0072     DMI_ENTRY_INACTIVE = 126,
0073     DMI_ENTRY_END_OF_TABLE = 127,
0074 };
0075 
0076 struct dmi_header {
0077     u8 type;
0078     u8 length;
0079     u16 handle;
0080 } __packed;
0081 
0082 struct dmi_device {
0083     struct list_head list;
0084     int type;
0085     const char *name;
0086     void *device_data;  /* Type specific data */
0087 };
0088 
0089 #ifdef CONFIG_DMI
0090 
0091 struct dmi_dev_onboard {
0092     struct dmi_device dev;
0093     int instance;
0094     int segment;
0095     int bus;
0096     int devfn;
0097 };
0098 
0099 extern struct kobject *dmi_kobj;
0100 extern int dmi_check_system(const struct dmi_system_id *list);
0101 const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list);
0102 extern const char * dmi_get_system_info(int field);
0103 extern const struct dmi_device * dmi_find_device(int type, const char *name,
0104     const struct dmi_device *from);
0105 extern void dmi_setup(void);
0106 extern bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp);
0107 extern int dmi_get_bios_year(void);
0108 extern int dmi_name_in_vendors(const char *str);
0109 extern int dmi_name_in_serial(const char *str);
0110 extern int dmi_available;
0111 extern int dmi_walk(void (*decode)(const struct dmi_header *, void *),
0112     void *private_data);
0113 extern bool dmi_match(enum dmi_field f, const char *str);
0114 extern void dmi_memdev_name(u16 handle, const char **bank, const char **device);
0115 extern u64 dmi_memdev_size(u16 handle);
0116 extern u8 dmi_memdev_type(u16 handle);
0117 extern u16 dmi_memdev_handle(int slot);
0118 
0119 #else
0120 
0121 static inline int dmi_check_system(const struct dmi_system_id *list) { return 0; }
0122 static inline const char * dmi_get_system_info(int field) { return NULL; }
0123 static inline const struct dmi_device * dmi_find_device(int type, const char *name,
0124     const struct dmi_device *from) { return NULL; }
0125 static inline void dmi_setup(void) { }
0126 static inline bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp)
0127 {
0128     if (yearp)
0129         *yearp = 0;
0130     if (monthp)
0131         *monthp = 0;
0132     if (dayp)
0133         *dayp = 0;
0134     return false;
0135 }
0136 static inline int dmi_get_bios_year(void) { return -ENXIO; }
0137 static inline int dmi_name_in_vendors(const char *s) { return 0; }
0138 static inline int dmi_name_in_serial(const char *s) { return 0; }
0139 #define dmi_available 0
0140 static inline int dmi_walk(void (*decode)(const struct dmi_header *, void *),
0141     void *private_data) { return -ENXIO; }
0142 static inline bool dmi_match(enum dmi_field f, const char *str)
0143     { return false; }
0144 static inline void dmi_memdev_name(u16 handle, const char **bank,
0145         const char **device) { }
0146 static inline u64 dmi_memdev_size(u16 handle) { return ~0ul; }
0147 static inline u8 dmi_memdev_type(u16 handle) { return 0x0; }
0148 static inline u16 dmi_memdev_handle(int slot) { return 0xffff; }
0149 static inline const struct dmi_system_id *
0150     dmi_first_match(const struct dmi_system_id *list) { return NULL; }
0151 
0152 #endif
0153 
0154 #endif  /* __DMI_H__ */