From dced22d6dee346ac4d98502c9008fd3d5c6197d2 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 29 Dec 2020 14:37:54 +0000 Subject: [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 --- src/interface/efi/efi_smbios.c | 44 +++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'src/interface/efi/efi_smbios.c') diff --git a/src/interface/efi/efi_smbios.c b/src/interface/efi/efi_smbios.c index 304f95a56..d7877b0aa 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 ); -- cgit v1.2.3-55-g7522