Skip to content

Commit

Permalink
[smbios] Provide SMBIOS version number via smbios_version()
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Mar 20, 2013
1 parent 2ec0c1e commit 4f742bc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/arch/i386/interface/pcbios/bios_smbios.c
Expand Up @@ -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;
}

Expand Down
12 changes: 12 additions & 0 deletions src/include/ipxe/smbios.h
Expand Up @@ -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 );
Expand All @@ -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 */
2 changes: 2 additions & 0 deletions src/interface/efi/efi_smbios.c
Expand Up @@ -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 );
Expand Down
17 changes: 17 additions & 0 deletions src/interface/smbios/smbios.c
Expand Up @@ -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;
}

0 comments on commit 4f742bc

Please sign in to comment.