iPXE
bios_smbios.c File Reference

System Management BIOS. More...

#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <ipxe/uaccess.h>
#include <ipxe/smbios.h>
#include <realmode.h>
#include <pnpbios.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static int bios_find_smbios2 (struct smbios *smbios)
 Find SMBIOS.
static int bios_find_smbios3 (struct smbios *smbios)
 Find SMBIOS.
static int bios_find_smbios (struct smbios *smbios)
 Find SMBIOS.
 PROVIDE_SMBIOS (pcbios, find_smbios, bios_find_smbios)

Detailed Description

System Management BIOS.

Definition in file bios_smbios.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ bios_find_smbios2()

int bios_find_smbios2 ( struct smbios * smbios)
static

Find SMBIOS.

Parameters
smbiosSMBIOS entry point descriptor structure to fill in
Return values
rcReturn status code

Definition at line 47 of file bios_smbios.c.

47 {
48 const struct smbios_entry *entry;
49
50 /* Scan through BIOS segment to find SMBIOS 32-bit entry point */
51 entry = find_smbios_entry ( real_to_virt ( BIOS_SEG, 0 ), 0x10000 );
52 if ( ! entry )
53 return -ENOENT;
54
55 /* Fill in entry point descriptor structure */
56 smbios->address = phys_to_virt ( entry->smbios_address );
57 smbios->len = entry->smbios_len;
58 smbios->count = entry->smbios_count;
59 smbios->version = SMBIOS_VERSION ( entry->major, entry->minor );
60
61 return 0;
62}
#define ENOENT
No such file or directory.
Definition errno.h:515
#define SMBIOS_VERSION(major, minor)
Calculate SMBIOS version.
Definition smbios.h:216
#define BIOS_SEG
Definition pnpbios.h:13
static __always_inline void * real_to_virt(unsigned int segment, unsigned int offset)
Convert segment:offset address to virtual address.
Definition realmode.h:77
const struct smbios_entry * find_smbios_entry(const void *start, size_t len)
Scan for SMBIOS 32-bit entry point structure.
Definition smbios.c:70
SMBIOS 32-bit entry point.
Definition smbios.h:50
uint32_t smbios_address
Structure table address.
Definition smbios.h:77
uint8_t minor
Minor version.
Definition smbios.h:63
uint16_t smbios_count
Number of SMBIOS structures.
Definition smbios.h:79
uint16_t smbios_len
Structure table length.
Definition smbios.h:75
uint8_t major
Major version.
Definition smbios.h:61
SMBIOS entry point descriptor.
Definition smbios.h:198
size_t len
Length of SMBIOS structures.
Definition smbios.h:202
unsigned int count
Number of SMBIOS structures.
Definition smbios.h:204
uint16_t version
SMBIOS version.
Definition smbios.h:206
const void * address
Start of SMBIOS structures.
Definition smbios.h:200

References smbios::address, BIOS_SEG, smbios::count, ENOENT, find_smbios_entry(), smbios::len, smbios_entry::major, smbios_entry::minor, real_to_virt(), smbios_entry::smbios_address, smbios_entry::smbios_count, smbios_entry::smbios_len, SMBIOS_VERSION, and smbios::version.

Referenced by bios_find_smbios().

◆ bios_find_smbios3()

int bios_find_smbios3 ( struct smbios * smbios)
static

Find SMBIOS.

Parameters
smbiosSMBIOS entry point descriptor structure to fill in
Return values
rcReturn status code

Definition at line 70 of file bios_smbios.c.

70 {
71 const struct smbios3_entry *entry;
72
73 /* Scan through BIOS segment to find SMBIOS 64-bit entry point */
74 entry = find_smbios3_entry ( real_to_virt ( BIOS_SEG, 0 ), 0x10000 );
75 if ( ! entry )
76 return -ENOENT;
77
78 /* Check that address is accessible */
79 if ( entry->smbios_address > ~( ( physaddr_t ) 0 ) ) {
80 DBG ( "SMBIOS3 at %08llx is inaccessible\n",
81 ( ( unsigned long long ) entry->smbios_address ) );
82 return -ENOTSUP;
83 }
84
85 /* Fill in entry point descriptor structure */
86 smbios->address = phys_to_virt ( entry->smbios_address );
87 smbios->len = entry->smbios_len;
88 smbios->count = 0;
89 smbios->version = SMBIOS_VERSION ( entry->major, entry->minor );
90
91 return 0;
92}
unsigned long physaddr_t
Definition stdint.h:20
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
#define ENOTSUP
Operation not supported.
Definition errno.h:590
const struct smbios3_entry * find_smbios3_entry(const void *start, size_t len)
Scan for SMBIOS 64-bit entry point structure.
Definition smbios.c:116
SMBIOS 64-bit entry point.
Definition smbios.h:91
uint8_t major
Major version.
Definition smbios.h:104
uint64_t smbios_address
Structure table address.
Definition smbios.h:116
uint8_t minor
Minor version.
Definition smbios.h:106
uint32_t smbios_len
Structure table length.
Definition smbios.h:114

References smbios::address, BIOS_SEG, smbios::count, DBG, ENOENT, ENOTSUP, find_smbios3_entry(), smbios::len, smbios3_entry::major, smbios3_entry::minor, real_to_virt(), smbios3_entry::smbios_address, smbios3_entry::smbios_len, SMBIOS_VERSION, and smbios::version.

Referenced by bios_find_smbios().

◆ bios_find_smbios()

int bios_find_smbios ( struct smbios * smbios)
static

Find SMBIOS.

Parameters
smbiosSMBIOS entry point descriptor structure to fill in
Return values
rcReturn status code

Definition at line 100 of file bios_smbios.c.

100 {
101 int rc;
102
103 /* Use 32-bit table if present */
104 if ( ( rc = bios_find_smbios2 ( smbios ) ) == 0 )
105 return 0;
106
107 /* Otherwise, use 64-bit table if present and accessible */
108 if ( ( rc = bios_find_smbios3 ( smbios ) ) == 0 )
109 return 0;
110
111 return rc;
112}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
static int bios_find_smbios2(struct smbios *smbios)
Find SMBIOS.
Definition bios_smbios.c:47
static int bios_find_smbios3(struct smbios *smbios)
Find SMBIOS.
Definition bios_smbios.c:70

References bios_find_smbios2(), bios_find_smbios3(), and rc.

Referenced by PROVIDE_SMBIOS().

◆ PROVIDE_SMBIOS()

PROVIDE_SMBIOS ( pcbios ,
find_smbios ,
bios_find_smbios  )