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 
16 /**
17  * Provide an SMBIOS API implementation
18  *
19  * @v _prefix Subsystem prefix
20  * @v _api_func API function
21  * @v _func Implementing function
22  */
23 #define PROVIDE_SMBIOS( _subsys, _api_func, _func ) \
24  PROVIDE_SINGLE_API ( SMBIOS_PREFIX_ ## _subsys, _api_func, _func )
25 
26 /* 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 system information structure */
130  /** SMBIOS structure header */
132  /** Manufacturer string */
134  /** Product string */
136  /** Version string */
138  /** Serial number string */
140  /** UUID */
142  /** Wake-up type */
144 } __attribute__ (( packed ));
145 
146 /** SMBIOS system information structure type */
147 #define SMBIOS_TYPE_SYSTEM_INFORMATION 1
148 
149 /** SMBIOS base board information structure */
151  /** SMBIOS structure header */
153  /** Manufacturer string */
155  /** Product string */
157  /** Version string */
159  /** Serial number string */
161 } __attribute__ (( packed ));
162 
163 /** SMBIOS base board information structure type */
164 #define SMBIOS_TYPE_BASE_BOARD_INFORMATION 2
165 
166 /** SMBIOS enclosure information structure */
168  /** SMBIOS structure header */
170  /** Manufacturer string */
172  /** Type string */
174  /** Version string */
176  /** Serial number string */
178  /** Asset tag */
180 } __attribute__ (( packed ));
181 
182 /** SMBIOS enclosure information structure type */
183 #define SMBIOS_TYPE_ENCLOSURE_INFORMATION 3
184 
185 /** SMBIOS OEM strings structure type */
186 #define SMBIOS_TYPE_OEM_STRINGS 11
187 
188 /** SMBIOS end of table type */
189 #define SMBIOS_TYPE_END 127
190 
191 /**
192  * SMBIOS entry point descriptor
193  *
194  * This contains the information from the SMBIOS entry point that we
195  * care about.
196  */
197 struct smbios {
198  /** Start of SMBIOS structures */
199  const void *address;
200  /** Length of SMBIOS structures */
201  size_t len;
202  /** Number of SMBIOS structures */
203  unsigned int count;
204  /** SMBIOS version */
206 };
207 
208 /**
209  * Calculate SMBIOS version
210  *
211  * @v major Major version
212  * @v minor Minor version
213  * @ret version SMBIOS version
214  */
215 #define SMBIOS_VERSION( major, minor ) ( ( (major) << 8 ) | (minor) )
216 
217 extern int find_smbios ( struct smbios *smbios );
218 extern const struct smbios_entry * find_smbios_entry ( const void *start,
219  size_t len );
220 extern const struct smbios3_entry * find_smbios3_entry ( const void *start,
221  size_t len );
222 extern const struct smbios_header * smbios_structure ( unsigned int type,
223  unsigned int instance );
224 extern const char * smbios_string ( const struct smbios_header *header,
225  unsigned int index );
226 extern int smbios_version ( void );
227 extern void smbios_clear ( void );
228 
229 #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
struct smbios_header header
SMBIOS structure header.
Definition: smbios.h:152
const char * smbios_string(const struct smbios_header *header, unsigned int index)
Get indexed string within SMBIOS structure.
Definition: smbios.c:251
unsigned short uint16_t
Definition: stdint.h:11
Null SMBIOS API.
uint8_t serial
Serial number string.
Definition: smbios.h:177
uint8_t asset_tag
Asset tag.
Definition: smbios.h:179
uint8_t wakeup
Wake-up type.
Definition: smbios.h:143
iPXE internal APIs
uint8_t dmi_checksum
DMI checksum.
Definition: smbios.h:72
unsigned int count
Number of SMBIOS structures.
Definition: smbios.h:203
uint8_t version
Version string.
Definition: smbios.h:158
iPXE SMBIOS API for EFI
A universally unique ID.
Definition: uuid.h:15
uint8_t product
Product string.
Definition: smbios.h:135
uint8_t revision
Entry point revision.
Definition: smbios.h:66
struct smbios_header header
SMBIOS structure header.
Definition: smbios.h:12
size_t len
Length of SMBIOS structures.
Definition: smbios.h:201
long index
Definition: bigint.h:62
unsigned long long uint64_t
Definition: stdint.h:13
const struct smbios3_entry * find_smbios3_entry(const void *start, size_t len)
Scan for SMBIOS 64-bit entry point structure.
Definition: smbios.c:115
SMBIOS entry point descriptor.
Definition: smbios.h:197
int smbios_version(void)
Get SMBIOS version.
Definition: smbios.c:284
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:154
int find_smbios(struct smbios *smbios)
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:171
uint8_t serial
Serial number string.
Definition: smbios.h:160
uint8_t serial
Serial number string.
Definition: smbios.h:139
uint16_t version
SMBIOS version.
Definition: smbios.h:205
struct smbios_header header
SMBIOS structure header.
Definition: smbios.h:131
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:173
const struct smbios_header * smbios_structure(unsigned int type, unsigned int instance)
Find specific structure type within SMBIOS.
Definition: smbios.c:182
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:175
iPXE SMBIOS API for Linux
struct smbios __attribute__
uint8_t bcd_revision
BCD revision.
Definition: smbios.h:80
uint8_t extra
Signature extra byte.
Definition: smbios.h:97
const void * address
Start of SMBIOS structures.
Definition: smbios.h:199
uint8_t version
Version string.
Definition: smbios.h:137
unsigned char uint8_t
Definition: stdint.h:10
const struct smbios_entry * find_smbios_entry(const void *start, size_t len)
Scan for SMBIOS 32-bit entry point structure.
Definition: smbios.c:69
uint8_t type
Type.
Definition: smbios.h:12
uint8_t revision
Entry point revision.
Definition: smbios.h:109
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
uint8_t checksum
Checksum.
Definition: smbios.h:99
An SMBIOS structure header.
Definition: smbios.h:119
SMBIOS system information structure.
Definition: smbios.h:129
struct smbios_header header
SMBIOS structure header.
Definition: smbios.h:169
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
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:300
uint8_t reserved
Reserved.
Definition: smbios.h:111
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:133
uint8_t len
Length.
Definition: smbios.h:58
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint8_t product
Product string.
Definition: smbios.h:156
SMBIOS base board information structure.
Definition: smbios.h:150
uint8_t major
Major version.
Definition: smbios.h:60
SMBIOS enclosure information structure.
Definition: smbios.h:167
uint8_t major
Major version.
Definition: smbios.h:103
SMBIOS 64-bit entry point.
Definition: smbios.h:90