smbios.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. #ifndef QEMU_SMBIOS_H
  2. #define QEMU_SMBIOS_H
  3. #include "qapi/qapi-types-machine.h"
  4. #include "qemu/bitmap.h"
  5. /*
  6. * SMBIOS Support
  7. *
  8. * Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
  9. *
  10. * Authors:
  11. * Alex Williamson <alex.williamson@hp.com>
  12. *
  13. * This work is licensed under the terms of the GNU GPL, version 2. See
  14. * the COPYING file in the top-level directory.
  15. *
  16. */
  17. extern uint8_t *usr_blobs;
  18. extern GArray *usr_blobs_sizes;
  19. typedef struct {
  20. const char *vendor, *version, *date;
  21. bool have_major_minor, uefi;
  22. uint8_t major, minor;
  23. } smbios_type0_t;
  24. extern smbios_type0_t smbios_type0;
  25. typedef struct {
  26. const char *manufacturer, *product, *version, *serial, *sku, *family;
  27. /* uuid is in qemu_uuid */
  28. } smbios_type1_t;
  29. extern smbios_type1_t smbios_type1;
  30. #define SMBIOS_MAX_TYPE 127
  31. extern DECLARE_BITMAP(smbios_have_binfile_bitmap, SMBIOS_MAX_TYPE + 1);
  32. extern DECLARE_BITMAP(smbios_have_fields_bitmap, SMBIOS_MAX_TYPE + 1);
  33. #define offsetofend(TYPE, MEMBER) \
  34. (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER))
  35. /* memory area description, used by type 19 table */
  36. struct smbios_phys_mem_area {
  37. uint64_t address;
  38. uint64_t length;
  39. };
  40. /* SMBIOS Entry Point
  41. * There are two types of entry points defined in the SMBIOS specification
  42. * (see below). BIOS must place the entry point(s) at a 16-byte-aligned
  43. * address between 0xf0000 and 0xfffff. Note that either entry point type
  44. * can be used in a 64-bit target system, except that SMBIOS 2.1 entry point
  45. * only allows the SMBIOS struct table to reside below 4GB address space.
  46. */
  47. /* SMBIOS 2.1 (32-bit) Entry Point
  48. * - introduced since SMBIOS 2.1
  49. * - supports structure table below 4GB only
  50. */
  51. struct smbios_21_entry_point {
  52. uint8_t anchor_string[4];
  53. uint8_t checksum;
  54. uint8_t length;
  55. uint8_t smbios_major_version;
  56. uint8_t smbios_minor_version;
  57. uint16_t max_structure_size;
  58. uint8_t entry_point_revision;
  59. uint8_t formatted_area[5];
  60. uint8_t intermediate_anchor_string[5];
  61. uint8_t intermediate_checksum;
  62. uint16_t structure_table_length;
  63. uint32_t structure_table_address;
  64. uint16_t number_of_structures;
  65. uint8_t smbios_bcd_revision;
  66. } QEMU_PACKED;
  67. /* SMBIOS 3.0 (64-bit) Entry Point
  68. * - introduced since SMBIOS 3.0
  69. * - supports structure table at 64-bit address space
  70. */
  71. struct smbios_30_entry_point {
  72. uint8_t anchor_string[5];
  73. uint8_t checksum;
  74. uint8_t length;
  75. uint8_t smbios_major_version;
  76. uint8_t smbios_minor_version;
  77. uint8_t smbios_doc_rev;
  78. uint8_t entry_point_revision;
  79. uint8_t reserved;
  80. uint32_t structure_table_max_size;
  81. uint64_t structure_table_address;
  82. } QEMU_PACKED;
  83. typedef union {
  84. struct smbios_21_entry_point ep21;
  85. struct smbios_30_entry_point ep30;
  86. } QEMU_PACKED SmbiosEntryPoint;
  87. /* This goes at the beginning of every SMBIOS structure. */
  88. struct smbios_structure_header {
  89. uint8_t type;
  90. uint8_t length;
  91. uint16_t handle;
  92. } QEMU_PACKED;
  93. /* SMBIOS type 0 - BIOS Information */
  94. struct smbios_type_0 {
  95. struct smbios_structure_header header;
  96. uint8_t vendor_str;
  97. uint8_t bios_version_str;
  98. uint16_t bios_starting_address_segment;
  99. uint8_t bios_release_date_str;
  100. uint8_t bios_rom_size;
  101. uint64_t bios_characteristics;
  102. uint8_t bios_characteristics_extension_bytes[2];
  103. uint8_t system_bios_major_release;
  104. uint8_t system_bios_minor_release;
  105. uint8_t embedded_controller_major_release;
  106. uint8_t embedded_controller_minor_release;
  107. } QEMU_PACKED;
  108. /* UUID encoding. The time_* fields are little-endian, as specified by SMBIOS
  109. * version 2.6.
  110. */
  111. struct smbios_uuid {
  112. uint32_t time_low;
  113. uint16_t time_mid;
  114. uint16_t time_hi_and_version;
  115. uint8_t clock_seq_hi_and_reserved;
  116. uint8_t clock_seq_low;
  117. uint8_t node[6];
  118. } QEMU_PACKED;
  119. /* SMBIOS type 1 - System Information */
  120. struct smbios_type_1 {
  121. struct smbios_structure_header header;
  122. uint8_t manufacturer_str;
  123. uint8_t product_name_str;
  124. uint8_t version_str;
  125. uint8_t serial_number_str;
  126. struct smbios_uuid uuid;
  127. uint8_t wake_up_type;
  128. uint8_t sku_number_str;
  129. uint8_t family_str;
  130. } QEMU_PACKED;
  131. /* SMBIOS type 2 - Base Board */
  132. struct smbios_type_2 {
  133. struct smbios_structure_header header;
  134. uint8_t manufacturer_str;
  135. uint8_t product_str;
  136. uint8_t version_str;
  137. uint8_t serial_number_str;
  138. uint8_t asset_tag_number_str;
  139. uint8_t feature_flags;
  140. uint8_t location_str;
  141. uint16_t chassis_handle;
  142. uint8_t board_type;
  143. uint8_t contained_element_count;
  144. /* contained elements follow */
  145. } QEMU_PACKED;
  146. /* SMBIOS type 3 - System Enclosure (v2.7) */
  147. struct smbios_type_3 {
  148. struct smbios_structure_header header;
  149. uint8_t manufacturer_str;
  150. uint8_t type;
  151. uint8_t version_str;
  152. uint8_t serial_number_str;
  153. uint8_t asset_tag_number_str;
  154. uint8_t boot_up_state;
  155. uint8_t power_supply_state;
  156. uint8_t thermal_state;
  157. uint8_t security_status;
  158. uint32_t oem_defined;
  159. uint8_t height;
  160. uint8_t number_of_power_cords;
  161. uint8_t contained_element_count;
  162. uint8_t contained_element_record_length;
  163. uint8_t sku_number_str;
  164. /* contained elements follow */
  165. } QEMU_PACKED;
  166. /* SMBIOS type 4 - Processor Information (v2.6) */
  167. struct smbios_type_4 {
  168. struct smbios_structure_header header;
  169. uint8_t socket_designation_str;
  170. uint8_t processor_type;
  171. uint8_t processor_family;
  172. uint8_t processor_manufacturer_str;
  173. uint32_t processor_id[2];
  174. uint8_t processor_version_str;
  175. uint8_t voltage;
  176. uint16_t external_clock;
  177. uint16_t max_speed;
  178. uint16_t current_speed;
  179. uint8_t status;
  180. uint8_t processor_upgrade;
  181. uint16_t l1_cache_handle;
  182. uint16_t l2_cache_handle;
  183. uint16_t l3_cache_handle;
  184. uint8_t serial_number_str;
  185. uint8_t asset_tag_number_str;
  186. uint8_t part_number_str;
  187. uint8_t core_count;
  188. uint8_t core_enabled;
  189. uint8_t thread_count;
  190. uint16_t processor_characteristics;
  191. uint16_t processor_family2;
  192. /* SMBIOS spec 3.0.0, Table 21 */
  193. uint16_t core_count2;
  194. uint16_t core_enabled2;
  195. uint16_t thread_count2;
  196. } QEMU_PACKED;
  197. typedef enum smbios_type_4_len_ver {
  198. SMBIOS_TYPE_4_LEN_V28 = offsetofend(struct smbios_type_4,
  199. processor_family2),
  200. SMBIOS_TYPE_4_LEN_V30 = offsetofend(struct smbios_type_4, thread_count2),
  201. } smbios_type_4_len_ver;
  202. /* SMBIOS type 8 - Port Connector Information */
  203. struct smbios_type_8 {
  204. struct smbios_structure_header header;
  205. uint8_t internal_reference_str;
  206. uint8_t internal_connector_type;
  207. uint8_t external_reference_str;
  208. uint8_t external_connector_type;
  209. uint8_t port_type;
  210. } QEMU_PACKED;
  211. /* SMBIOS type 9 - System Slots (v2.1+) */
  212. struct smbios_type_9 {
  213. struct smbios_structure_header header;
  214. uint8_t slot_designation;
  215. uint8_t slot_type;
  216. uint8_t slot_data_bus_width;
  217. uint8_t current_usage;
  218. uint8_t slot_length;
  219. uint16_t slot_id;
  220. uint8_t slot_characteristics1;
  221. uint8_t slot_characteristics2;
  222. /* SMBIOS spec v2.6+ */
  223. uint16_t segment_group_number;
  224. uint8_t bus_number;
  225. uint8_t device_number;
  226. } QEMU_PACKED;
  227. /* SMBIOS type 11 - OEM strings */
  228. struct smbios_type_11 {
  229. struct smbios_structure_header header;
  230. uint8_t count;
  231. } QEMU_PACKED;
  232. /* SMBIOS type 16 - Physical Memory Array (v2.7) */
  233. struct smbios_type_16 {
  234. struct smbios_structure_header header;
  235. uint8_t location;
  236. uint8_t use;
  237. uint8_t error_correction;
  238. uint32_t maximum_capacity;
  239. uint16_t memory_error_information_handle;
  240. uint16_t number_of_memory_devices;
  241. uint64_t extended_maximum_capacity;
  242. } QEMU_PACKED;
  243. /* SMBIOS type 17 - Memory Device (v2.8) */
  244. struct smbios_type_17 {
  245. struct smbios_structure_header header;
  246. uint16_t physical_memory_array_handle;
  247. uint16_t memory_error_information_handle;
  248. uint16_t total_width;
  249. uint16_t data_width;
  250. uint16_t size;
  251. uint8_t form_factor;
  252. uint8_t device_set;
  253. uint8_t device_locator_str;
  254. uint8_t bank_locator_str;
  255. uint8_t memory_type;
  256. uint16_t type_detail;
  257. uint16_t speed;
  258. uint8_t manufacturer_str;
  259. uint8_t serial_number_str;
  260. uint8_t asset_tag_number_str;
  261. uint8_t part_number_str;
  262. uint8_t attributes;
  263. uint32_t extended_size;
  264. uint16_t configured_clock_speed;
  265. uint16_t minimum_voltage;
  266. uint16_t maximum_voltage;
  267. uint16_t configured_voltage;
  268. } QEMU_PACKED;
  269. /* SMBIOS type 19 - Memory Array Mapped Address (v2.7) */
  270. struct smbios_type_19 {
  271. struct smbios_structure_header header;
  272. uint32_t starting_address;
  273. uint32_t ending_address;
  274. uint16_t memory_array_handle;
  275. uint8_t partition_width;
  276. uint64_t extended_starting_address;
  277. uint64_t extended_ending_address;
  278. } QEMU_PACKED;
  279. /* SMBIOS type 32 - System Boot Information */
  280. struct smbios_type_32 {
  281. struct smbios_structure_header header;
  282. uint8_t reserved[6];
  283. uint8_t boot_status;
  284. } QEMU_PACKED;
  285. /* SMBIOS type 41 - Onboard Devices Extended Information */
  286. struct smbios_type_41 {
  287. struct smbios_structure_header header;
  288. uint8_t reference_designation_str;
  289. uint8_t device_type;
  290. uint8_t device_type_instance;
  291. uint16_t segment_group_number;
  292. uint8_t bus_number;
  293. uint8_t device_number;
  294. } QEMU_PACKED;
  295. /* SMBIOS type 127 -- End-of-table */
  296. struct smbios_type_127 {
  297. struct smbios_structure_header header;
  298. } QEMU_PACKED;
  299. bool smbios_validate_table(SmbiosEntryPointType ep_type, Error **errp);
  300. void smbios_add_usr_blob_size(size_t size);
  301. void smbios_entry_add(QemuOpts *opts, Error **errp);
  302. void smbios_set_cpuid(uint32_t version, uint32_t features);
  303. void smbios_set_defaults(const char *manufacturer, const char *product,
  304. const char *version);
  305. void smbios_set_default_processor_family(uint16_t processor_family);
  306. uint8_t *smbios_get_table_legacy(size_t *length, Error **errp);
  307. void smbios_get_tables(MachineState *ms,
  308. SmbiosEntryPointType ep_type,
  309. const struct smbios_phys_mem_area *mem_array,
  310. const unsigned int mem_array_size,
  311. uint8_t **tables, size_t *tables_len,
  312. uint8_t **anchor, size_t *anchor_len,
  313. Error **errp);
  314. #endif /* QEMU_SMBIOS_H */