diff options
author | Michael Brown <mcb30@ipxe.org> | 2020-12-29 14:37:54 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2020-12-29 14:41:50 +0000 |
commit | dced22d6dee346ac4d98502c9008fd3d5c6197d2 (patch) | |
tree | 6d01b40c5cafc6b1a9962b097ec54d439c8807ad /src/interface | |
parent | 485f8ce5547f5c165b4eeecb388bc7e1ce5cad12 (diff) | |
download | ipxe-dced22d6dee346ac4d98502c9008fd3d5c6197d2.zip ipxe-dced22d6dee346ac4d98502c9008fd3d5c6197d2.tar.gz ipxe-dced22d6dee346ac4d98502c9008fd3d5c6197d2.tar.bz2 |
[smbios] Add support for the 64-bit SMBIOS3 entry point
Support UEFI systems that provide only 64-bit versions of the SMBIOS
entry point.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface')
-rw-r--r-- | src/interface/efi/efi_smbios.c | 44 | ||||
-rw-r--r-- | src/interface/smbios/smbios.c | 9 |
2 files changed, 35 insertions, 18 deletions
diff --git a/src/interface/efi/efi_smbios.c b/src/interface/efi/efi_smbios.c index 304f95a..d7877b0 100644 --- a/src/interface/efi/efi_smbios.c +++ b/src/interface/efi/efi_smbios.c @@ -34,6 +34,10 @@ FILE_LICENCE ( GPL2_OR_LATER ); static struct smbios_entry *smbios_entry; EFI_USE_TABLE ( SMBIOS_TABLE, &smbios_entry, 0 ); +/** SMBIOS configuration table */ +static struct smbios3_entry *smbios3_entry; +EFI_USE_TABLE ( SMBIOS3_TABLE, &smbios3_entry, 0 ); + /** * Find SMBIOS * @@ -42,26 +46,34 @@ EFI_USE_TABLE ( SMBIOS_TABLE, &smbios_entry, 0 ); */ static int efi_find_smbios ( struct smbios *smbios ) { - if ( ! smbios_entry ) { - DBG ( "No SMBIOS table provided\n" ); - return -ENODEV; + /* Use 64-bit table if present */ + if ( smbios3_entry && ( smbios3_entry->signature == SMBIOS3_SIGNATURE ) ) { + smbios->address = phys_to_user ( smbios3_entry->smbios_address ); + smbios->len = smbios3_entry->smbios_len; + smbios->count = 0; + smbios->version = + SMBIOS_VERSION ( smbios3_entry->major, smbios3_entry->minor ); + DBG ( "Found 64-bit SMBIOS v%d.%d entry point at %p (%lx+%zx)\n", + smbios3_entry->major, smbios3_entry->minor, smbios3_entry, + user_to_phys ( smbios->address, 0 ), smbios->len ); + return 0; } - if ( smbios_entry->signature != SMBIOS_SIGNATURE ) { - DBG ( "Invalid SMBIOS signature\n" ); - return -ENODEV; + /* Otherwise, use 32-bit table if present */ + if ( smbios_entry && ( smbios_entry->signature == SMBIOS_SIGNATURE ) ) { + 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 32-bit SMBIOS v%d.%d entry point at %p (%lx+%zx)\n", + smbios_entry->major, smbios_entry->minor, smbios_entry, + user_to_phys ( smbios->address, 0 ), smbios->len ); + return 0; } - 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 ); - - return 0; + DBG ( "No SMBIOS table provided\n" ); + return -ENODEV; } PROVIDE_SMBIOS ( efi, find_smbios, efi_find_smbios ); diff --git a/src/interface/smbios/smbios.c b/src/interface/smbios/smbios.c index 1dcf819..5bd76f1 100644 --- a/src/interface/smbios/smbios.c +++ b/src/interface/smbios/smbios.c @@ -130,8 +130,8 @@ int find_smbios_structure ( unsigned int type, unsigned int instance, assert ( smbios.address != UNULL ); /* Scan through list of structures */ - while ( ( ( offset + sizeof ( structure->header ) ) < smbios.len ) - && ( count < smbios.count ) ) { + while ( ( ( offset + sizeof ( structure->header ) ) < smbios.len ) && + ( ( smbios.count == 0 ) || ( count < smbios.count ) ) ) { /* Read next SMBIOS structure header */ copy_from_user ( &structure->header, smbios.address, offset, @@ -157,6 +157,11 @@ int find_smbios_structure ( unsigned int type, unsigned int instance, "strings length %zx\n", offset, structure->header.type, structure->header.len, structure->strings_len ); + /* Stop if we have reached an end-of-table marker */ + if ( ( smbios.count == 0 ) && + ( structure->header.type == SMBIOS_TYPE_END ) ) + break; + /* If this is the structure we want, return */ if ( ( structure->header.type == type ) && ( instance-- == 0 ) ) { |