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