From patchwork Wed Feb 5 05:53:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 235987 List-Id: U-Boot discussion From: xypron.glpk at gmx.de (Heinrich Schuchardt) Date: Wed, 5 Feb 2020 06:53:34 +0100 Subject: [PATCH v2 1/1] efi_loader: architecture specific UEFI setup Message-ID: <20200205055334.4072-1-xypron.glpk@gmx.de> RISC-V booting currently is based on a per boot stage lottery to determine the active CPU. The Hart State Management (HSM) SBI extension replaces this lottery by using a dedicated primary CPU. Cf. Hart State Management Extension, Extension ID: 0x48534D (HSM) https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc In this scenario the id of the active hart has to be passed from boot stage to boot stage. Using a UEFI variable would provide an easy implementation. This patch provides a weak function that is called at the end of the setup of U-Boot's UEFI sub-system. By overriding this function architecture specific UEFI variables or configuration tables can be created. Signed-off-by: Heinrich Schuchardt Reviewed-by: Atish Patra --- v2: reference the Hart State Management Extension in the commit message --- include/efi_loader.h | 3 +++ lib/efi_loader/efi_setup.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) -- 2.24.1 diff --git a/include/efi_loader.h b/include/efi_loader.h index d4c59b54c4..d87de85e83 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -116,6 +116,9 @@ extern efi_uintn_t efi_memory_map_key; extern struct efi_runtime_services efi_runtime_services; extern struct efi_system_table systab; +/* Architecture specific initialization of the UEFI system */ +efi_status_t efi_setup_arch_specific(void); + extern struct efi_simple_text_output_protocol efi_con_out; extern struct efi_simple_text_input_protocol efi_con_in; extern struct efi_console_control_protocol efi_console_control; diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index de7b616c6d..8469f0f43c 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -22,6 +22,17 @@ void __weak allow_unaligned(void) { } +/** + * efi_setup_arch_specific() - architecture specific UEFI setup + * + * This routine can be used to define architecture specific variables + * or configuration tables, e.g. HART id for RISC-V + */ +efi_status_t __weak efi_setup_arch_specific(void) +{ + return EFI_SUCCESS; +} + /** * efi_init_platform_lang() - define supported languages * @@ -179,6 +190,11 @@ efi_status_t efi_init_obj_list(void) if (ret != EFI_SUCCESS) goto out; + /* Architecture specific setup */ + ret = efi_setup_arch_specific(); + if (ret != EFI_SUCCESS) + goto out; + out: efi_obj_list_initialized = ret; return ret;