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