xref: /qemu/include/hw/firmware/smbios.h (revision a0628599fa72524a1f59bbaa7410e6825a8feb3f)
1b6f6e3d3Saliguori #ifndef QEMU_SMBIOS_H
2b6f6e3d3Saliguori #define QEMU_SMBIOS_H
3175de524SMarkus Armbruster 
4b6f6e3d3Saliguori /*
5b6f6e3d3Saliguori  * SMBIOS Support
6b6f6e3d3Saliguori  *
7b6f6e3d3Saliguori  * Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
8b6f6e3d3Saliguori  *
9b6f6e3d3Saliguori  * Authors:
10b6f6e3d3Saliguori  *  Alex Williamson <alex.williamson@hp.com>
11b6f6e3d3Saliguori  *
12b6f6e3d3Saliguori  * This work is licensed under the terms of the GNU GPL, version 2.  See
13b6f6e3d3Saliguori  * the COPYING file in the top-level directory.
14b6f6e3d3Saliguori  *
15b6f6e3d3Saliguori  */
16b6f6e3d3Saliguori 
174f953d2fSMarkus Armbruster 
182e6e8d7aSGabriel L. Somlo #define SMBIOS_MAX_TYPE 127
192e6e8d7aSGabriel L. Somlo 
2089cc4a27SWei Huang /* memory area description, used by type 19 table */
2189cc4a27SWei Huang struct smbios_phys_mem_area {
2289cc4a27SWei Huang     uint64_t address;
2389cc4a27SWei Huang     uint64_t length;
2489cc4a27SWei Huang };
2589cc4a27SWei Huang 
26b6f6e3d3Saliguori /*
27b6f6e3d3Saliguori  * SMBIOS spec defined tables
28b6f6e3d3Saliguori  */
2986299120SWei Huang typedef enum SmbiosEntryPointType {
3086299120SWei Huang     SMBIOS_ENTRY_POINT_21,
3186299120SWei Huang     SMBIOS_ENTRY_POINT_30,
3286299120SWei Huang } SmbiosEntryPointType;
33b6f6e3d3Saliguori 
3486299120SWei Huang /* SMBIOS Entry Point
3586299120SWei Huang  * There are two types of entry points defined in the SMBIOS specification
36cc2324d0SCao jin  * (see below). BIOS must place the entry point(s) at a 16-byte-aligned
3786299120SWei Huang  * address between 0xf0000 and 0xfffff. Note that either entry point type
3886299120SWei Huang  * can be used in a 64-bit target system, except that SMBIOS 2.1 entry point
3986299120SWei Huang  * only allows the SMBIOS struct table to reside below 4GB address space.
40e41fca3dSGabriel L. Somlo  */
4186299120SWei Huang 
4286299120SWei Huang /* SMBIOS 2.1 (32-bit) Entry Point
4386299120SWei Huang  *  - introduced since SMBIOS 2.1
4486299120SWei Huang  *  - supports structure table below 4GB only
4586299120SWei Huang  */
4686299120SWei Huang struct smbios_21_entry_point {
47e41fca3dSGabriel L. Somlo     uint8_t anchor_string[4];
48e41fca3dSGabriel L. Somlo     uint8_t checksum;
49e41fca3dSGabriel L. Somlo     uint8_t length;
50e41fca3dSGabriel L. Somlo     uint8_t smbios_major_version;
51e41fca3dSGabriel L. Somlo     uint8_t smbios_minor_version;
52e41fca3dSGabriel L. Somlo     uint16_t max_structure_size;
53e41fca3dSGabriel L. Somlo     uint8_t entry_point_revision;
54e41fca3dSGabriel L. Somlo     uint8_t formatted_area[5];
55e41fca3dSGabriel L. Somlo     uint8_t intermediate_anchor_string[5];
56e41fca3dSGabriel L. Somlo     uint8_t intermediate_checksum;
57e41fca3dSGabriel L. Somlo     uint16_t structure_table_length;
58e41fca3dSGabriel L. Somlo     uint32_t structure_table_address;
59e41fca3dSGabriel L. Somlo     uint16_t number_of_structures;
60e41fca3dSGabriel L. Somlo     uint8_t smbios_bcd_revision;
61e41fca3dSGabriel L. Somlo } QEMU_PACKED;
62e41fca3dSGabriel L. Somlo 
6386299120SWei Huang /* SMBIOS 3.0 (64-bit) Entry Point
6486299120SWei Huang  *  - introduced since SMBIOS 3.0
6586299120SWei Huang  *  - supports structure table at 64-bit address space
6686299120SWei Huang  */
6786299120SWei Huang struct smbios_30_entry_point {
6886299120SWei Huang     uint8_t anchor_string[5];
6986299120SWei Huang     uint8_t checksum;
7086299120SWei Huang     uint8_t length;
7186299120SWei Huang     uint8_t smbios_major_version;
7286299120SWei Huang     uint8_t smbios_minor_version;
7386299120SWei Huang     uint8_t smbios_doc_rev;
7486299120SWei Huang     uint8_t entry_point_revision;
7586299120SWei Huang     uint8_t reserved;
7686299120SWei Huang     uint32_t structure_table_max_size;
7786299120SWei Huang     uint64_t structure_table_address;
7886299120SWei Huang } QEMU_PACKED;
7986299120SWei Huang 
8086299120SWei Huang typedef union {
8186299120SWei Huang     struct smbios_21_entry_point ep21;
8286299120SWei Huang     struct smbios_30_entry_point ep30;
8386299120SWei Huang } QEMU_PACKED SmbiosEntryPoint;
8486299120SWei Huang 
85b6f6e3d3Saliguori /* This goes at the beginning of every SMBIOS structure. */
86b6f6e3d3Saliguori struct smbios_structure_header {
87b6f6e3d3Saliguori     uint8_t type;
88b6f6e3d3Saliguori     uint8_t length;
89b6f6e3d3Saliguori     uint16_t handle;
90541dc0d4SStefan Weil } QEMU_PACKED;
91b6f6e3d3Saliguori 
92b6f6e3d3Saliguori /* SMBIOS type 0 - BIOS Information */
93b6f6e3d3Saliguori struct smbios_type_0 {
94b6f6e3d3Saliguori     struct smbios_structure_header header;
95b6f6e3d3Saliguori     uint8_t vendor_str;
96b6f6e3d3Saliguori     uint8_t bios_version_str;
97b6f6e3d3Saliguori     uint16_t bios_starting_address_segment;
98b6f6e3d3Saliguori     uint8_t bios_release_date_str;
99b6f6e3d3Saliguori     uint8_t bios_rom_size;
10084351843SGabriel L. Somlo     uint64_t bios_characteristics;
101b6f6e3d3Saliguori     uint8_t bios_characteristics_extension_bytes[2];
102b6f6e3d3Saliguori     uint8_t system_bios_major_release;
103b6f6e3d3Saliguori     uint8_t system_bios_minor_release;
104b6f6e3d3Saliguori     uint8_t embedded_controller_major_release;
105b6f6e3d3Saliguori     uint8_t embedded_controller_minor_release;
106541dc0d4SStefan Weil } QEMU_PACKED;
107b6f6e3d3Saliguori 
108caad057bSEduardo Habkost /* UUID encoding. The time_* fields are little-endian, as specified by SMBIOS
109caad057bSEduardo Habkost  * version 2.6.
110caad057bSEduardo Habkost  */
111caad057bSEduardo Habkost struct smbios_uuid {
112caad057bSEduardo Habkost     uint32_t time_low;
113caad057bSEduardo Habkost     uint16_t time_mid;
114caad057bSEduardo Habkost     uint16_t time_hi_and_version;
115caad057bSEduardo Habkost     uint8_t clock_seq_hi_and_reserved;
116caad057bSEduardo Habkost     uint8_t clock_seq_low;
117caad057bSEduardo Habkost     uint8_t node[6];
118caad057bSEduardo Habkost } QEMU_PACKED;
119caad057bSEduardo Habkost 
120b6f6e3d3Saliguori /* SMBIOS type 1 - System Information */
121b6f6e3d3Saliguori struct smbios_type_1 {
122b6f6e3d3Saliguori     struct smbios_structure_header header;
123b6f6e3d3Saliguori     uint8_t manufacturer_str;
124b6f6e3d3Saliguori     uint8_t product_name_str;
125b6f6e3d3Saliguori     uint8_t version_str;
126b6f6e3d3Saliguori     uint8_t serial_number_str;
127caad057bSEduardo Habkost     struct smbios_uuid uuid;
128b6f6e3d3Saliguori     uint8_t wake_up_type;
129b6f6e3d3Saliguori     uint8_t sku_number_str;
130b6f6e3d3Saliguori     uint8_t family_str;
131541dc0d4SStefan Weil } QEMU_PACKED;
132b6f6e3d3Saliguori 
133e41fca3dSGabriel L. Somlo /* SMBIOS type 2 - Base Board */
134e41fca3dSGabriel L. Somlo struct smbios_type_2 {
135e41fca3dSGabriel L. Somlo     struct smbios_structure_header header;
136e41fca3dSGabriel L. Somlo     uint8_t manufacturer_str;
137e41fca3dSGabriel L. Somlo     uint8_t product_str;
138e41fca3dSGabriel L. Somlo     uint8_t version_str;
139e41fca3dSGabriel L. Somlo     uint8_t serial_number_str;
140e41fca3dSGabriel L. Somlo     uint8_t asset_tag_number_str;
141e41fca3dSGabriel L. Somlo     uint8_t feature_flags;
142e41fca3dSGabriel L. Somlo     uint8_t location_str;
143e41fca3dSGabriel L. Somlo     uint16_t chassis_handle;
144e41fca3dSGabriel L. Somlo     uint8_t board_type;
145e41fca3dSGabriel L. Somlo     uint8_t contained_element_count;
146e41fca3dSGabriel L. Somlo     /* contained elements follow */
147e41fca3dSGabriel L. Somlo } QEMU_PACKED;
148e41fca3dSGabriel L. Somlo 
149e41fca3dSGabriel L. Somlo /* SMBIOS type 3 - System Enclosure (v2.7) */
150b6f6e3d3Saliguori struct smbios_type_3 {
151b6f6e3d3Saliguori     struct smbios_structure_header header;
152b6f6e3d3Saliguori     uint8_t manufacturer_str;
153b6f6e3d3Saliguori     uint8_t type;
154b6f6e3d3Saliguori     uint8_t version_str;
155b6f6e3d3Saliguori     uint8_t serial_number_str;
156b6f6e3d3Saliguori     uint8_t asset_tag_number_str;
157b6f6e3d3Saliguori     uint8_t boot_up_state;
158b6f6e3d3Saliguori     uint8_t power_supply_state;
159b6f6e3d3Saliguori     uint8_t thermal_state;
160b6f6e3d3Saliguori     uint8_t security_status;
161b6f6e3d3Saliguori     uint32_t oem_defined;
162b6f6e3d3Saliguori     uint8_t height;
163b6f6e3d3Saliguori     uint8_t number_of_power_cords;
164b6f6e3d3Saliguori     uint8_t contained_element_count;
165b81a5f94SDaniel P. Berrangé     uint8_t contained_element_record_length;
166e41fca3dSGabriel L. Somlo     uint8_t sku_number_str;
167e41fca3dSGabriel L. Somlo     /* contained elements follow */
168541dc0d4SStefan Weil } QEMU_PACKED;
169b6f6e3d3Saliguori 
170e41fca3dSGabriel L. Somlo /* SMBIOS type 4 - Processor Information (v2.6) */
171b6f6e3d3Saliguori struct smbios_type_4 {
172b6f6e3d3Saliguori     struct smbios_structure_header header;
173b6f6e3d3Saliguori     uint8_t socket_designation_str;
174b6f6e3d3Saliguori     uint8_t processor_type;
175b6f6e3d3Saliguori     uint8_t processor_family;
176b6f6e3d3Saliguori     uint8_t processor_manufacturer_str;
177b6f6e3d3Saliguori     uint32_t processor_id[2];
178b6f6e3d3Saliguori     uint8_t processor_version_str;
179b6f6e3d3Saliguori     uint8_t voltage;
180b6f6e3d3Saliguori     uint16_t external_clock;
181b6f6e3d3Saliguori     uint16_t max_speed;
182b6f6e3d3Saliguori     uint16_t current_speed;
183b6f6e3d3Saliguori     uint8_t status;
184b6f6e3d3Saliguori     uint8_t processor_upgrade;
185b6f6e3d3Saliguori     uint16_t l1_cache_handle;
186b6f6e3d3Saliguori     uint16_t l2_cache_handle;
187b6f6e3d3Saliguori     uint16_t l3_cache_handle;
188e41fca3dSGabriel L. Somlo     uint8_t serial_number_str;
189e41fca3dSGabriel L. Somlo     uint8_t asset_tag_number_str;
190e41fca3dSGabriel L. Somlo     uint8_t part_number_str;
191e41fca3dSGabriel L. Somlo     uint8_t core_count;
192e41fca3dSGabriel L. Somlo     uint8_t core_enabled;
193e41fca3dSGabriel L. Somlo     uint8_t thread_count;
194e41fca3dSGabriel L. Somlo     uint16_t processor_characteristics;
195e41fca3dSGabriel L. Somlo     uint16_t processor_family2;
196541dc0d4SStefan Weil } QEMU_PACKED;
197b6f6e3d3Saliguori 
1982d6dcbf9SDaniel P. Berrange /* SMBIOS type 11 - OEM strings */
1992d6dcbf9SDaniel P. Berrange struct smbios_type_11 {
2002d6dcbf9SDaniel P. Berrange     struct smbios_structure_header header;
2012d6dcbf9SDaniel P. Berrange     uint8_t count;
2022d6dcbf9SDaniel P. Berrange } QEMU_PACKED;
2032d6dcbf9SDaniel P. Berrange 
204e41fca3dSGabriel L. Somlo /* SMBIOS type 16 - Physical Memory Array (v2.7) */
205b6f6e3d3Saliguori struct smbios_type_16 {
206b6f6e3d3Saliguori     struct smbios_structure_header header;
207b6f6e3d3Saliguori     uint8_t location;
208b6f6e3d3Saliguori     uint8_t use;
209b6f6e3d3Saliguori     uint8_t error_correction;
210b6f6e3d3Saliguori     uint32_t maximum_capacity;
211b6f6e3d3Saliguori     uint16_t memory_error_information_handle;
212b6f6e3d3Saliguori     uint16_t number_of_memory_devices;
213e41fca3dSGabriel L. Somlo     uint64_t extended_maximum_capacity;
214541dc0d4SStefan Weil } QEMU_PACKED;
215e41fca3dSGabriel L. Somlo 
216e41fca3dSGabriel L. Somlo /* SMBIOS type 17 - Memory Device (v2.8) */
217b6f6e3d3Saliguori struct smbios_type_17 {
218b6f6e3d3Saliguori     struct smbios_structure_header header;
219b6f6e3d3Saliguori     uint16_t physical_memory_array_handle;
220b6f6e3d3Saliguori     uint16_t memory_error_information_handle;
221b6f6e3d3Saliguori     uint16_t total_width;
222b6f6e3d3Saliguori     uint16_t data_width;
223b6f6e3d3Saliguori     uint16_t size;
224b6f6e3d3Saliguori     uint8_t form_factor;
225b6f6e3d3Saliguori     uint8_t device_set;
226b6f6e3d3Saliguori     uint8_t device_locator_str;
227b6f6e3d3Saliguori     uint8_t bank_locator_str;
228b6f6e3d3Saliguori     uint8_t memory_type;
229b6f6e3d3Saliguori     uint16_t type_detail;
230e41fca3dSGabriel L. Somlo     uint16_t speed;
231e41fca3dSGabriel L. Somlo     uint8_t manufacturer_str;
232e41fca3dSGabriel L. Somlo     uint8_t serial_number_str;
233e41fca3dSGabriel L. Somlo     uint8_t asset_tag_number_str;
234e41fca3dSGabriel L. Somlo     uint8_t part_number_str;
235e41fca3dSGabriel L. Somlo     uint8_t attributes;
236e41fca3dSGabriel L. Somlo     uint32_t extended_size;
2370d73394aSGabriel L. Somlo     uint16_t configured_clock_speed;
2380d73394aSGabriel L. Somlo     uint16_t minimum_voltage;
2390d73394aSGabriel L. Somlo     uint16_t maximum_voltage;
2400d73394aSGabriel L. Somlo     uint16_t configured_voltage;
241541dc0d4SStefan Weil } QEMU_PACKED;
242b6f6e3d3Saliguori 
243e41fca3dSGabriel L. Somlo /* SMBIOS type 19 - Memory Array Mapped Address (v2.7) */
244b6f6e3d3Saliguori struct smbios_type_19 {
245b6f6e3d3Saliguori     struct smbios_structure_header header;
246b6f6e3d3Saliguori     uint32_t starting_address;
247b6f6e3d3Saliguori     uint32_t ending_address;
248b6f6e3d3Saliguori     uint16_t memory_array_handle;
249b6f6e3d3Saliguori     uint8_t partition_width;
250e41fca3dSGabriel L. Somlo     uint64_t extended_starting_address;
251e41fca3dSGabriel L. Somlo     uint64_t extended_ending_address;
252541dc0d4SStefan Weil } QEMU_PACKED;
253b6f6e3d3Saliguori 
254b6f6e3d3Saliguori /* SMBIOS type 32 - System Boot Information */
255b6f6e3d3Saliguori struct smbios_type_32 {
256b6f6e3d3Saliguori     struct smbios_structure_header header;
257b6f6e3d3Saliguori     uint8_t reserved[6];
258b6f6e3d3Saliguori     uint8_t boot_status;
259541dc0d4SStefan Weil } QEMU_PACKED;
260b6f6e3d3Saliguori 
261b6f6e3d3Saliguori /* SMBIOS type 127 -- End-of-table */
262b6f6e3d3Saliguori struct smbios_type_127 {
263b6f6e3d3Saliguori     struct smbios_structure_header header;
264541dc0d4SStefan Weil } QEMU_PACKED;
265b6f6e3d3Saliguori 
2661007a37eSLeif Lindholm void smbios_entry_add(QemuOpts *opts, Error **errp);
26786299120SWei Huang void smbios_set_cpuid(uint32_t version, uint32_t features);
26886299120SWei Huang void smbios_set_defaults(const char *manufacturer, const char *product,
26986299120SWei Huang                          const char *version, bool legacy_mode,
27086299120SWei Huang                          bool uuid_encoded, SmbiosEntryPointType ep_type);
271*a0628599SLike Xu uint8_t *smbios_get_table_legacy(MachineState *ms, size_t *length);
272*a0628599SLike Xu void smbios_get_tables(MachineState *ms,
273*a0628599SLike Xu                        const struct smbios_phys_mem_area *mem_array,
27486299120SWei Huang                        const unsigned int mem_array_size,
27586299120SWei Huang                        uint8_t **tables, size_t *tables_len,
27686299120SWei Huang                        uint8_t **anchor, size_t *anchor_len);
277b6f6e3d3Saliguori #endif /* QEMU_SMBIOS_H */
278