]> Git Repo - u-boot.git/blame - lib/efi_loader/efi_smbios.c
Merge branch '2023-07-24-introduce-FF-A-suppport'
[u-boot.git] / lib / efi_loader / efi_smbios.c
CommitLineData
f739fcd8 1// SPDX-License-Identifier: GPL-2.0+
e663b350
AG
2/*
3 * EFI application tables support
4 *
5 * Copyright (c) 2016 Alexander Graf
e663b350
AG
6 */
7
c193d9bd
HS
8#define LOG_CATEGORY LOGC_EFI
9
e663b350
AG
10#include <common.h>
11#include <efi_loader.h>
f7ae49fc 12#include <log.h>
a2505fc8 13#include <mapmem.h>
e663b350
AG
14#include <smbios.h>
15
7657152b
HS
16/*
17 * Install the SMBIOS table as a configuration table.
18 *
185f812c 19 * Return: status code
7657152b
HS
20 */
21efi_status_t efi_smbios_register(void)
e663b350
AG
22{
23 /* Map within the low 32 bits, to allow for 32bit SMBIOS tables */
a2505fc8 24 u64 dmi_addr = U32_MAX;
7657152b 25 efi_status_t ret;
a2505fc8 26 void *dmi;
e663b350 27
7657152b
HS
28 /* Reserve 4kiB page for SMBIOS */
29 ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
a2505fc8 30 EFI_RUNTIME_SERVICES_DATA, 1, &dmi_addr);
62f37578
AG
31
32 if (ret != EFI_SUCCESS) {
33 /* Could not find space in lowmem, use highmem instead */
34 ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
a2505fc8
SG
35 EFI_RUNTIME_SERVICES_DATA, 1,
36 &dmi_addr);
62f37578
AG
37
38 if (ret != EFI_SUCCESS)
39 return ret;
40 }
e663b350 41
0864c565
SG
42 /*
43 * Generate SMBIOS tables - we know that efi_allocate_pages() returns
44 * a 4k-aligned address, so it is safe to assume that
45 * write_smbios_table() will write the table at that address.
46 */
a2505fc8
SG
47 assert(!(dmi_addr & 0xf));
48 dmi = (void *)(uintptr_t)dmi_addr;
c193d9bd
HS
49 if (write_smbios_table(map_to_sysmem(dmi)))
50 /* Install SMBIOS information as configuration table */
51 return efi_install_configuration_table(&smbios_guid, dmi);
52 efi_free_pages(dmi_addr, 1);
53 log_err("Cannot create SMBIOS table\n");
54 return EFI_SUCCESS;
e663b350 55}
This page took 0.161899 seconds and 4 git commands to generate.