Browse Source

[smbios] Provide SMBIOS version number via smbios_version()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
4f742bcd95

+ 2
- 0
src/arch/i386/interface/pcbios/bios_smbios.c View File

77
 		smbios->address = phys_to_user ( u.entry.smbios_address );
77
 		smbios->address = phys_to_user ( u.entry.smbios_address );
78
 		smbios->len = u.entry.smbios_len;
78
 		smbios->len = u.entry.smbios_len;
79
 		smbios->count = u.entry.smbios_count;
79
 		smbios->count = u.entry.smbios_count;
80
+		smbios->version =
81
+			SMBIOS_VERSION ( u.entry.major, u.entry.minor );
80
 		return 0;
82
 		return 0;
81
 	}
83
 	}
82
 
84
 

+ 12
- 0
src/include/ipxe/smbios.h View File

148
 	size_t len;
148
 	size_t len;
149
 	/** Number of SMBIOS structures */
149
 	/** Number of SMBIOS structures */
150
 	unsigned int count;
150
 	unsigned int count;
151
+	/** SMBIOS version */
152
+	uint16_t version;
151
 };
153
 };
152
 
154
 
155
+/**
156
+ * Calculate SMBIOS version
157
+ *
158
+ * @v major		Major version
159
+ * @v minor		Minor version
160
+ * @ret version		SMBIOS version
161
+ */
162
+#define SMBIOS_VERSION( major, minor ) ( ( (major) << 8 ) | (minor) )
163
+
153
 extern int find_smbios ( struct smbios *smbios );
164
 extern int find_smbios ( struct smbios *smbios );
154
 extern int find_smbios_structure ( unsigned int type,
165
 extern int find_smbios_structure ( unsigned int type,
155
 				   struct smbios_structure *structure );
166
 				   struct smbios_structure *structure );
158
 extern int read_smbios_string ( struct smbios_structure *structure,
169
 extern int read_smbios_string ( struct smbios_structure *structure,
159
 				unsigned int index,
170
 				unsigned int index,
160
 				void *data, size_t len );
171
 				void *data, size_t len );
172
+extern int smbios_version ( void );
161
 
173
 
162
 #endif /* _IPXE_SMBIOS_H */
174
 #endif /* _IPXE_SMBIOS_H */

+ 2
- 0
src/interface/efi/efi_smbios.c View File

55
 	smbios->address = phys_to_user ( smbios_entry->smbios_address );
55
 	smbios->address = phys_to_user ( smbios_entry->smbios_address );
56
 	smbios->len = smbios_entry->smbios_len;
56
 	smbios->len = smbios_entry->smbios_len;
57
 	smbios->count = smbios_entry->smbios_count;
57
 	smbios->count = smbios_entry->smbios_count;
58
+	smbios->version =
59
+		SMBIOS_VERSION ( smbios_entry->major, smbios_entry->minor );
58
 	DBG ( "Found SMBIOS v%d.%d entry point at %p (%x+%zx)\n",
60
 	DBG ( "Found SMBIOS v%d.%d entry point at %p (%x+%zx)\n",
59
 	      smbios_entry->major, smbios_entry->minor, smbios_entry,
61
 	      smbios_entry->major, smbios_entry->minor, smbios_entry,
60
 	      smbios_entry->smbios_address, smbios->len );
62
 	      smbios_entry->smbios_address, smbios->len );

+ 17
- 0
src/interface/smbios/smbios.c View File

179
 	DBG ( "SMBIOS string index %d not found\n", index );
179
 	DBG ( "SMBIOS string index %d not found\n", index );
180
 	return -ENOENT;
180
 	return -ENOENT;
181
 }
181
 }
182
+
183
+/**
184
+ * Get SMBIOS version
185
+ *
186
+ * @ret version		Version, or negative error
187
+ */
188
+int smbios_version ( void ) {
189
+	int rc;
190
+
191
+	/* Find SMBIOS */
192
+	if ( ( smbios.address == UNULL ) &&
193
+	     ( ( rc = find_smbios ( &smbios ) ) != 0 ) )
194
+		return rc;
195
+	assert ( smbios.address != UNULL );
196
+
197
+	return smbios.version;
198
+}

Loading…
Cancel
Save