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 FILE_SECBOOT ( PERMITTED );
12 
13 #include <stdint.h>
14 #include <ipxe/api.h>
15 #include <config/general.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 */
29 #include <ipxe/efi/efi_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 system information structure */
131  /** SMBIOS structure header */
133  /** Manufacturer string */
135  /** Product string */
137  /** Version string */
139  /** Serial number string */
141  /** UUID */
143  /** Wake-up type */
145 } __attribute__ (( packed ));
146 
147 /** SMBIOS system information structure type */
148 #define SMBIOS_TYPE_SYSTEM_INFORMATION 1
149 
150 /** SMBIOS base board information structure */
152  /** SMBIOS structure header */
154  /** Manufacturer string */
156  /** Product string */
158  /** Version string */
160  /** Serial number string */
162 } __attribute__ (( packed ));
163 
164 /** SMBIOS base board information structure type */
165 #define SMBIOS_TYPE_BASE_BOARD_INFORMATION 2
166 
167 /** SMBIOS enclosure information structure */
169  /** SMBIOS structure header */
171  /** Manufacturer string */
173  /** Type string */
175  /** Version string */
177  /** Serial number string */
179  /** Asset tag */
181 } __attribute__ (( packed ));
182 
183 /** SMBIOS enclosure information structure type */
184 #define SMBIOS_TYPE_ENCLOSURE_INFORMATION 3
185 
186 /** SMBIOS OEM strings structure type */
187 #define SMBIOS_TYPE_OEM_STRINGS 11
188 
189 /** SMBIOS end of table type */
190 #define SMBIOS_TYPE_END 127
191 
192 /**
193  * SMBIOS entry point descriptor
194  *
195  * This contains the information from the SMBIOS entry point that we
196  * care about.
197  */
198 struct smbios {
199  /** Start of SMBIOS structures */
200  const void *address;
201  /** Length of SMBIOS structures */
202  size_t len;
203  /** Number of SMBIOS structures */
204  unsigned int count;
205  /** SMBIOS version */
207 };
208 
209 /**
210  * Calculate SMBIOS version
211  *
212  * @v major Major version
213  * @v minor Minor version
214  * @ret version SMBIOS version
215  */
216 #define SMBIOS_VERSION( major, minor ) ( ( (major) << 8 ) | (minor) )
217 
218 extern int find_smbios ( struct smbios *smbios );
219 extern const struct smbios_entry * find_smbios_entry ( const void *start,
220  size_t len );
221 extern const struct smbios3_entry * find_smbios3_entry ( const void *start,
222  size_t len );
223 extern const struct smbios_header * smbios_structure ( unsigned int type,
224  unsigned int instance );
225 extern const char * smbios_string ( const struct smbios_header *header,
226  unsigned int index );
227 extern int smbios_version ( void );
228 extern void smbios_clear ( void );
229 
230 #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:153
const char * smbios_string(const struct smbios_header *header, unsigned int index)
Get indexed string within SMBIOS structure.
Definition: smbios.c:252
unsigned short uint16_t
Definition: stdint.h:11
Null SMBIOS API.
uint8_t serial
Serial number string.
Definition: smbios.h:178
uint8_t asset_tag
Asset tag.
Definition: smbios.h:180
uint8_t wakeup
Wake-up type.
Definition: smbios.h:144
iPXE internal APIs
uint8_t dmi_checksum
DMI checksum.
Definition: smbios.h:73
unsigned int count
Number of SMBIOS structures.
Definition: smbios.h:204
uint8_t version
Version string.
Definition: smbios.h:159
iPXE SMBIOS API for EFI
A universally unique ID.
Definition: uuid.h:16
uint8_t product
Product string.
Definition: smbios.h:136
uint8_t revision
Entry point revision.
Definition: smbios.h:67
struct smbios_header header
SMBIOS structure header.
Definition: smbios.h:13
size_t len
Length of SMBIOS structures.
Definition: smbios.h:202
long index
Definition: bigint.h:65
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:116
SMBIOS entry point descriptor.
Definition: smbios.h:198
int smbios_version(void)
Get SMBIOS version.
Definition: smbios.c:285
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:155
int find_smbios(struct smbios *smbios)
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:172
uint8_t serial
Serial number string.
Definition: smbios.h:161
uint8_t serial
Serial number string.
Definition: smbios.h:140
uint16_t version
SMBIOS version.
Definition: smbios.h:206
struct smbios_header header
SMBIOS structure header.
Definition: smbios.h:132
uint8_t len
Length.
Definition: smbios.h:20
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
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:174
const struct smbios_header * smbios_structure(unsigned int type, unsigned int instance)
Find specific structure type within SMBIOS.
Definition: smbios.c:183
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:176
FILE_SECBOOT(PERMITTED)
iPXE SMBIOS API for Linux
struct smbios __attribute__
uint8_t bcd_revision
BCD revision.
Definition: smbios.h:81
uint8_t extra
Signature extra byte.
Definition: smbios.h:98
const void * address
Start of SMBIOS structures.
Definition: smbios.h:200
uint8_t version
Version string.
Definition: smbios.h:138
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:70
uint8_t type
Type.
Definition: smbios.h:13
uint8_t revision
Entry point revision.
Definition: smbios.h:110
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
uint8_t checksum
Checksum.
Definition: smbios.h:100
An SMBIOS structure header.
Definition: smbios.h:120
SMBIOS system information structure.
Definition: smbios.h:130
struct smbios_header header
SMBIOS structure header.
Definition: smbios.h:170
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
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:301
uint8_t reserved
Reserved.
Definition: smbios.h:112
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:134
uint8_t len
Length.
Definition: smbios.h:59
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint8_t product
Product string.
Definition: smbios.h:157
SMBIOS base board information structure.
Definition: smbios.h:151
uint8_t major
Major version.
Definition: smbios.h:61
SMBIOS enclosure information structure.
Definition: smbios.h:168
uint8_t major
Major version.
Definition: smbios.h:104
SMBIOS 64-bit entry point.
Definition: smbios.h:91