smbios.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*
  2. * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
  3. *
  4. * Adapted from coreboot src/include/smbios.h
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #ifndef _SMBIOS_H_
  9. #define _SMBIOS_H_
  10. /* SMBIOS spec version implemented */
  11. #define SMBIOS_MAJOR_VER 3
  12. #define SMBIOS_MINOR_VER 0
  13. /* SMBIOS structure types */
  14. enum {
  15. SMBIOS_BIOS_INFORMATION = 0,
  16. SMBIOS_SYSTEM_INFORMATION = 1,
  17. SMBIOS_BOARD_INFORMATION = 2,
  18. SMBIOS_SYSTEM_ENCLOSURE = 3,
  19. SMBIOS_PROCESSOR_INFORMATION = 4,
  20. SMBIOS_CACHE_INFORMATION = 7,
  21. SMBIOS_SYSTEM_SLOTS = 9,
  22. SMBIOS_PHYS_MEMORY_ARRAY = 16,
  23. SMBIOS_MEMORY_DEVICE = 17,
  24. SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS = 19,
  25. SMBIOS_SYSTEM_BOOT_INFORMATION = 32,
  26. SMBIOS_END_OF_TABLE = 127
  27. };
  28. #define SMBIOS_INTERMEDIATE_OFFSET 16
  29. #define SMBIOS_STRUCT_EOS_BYTES 2
  30. struct __packed smbios_entry {
  31. u8 anchor[4];
  32. u8 checksum;
  33. u8 length;
  34. u8 major_ver;
  35. u8 minor_ver;
  36. u16 max_struct_size;
  37. u8 entry_point_rev;
  38. u8 formatted_area[5];
  39. u8 intermediate_anchor[5];
  40. u8 intermediate_checksum;
  41. u16 struct_table_length;
  42. u32 struct_table_address;
  43. u16 struct_count;
  44. u8 bcd_rev;
  45. };
  46. /* BIOS characteristics */
  47. #define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7)
  48. #define BIOS_CHARACTERISTICS_UPGRADEABLE (1 << 11)
  49. #define BIOS_CHARACTERISTICS_SELECTABLE_BOOT (1 << 16)
  50. #define BIOS_CHARACTERISTICS_EXT1_ACPI (1 << 0)
  51. #define BIOS_CHARACTERISTICS_EXT2_TARGET (1 << 2)
  52. struct __packed smbios_type0 {
  53. u8 type;
  54. u8 length;
  55. u16 handle;
  56. u8 vendor;
  57. u8 bios_ver;
  58. u16 bios_start_segment;
  59. u8 bios_release_date;
  60. u8 bios_rom_size;
  61. u64 bios_characteristics;
  62. u8 bios_characteristics_ext1;
  63. u8 bios_characteristics_ext2;
  64. u8 bios_major_release;
  65. u8 bios_minor_release;
  66. u8 ec_major_release;
  67. u8 ec_minor_release;
  68. char eos[SMBIOS_STRUCT_EOS_BYTES];
  69. };
  70. struct __packed smbios_type1 {
  71. u8 type;
  72. u8 length;
  73. u16 handle;
  74. u8 manufacturer;
  75. u8 product_name;
  76. u8 version;
  77. u8 serial_number;
  78. u8 uuid[16];
  79. u8 wakeup_type;
  80. u8 sku_number;
  81. u8 family;
  82. char eos[SMBIOS_STRUCT_EOS_BYTES];
  83. };
  84. #define SMBIOS_BOARD_FEATURE_HOSTING (1 << 0)
  85. #define SMBIOS_BOARD_MOTHERBOARD 10
  86. struct __packed smbios_type2 {
  87. u8 type;
  88. u8 length;
  89. u16 handle;
  90. u8 manufacturer;
  91. u8 product_name;
  92. u8 version;
  93. u8 serial_number;
  94. u8 asset_tag_number;
  95. u8 feature_flags;
  96. u8 chassis_location;
  97. u16 chassis_handle;
  98. u8 board_type;
  99. char eos[SMBIOS_STRUCT_EOS_BYTES];
  100. };
  101. #define SMBIOS_ENCLOSURE_DESKTOP 3
  102. #define SMBIOS_STATE_SAFE 3
  103. #define SMBIOS_SECURITY_NONE 3
  104. struct __packed smbios_type3 {
  105. u8 type;
  106. u8 length;
  107. u16 handle;
  108. u8 manufacturer;
  109. u8 chassis_type;
  110. u8 version;
  111. u8 serial_number;
  112. u8 asset_tag_number;
  113. u8 bootup_state;
  114. u8 power_supply_state;
  115. u8 thermal_state;
  116. u8 security_status;
  117. u32 oem_defined;
  118. u8 height;
  119. u8 number_of_power_cords;
  120. u8 element_count;
  121. u8 element_record_length;
  122. char eos[SMBIOS_STRUCT_EOS_BYTES];
  123. };
  124. #define SMBIOS_PROCESSOR_TYPE_CENTRAL 3
  125. #define SMBIOS_PROCESSOR_STATUS_ENABLED 1
  126. #define SMBIOS_PROCESSOR_UPGRADE_NONE 6
  127. struct __packed smbios_type4 {
  128. u8 type;
  129. u8 length;
  130. u16 handle;
  131. u8 socket_designation;
  132. u8 processor_type;
  133. u8 processor_family;
  134. u8 processor_manufacturer;
  135. u32 processor_id[2];
  136. u8 processor_version;
  137. u8 voltage;
  138. u16 external_clock;
  139. u16 max_speed;
  140. u16 current_speed;
  141. u8 status;
  142. u8 processor_upgrade;
  143. u16 l1_cache_handle;
  144. u16 l2_cache_handle;
  145. u16 l3_cache_handle;
  146. u8 serial_number;
  147. u8 asset_tag;
  148. u8 part_number;
  149. u8 core_count;
  150. u8 core_enabled;
  151. u8 thread_count;
  152. u16 processor_characteristics;
  153. u16 processor_family2;
  154. u16 core_count2;
  155. u16 core_enabled2;
  156. u16 thread_count2;
  157. char eos[SMBIOS_STRUCT_EOS_BYTES];
  158. };
  159. struct __packed smbios_type32 {
  160. u8 type;
  161. u8 length;
  162. u16 handle;
  163. u8 reserved[6];
  164. u8 boot_status;
  165. u8 eos[SMBIOS_STRUCT_EOS_BYTES];
  166. };
  167. struct __packed smbios_type127 {
  168. u8 type;
  169. u8 length;
  170. u16 handle;
  171. u8 eos[SMBIOS_STRUCT_EOS_BYTES];
  172. };
  173. struct __packed smbios_header {
  174. u8 type;
  175. u8 length;
  176. u16 handle;
  177. };
  178. /**
  179. * fill_smbios_header() - Fill the header of an SMBIOS table
  180. *
  181. * This fills the header of an SMBIOS table structure.
  182. *
  183. * @table: start address of the structure
  184. * @type: the type of structure
  185. * @length: the length of the formatted area of the structure
  186. * @handle: the structure's handle, a unique 16-bit number
  187. */
  188. static inline void fill_smbios_header(void *table, int type,
  189. int length, int handle)
  190. {
  191. struct smbios_header *header = table;
  192. header->type = type;
  193. header->length = length - SMBIOS_STRUCT_EOS_BYTES;
  194. header->handle = handle;
  195. }
  196. /**
  197. * Function prototype to write a specific type of SMBIOS structure
  198. *
  199. * @addr: start address to write the structure
  200. * @handle: the structure's handle, a unique 16-bit number
  201. * @return: size of the structure
  202. */
  203. typedef int (*smbios_write_type)(u32 *addr, int handle);
  204. /**
  205. * write_smbios_table() - Write SMBIOS table
  206. *
  207. * This writes SMBIOS table at a given address.
  208. *
  209. * @addr: start address to write SMBIOS table
  210. * @return: end address of SMBIOS table
  211. */
  212. u32 write_smbios_table(u32 addr);
  213. #endif /* _SMBIOS_H_ */