iPXE
smbios.h
Go to the documentation of this file.
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>
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  */
55  /** Checksum */
57  /** Length */
59  /** Major version */
61  /** Minor version */
63  /** Maximum structure size */
65  /** Entry point revision */
67  /** Formatted area */
69  /** DMI Signature */
71  /** DMI checksum */
73  /** Structure table length */
75  /** Structure table address */
77  /** Number of SMBIOS structures */
79  /** 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  */
96  /** Signature extra byte */
98  /** Checksum */
100  /** Length */
102  /** Major version */
104  /** Minor version */
106  /** Documentation revision */
108  /** Entry point revision */
110  /** Reserved */
112  /** Structure table length */
114  /** Structure table address */
116 } __attribute__ (( packed ));
117 
118 /** An SMBIOS structure header */
120  /** Type */
122  /** Length */
124  /** Handle */
126 } __attribute__ (( packed ));
127 
128 /** SMBIOS structure descriptor */
130  /** Copy of SMBIOS structure 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 */
140  /** SMBIOS structure header */
142  /** Manufacturer string */
144  /** Product string */
146  /** Version string */
148  /** Serial number string */
150  /** UUID */
152  /** Wake-up type */
154 } __attribute__ (( packed ));
155 
156 /** SMBIOS system information structure type */
157 #define SMBIOS_TYPE_SYSTEM_INFORMATION 1
158 
159 /** SMBIOS base board information structure */
161  /** SMBIOS structure header */
163  /** Manufacturer string */
165  /** Product string */
167  /** Version string */
169  /** Serial number string */
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 */
178  /** SMBIOS structure header */
180  /** Manufacturer string */
182  /** Type string */
184  /** Version string */
186  /** Serial number string */
188  /** 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 */
210  /** Length of SMBIOS structures */
211  size_t len;
212  /** Number of SMBIOS structures */
213  unsigned int count;
214  /** SMBIOS 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_smbios3_entry ( userptr_t start, size_t len,
231  struct smbios3_entry *entry );
232 extern int find_smbios_structure ( unsigned int type, unsigned int instance,
233  struct smbios_structure *structure );
234 extern int read_smbios_structure ( struct smbios_structure *structure,
235  void *data, size_t len );
236 extern int read_smbios_string ( struct smbios_structure *structure,
237  unsigned int index,
238  void *data, size_t len );
239 extern int smbios_version ( void );
240 extern void smbios_clear ( void );
241 
242 #endif /* _IPXE_SMBIOS_H */
uint8_t docrev
Documentation revision.
Definition: smbios.h:107
uint16_t max
Maximum structure size.
Definition: smbios.h:64
uint32_t signature
Signature.
Definition: smbios.h:54
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct smbios_header header
SMBIOS structure header.
Definition: smbios.h:162
size_t strings_len
Length of strings section.
Definition: smbios.h:135
unsigned short uint16_t
Definition: stdint.h:11
uint8_t serial
Serial number string.
Definition: smbios.h:187
uint8_t asset_tag
Asset tag.
Definition: smbios.h:189
uint8_t wakeup
Wake-up type.
Definition: smbios.h:153
iPXE internal APIs
uint8_t dmi_checksum
DMI checksum.
Definition: smbios.h:72
unsigned int count
Number of SMBIOS structures.
Definition: smbios.h:213
uint8_t version
Version string.
Definition: smbios.h:168
iPXE SMBIOS API for EFI
A universally unique ID.
Definition: uuid.h:15
uint8_t product
Product string.
Definition: smbios.h:145
uint8_t revision
Entry point revision.
Definition: smbios.h:66
size_t len
Length of SMBIOS structures.
Definition: smbios.h:211
unsigned long long uint64_t
Definition: stdint.h:13
SMBIOS entry point descriptor.
Definition: smbios.h:207
struct smbios_header header
Copy of SMBIOS structure header.
Definition: smbios.h:131
int smbios_version(void)
Get SMBIOS version.
Definition: smbios.c:299
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:164
int find_smbios(struct smbios *smbios)
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:181
uint8_t serial
Serial number string.
Definition: smbios.h:170
Access to external ("user") memory.
uint8_t serial
Serial number string.
Definition: smbios.h:149
uint16_t version
SMBIOS version.
Definition: smbios.h:215
struct smbios_header header
SMBIOS structure header.
Definition: smbios.h:141
uint8_t len
Length.
Definition: smbios.h:19
uint32_t start
Starting offset.
Definition: netvsc.h:12
uint8_t checksum
Checksum.
Definition: smbios.h:56
uint8_t len
Length.
Definition: smbios.h:101
uint8_t len
Length.
Definition: smbios.h:123
uint16_t smbios_len
Structure table length.
Definition: smbios.h:74
uint32_t signature
Signature.
Definition: smbios.h:95
uint8_t type
Type string.
Definition: smbios.h:183
SMBIOS 32-bit entry point.
Definition: smbios.h:49
uint32_t smbios_address
Structure table address.
Definition: smbios.h:76
uint8_t dmi_signature[5]
DMI Signature.
Definition: smbios.h:70
uint8_t version
Version string.
Definition: smbios.h:185
int find_smbios3_entry(userptr_t start, size_t len, struct smbios3_entry *entry)
Scan for SMBIOS 64-bit entry point structure.
Definition: smbios.c:112
int find_smbios_structure(unsigned int type, unsigned int instance, struct smbios_structure *structure)
Find specific structure type within SMBIOS.
Definition: smbios.c:170
iPXE SMBIOS API for Linux
union aes_table_entry entry[256]
Table entries, indexed by S(N)
Definition: aes.c:26
struct smbios_structure __attribute__
uint8_t bcd_revision
BCD revision.
Definition: smbios.h:80
uint8_t extra
Signature extra byte.
Definition: smbios.h:97
uint8_t version
Version string.
Definition: smbios.h:147
unsigned char uint8_t
Definition: stdint.h:10
uint8_t type
Type.
Definition: smbios.h:12
uint8_t revision
Entry point revision.
Definition: smbios.h:109
int read_smbios_structure(struct smbios_structure *structure, void *data, size_t len)
Copy SMBIOS structure.
Definition: smbios.c:241
uint8_t formatted[5]
Formatted area.
Definition: smbios.h:68
unsigned int uint32_t
Definition: stdint.h:12
uint16_t smbios_count
Number of SMBIOS structures.
Definition: smbios.h:78
uint8_t minor
Minor version.
Definition: smbios.h:62
int find_smbios_entry(userptr_t start, size_t len, struct smbios_entry *entry)
Scan for SMBIOS 32-bit entry point structure.
Definition: smbios.c:72
uint8_t checksum
Checksum.
Definition: smbios.h:99
int read_smbios_string(struct smbios_structure *structure, unsigned int index, void *data, size_t len)
Find indexed string within SMBIOS structure.
Definition: smbios.c:261
An SMBIOS structure header.
Definition: smbios.h:119
SMBIOS system information structure.
Definition: smbios.h:139
struct smbios_header header
SMBIOS structure header.
Definition: smbios.h:179
uint8_t type
Type.
Definition: smbios.h:121
General configuration.
uint16_t handle
Handle.
Definition: smbios.h:125
uint8_t minor
Minor version.
Definition: smbios.h:105
userptr_t address
Start of SMBIOS structures.
Definition: smbios.h:209
uint32_t smbios_len
Structure table length.
Definition: smbios.h:113
uint64_t smbios_address
Structure table address.
Definition: smbios.h:115
void smbios_clear(void)
Clear SMBIOS entry point descriptor.
Definition: smbios.c:315
uint8_t reserved
Reserved.
Definition: smbios.h:111
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:143
uint8_t len
Length.
Definition: smbios.h:58
uint8_t data[48]
Additional event data.
Definition: ena.h:22
uint8_t product
Product string.
Definition: smbios.h:166
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
SMBIOS base board information structure.
Definition: smbios.h:160
x86-specific SMBIOS API implementations
uint8_t major
Major version.
Definition: smbios.h:60
SMBIOS structure descriptor.
Definition: smbios.h:129
size_t offset
Offset of structure within SMBIOS.
Definition: smbios.h:133
SMBIOS enclosure information structure.
Definition: smbios.h:177
uint8_t major
Major version.
Definition: smbios.h:103
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33
SMBIOS 64-bit entry point.
Definition: smbios.h:90