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: 1233664 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=D5MY3Efn; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48C9jm2vz4z9sSY for ; Wed, 5 Feb 2020 16:54:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DDEB7819C7; Wed, 5 Feb 2020 06:53:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="D5MY3Efn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AD4A5819D7; Wed, 5 Feb 2020 06:53:47 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CA6FD819C6 for ; Wed, 5 Feb 2020 06:53:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1580882020; bh=Pv0X8yAi/bFfMRCSGVv5actteI0c84jJH1otGQt3NNA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=D5MY3EfnXTHyBJNi7SO+b+p17BFOKqzZoO/yxsUs7JuPwZzfD2+v9SP0QOtok/7ov U5/m176ToO0vHOB9VJsSqL1A+WVfAco7wFWQ7150O/5rdQd20hrPlO9Y59CY9hpfYR 231LI7hprOMTFGGl/GpOKtJG6T7GKwI4oiXt7W2o= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([84.119.33.160]) by mail.gmx.com (mrgmx004 [212.227.17.184]) with ESMTPSA (Nemesis) id 1MMobO-1jHqwZ3shQ-00ImXy; Wed, 05 Feb 2020 06:53:40 +0100 From: Heinrich Schuchardt To: Alexander Graf Subject: [PATCH v2 1/1] efi_loader: architecture specific UEFI setup Date: Wed, 5 Feb 2020 06:53:34 +0100 Message-Id: <20200205055334.4072-1-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:IyP9HolpkloI6Rps32KfKTaavy47UZ6FpXCw537oC9aluhHG7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ky6wwInkOXcAvXOPtDNn3kh0bSR/C AwvMjmdTmyB+Vt54VOXYO32XG8hjVAE+H8ezMdYLZTKYPrFCAksWTpIh1lko/GLBcki7Dzj24 0qZgFn0R/1KJ0AdKUXXVIBn7IP5TOIuQyysBM8N/Z1fIbjO07CKabcHqQxL0lYCRTfIOyh938 i5rIHERSOsXYS9CRfp+5USIbD5gFcWxu9uWOe/OdUUUMmk9xr+JCGwiaHXdaWXqdkGBdgKOH1 T22lTG+UTr+UA8uVVZqBPqu+AgsTUkuqglo1omSBdlAMi2ae29rccOiBXXdi5ZycsuiSm58gS NETlKJfJL3SfvHHmhmRoOheb+5ePSA8pdLv5A+bUJLrnVFAInQQwGatOBoRz2roi9pKdYuMnT 1A8F6Uv9TWzW5alet X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: u-boot@lists.denx.de, Ard Biesheuvel , Heinrich Schuchardt , Atish Patra Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean 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;