Kaynağa Gözat

[smbios] Provide SMBIOS version number via smbios_version()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 yıl önce
ebeveyn
işleme
4f742bcd95

+ 2
- 0
src/arch/i386/interface/pcbios/bios_smbios.c Dosyayı Görüntüle

@@ -77,6 +77,8 @@ static int bios_find_smbios ( struct smbios *smbios ) {
77 77
 		smbios->address = phys_to_user ( u.entry.smbios_address );
78 78
 		smbios->len = u.entry.smbios_len;
79 79
 		smbios->count = u.entry.smbios_count;
80
+		smbios->version =
81
+			SMBIOS_VERSION ( u.entry.major, u.entry.minor );
80 82
 		return 0;
81 83
 	}
82 84
 

+ 12
- 0
src/include/ipxe/smbios.h Dosyayı Görüntüle

@@ -148,8 +148,19 @@ struct smbios {
148 148
 	size_t len;
149 149
 	/** Number of SMBIOS structures */
150 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 164
 extern int find_smbios ( struct smbios *smbios );
154 165
 extern int find_smbios_structure ( unsigned int type,
155 166
 				   struct smbios_structure *structure );
@@ -158,5 +169,6 @@ extern int read_smbios_structure ( struct smbios_structure *structure,
158 169
 extern int read_smbios_string ( struct smbios_structure *structure,
159 170
 				unsigned int index,
160 171
 				void *data, size_t len );
172
+extern int smbios_version ( void );
161 173
 
162 174
 #endif /* _IPXE_SMBIOS_H */

+ 2
- 0
src/interface/efi/efi_smbios.c Dosyayı Görüntüle

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

+ 17
- 0
src/interface/smbios/smbios.c Dosyayı Görüntüle

@@ -179,3 +179,20 @@ int read_smbios_string ( struct smbios_structure *structure,
179 179
 	DBG ( "SMBIOS string index %d not found\n", index );
180 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…
İptal
Kaydet