blob: 7c3fc8af0b250f316ff37557fba4f914de07fb1f [file] [log] [blame]
Tom Rinif739fcd2018-05-07 17:02:21 -04001// SPDX-License-Identifier: GPL-2.0+
Alexander Grafe663b352016-08-19 01:23:29 +02002/*
3 * EFI application tables support
4 *
5 * Copyright (c) 2016 Alexander Graf
Alexander Grafe663b352016-08-19 01:23:29 +02006 */
7
8#include <common.h>
9#include <efi_loader.h>
10#include <inttypes.h>
11#include <smbios.h>
12
13static const efi_guid_t smbios_guid = SMBIOS_TABLE_GUID;
14
Heinrich Schuchardt76571522018-03-03 15:28:54 +010015/*
16 * Install the SMBIOS table as a configuration table.
17 *
18 * @return status code
19 */
20efi_status_t efi_smbios_register(void)
Alexander Grafe663b352016-08-19 01:23:29 +020021{
22 /* Map within the low 32 bits, to allow for 32bit SMBIOS tables */
Heinrich Schuchardt76571522018-03-03 15:28:54 +010023 u64 dmi = U32_MAX;
24 efi_status_t ret;
Alexander Grafe663b352016-08-19 01:23:29 +020025
Heinrich Schuchardt76571522018-03-03 15:28:54 +010026 /* Reserve 4kiB page for SMBIOS */
27 ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
28 EFI_RUNTIME_SERVICES_DATA, 1, &dmi);
29 if (ret != EFI_SUCCESS)
30 return ret;
Alexander Grafe663b352016-08-19 01:23:29 +020031
Simon Glass0864c562018-05-16 09:42:19 -060032 /*
33 * Generate SMBIOS tables - we know that efi_allocate_pages() returns
34 * a 4k-aligned address, so it is safe to assume that
35 * write_smbios_table() will write the table at that address.
36 */
37 assert(!(dmi & 0xf));
Alexander Grafe663b352016-08-19 01:23:29 +020038 write_smbios_table(dmi);
39
40 /* And expose them to our EFI payload */
Heinrich Schuchardt76571522018-03-03 15:28:54 +010041 return efi_install_configuration_table(&smbios_guid,
42 (void *)(uintptr_t)dmi);
Alexander Grafe663b352016-08-19 01:23:29 +020043}