mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-19 17:53:08 +00:00
53fab13a7b
U-Boot should set up the SMBIOS tables during startup, as it does on x86. Ensure that it does this correctly on non-x86 machines too, by creating an event spy for last-stage init. Tidy up the installation-condition code while we are here. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
75 lines
1.6 KiB
C
75 lines
1.6 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* EFI application tables support
|
|
*
|
|
* Copyright (c) 2016 Alexander Graf
|
|
*/
|
|
|
|
#define LOG_CATEGORY LOGC_EFI
|
|
|
|
#include <common.h>
|
|
#include <efi_loader.h>
|
|
#include <log.h>
|
|
#include <malloc.h>
|
|
#include <mapmem.h>
|
|
#include <smbios.h>
|
|
#include <linux/sizes.h>
|
|
|
|
enum {
|
|
TABLE_SIZE = SZ_4K,
|
|
};
|
|
|
|
/*
|
|
* Install the SMBIOS table as a configuration table.
|
|
*
|
|
* Return: status code
|
|
*/
|
|
efi_status_t efi_smbios_register(void)
|
|
{
|
|
ulong addr;
|
|
efi_status_t ret;
|
|
|
|
addr = gd->arch.smbios_start;
|
|
if (!addr) {
|
|
log_err("No SMBIOS tables to install\n");
|
|
return EFI_NOT_FOUND;
|
|
}
|
|
|
|
/* Mark space used for tables */
|
|
ret = efi_add_memory_map(addr, TABLE_SIZE, EFI_RUNTIME_SERVICES_DATA);
|
|
if (ret)
|
|
return ret;
|
|
|
|
log_debug("EFI using SMBIOS tables at %lx\n", addr);
|
|
|
|
/* Install SMBIOS information as configuration table */
|
|
return efi_install_configuration_table(&smbios_guid,
|
|
map_sysmem(addr, 0));
|
|
}
|
|
|
|
static int install_smbios_table(void)
|
|
{
|
|
ulong addr;
|
|
void *buf;
|
|
|
|
if (!IS_ENABLED(CONFIG_GENERATE_SMBIOS_TABLE) || IS_ENABLED(CONFIG_X86))
|
|
return 0;
|
|
|
|
/* Align the table to a 4KB boundary to keep EFI happy */
|
|
buf = memalign(SZ_4K, TABLE_SIZE);
|
|
if (!buf)
|
|
return log_msg_ret("mem", -ENOMEM);
|
|
|
|
addr = map_to_sysmem(buf);
|
|
if (!write_smbios_table(addr)) {
|
|
log_err("Failed to write SMBIOS table\n");
|
|
return log_msg_ret("smbios", -EINVAL);
|
|
}
|
|
|
|
/* Make a note of where we put it */
|
|
log_debug("SMBIOS tables written to %lx\n", addr);
|
|
gd->arch.smbios_start = addr;
|
|
|
|
return 0;
|
|
}
|
|
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, install_smbios_table);
|