From patchwork Fri Oct 19 22:07:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Auer X-Patchwork-Id: 987067 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=aisec.fraunhofer.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42cKzz5HHcz9t0P for ; Sat, 20 Oct 2018 09:18:07 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 3E01AC21C27; Fri, 19 Oct 2018 22:15:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E548CC21E16; Fri, 19 Oct 2018 22:12:47 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id F1ADCC21E16; Fri, 19 Oct 2018 22:11:18 +0000 (UTC) Received: from mail-edgeKA27.fraunhofer.de (mail-edgeka27.fraunhofer.de [153.96.1.27]) by lists.denx.de (Postfix) with ESMTPS id F23F2C21D83 for ; Fri, 19 Oct 2018 22:11:14 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2FSAAAHVspb/xwBYJlkGwEBAQEDAQEBBwMBAQGBVAMBAQELAYIEgVM6jGyLO5sWDYRsAoUJITcKDQEDAQECAQECAgJpKIU8BnQFEFE9GgYOBYMhggEBqHuKGwkBhyKEI4FYP4ERiF2FDQKISZV4BwKBDYEBBI5PCxeJK4Z+gmOTb4FZI4FVMxokgzuQWW0BjCQBAQ X-IPAS-Result: A2FSAAAHVspb/xwBYJlkGwEBAQEDAQEBBwMBAQGBVAMBAQELAYIEgVM6jGyLO5sWDYRsAoUJITcKDQEDAQECAQECAgJpKIU8BnQFEFE9GgYOBYMhggEBqHuKGwkBhyKEI4FYP4ERiF2FDQKISZV4BwKBDYEBBI5PCxeJK4Z+gmOTb4FZI4FVMxokgzuQWW0BjCQBAQ X-IronPort-AV: E=Sophos;i="5.54,401,1534802400"; d="scan'208";a="10883217" Received: from mail-mtaka28.fraunhofer.de ([153.96.1.28]) by mail-edgeKA27.fraunhofer.de with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Oct 2018 00:11:14 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CjAAAHVspb/xBhWMBkHAEBAQQBAQcEAQGBVAQBAQsBhBGMbKZRDYRsAoUpNwoNAQMBAQIBAQJtKIU7BnQFEFE9GgYOBYMhggKoe4obCQGHIoV7P4ERiF2FDQKISZV4BwKBDYEBBI5PCxeJK4Z+gmOTb4FZIoFVMxokgzuQWT0wAYwkAQE X-IronPort-AV: E=Sophos;i="5.54,401,1534802400"; d="scan'208";a="18910116" Received: from fgdemucivp01ltm.xch.fraunhofer.de (HELO FGDEMUCIMP11EXC.ads.fraunhofer.de) ([192.88.97.16]) by mail-mtaKA28.fraunhofer.de with ESMTP/TLS/AES256-SHA; 20 Oct 2018 00:10:55 +0200 Received: from localhost.de (10.80.233.50) by FGDEMUCIMP11EXC.ads.fraunhofer.de (10.80.232.42) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sat, 20 Oct 2018 00:12:14 +0200 From: Lukas Auer To: Date: Sat, 20 Oct 2018 00:07:37 +0200 Message-ID: <20181019220743.15020-25-lukas.auer@aisec.fraunhofer.de> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181019220743.15020-1-lukas.auer@aisec.fraunhofer.de> References: <20181019220743.15020-1-lukas.auer@aisec.fraunhofer.de> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-11.0.0.4179-8.200.1013-24166.002 X-TM-AS-Result: No--9.263700-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No Cc: Greentime Hu Subject: [U-Boot] [PATCH 24/30] riscv: save hart ID and device tree passed by prior boot stage X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Store the hart ID and device tree passed by the prior boot stage (in a0 and a1) in registers s0 and s1. Replace one use of s1 in start.S to avoid overwriting it. The device tree is also stored in memory to make it available to u-boot with the configuration CONFIG_OF_PRIOR_STAGE. Signed-off-by: Lukas Auer Reviewed-by: Bin Meng Reviewed-by: Rick Chen --- arch/riscv/cpu/cpu.c | 6 ++++++ arch/riscv/cpu/start.S | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c index ae57fb8313..d9f820c44c 100644 --- a/arch/riscv/cpu/cpu.c +++ b/arch/riscv/cpu/cpu.c @@ -6,6 +6,12 @@ #include #include +/* + * prior_stage_fdt_address must be stored in the data section since it is used + * before the bss section is available. + */ +phys_addr_t prior_stage_fdt_address __attribute__((section(".data"))); + enum { ISA_INVALID = 0, ISA_32BIT, diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index 4fa663c6d6..8f96c5dbe8 100644 --- a/arch/riscv/cpu/start.S +++ b/arch/riscv/cpu/start.S @@ -34,6 +34,10 @@ .section .text .globl _start _start: + /* save hart id and dtb pointer */ + mv s0, a0 + mv s1, a1 + la t0, trap_entry csrw mtvec, t0 @@ -56,6 +60,10 @@ call_board_init_f_0: mv a0, sp jal board_init_f_alloc_reserve mv sp, a0 + + la t0, prior_stage_fdt_address + SREG s1, 0(t0) + jal board_init_f_init_reserve mv a0, zero /* a0 <-- boot_flags = 0 */ @@ -138,8 +146,8 @@ fix_rela_dyn: LREG t3, -(REGBYTES*3)(t1) li t5, SYM_SIZE mul t0, t0, t5 - add s1, t4, t0 - LREG t5, REGBYTES(s1) + add s5, t4, t0 + LREG t5, REGBYTES(s5) add t5, t5, t6 /* t5 <-- location to fix up in RAM */ add t3, t3, t6 /* t3 <-- location to fix up in RAM */ SREG t5, 0(t3)