tizen 2.3.1 release
[external/qemu.git] / 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 enclosure information structure */
120 struct smbios_enclosure_information {
121         /** SMBIOS structure header */
122         struct smbios_header header;
123         /** Manufacturer string */
124         uint8_t manufacturer;
125         /** Type string */
126         uint8_t type;
127         /** Version string */
128         uint8_t version;
129         /** Serial number string */
130         uint8_t serial;
131         /** Asset tag */
132         uint8_t asset_tag;
133 } __attribute__ (( packed ));
134
135 /** SMBIOS enclosure information structure type */
136 #define SMBIOS_TYPE_ENCLOSURE_INFORMATION 3
137
138 /**
139  * SMBIOS entry point descriptor
140  *
141  * This contains the information from the SMBIOS entry point that we
142  * care about.
143  */
144 struct smbios {
145         /** Start of SMBIOS structures */
146         userptr_t address;
147         /** Length of SMBIOS structures */
148         size_t len;
149         /** Number of SMBIOS structures */
150         unsigned int count;
151 };
152
153 extern int find_smbios ( struct smbios *smbios );
154 extern int find_smbios_structure ( unsigned int type,
155                                    struct smbios_structure *structure );
156 extern int read_smbios_structure ( struct smbios_structure *structure,
157                                    void *data, size_t len );
158 extern int read_smbios_string ( struct smbios_structure *structure,
159                                 unsigned int index,
160                                 void *data, size_t len );
161
162 #endif /* _IPXE_SMBIOS_H */