]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[smbios] Provide SMBIOS version number via smbios_version()
authorMichael Brown <mcb30@ipxe.org>
Wed, 20 Mar 2013 00:12:30 +0000 (00:12 +0000)
committerMichael Brown <mcb30@ipxe.org>
Wed, 20 Mar 2013 00:12:30 +0000 (00:12 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/i386/interface/pcbios/bios_smbios.c
src/include/ipxe/smbios.h
src/interface/efi/efi_smbios.c
src/interface/smbios/smbios.c

index 2ecc24ea5a2bc9bc97d4f24039744422c86264f5..76a32e93db69081b8962d3068e4fe1be9e28aab9 100644 (file)
@@ -77,6 +77,8 @@ static int bios_find_smbios ( struct smbios *smbios ) {
                smbios->address = phys_to_user ( u.entry.smbios_address );
                smbios->len = u.entry.smbios_len;
                smbios->count = u.entry.smbios_count;
+               smbios->version =
+                       SMBIOS_VERSION ( u.entry.major, u.entry.minor );
                return 0;
        }
 
index fcf149ea7353031e8233e669982d1c604d9cfe5b..0765c4e4a3365cda290894312ab668718c724e07 100644 (file)
@@ -148,8 +148,19 @@ struct smbios {
        size_t len;
        /** Number of SMBIOS structures */
        unsigned int count;
+       /** SMBIOS version */
+       uint16_t version;
 };
 
+/**
+ * Calculate SMBIOS version
+ *
+ * @v major            Major version
+ * @v minor            Minor version
+ * @ret version                SMBIOS version
+ */
+#define SMBIOS_VERSION( major, minor ) ( ( (major) << 8 ) | (minor) )
+
 extern int find_smbios ( struct smbios *smbios );
 extern int find_smbios_structure ( unsigned int type,
                                   struct smbios_structure *structure );
@@ -158,5 +169,6 @@ extern int read_smbios_structure ( struct smbios_structure *structure,
 extern int read_smbios_string ( struct smbios_structure *structure,
                                unsigned int index,
                                void *data, size_t len );
+extern int smbios_version ( void );
 
 #endif /* _IPXE_SMBIOS_H */
index 506b04e77a51eeb4aeedb89387ba146c07e66a8e..304f95a56750905a81f231d5a383c4eff9aa0559 100644 (file)
@@ -55,6 +55,8 @@ static int efi_find_smbios ( struct smbios *smbios ) {
        smbios->address = phys_to_user ( smbios_entry->smbios_address );
        smbios->len = smbios_entry->smbios_len;
        smbios->count = smbios_entry->smbios_count;
+       smbios->version =
+               SMBIOS_VERSION ( smbios_entry->major, smbios_entry->minor );
        DBG ( "Found SMBIOS v%d.%d entry point at %p (%x+%zx)\n",
              smbios_entry->major, smbios_entry->minor, smbios_entry,
              smbios_entry->smbios_address, smbios->len );
index 8ed24dd66ace57345e6bc0c49a2e01b661e7dcb1..2adaa53d98070f98fa3d3ae3ec8be6a8f44c6414 100644 (file)
@@ -179,3 +179,20 @@ int read_smbios_string ( struct smbios_structure *structure,
        DBG ( "SMBIOS string index %d not found\n", index );
        return -ENOENT;
 }
+
+/**
+ * Get SMBIOS version
+ *
+ * @ret version                Version, or negative error
+ */
+int smbios_version ( void ) {
+       int rc;
+
+       /* Find SMBIOS */
+       if ( ( smbios.address == UNULL ) &&
+            ( ( rc = find_smbios ( &smbios ) ) != 0 ) )
+               return rc;
+       assert ( smbios.address != UNULL );
+
+       return smbios.version;
+}