smbios.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
  4. *
  5. * Adapted from coreboot src/include/smbios.h
  6. */
  7. #ifndef _SMBIOS_H_
  8. #define _SMBIOS_H_
  9. /* SMBIOS spec version implemented */
  10. #define SMBIOS_MAJOR_VER 3
  11. #define SMBIOS_MINOR_VER 0
  12. /* SMBIOS structure types */
  13. enum {
  14. SMBIOS_BIOS_INFORMATION = 0,
  15. SMBIOS_SYSTEM_INFORMATION = 1,
  16. SMBIOS_BOARD_INFORMATION = 2,
  17. SMBIOS_SYSTEM_ENCLOSURE = 3,
  18. SMBIOS_PROCESSOR_INFORMATION = 4,
  19. SMBIOS_CACHE_INFORMATION = 7,
  20. SMBIOS_SYSTEM_SLOTS = 9,
  21. SMBIOS_PHYS_MEMORY_ARRAY = 16,
  22. SMBIOS_MEMORY_DEVICE = 17,
  23. SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS = 19,
  24. SMBIOS_SYSTEM_BOOT_INFORMATION = 32,
  25. SMBIOS_END_OF_TABLE = 127
  26. };
  27. #define SMBIOS_INTERMEDIATE_OFFSET 16
  28. #define SMBIOS_STRUCT_EOS_BYTES 2
  29. struct __packed smbios_entry {
  30. u8 anchor[4];
  31. u8 checksum;
  32. u8 length;
  33. u8 major_ver;
  34. u8 minor_ver;
  35. u16 max_struct_size;
  36. u8 entry_point_rev;
  37. u8 formatted_area[5];
  38. u8 intermediate_anchor[5];
  39. u8 intermediate_checksum;
  40. u16 struct_table_length;
  41. u32 struct_table_address;
  42. u16 struct_count;
  43. u8 bcd_rev;
  44. };
  45. /* BIOS characteristics */
  46. #define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7)
  47. #define BIOS_CHARACTERISTICS_UPGRADEABLE (1 << 11)
  48. #define BIOS_CHARACTERISTICS_SELECTABLE_BOOT (1 << 16)
  49. #define BIOS_CHARACTERISTICS_EXT1_ACPI (1 << 0)
  50. #define BIOS_CHARACTERISTICS_EXT1_UEFI (1 << 3)
  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. #define SMBIOS_PROCESSOR_FAMILY_OTHER 1
  128. #define SMBIOS_PROCESSOR_FAMILY_UNKNOWN 2
  129. struct __packed smbios_type4 {
  130. u8 type;
  131. u8 length;
  132. u16 handle;
  133. u8 socket_designation;
  134. u8 processor_type;
  135. u8 processor_family;
  136. u8 processor_manufacturer;
  137. u32 processor_id[2];
  138. u8 processor_version;
  139. u8 voltage;
  140. u16 external_clock;
  141. u16 max_speed;
  142. u16 current_speed;
  143. u8 status;
  144. u8 processor_upgrade;
  145. u16 l1_cache_handle;
  146. u16 l2_cache_handle;
  147. u16 l3_cache_handle;
  148. u8 serial_number;
  149. u8 asset_tag;
  150. u8 part_number;
  151. u8 core_count;
  152. u8 core_enabled;
  153. u8 thread_count;
  154. u16 processor_characteristics;
  155. u16 processor_family2;
  156. u16 core_count2;
  157. u16 core_enabled2;
  158. u16 thread_count2;
  159. char eos[SMBIOS_STRUCT_EOS_BYTES];
  160. };
  161. struct __packed smbios_type32 {
  162. u8 type;
  163. u8 length;
  164. u16 handle;
  165. u8 reserved[6];
  166. u8 boot_status;
  167. u8 eos[SMBIOS_STRUCT_EOS_BYTES];
  168. };
  169. struct __packed smbios_type127 {
  170. u8 type;
  171. u8 length;
  172. u16 handle;
  173. u8 eos[SMBIOS_STRUCT_EOS_BYTES];
  174. };
  175. struct __packed smbios_header {
  176. u8 type;
  177. u8 length;
  178. u16 handle;
  179. };
  180. /**
  181. * fill_smbios_header() - Fill the header of an SMBIOS table
  182. *
  183. * This fills the header of an SMBIOS table structure.
  184. *
  185. * @table: start address of the structure
  186. * @type: the type of structure
  187. * @length: the length of the formatted area of the structure
  188. * @handle: the structure's handle, a unique 16-bit number
  189. */
  190. static inline void fill_smbios_header(void *table, int type,
  191. int length, int handle)
  192. {
  193. struct smbios_header *header = table;
  194. header->type = type;
  195. header->length = length - SMBIOS_STRUCT_EOS_BYTES;
  196. header->handle = handle;
  197. }
  198. /**
  199. * Function prototype to write a specific type of SMBIOS structure
  200. *
  201. * @addr: start address to write the structure
  202. * @handle: the structure's handle, a unique 16-bit number
  203. * @return: size of the structure
  204. */
  205. typedef int (*smbios_write_type)(ulong *addr, int handle);
  206. /**
  207. * write_smbios_table() - Write SMBIOS table
  208. *
  209. * This writes SMBIOS table at a given address.
  210. *
  211. * @addr: start address to write SMBIOS table. If this is not
  212. * 16-byte-aligned then it will be aligned before the table is written
  213. * @return: end address of SMBIOS table (and start address for next entry)
  214. */
  215. ulong write_smbios_table(ulong addr);
  216. #endif /* _SMBIOS_H_ */