1b6f6e3d3Saliguori #ifndef QEMU_SMBIOS_H 2b6f6e3d3Saliguori #define QEMU_SMBIOS_H 3175de524SMarkus Armbruster 4bdf54a9aSEduardo Habkost #include "qapi/qapi-types-machine.h" 5bdf54a9aSEduardo Habkost 6b6f6e3d3Saliguori /* 7b6f6e3d3Saliguori * SMBIOS Support 8b6f6e3d3Saliguori * 9b6f6e3d3Saliguori * Copyright (C) 2009 Hewlett-Packard Development Company, L.P. 10b6f6e3d3Saliguori * 11b6f6e3d3Saliguori * Authors: 12b6f6e3d3Saliguori * Alex Williamson <alex.williamson@hp.com> 13b6f6e3d3Saliguori * 14b6f6e3d3Saliguori * This work is licensed under the terms of the GNU GPL, version 2. See 15b6f6e3d3Saliguori * the COPYING file in the top-level directory. 16b6f6e3d3Saliguori * 17b6f6e3d3Saliguori */ 18b6f6e3d3Saliguori 194f953d2fSMarkus Armbruster 202e6e8d7aSGabriel L. Somlo #define SMBIOS_MAX_TYPE 127 212e6e8d7aSGabriel L. Somlo 2289cc4a27SWei Huang /* memory area description, used by type 19 table */ 2389cc4a27SWei Huang struct smbios_phys_mem_area { 2489cc4a27SWei Huang uint64_t address; 2589cc4a27SWei Huang uint64_t length; 2689cc4a27SWei Huang }; 2789cc4a27SWei Huang 2886299120SWei Huang /* SMBIOS Entry Point 2986299120SWei Huang * There are two types of entry points defined in the SMBIOS specification 30cc2324d0SCao jin * (see below). BIOS must place the entry point(s) at a 16-byte-aligned 3186299120SWei Huang * address between 0xf0000 and 0xfffff. Note that either entry point type 3286299120SWei Huang * can be used in a 64-bit target system, except that SMBIOS 2.1 entry point 3386299120SWei Huang * only allows the SMBIOS struct table to reside below 4GB address space. 34e41fca3dSGabriel L. Somlo */ 3586299120SWei Huang 3686299120SWei Huang /* SMBIOS 2.1 (32-bit) Entry Point 3786299120SWei Huang * - introduced since SMBIOS 2.1 3886299120SWei Huang * - supports structure table below 4GB only 3986299120SWei Huang */ 4086299120SWei Huang struct smbios_21_entry_point { 41e41fca3dSGabriel L. Somlo uint8_t anchor_string[4]; 42e41fca3dSGabriel L. Somlo uint8_t checksum; 43e41fca3dSGabriel L. Somlo uint8_t length; 44e41fca3dSGabriel L. Somlo uint8_t smbios_major_version; 45e41fca3dSGabriel L. Somlo uint8_t smbios_minor_version; 46e41fca3dSGabriel L. Somlo uint16_t max_structure_size; 47e41fca3dSGabriel L. Somlo uint8_t entry_point_revision; 48e41fca3dSGabriel L. Somlo uint8_t formatted_area[5]; 49e41fca3dSGabriel L. Somlo uint8_t intermediate_anchor_string[5]; 50e41fca3dSGabriel L. Somlo uint8_t intermediate_checksum; 51e41fca3dSGabriel L. Somlo uint16_t structure_table_length; 52e41fca3dSGabriel L. Somlo uint32_t structure_table_address; 53e41fca3dSGabriel L. Somlo uint16_t number_of_structures; 54e41fca3dSGabriel L. Somlo uint8_t smbios_bcd_revision; 55e41fca3dSGabriel L. Somlo } QEMU_PACKED; 56e41fca3dSGabriel L. Somlo 5786299120SWei Huang /* SMBIOS 3.0 (64-bit) Entry Point 5886299120SWei Huang * - introduced since SMBIOS 3.0 5986299120SWei Huang * - supports structure table at 64-bit address space 6086299120SWei Huang */ 6186299120SWei Huang struct smbios_30_entry_point { 6286299120SWei Huang uint8_t anchor_string[5]; 6386299120SWei Huang uint8_t checksum; 6486299120SWei Huang uint8_t length; 6586299120SWei Huang uint8_t smbios_major_version; 6686299120SWei Huang uint8_t smbios_minor_version; 6786299120SWei Huang uint8_t smbios_doc_rev; 6886299120SWei Huang uint8_t entry_point_revision; 6986299120SWei Huang uint8_t reserved; 7086299120SWei Huang uint32_t structure_table_max_size; 7186299120SWei Huang uint64_t structure_table_address; 7286299120SWei Huang } QEMU_PACKED; 7386299120SWei Huang 7486299120SWei Huang typedef union { 7586299120SWei Huang struct smbios_21_entry_point ep21; 7686299120SWei Huang struct smbios_30_entry_point ep30; 7786299120SWei Huang } QEMU_PACKED SmbiosEntryPoint; 7886299120SWei Huang 79b6f6e3d3Saliguori /* This goes at the beginning of every SMBIOS structure. */ 80b6f6e3d3Saliguori struct smbios_structure_header { 81b6f6e3d3Saliguori uint8_t type; 82b6f6e3d3Saliguori uint8_t length; 83b6f6e3d3Saliguori uint16_t handle; 84541dc0d4SStefan Weil } QEMU_PACKED; 85b6f6e3d3Saliguori 86b6f6e3d3Saliguori /* SMBIOS type 0 - BIOS Information */ 87b6f6e3d3Saliguori struct smbios_type_0 { 88b6f6e3d3Saliguori struct smbios_structure_header header; 89b6f6e3d3Saliguori uint8_t vendor_str; 90b6f6e3d3Saliguori uint8_t bios_version_str; 91b6f6e3d3Saliguori uint16_t bios_starting_address_segment; 92b6f6e3d3Saliguori uint8_t bios_release_date_str; 93b6f6e3d3Saliguori uint8_t bios_rom_size; 9484351843SGabriel L. Somlo uint64_t bios_characteristics; 95b6f6e3d3Saliguori uint8_t bios_characteristics_extension_bytes[2]; 96b6f6e3d3Saliguori uint8_t system_bios_major_release; 97b6f6e3d3Saliguori uint8_t system_bios_minor_release; 98b6f6e3d3Saliguori uint8_t embedded_controller_major_release; 99b6f6e3d3Saliguori uint8_t embedded_controller_minor_release; 100541dc0d4SStefan Weil } QEMU_PACKED; 101b6f6e3d3Saliguori 102caad057bSEduardo Habkost /* UUID encoding. The time_* fields are little-endian, as specified by SMBIOS 103caad057bSEduardo Habkost * version 2.6. 104caad057bSEduardo Habkost */ 105caad057bSEduardo Habkost struct smbios_uuid { 106caad057bSEduardo Habkost uint32_t time_low; 107caad057bSEduardo Habkost uint16_t time_mid; 108caad057bSEduardo Habkost uint16_t time_hi_and_version; 109caad057bSEduardo Habkost uint8_t clock_seq_hi_and_reserved; 110caad057bSEduardo Habkost uint8_t clock_seq_low; 111caad057bSEduardo Habkost uint8_t node[6]; 112caad057bSEduardo Habkost } QEMU_PACKED; 113caad057bSEduardo Habkost 114b6f6e3d3Saliguori /* SMBIOS type 1 - System Information */ 115b6f6e3d3Saliguori struct smbios_type_1 { 116b6f6e3d3Saliguori struct smbios_structure_header header; 117b6f6e3d3Saliguori uint8_t manufacturer_str; 118b6f6e3d3Saliguori uint8_t product_name_str; 119b6f6e3d3Saliguori uint8_t version_str; 120b6f6e3d3Saliguori uint8_t serial_number_str; 121caad057bSEduardo Habkost struct smbios_uuid uuid; 122b6f6e3d3Saliguori uint8_t wake_up_type; 123b6f6e3d3Saliguori uint8_t sku_number_str; 124b6f6e3d3Saliguori uint8_t family_str; 125541dc0d4SStefan Weil } QEMU_PACKED; 126b6f6e3d3Saliguori 127e41fca3dSGabriel L. Somlo /* SMBIOS type 2 - Base Board */ 128e41fca3dSGabriel L. Somlo struct smbios_type_2 { 129e41fca3dSGabriel L. Somlo struct smbios_structure_header header; 130e41fca3dSGabriel L. Somlo uint8_t manufacturer_str; 131e41fca3dSGabriel L. Somlo uint8_t product_str; 132e41fca3dSGabriel L. Somlo uint8_t version_str; 133e41fca3dSGabriel L. Somlo uint8_t serial_number_str; 134e41fca3dSGabriel L. Somlo uint8_t asset_tag_number_str; 135e41fca3dSGabriel L. Somlo uint8_t feature_flags; 136e41fca3dSGabriel L. Somlo uint8_t location_str; 137e41fca3dSGabriel L. Somlo uint16_t chassis_handle; 138e41fca3dSGabriel L. Somlo uint8_t board_type; 139e41fca3dSGabriel L. Somlo uint8_t contained_element_count; 140e41fca3dSGabriel L. Somlo /* contained elements follow */ 141e41fca3dSGabriel L. Somlo } QEMU_PACKED; 142e41fca3dSGabriel L. Somlo 143e41fca3dSGabriel L. Somlo /* SMBIOS type 3 - System Enclosure (v2.7) */ 144b6f6e3d3Saliguori struct smbios_type_3 { 145b6f6e3d3Saliguori struct smbios_structure_header header; 146b6f6e3d3Saliguori uint8_t manufacturer_str; 147b6f6e3d3Saliguori uint8_t type; 148b6f6e3d3Saliguori uint8_t version_str; 149b6f6e3d3Saliguori uint8_t serial_number_str; 150b6f6e3d3Saliguori uint8_t asset_tag_number_str; 151b6f6e3d3Saliguori uint8_t boot_up_state; 152b6f6e3d3Saliguori uint8_t power_supply_state; 153b6f6e3d3Saliguori uint8_t thermal_state; 154b6f6e3d3Saliguori uint8_t security_status; 155b6f6e3d3Saliguori uint32_t oem_defined; 156b6f6e3d3Saliguori uint8_t height; 157b6f6e3d3Saliguori uint8_t number_of_power_cords; 158b6f6e3d3Saliguori uint8_t contained_element_count; 159b81a5f94SDaniel P. Berrangé uint8_t contained_element_record_length; 160e41fca3dSGabriel L. Somlo uint8_t sku_number_str; 161e41fca3dSGabriel L. Somlo /* contained elements follow */ 162541dc0d4SStefan Weil } QEMU_PACKED; 163b6f6e3d3Saliguori 164e41fca3dSGabriel L. Somlo /* SMBIOS type 4 - Processor Information (v2.6) */ 165b6f6e3d3Saliguori struct smbios_type_4 { 166b6f6e3d3Saliguori struct smbios_structure_header header; 167b6f6e3d3Saliguori uint8_t socket_designation_str; 168b6f6e3d3Saliguori uint8_t processor_type; 169b6f6e3d3Saliguori uint8_t processor_family; 170b6f6e3d3Saliguori uint8_t processor_manufacturer_str; 171b6f6e3d3Saliguori uint32_t processor_id[2]; 172b6f6e3d3Saliguori uint8_t processor_version_str; 173b6f6e3d3Saliguori uint8_t voltage; 174b6f6e3d3Saliguori uint16_t external_clock; 175b6f6e3d3Saliguori uint16_t max_speed; 176b6f6e3d3Saliguori uint16_t current_speed; 177b6f6e3d3Saliguori uint8_t status; 178b6f6e3d3Saliguori uint8_t processor_upgrade; 179b6f6e3d3Saliguori uint16_t l1_cache_handle; 180b6f6e3d3Saliguori uint16_t l2_cache_handle; 181b6f6e3d3Saliguori uint16_t l3_cache_handle; 182e41fca3dSGabriel L. Somlo uint8_t serial_number_str; 183e41fca3dSGabriel L. Somlo uint8_t asset_tag_number_str; 184e41fca3dSGabriel L. Somlo uint8_t part_number_str; 185e41fca3dSGabriel L. Somlo uint8_t core_count; 186e41fca3dSGabriel L. Somlo uint8_t core_enabled; 187e41fca3dSGabriel L. Somlo uint8_t thread_count; 188e41fca3dSGabriel L. Somlo uint16_t processor_characteristics; 189e41fca3dSGabriel L. Somlo uint16_t processor_family2; 190541dc0d4SStefan Weil } QEMU_PACKED; 191b6f6e3d3Saliguori 192*fd8caa25SHal Martin /* SMBIOS type 8 - Port Connector Information */ 193*fd8caa25SHal Martin struct smbios_type_8 { 194*fd8caa25SHal Martin struct smbios_structure_header header; 195*fd8caa25SHal Martin uint8_t internal_reference_str; 196*fd8caa25SHal Martin uint8_t internal_connector_type; 197*fd8caa25SHal Martin uint8_t external_reference_str; 198*fd8caa25SHal Martin uint8_t external_connector_type; 199*fd8caa25SHal Martin uint8_t port_type; 200*fd8caa25SHal Martin } QEMU_PACKED; 201*fd8caa25SHal Martin 2022d6dcbf9SDaniel P. Berrange /* SMBIOS type 11 - OEM strings */ 2032d6dcbf9SDaniel P. Berrange struct smbios_type_11 { 2042d6dcbf9SDaniel P. Berrange struct smbios_structure_header header; 2052d6dcbf9SDaniel P. Berrange uint8_t count; 2062d6dcbf9SDaniel P. Berrange } QEMU_PACKED; 2072d6dcbf9SDaniel P. Berrange 208e41fca3dSGabriel L. Somlo /* SMBIOS type 16 - Physical Memory Array (v2.7) */ 209b6f6e3d3Saliguori struct smbios_type_16 { 210b6f6e3d3Saliguori struct smbios_structure_header header; 211b6f6e3d3Saliguori uint8_t location; 212b6f6e3d3Saliguori uint8_t use; 213b6f6e3d3Saliguori uint8_t error_correction; 214b6f6e3d3Saliguori uint32_t maximum_capacity; 215b6f6e3d3Saliguori uint16_t memory_error_information_handle; 216b6f6e3d3Saliguori uint16_t number_of_memory_devices; 217e41fca3dSGabriel L. Somlo uint64_t extended_maximum_capacity; 218541dc0d4SStefan Weil } QEMU_PACKED; 219e41fca3dSGabriel L. Somlo 220e41fca3dSGabriel L. Somlo /* SMBIOS type 17 - Memory Device (v2.8) */ 221b6f6e3d3Saliguori struct smbios_type_17 { 222b6f6e3d3Saliguori struct smbios_structure_header header; 223b6f6e3d3Saliguori uint16_t physical_memory_array_handle; 224b6f6e3d3Saliguori uint16_t memory_error_information_handle; 225b6f6e3d3Saliguori uint16_t total_width; 226b6f6e3d3Saliguori uint16_t data_width; 227b6f6e3d3Saliguori uint16_t size; 228b6f6e3d3Saliguori uint8_t form_factor; 229b6f6e3d3Saliguori uint8_t device_set; 230b6f6e3d3Saliguori uint8_t device_locator_str; 231b6f6e3d3Saliguori uint8_t bank_locator_str; 232b6f6e3d3Saliguori uint8_t memory_type; 233b6f6e3d3Saliguori uint16_t type_detail; 234e41fca3dSGabriel L. Somlo uint16_t speed; 235e41fca3dSGabriel L. Somlo uint8_t manufacturer_str; 236e41fca3dSGabriel L. Somlo uint8_t serial_number_str; 237e41fca3dSGabriel L. Somlo uint8_t asset_tag_number_str; 238e41fca3dSGabriel L. Somlo uint8_t part_number_str; 239e41fca3dSGabriel L. Somlo uint8_t attributes; 240e41fca3dSGabriel L. Somlo uint32_t extended_size; 2410d73394aSGabriel L. Somlo uint16_t configured_clock_speed; 2420d73394aSGabriel L. Somlo uint16_t minimum_voltage; 2430d73394aSGabriel L. Somlo uint16_t maximum_voltage; 2440d73394aSGabriel L. Somlo uint16_t configured_voltage; 245541dc0d4SStefan Weil } QEMU_PACKED; 246b6f6e3d3Saliguori 247e41fca3dSGabriel L. Somlo /* SMBIOS type 19 - Memory Array Mapped Address (v2.7) */ 248b6f6e3d3Saliguori struct smbios_type_19 { 249b6f6e3d3Saliguori struct smbios_structure_header header; 250b6f6e3d3Saliguori uint32_t starting_address; 251b6f6e3d3Saliguori uint32_t ending_address; 252b6f6e3d3Saliguori uint16_t memory_array_handle; 253b6f6e3d3Saliguori uint8_t partition_width; 254e41fca3dSGabriel L. Somlo uint64_t extended_starting_address; 255e41fca3dSGabriel L. Somlo uint64_t extended_ending_address; 256541dc0d4SStefan Weil } QEMU_PACKED; 257b6f6e3d3Saliguori 258b6f6e3d3Saliguori /* SMBIOS type 32 - System Boot Information */ 259b6f6e3d3Saliguori struct smbios_type_32 { 260b6f6e3d3Saliguori struct smbios_structure_header header; 261b6f6e3d3Saliguori uint8_t reserved[6]; 262b6f6e3d3Saliguori uint8_t boot_status; 263541dc0d4SStefan Weil } QEMU_PACKED; 264b6f6e3d3Saliguori 26505dfb447SVincent Bernat /* SMBIOS type 41 - Onboard Devices Extended Information */ 26605dfb447SVincent Bernat struct smbios_type_41 { 26705dfb447SVincent Bernat struct smbios_structure_header header; 26805dfb447SVincent Bernat uint8_t reference_designation_str; 26905dfb447SVincent Bernat uint8_t device_type; 27005dfb447SVincent Bernat uint8_t device_type_instance; 27105dfb447SVincent Bernat uint16_t segment_group_number; 27205dfb447SVincent Bernat uint8_t bus_number; 27305dfb447SVincent Bernat uint8_t device_number; 27405dfb447SVincent Bernat } QEMU_PACKED; 27505dfb447SVincent Bernat 276b6f6e3d3Saliguori /* SMBIOS type 127 -- End-of-table */ 277b6f6e3d3Saliguori struct smbios_type_127 { 278b6f6e3d3Saliguori struct smbios_structure_header header; 279541dc0d4SStefan Weil } QEMU_PACKED; 280b6f6e3d3Saliguori 2811007a37eSLeif Lindholm void smbios_entry_add(QemuOpts *opts, Error **errp); 28286299120SWei Huang void smbios_set_cpuid(uint32_t version, uint32_t features); 28386299120SWei Huang void smbios_set_defaults(const char *manufacturer, const char *product, 28486299120SWei Huang const char *version, bool legacy_mode, 28586299120SWei Huang bool uuid_encoded, SmbiosEntryPointType ep_type); 286a0628599SLike Xu uint8_t *smbios_get_table_legacy(MachineState *ms, size_t *length); 287a0628599SLike Xu void smbios_get_tables(MachineState *ms, 288a0628599SLike Xu const struct smbios_phys_mem_area *mem_array, 28986299120SWei Huang const unsigned int mem_array_size, 29086299120SWei Huang uint8_t **tables, size_t *tables_len, 29105dfb447SVincent Bernat uint8_t **anchor, size_t *anchor_len, 29205dfb447SVincent Bernat Error **errp); 293b6f6e3d3Saliguori #endif /* QEMU_SMBIOS_H */ 294