iPXE
efi_smbios.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  */
19 
20 FILE_LICENCE ( GPL2_OR_LATER );
21 
22 #include <errno.h>
23 #include <ipxe/uaccess.h>
24 #include <ipxe/smbios.h>
25 #include <ipxe/efi/efi.h>
26 #include <ipxe/efi/Guid/SmBios.h>
27 
28 /** @file
29  *
30  * iPXE SMBIOS API for EFI
31  *
32  */
33 
34 /** SMBIOS configuration table */
35 static struct smbios_entry *smbios_entry;
36 EFI_USE_TABLE ( SMBIOS_TABLE, &smbios_entry, 0 );
37 
38 /** SMBIOS configuration table */
40 EFI_USE_TABLE ( SMBIOS3_TABLE, &smbios3_entry, 0 );
41 
42 /**
43  * Find SMBIOS
44  *
45  * @v smbios SMBIOS entry point descriptor structure to fill in
46  * @ret rc Return status code
47  */
48 static int efi_find_smbios ( struct smbios *smbios ) {
49 
50  /* Use 64-bit table if present */
52  smbios->address = phys_to_virt ( smbios3_entry->smbios_address );
54  smbios->count = 0;
55  smbios->version =
57  DBG ( "Found 64-bit SMBIOS v%d.%d entry point at %p (%lx+%zx)\n",
59  virt_to_phys ( smbios->address ), smbios->len );
60  return 0;
61  }
62 
63  /* Otherwise, use 32-bit table if present */
65  smbios->address = phys_to_virt ( smbios_entry->smbios_address );
68  smbios->version =
70  DBG ( "Found 32-bit SMBIOS v%d.%d entry point at %p (%lx+%zx)\n",
72  virt_to_phys ( smbios->address ), smbios->len );
73  return 0;
74  }
75 
76  DBG ( "No SMBIOS table provided\n" );
77  return -ENODEV;
78 }
79 
uint32_t signature
Signature.
Definition: smbios.h:54
#define SMBIOS_SIGNATURE
Signature for 32-bit SMBIOS entry point.
Definition: smbios.h:35
unsigned int count
Number of SMBIOS structures.
Definition: smbios.h:203
Error codes.
size_t len
Length of SMBIOS structures.
Definition: smbios.h:201
SMBIOS entry point descriptor.
Definition: smbios.h:197
#define SMBIOS3_SIGNATURE
Signature for 64-bit SMBIOS entry point.
Definition: smbios.h:39
int find_smbios(struct smbios *smbios)
uint16_t version
SMBIOS version.
Definition: smbios.h:205
PROVIDE_SMBIOS(efi, find_smbios, efi_find_smbios)
uint16_t smbios_len
Structure table length.
Definition: smbios.h:74
Access to external ("user") memory.
uint32_t signature
Signature.
Definition: smbios.h:95
SMBIOS 32-bit entry point.
Definition: smbios.h:49
uint32_t smbios_address
Structure table address.
Definition: smbios.h:76
#define SMBIOS_VERSION(major, minor)
Calculate SMBIOS version.
Definition: smbios.h:215
static struct smbios_entry * smbios_entry
SMBIOS configuration table.
Definition: efi_smbios.c:35
const void * address
Start of SMBIOS structures.
Definition: smbios.h:199
#define ENODEV
No such device.
Definition: errno.h:509
EFI_USE_TABLE(SMBIOS_TABLE, &smbios_entry, 0)
FILE_LICENCE(GPL2_OR_LATER)
uint16_t smbios_count
Number of SMBIOS structures.
Definition: smbios.h:78
EFI API.
System Management BIOS.
static int efi_find_smbios(struct smbios *smbios)
Find SMBIOS.
Definition: efi_smbios.c:48
uint8_t minor
Minor version.
Definition: smbios.h:62
GUIDs used to locate the SMBIOS tables in the UEFI 2.5 system table.
uint8_t minor
Minor version.
Definition: smbios.h:105
uint32_t smbios_len
Structure table length.
Definition: smbios.h:113
uint64_t smbios_address
Structure table address.
Definition: smbios.h:115
static struct smbios3_entry * smbios3_entry
SMBIOS configuration table.
Definition: efi_smbios.c:39
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
uint8_t major
Major version.
Definition: smbios.h:60
uint8_t major
Major version.
Definition: smbios.h:103
SMBIOS 64-bit entry point.
Definition: smbios.h:90