1 // SPDX-License-Identifier: GPL-2.0+
3 * EFI application tables support
5 * Copyright (c) 2016 Alexander Graf
8 #define LOG_CATEGORY LOGC_EFI
10 #include <efi_loader.h>
15 #include <linux/sizes.h>
16 #include <asm/global_data.h>
18 DECLARE_GLOBAL_DATA_PTR;
20 const efi_guid_t smbios3_guid = SMBIOS3_TABLE_GUID;
27 * Install the SMBIOS table as a configuration table.
31 efi_status_t efi_smbios_register(void)
37 addr = gd_smbios_start();
39 log_err("No SMBIOS tables to install\n");
43 /* Mark space used for tables */
44 ret = efi_add_memory_map(addr, TABLE_SIZE, EFI_RUNTIME_SERVICES_DATA);
48 log_debug("EFI using SMBIOS tables at %lx\n", addr);
50 /* Install SMBIOS information as configuration table */
51 buf = map_sysmem(addr, 0);
52 ret = efi_install_configuration_table(&smbios3_guid, buf);
58 static int install_smbios_table(void)
63 if (!IS_ENABLED(CONFIG_GENERATE_SMBIOS_TABLE) ||
64 IS_ENABLED(CONFIG_X86) ||
65 IS_ENABLED(CONFIG_QFW_SMBIOS))
68 /* Align the table to a 4KB boundary to keep EFI happy */
69 buf = memalign(SZ_4K, TABLE_SIZE);
71 return log_msg_ret("mem", -ENOMEM);
73 addr = map_to_sysmem(buf);
74 if (!write_smbios_table(addr)) {
75 log_err("Failed to write SMBIOS table\n");
76 return log_msg_ret("smbios", -EINVAL);
79 /* Make a note of where we put it */
80 log_debug("SMBIOS tables written to %lx\n", addr);
81 gd->arch.smbios_start = addr;
85 EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, install_smbios_table);