mirror of https://github.com/ipxe/ipxe.git
[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>pull/312/head
parent
485f8ce554
commit
dced22d6de
|
@ -31,15 +31,20 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
/* Include all architecture-dependent SMBIOS API headers */
|
/* Include all architecture-dependent SMBIOS API headers */
|
||||||
#include <bits/smbios.h>
|
#include <bits/smbios.h>
|
||||||
|
|
||||||
/** Signature for SMBIOS entry point */
|
/** Signature for 32-bit SMBIOS entry point */
|
||||||
#define SMBIOS_SIGNATURE \
|
#define SMBIOS_SIGNATURE \
|
||||||
( ( '_' << 0 ) + ( 'S' << 8 ) + ( 'M' << 16 ) + ( '_' << 24 ) )
|
( ( '_' << 0 ) + ( 'S' << 8 ) + ( 'M' << 16 ) + ( '_' << 24 ) )
|
||||||
|
|
||||||
|
/** Signature for 64-bit SMBIOS entry point */
|
||||||
|
#define SMBIOS3_SIGNATURE \
|
||||||
|
( ( '_' << 0 ) + ( 'S' << 8 ) + ( 'M' << 16 ) + ( '3' << 24 ) )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMBIOS entry point
|
* SMBIOS 32-bit entry point
|
||||||
*
|
*
|
||||||
* This is the single table which describes the list of SMBIOS
|
* This is the 32-bit version of the table which describes the list of
|
||||||
* structures. It is located by scanning through the BIOS segment.
|
* SMBIOS structures. It may be located by scanning through the BIOS
|
||||||
|
* segment or via an EFI configuration table.
|
||||||
*/
|
*/
|
||||||
struct smbios_entry {
|
struct smbios_entry {
|
||||||
/** Signature
|
/** Signature
|
||||||
|
@ -75,6 +80,41 @@ struct smbios_entry {
|
||||||
uint8_t bcd_revision;
|
uint8_t bcd_revision;
|
||||||
} __attribute__ (( packed ));
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SMBIOS 64-bit entry point
|
||||||
|
*
|
||||||
|
* This is the 64-bit version of the table which describes the list of
|
||||||
|
* SMBIOS structures. It may be located by scanning through the BIOS
|
||||||
|
* segment or via an EFI configuration table.
|
||||||
|
*/
|
||||||
|
struct smbios3_entry {
|
||||||
|
/** Signature
|
||||||
|
*
|
||||||
|
* Must be equal to SMBIOS3_SIGNATURE
|
||||||
|
*/
|
||||||
|
uint32_t signature;
|
||||||
|
/** Signature extra byte */
|
||||||
|
uint8_t extra;
|
||||||
|
/** Checksum */
|
||||||
|
uint8_t checksum;
|
||||||
|
/** Length */
|
||||||
|
uint8_t len;
|
||||||
|
/** Major version */
|
||||||
|
uint8_t major;
|
||||||
|
/** Minor version */
|
||||||
|
uint8_t minor;
|
||||||
|
/** Documentation revision */
|
||||||
|
uint8_t docrev;
|
||||||
|
/** Entry point revision */
|
||||||
|
uint8_t revision;
|
||||||
|
/** Reserved */
|
||||||
|
uint8_t reserved;
|
||||||
|
/** Structure table length */
|
||||||
|
uint32_t smbios_len;
|
||||||
|
/** Structure table address */
|
||||||
|
uint64_t smbios_address;
|
||||||
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
/** An SMBIOS structure header */
|
/** An SMBIOS structure header */
|
||||||
struct smbios_header {
|
struct smbios_header {
|
||||||
/** Type */
|
/** Type */
|
||||||
|
@ -155,6 +195,9 @@ struct smbios_enclosure_information {
|
||||||
/** SMBIOS OEM strings structure type */
|
/** SMBIOS OEM strings structure type */
|
||||||
#define SMBIOS_TYPE_OEM_STRINGS 11
|
#define SMBIOS_TYPE_OEM_STRINGS 11
|
||||||
|
|
||||||
|
/** SMBIOS end of table type */
|
||||||
|
#define SMBIOS_TYPE_END 127
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMBIOS entry point descriptor
|
* SMBIOS entry point descriptor
|
||||||
*
|
*
|
||||||
|
|
|
@ -34,6 +34,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
static struct smbios_entry *smbios_entry;
|
static struct smbios_entry *smbios_entry;
|
||||||
EFI_USE_TABLE ( SMBIOS_TABLE, &smbios_entry, 0 );
|
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
|
* Find SMBIOS
|
||||||
*
|
*
|
||||||
|
@ -42,26 +46,34 @@ EFI_USE_TABLE ( SMBIOS_TABLE, &smbios_entry, 0 );
|
||||||
*/
|
*/
|
||||||
static int efi_find_smbios ( struct smbios *smbios ) {
|
static int efi_find_smbios ( struct smbios *smbios ) {
|
||||||
|
|
||||||
if ( ! smbios_entry ) {
|
/* Use 64-bit table if present */
|
||||||
DBG ( "No SMBIOS table provided\n" );
|
if ( smbios3_entry && ( smbios3_entry->signature == SMBIOS3_SIGNATURE ) ) {
|
||||||
return -ENODEV;
|
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 ) {
|
/* Otherwise, use 32-bit table if present */
|
||||||
DBG ( "Invalid SMBIOS signature\n" );
|
if ( smbios_entry && ( smbios_entry->signature == SMBIOS_SIGNATURE ) ) {
|
||||||
return -ENODEV;
|
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 );
|
DBG ( "No SMBIOS table provided\n" );
|
||||||
smbios->len = smbios_entry->smbios_len;
|
return -ENODEV;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PROVIDE_SMBIOS ( efi, find_smbios, efi_find_smbios );
|
PROVIDE_SMBIOS ( efi, find_smbios, efi_find_smbios );
|
||||||
|
|
|
@ -130,8 +130,8 @@ int find_smbios_structure ( unsigned int type, unsigned int instance,
|
||||||
assert ( smbios.address != UNULL );
|
assert ( smbios.address != UNULL );
|
||||||
|
|
||||||
/* Scan through list of structures */
|
/* Scan through list of structures */
|
||||||
while ( ( ( offset + sizeof ( structure->header ) ) < smbios.len )
|
while ( ( ( offset + sizeof ( structure->header ) ) < smbios.len ) &&
|
||||||
&& ( count < smbios.count ) ) {
|
( ( smbios.count == 0 ) || ( count < smbios.count ) ) ) {
|
||||||
|
|
||||||
/* Read next SMBIOS structure header */
|
/* Read next SMBIOS structure header */
|
||||||
copy_from_user ( &structure->header, smbios.address, offset,
|
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,
|
"strings length %zx\n", offset, structure->header.type,
|
||||||
structure->header.len, structure->strings_len );
|
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 this is the structure we want, return */
|
||||||
if ( ( structure->header.type == type ) &&
|
if ( ( structure->header.type == type ) &&
|
||||||
( instance-- == 0 ) ) {
|
( instance-- == 0 ) ) {
|
||||||
|
|
Loading…
Reference in New Issue