dmi.h 4.3 KB

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