1 #ifndef _IPXE_SMBIOS_H 2 #define _IPXE_SMBIOS_H 3 4 /** @file 5 * 6 * System Management BIOS 7 * 8 */ 9 10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); 11 12 #include <stdint.h> 13 #include <ipxe/api.h> 14 #include <config/general.h> 15 #include <ipxe/uaccess.h> 16 17 /** 18 * Provide an SMBIOS API implementation 19 * 20 * @v _prefix Subsystem prefix 21 * @v _api_func API function 22 * @v _func Implementing function 23 */ 24 #define PROVIDE_SMBIOS( _subsys, _api_func, _func ) \ 25 PROVIDE_SINGLE_API ( SMBIOS_PREFIX_ ## _subsys, _api_func, _func ) 26 27 /* Include all architecture-independent SMBIOS API headers */ 28 #include <ipxe/efi/efi_smbios.h> 29 #include <ipxe/linux/linux_smbios.h> 30 31 /* Include all architecture-dependent SMBIOS API headers */ 32 #include <bits/smbios.h> 33 34 /** Signature for 32-bit SMBIOS entry point */ 35 #define SMBIOS_SIGNATURE \ 36 ( ( '_' << 0 ) + ( 'S' << 8 ) + ( 'M' << 16 ) + ( '_' << 24 ) ) 37 38 /** Signature for 64-bit SMBIOS entry point */ 39 #define SMBIOS3_SIGNATURE \ 40 ( ( '_' << 0 ) + ( 'S' << 8 ) + ( 'M' << 16 ) + ( '3' << 24 ) ) 41 42 /** 43 * SMBIOS 32-bit entry point 44 * 45 * This is the 32-bit version of the table which describes the list of 46 * SMBIOS structures. It may be located by scanning through the BIOS 47 * segment or via an EFI configuration table. 48 */ 49 struct smbios_entry { 50 /** Signature 51 * 52 * Must be equal to SMBIOS_SIGNATURE 53 */ 54 uint32_t signature; 55 /** Checksum */ 56 uint8_t checksum; 57 /** Length */ 58 uint8_t len; 59 /** Major version */ 60 uint8_t major; 61 /** Minor version */ 62 uint8_t minor; 63 /** Maximum structure size */ 64 uint16_t max; 65 /** Entry point revision */ 66 uint8_t revision; 67 /** Formatted area */ 68 uint8_t formatted[5]; 69 /** DMI Signature */ 70 uint8_t dmi_signature[5]; 71 /** DMI checksum */ 72 uint8_t dmi_checksum; 73 /** Structure table length */ 74 uint16_t smbios_len; 75 /** Structure table address */ 76 uint32_t smbios_address; 77 /** Number of SMBIOS structures */ 78 uint16_t smbios_count; 79 /** BCD revision */ 80 uint8_t bcd_revision; 81 } __attribute__ (( packed )); 82 83 /** 84 * SMBIOS 64-bit entry point 85 * 86 * This is the 64-bit version of the table which describes the list of 87 * SMBIOS structures. It may be located by scanning through the BIOS 88 * segment or via an EFI configuration table. 89 */ 90 struct smbios3_entry { 91 /** Signature 92 * 93 * Must be equal to SMBIOS3_SIGNATURE 94 */ 95 uint32_t signature; 96 /** Signature extra byte */ 97 uint8_t extra; 98 /** Checksum */ 99 uint8_t checksum; 100 /** Length */ 101 uint8_t len; 102 /** Major version */ 103 uint8_t major; 104 /** Minor version */ 105 uint8_t minor; 106 /** Documentation revision */ 107 uint8_t docrev; 108 /** Entry point revision */ 109 uint8_t revision; 110 /** Reserved */ 111 uint8_t reserved; 112 /** Structure table length */ 113 uint32_t smbios_len; 114 /** Structure table address */ 115 uint64_t smbios_address; 116 } __attribute__ (( packed )); 117 118 /** An SMBIOS structure header */ 119 struct smbios_header { 120 /** Type */ 121 uint8_t type; 122 /** Length */ 123 uint8_t len; 124 /** Handle */ 125 uint16_t handle; 126 } __attribute__ (( packed )); 127 128 /** SMBIOS structure descriptor */ 129 struct smbios_structure { 130 /** Copy of SMBIOS structure header */ 131 struct smbios_header header; 132 /** Offset of structure within SMBIOS */ 133 size_t offset; 134 /** Length of strings section */ 135 size_t strings_len; 136 }; 137 138 /** SMBIOS system information structure */ 139 struct smbios_system_information { 140 /** SMBIOS structure header */ 141 struct smbios_header header; 142 /** Manufacturer string */ 143 uint8_t manufacturer; 144 /** Product string */ 145 uint8_t product; 146 /** Version string */ 147 uint8_t version; 148 /** Serial number string */ 149 uint8_t serial; 150 /** UUID */ 151 uint8_t uuid[16]; 152 /** Wake-up type */ 153 uint8_t wakeup; 154 } __attribute__ (( packed )); 155 156 /** SMBIOS system information structure type */ 157 #define SMBIOS_TYPE_SYSTEM_INFORMATION 1 158 159 /** SMBIOS base board information structure */ 160 struct smbios_base_board_information { 161 /** SMBIOS structure header */ 162 struct smbios_header header; 163 /** Manufacturer string */ 164 uint8_t manufacturer; 165 /** Product string */ 166 uint8_t product; 167 /** Version string */ 168 uint8_t version; 169 /** Serial number string */ 170 uint8_t serial; 171 } __attribute__ (( packed )); 172 173 /** SMBIOS base board information structure type */ 174 #define SMBIOS_TYPE_BASE_BOARD_INFORMATION 2 175 176 /** SMBIOS enclosure information structure */ 177 struct smbios_enclosure_information { 178 /** SMBIOS structure header */ 179 struct smbios_header header; 180 /** Manufacturer string */ 181 uint8_t manufacturer; 182 /** Type string */ 183 uint8_t type; 184 /** Version string */ 185 uint8_t version; 186 /** Serial number string */ 187 uint8_t serial; 188 /** Asset tag */ 189 uint8_t asset_tag; 190 } __attribute__ (( packed )); 191 192 /** SMBIOS enclosure information structure type */ 193 #define SMBIOS_TYPE_ENCLOSURE_INFORMATION 3 194 195 /** SMBIOS OEM strings structure type */ 196 #define SMBIOS_TYPE_OEM_STRINGS 11 197 198 /** SMBIOS end of table type */ 199 #define SMBIOS_TYPE_END 127 200 201 /** 202 * SMBIOS entry point descriptor 203 * 204 * This contains the information from the SMBIOS entry point that we 205 * care about. 206 */ 207 struct smbios { 208 /** Start of SMBIOS structures */ 209 userptr_t address; 210 /** Length of SMBIOS structures */ 211 size_t len; 212 /** Number of SMBIOS structures */ 213 unsigned int count; 214 /** SMBIOS version */ 215 uint16_t version; 216 }; 217 218 /** 219 * Calculate SMBIOS version 220 * 221 * @v major Major version 222 * @v minor Minor version 223 * @ret version SMBIOS version 224 */ 225 #define SMBIOS_VERSION( major, minor ) ( ( (major) << 8 ) | (minor) ) 226 227 extern int find_smbios ( struct smbios *smbios ); 228 extern int find_smbios_entry ( userptr_t start, size_t len, 229 struct smbios_entry *entry ); 230 extern int find_smbios_structure ( unsigned int type, unsigned int instance, 231 struct smbios_structure *structure ); 232 extern int read_smbios_structure ( struct smbios_structure *structure, 233 void *data, size_t len ); 234 extern int read_smbios_string ( struct smbios_structure *structure, 235 unsigned int index, 236 void *data, size_t len ); 237 extern int smbios_version ( void ); 238 extern void smbios_clear ( void ); 239 240 #endif /* _IPXE_SMBIOS_H */ 241