Add a 'coreboot' cpu to armv8 that looks for the coreboot table near the top of the 4G address space.
Signed-off-by: Stephen Boyd <swb...@chromium.org> --- arch/arm/cpu/armv8/Makefile | 1 + arch/arm/cpu/armv8/coreboot/Makefile | 4 ++++ arch/arm/cpu/armv8/coreboot/cpu.c | 33 ++++++++++++++++++++++++++++ arch/arm/include/asm/global_data.h | 3 +++ arch/x86/cpu/cpu.c | 13 ----------- include/cb_sysinfo.h | 7 ++++++ lib/coreboot/Kconfig | 14 ++++++------ lib/coreboot/cb_sysinfo.c | 13 +++++++++++ 8 files changed, 68 insertions(+), 20 deletions(-) create mode 100644 arch/arm/cpu/armv8/coreboot/Makefile create mode 100644 arch/arm/cpu/armv8/coreboot/cpu.c diff --git a/arch/arm/cpu/armv8/Makefile b/arch/arm/cpu/armv8/Makefile index b4126c61df15..39258a07db6c 100644 --- a/arch/arm/cpu/armv8/Makefile +++ b/arch/arm/cpu/armv8/Makefile @@ -48,3 +48,4 @@ obj-$(CONFIG_ARMV8_CE_SHA1) += sha1_ce_glue.o sha1_ce_core.o obj-$(CONFIG_ARMV8_CE_SHA256) += sha256_ce_glue.o sha256_ce_core.o obj-$(CONFIG_SYSINFO_SMBIOS) += sysinfo.o +obj-$(CONFIG_SYS_COREBOOT) += coreboot/ diff --git a/arch/arm/cpu/armv8/coreboot/Makefile b/arch/arm/cpu/armv8/coreboot/Makefile new file mode 100644 index 000000000000..0eca9ff05900 --- /dev/null +++ b/arch/arm/cpu/armv8/coreboot/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-y += cpu.o + diff --git a/arch/arm/cpu/armv8/coreboot/cpu.c b/arch/arm/cpu/armv8/coreboot/cpu.c new file mode 100644 index 000000000000..05ceff967989 --- /dev/null +++ b/arch/arm/cpu/armv8/coreboot/cpu.c @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <cb_sysinfo.h> +#include <linux/errno.h> +#include <linux/sizes.h> +#include <log.h> + +long locate_coreboot_table(void) +{ + long addr; + + /* + * We look for LBIO somewhere inside the CBMEM arena, which is + * typically at the top of the first 4G of RAM. + */ + addr = detect_coreboot_table_at(SZ_4G - SZ_8M, SZ_8M); + if (addr < 0) + return -ENOENT; + + debug("Located coreboot table at %#lx\n", addr); + return addr; +} + +int arch_cpu_init(void) +{ + int ret; + + ret = get_coreboot_info(&lib_sysinfo); + if (ret != 0) + debug("Failed to parse coreboot tables.\n"); + + return 0; +} diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h index 45401d5e3c8a..70299aec2df4 100644 --- a/arch/arm/include/asm/global_data.h +++ b/arch/arm/include/asm/global_data.h @@ -108,6 +108,9 @@ struct arch_global_data { #ifdef CONFIG_SMBIOS ulong smbios_start; /* Start address of SMBIOS table */ #endif +#ifdef CONFIG_SYS_COREBOOT + ulong coreboot_table; /* Address of coreboot table */ +#endif }; #include <asm-generic/global_data.h> diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c index 9ac2a6bf4a09..704a00e26045 100644 --- a/arch/x86/cpu/cpu.c +++ b/arch/x86/cpu/cpu.c @@ -340,19 +340,6 @@ int reserve_arch(void) } #endif -static long detect_coreboot_table_at(ulong start, ulong size) -{ - u32 *ptr, *end; - - size /= 4; - for (ptr = (void *)start, end = ptr + size; ptr < end; ptr += 4) { - if (*ptr == 0x4f49424c) /* "LBIO" */ - return (long)ptr; - } - - return -ENOENT; -} - long locate_coreboot_table(void) { long addr; diff --git a/include/cb_sysinfo.h b/include/cb_sysinfo.h index 62a483e10cef..3bd997dcca39 100644 --- a/include/cb_sysinfo.h +++ b/include/cb_sysinfo.h @@ -228,6 +228,13 @@ struct sysinfo_t { extern struct sysinfo_t lib_sysinfo; +/** + * detect_coreboot_table_at() - Helper to find coreboot table + * + * Return: Address of coreboot table or -ENOENT on failure + */ +long detect_coreboot_table_at(ulong start, ulong size); + /** * get_coreboot_info() - parse the coreboot sysinfo table * diff --git a/lib/coreboot/Kconfig b/lib/coreboot/Kconfig index 870693dca66c..eb686ac3c69f 100644 --- a/lib/coreboot/Kconfig +++ b/lib/coreboot/Kconfig @@ -1,9 +1,9 @@ menu "U-Boot as Coreboot payload" - depends on VENDOR_COREBOOT + depends on ARM64 || VENDOR_COREBOOT config SYS_COREBOOT - bool - default y + bool "Support for booting u-boot as a coreboot payload" if ARM64 + default VENDOR_COREBOOT imply SYS_NS16550 imply SCSI imply SCSI_AHCI @@ -17,15 +17,15 @@ config SYS_COREBOOT imply USB_XHCI_HCD imply USB_STORAGE imply USB_KEYBOARD - imply VIDEO_COREBOOT - imply E1000 + imply VIDEO_COREBOOT if x86 + imply E1000 if x86 imply ETH_DESIGNWARE - imply PCH_GBE + imply PCH_GBE if X86 imply RTL8169 imply CMD_CBFS imply FS_CBFS imply CBMEM_CONSOLE - imply X86_TSC_READ_BASE + imply X86_TSC_READ_BASE if X86 imply USE_PREBOOT select BINMAN if X86_64 select SYSINFO diff --git a/lib/coreboot/cb_sysinfo.c b/lib/coreboot/cb_sysinfo.c index f8f2002d46f0..36cd352818a2 100644 --- a/lib/coreboot/cb_sysinfo.c +++ b/lib/coreboot/cb_sysinfo.c @@ -446,6 +446,19 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info) return 1; } +long detect_coreboot_table_at(ulong start, ulong size) +{ + u32 *ptr, *end; + + size /= 4; + for (ptr = (void *)start, end = ptr + size; ptr < end; ptr += 4) { + if (*ptr == 0x4f49424c) /* "LBIO" */ + return (long)ptr; + } + + return -ENOENT; +} + int get_coreboot_info(struct sysinfo_t *info) { long addr; -- Sent by a computer, using git, on the internet