Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / include / ipxe / smbios.h
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 );
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 /**
156  * SMBIOS entry point descriptor
157  *
158  * This contains the information from the SMBIOS entry point that we
159  * care about.
160  */
161 struct smbios {
162         /** Start of SMBIOS structures */
163         userptr_t address;
164         /** Length of SMBIOS structures */
165         size_t len;
166         /** Number of SMBIOS structures */
167         unsigned int count;
168         /** SMBIOS version */
169         uint16_t version;
170 };
171
172 /**
173  * Calculate SMBIOS version
174  *
175  * @v major             Major version
176  * @v minor             Minor version
177  * @ret version         SMBIOS version
178  */
179 #define SMBIOS_VERSION( major, minor ) ( ( (major) << 8 ) | (minor) )
180
181 extern int find_smbios ( struct smbios *smbios );
182 extern int find_smbios_entry ( userptr_t start, size_t len,
183                                struct smbios_entry *entry );
184 extern int find_smbios_structure ( unsigned int type, unsigned int instance,
185                                    struct smbios_structure *structure );
186 extern int read_smbios_structure ( struct smbios_structure *structure,
187                                    void *data, size_t len );
188 extern int read_smbios_string ( struct smbios_structure *structure,
189                                 unsigned int index,
190                                 void *data, size_t len );
191 extern int smbios_version ( void );
192
193 #endif /* _IPXE_SMBIOS_H */