• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _GPXE_SMBIOS_H
2 #define _GPXE_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 <gpxe/api.h>
14 #include <config/general.h>
15 #include <gpxe/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 <gpxe/efi/efi_smbios.h>
29 
30 /* Include all architecture-dependent SMBIOS API headers */
31 #include <bits/smbios.h>
32 
33 /** Signature for SMBIOS entry point */
34 #define SMBIOS_SIGNATURE \
35         ( ( '_' << 0 ) + ( 'S' << 8 ) + ( 'M' << 16 ) + ( '_' << 24 ) )
36 
37 /**
38  * SMBIOS entry point
39  *
40  * This is the single table which describes the list of SMBIOS
41  * structures.  It is located by scanning through the BIOS segment.
42  */
43 struct smbios_entry {
44 	/** Signature
45 	 *
46 	 * Must be equal to SMBIOS_SIGNATURE
47 	 */
48 	uint32_t signature;
49 	/** Checksum */
50 	uint8_t checksum;
51 	/** Length */
52 	uint8_t len;
53 	/** Major version */
54 	uint8_t major;
55 	/** Minor version */
56 	uint8_t minor;
57 	/** Maximum structure size */
58 	uint16_t max;
59 	/** Entry point revision */
60 	uint8_t revision;
61 	/** Formatted area */
62 	uint8_t formatted[5];
63 	/** DMI Signature */
64 	uint8_t dmi_signature[5];
65 	/** DMI checksum */
66 	uint8_t dmi_checksum;
67 	/** Structure table length */
68 	uint16_t smbios_len;
69 	/** Structure table address */
70 	uint32_t smbios_address;
71 	/** Number of SMBIOS structures */
72 	uint16_t smbios_count;
73 	/** BCD revision */
74 	uint8_t bcd_revision;
75 } __attribute__ (( packed ));
76 
77 /** An SMBIOS structure header */
78 struct smbios_header {
79 	/** Type */
80 	uint8_t type;
81 	/** Length */
82 	uint8_t len;
83 	/** Handle */
84 	uint16_t handle;
85 } __attribute__ (( packed ));
86 
87 /** SMBIOS structure descriptor */
88 struct smbios_structure {
89 	/** Copy of SMBIOS structure header */
90 	struct smbios_header header;
91 	/** Offset of structure within SMBIOS */
92 	size_t offset;
93 	/** Length of strings section */
94 	size_t strings_len;
95 };
96 
97 /** SMBIOS system information structure */
98 struct smbios_system_information {
99 	/** SMBIOS structure header */
100 	struct smbios_header header;
101 	/** Manufacturer string */
102 	uint8_t manufacturer;
103 	/** Product string */
104 	uint8_t product;
105 	/** Version string */
106 	uint8_t version;
107 	/** Serial number string */
108 	uint8_t serial;
109 	/** UUID */
110 	uint8_t uuid[16];
111 	/** Wake-up type */
112 	uint8_t wakeup;
113 } __attribute__ (( packed ));
114 
115 /** SMBIOS system information structure type */
116 #define SMBIOS_TYPE_SYSTEM_INFORMATION 1
117 
118 /** SMBIOS enclosure information structure */
119 struct smbios_enclosure_information {
120 	/** SMBIOS structure header */
121 	struct smbios_header header;
122 	/** Manufacturer string */
123 	uint8_t manufacturer;
124 	/** Type string */
125 	uint8_t type;
126 	/** Version string */
127 	uint8_t version;
128 	/** Serial number string */
129 	uint8_t serial;
130 	/** Asset tag */
131 	uint8_t asset_tag;
132 } __attribute__ (( packed ));
133 
134 /** SMBIOS enclosure information structure type */
135 #define SMBIOS_TYPE_ENCLOSURE_INFORMATION 3
136 
137 /**
138  * SMBIOS entry point descriptor
139  *
140  * This contains the information from the SMBIOS entry point that we
141  * care about.
142  */
143 struct smbios {
144 	/** Start of SMBIOS structures */
145 	userptr_t address;
146 	/** Length of SMBIOS structures */
147 	size_t len;
148 	/** Number of SMBIOS structures */
149 	unsigned int count;
150 };
151 
152 extern int find_smbios ( struct smbios *smbios );
153 extern int find_smbios_structure ( unsigned int type,
154 				   struct smbios_structure *structure );
155 extern int read_smbios_structure ( struct smbios_structure *structure,
156 				   void *data, size_t len );
157 extern int read_smbios_string ( struct smbios_structure *structure,
158 				unsigned int index,
159 				void *data, size_t len );
160 
161 #endif /* _GPXE_SMBIOS_H */
162