[efi] Attempt to fetch autoexec script via TFTP
[ipxe.git] / src / interface / efi / efi_smbios.c
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/smbios.h>
24 #include <ipxe/efi/efi.h>
25 #include <ipxe/efi/Guid/SmBios.h>
26
27 /** @file
28 *
29 * iPXE SMBIOS API for EFI
30 *
31 */
32
33 /** SMBIOS configuration table */
34 static struct smbios_entry *smbios_entry;
35 EFI_USE_TABLE ( SMBIOS_TABLE, &smbios_entry, 0 );
36
37 /** SMBIOS configuration table */
38 static struct smbios3_entry *smbios3_entry;
39 EFI_USE_TABLE ( SMBIOS3_TABLE, &smbios3_entry, 0 );
40
41 /**
42 * Find SMBIOS
43 *
44 * @v smbios SMBIOS entry point descriptor structure to fill in
45 * @ret rc Return status code
46 */
47 static int efi_find_smbios ( struct smbios *smbios ) {
48
49 /* Use 64-bit table if present */
50 if ( smbios3_entry && ( smbios3_entry->signature == SMBIOS3_SIGNATURE ) ) {
51 smbios->address = phys_to_user ( smbios3_entry->smbios_address );
52 smbios->len = smbios3_entry->smbios_len;
53 smbios->count = 0;
54 smbios->version =
55 SMBIOS_VERSION ( smbios3_entry->major, smbios3_entry->minor );
56 DBG ( "Found 64-bit SMBIOS v%d.%d entry point at %p (%lx+%zx)\n",
57 smbios3_entry->major, smbios3_entry->minor, smbios3_entry,
58 user_to_phys ( smbios->address, 0 ), smbios->len );
59 return 0;
60 }
61
62 /* Otherwise, use 32-bit table if present */
63 if ( smbios_entry && ( smbios_entry->signature == SMBIOS_SIGNATURE ) ) {
64 smbios->address = phys_to_user ( smbios_entry->smbios_address );
65 smbios->len = smbios_entry->smbios_len;
66 smbios->count = smbios_entry->smbios_count;
67 smbios->version =
68 SMBIOS_VERSION ( smbios_entry->major, smbios_entry->minor );
69 DBG ( "Found 32-bit SMBIOS v%d.%d entry point at %p (%lx+%zx)\n",
70 smbios_entry->major, smbios_entry->minor, smbios_entry,
71 user_to_phys ( smbios->address, 0 ), smbios->len );
72 return 0;
73 }
74
75 DBG ( "No SMBIOS table provided\n" );
76 return -ENODEV;
77 }
78
79 PROVIDE_SMBIOS ( efi, find_smbios, efi_find_smbios );