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 SMBIOS entry point */ 35 #define SMBIOS_SIGNATURE \ 36 ( ( '_' << 0 ) + ( 'S' << 8 ) + ( 'M' << 16 ) + ( '_' << 24 ) ) 37 38 /** 39 * SMBIOS entry point 40 * 41 * This is the single table which describes the list of SMBIOS 42 * structures. It is located by scanning through the BIOS segment. 43 */ 44 struct smbios_entry { 45 /** Signature 46 * 47 * Must be equal to SMBIOS_SIGNATURE 48 */ 49 uint32_t signature; 50 /** Checksum */ 51 uint8_t checksum; 52 /** Length */ 53 uint8_t len; 54 /** Major version */ 55 uint8_t major; 56 /** Minor version */ 57 uint8_t minor; 58 /** Maximum structure size */ 59 uint16_t max; 60 /** Entry point revision */ 61 uint8_t revision; 62 /** Formatted area */ 63 uint8_t formatted[5]; 64 /** DMI Signature */ 65 uint8_t dmi_signature[5]; 66 /** DMI checksum */ 67 uint8_t dmi_checksum; 68 /** Structure table length */ 69 uint16_t smbios_len; 70 /** Structure table address */ 71 uint32_t smbios_address; 72 /** Number of SMBIOS structures */ 73 uint16_t smbios_count; 74 /** BCD revision */ 75 uint8_t bcd_revision; 76 } __attribute__ (( packed )); 77 78 /** An SMBIOS structure header */ 79 struct smbios_header { 80 /** Type */ 81 uint8_t type; 82 /** Length */ 83 uint8_t len; 84 /** Handle */ 85 uint16_t handle; 86 } __attribute__ (( packed )); 87 88 /** SMBIOS structure descriptor */ 89 struct smbios_structure { 90 /** Copy of SMBIOS structure header */ 91 struct smbios_header header; 92 /** Offset of structure within SMBIOS */ 93 size_t offset; 94 /** Length of strings section */ 95 size_t strings_len; 96 }; 97 98 /** SMBIOS system information structure */ 99 struct smbios_system_information { 100 /** SMBIOS structure header */ 101 struct smbios_header header; 102 /** Manufacturer string */ 103 uint8_t manufacturer; 104 /** Product string */ 105 uint8_t product; 106 /** Version string */ 107 uint8_t version; 108 /** Serial number string */ 109 uint8_t serial; 110 /** UUID */ 111 uint8_t uuid[16]; 112 /** Wake-up type */ 113 uint8_t wakeup; 114 } __attribute__ (( packed )); 115 116 /** SMBIOS system information structure type */ 117 #define SMBIOS_TYPE_SYSTEM_INFORMATION 1 118 119 /** SMBIOS base board information structure */ 120 struct smbios_base_board_information { 121 /** SMBIOS structure header */ 122 struct smbios_header header; 123 /** Manufacturer string */ 124 uint8_t manufacturer; 125 /** Product string */ 126 uint8_t product; 127 /** Version string */ 128 uint8_t version; 129 /** Serial number string */ 130 uint8_t serial; 131 } __attribute__ (( packed )); 132 133 /** SMBIOS base board information structure type */ 134 #define SMBIOS_TYPE_BASE_BOARD_INFORMATION 2 135 136 /** SMBIOS enclosure information structure */ 137 struct smbios_enclosure_information { 138 /** SMBIOS structure header */ 139 struct smbios_header header; 140 /** Manufacturer string */ 141 uint8_t manufacturer; 142 /** Type string */ 143 uint8_t type; 144 /** Version string */ 145 uint8_t version; 146 /** Serial number string */ 147 uint8_t serial; 148 /** Asset tag */ 149 uint8_t asset_tag; 150 } __attribute__ (( packed )); 151 152 /** SMBIOS enclosure information structure type */ 153 #define SMBIOS_TYPE_ENCLOSURE_INFORMATION 3 154 155 /** SMBIOS OEM strings structure type */ 156 #define SMBIOS_TYPE_OEM_STRINGS 11 157 158 /** 159 * SMBIOS entry point descriptor 160 * 161 * This contains the information from the SMBIOS entry point that we 162 * care about. 163 */ 164 struct smbios { 165 /** Start of SMBIOS structures */ 166 userptr_t address; 167 /** Length of SMBIOS structures */ 168 size_t len; 169 /** Number of SMBIOS structures */ 170 unsigned int count; 171 /** SMBIOS version */ 172 uint16_t version; 173 }; 174 175 /** 176 * Calculate SMBIOS version 177 * 178 * @v major Major version 179 * @v minor Minor version 180 * @ret version SMBIOS version 181 */ 182 #define SMBIOS_VERSION( major, minor ) ( ( (major) << 8 ) | (minor) ) 183 184 extern int find_smbios ( struct smbios *smbios ); 185 extern int find_smbios_entry ( userptr_t start, size_t len, 186 struct smbios_entry *entry ); 187 extern int find_smbios_structure ( unsigned int type, unsigned int instance, 188 struct smbios_structure *structure ); 189 extern int read_smbios_structure ( struct smbios_structure *structure, 190 void *data, size_t len ); 191 extern int read_smbios_string ( struct smbios_structure *structure, 192 unsigned int index, 193 void *data, size_t len ); 194 extern int smbios_version ( void ); 195 196 #endif /* _IPXE_SMBIOS_H */ 197