From patchwork Mon Apr 23 05:59:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 133953 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp616848lji; Sun, 22 Apr 2018 23:02:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/xm5812etrPUlD4dqtjgWYnyrOBR2VE8E10XYvQTmze8i9O0cbQgdJ65DcJhLgwRi+i/Ck X-Received: by 10.80.165.246 with SMTP id b51mr26386140edc.147.1524463368860; Sun, 22 Apr 2018 23:02:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524463368; cv=none; d=google.com; s=arc-20160816; b=Wj2rUY7IbDHX3d8JU9R5WIFXU2QDXjSu+gKi5Zrpecg0Idmt3E9y+4pBFGwiQ5UvyK EdTBPyNwsJbeXSIIvqVCLmg246UbC0dQC8nNvw/a3iq7At55Hvht8Favu2E2m9yohBD9 KxwJnwVATK4vMPxWh6xlFXvnTdbJetgZJ0h66XuvkrLalLVe4yikgqLufb7RMP424O3L GY/lWHqwcdXkoJXjRthBGZASeXBSuqyKJ/26ceWZdP0bJhaAOy5Nf8p0gNTwuYZ/qUbg mNq0uAZBYnJqFRMmnvRO56zyZLB8syJssUflPVWOxDeT2sW2Jgc1y/CLbHgH06G6iEfB 88zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=z0MZGJsQL0BFtqW+Je/b/FhRDWjoAwmbPgDDAUCb0so=; b=TN688IPLWyc+OLHwHHopJ52hJJAJ+joIrySLWfWiPvJoLS+qGyPe6F0yNqOGoH4dO0 E1GTkHIwGxCiffz/I/a8gpk/gr9oq+QTDK2At4kgQagoJ91O1fkNSl9OTInFGCmq1Ul7 8xIMxH5e1aKyBA4DpdM3do9S4UyW+PfHPPtk9Si70GLHCTOdcBNhqsVI5LN/s/rv59Ap VbL0gPSG/YazoCVZB6bdWOM7FPu0z2uqLDbNdw7bqwzRlzGNHaFzkg4IXoUdMARsZj+0 WmbtLt4dwow8eGXDXtTcygpTM/dNKURK2bkS68rbvD7mozOJ5I79UCAeB6Wc5NXAvo5/ ORcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id m7si488188eda.200.2018.04.22.23.02.48; Sun, 22 Apr 2018 23:02:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 736E6C21DD7; Mon, 23 Apr 2018 06:01:17 +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=RCVD_IN_DNSWL_BLOCKED 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 61246C21DB3; Mon, 23 Apr 2018 06:00:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 49B89C21D8E; Mon, 23 Apr 2018 05:59:52 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id AE1DDC21DA6 for ; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 51A30AC7F; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 23 Apr 2018 07:59:43 +0200 Message-Id: <20180423055950.78818-2-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180423055950.78818-1-agraf@suse.de> References: <20180423055950.78818-1-agraf@suse.de> Cc: Heinrich Schuchardt , schwab@suse.de, Greentime Hu Subject: [U-Boot] [PATCH v3 1/8] riscv: Add setjmp/longjmp code 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" To support efi_loader we need to have platform support for setjmp/longjmp. Add it here. Signed-off-by: Alexander Graf Reviewed-by: Rick Chen --- v1 -> v2: - Allow 32bit target - Also save/restore ra, sp --- arch/riscv/include/asm/setjmp.h | 26 ++++++++++++++++ arch/riscv/lib/Makefile | 1 + arch/riscv/lib/setjmp.S | 66 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 arch/riscv/include/asm/setjmp.h create mode 100644 arch/riscv/lib/setjmp.S diff --git a/arch/riscv/include/asm/setjmp.h b/arch/riscv/include/asm/setjmp.h new file mode 100644 index 0000000000..01ad6d081f --- /dev/null +++ b/arch/riscv/include/asm/setjmp.h @@ -0,0 +1,26 @@ +/* + * (C) Copyright 2018 Alexander Graf + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef _SETJMP_H_ +#define _SETJMP_H_ 1 + +/* + * This really should be opaque, but the EFI implementation wrongly + * assumes that a 'struct jmp_buf_data' is defined. + */ +struct jmp_buf_data { + /* x2, x8, x9, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, sp */ + unsigned long s_regs[12]; /* s0 - s11 */ + unsigned long ra; + unsigned long sp; +}; + +typedef struct jmp_buf_data jmp_buf[1]; + +int setjmp(jmp_buf jmp); +void longjmp(jmp_buf jmp, int ret); + +#endif /* _SETJMP_H_ */ diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile index 323cf3e835..6d97aa2719 100644 --- a/arch/riscv/lib/Makefile +++ b/arch/riscv/lib/Makefile @@ -12,3 +12,4 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o obj-$(CONFIG_CMD_GO) += boot.o obj-y += cache.o obj-y += interrupts.o +obj-y += setjmp.o diff --git a/arch/riscv/lib/setjmp.S b/arch/riscv/lib/setjmp.S new file mode 100644 index 0000000000..103f359185 --- /dev/null +++ b/arch/riscv/lib/setjmp.S @@ -0,0 +1,66 @@ +/* + * (C) 2018 Alexander Graf + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include + +#ifdef CONFIG_CPU_RISCV_64 +#define STORE_IDX(reg, idx) sd reg, (idx*8)(a0) +#define LOAD_IDX(reg, idx) ld reg, (idx*8)(a0) +#else +#define STORE_IDX(reg, idx) sw reg, (idx*4)(a0) +#define LOAD_IDX(reg, idx) lw reg, (idx*4)(a0) +#endif + +.pushsection .text.setjmp, "ax" +ENTRY(setjmp) + /* Preserve all callee-saved registers and the SP */ + STORE_IDX(s0, 0) + STORE_IDX(s1, 1) + STORE_IDX(s2, 2) + STORE_IDX(s3, 3) + STORE_IDX(s4, 4) + STORE_IDX(s5, 5) + STORE_IDX(s6, 6) + STORE_IDX(s7, 7) + STORE_IDX(s8, 8) + STORE_IDX(s9, 9) + STORE_IDX(s10, 10) + STORE_IDX(s11, 11) + STORE_IDX(ra, 12) + STORE_IDX(sp, 13) + li a0, 0 + ret +ENDPROC(setjmp) +.popsection + +.pushsection .text.longjmp, "ax" +ENTRY(longjmp) + LOAD_IDX(s0, 0) + LOAD_IDX(s1, 1) + LOAD_IDX(s2, 2) + LOAD_IDX(s3, 3) + LOAD_IDX(s4, 4) + LOAD_IDX(s5, 5) + LOAD_IDX(s6, 6) + LOAD_IDX(s7, 7) + LOAD_IDX(s8, 8) + LOAD_IDX(s9, 9) + LOAD_IDX(s10, 10) + LOAD_IDX(s11, 11) + LOAD_IDX(ra, 12) + LOAD_IDX(sp, 13) + + /* Move the return value in place, but return 1 if passed 0. */ + beq a1, zero, longjmp_1 + mv a0, a1 + ret + + longjmp_1: + li a0, 1 + ret +ENDPROC(longjmp) +.popsection From patchwork Mon Apr 23 05:59:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 133956 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp618770lji; Sun, 22 Apr 2018 23:05:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx481k7GVOm6R7o93sUcYVkrxmYxp+BLk2Teyt5Dp47r/6+NY+G0xVsQLSNShy/6YQlu0nsSF X-Received: by 10.167.212.137 with SMTP id b9mr12152305edr.121.1524463508363; Sun, 22 Apr 2018 23:05:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524463508; cv=none; d=google.com; s=arc-20160816; b=c/9i+UlrlzLMqwM31iLGZsR+6JwI6ZZvAjtMSHqWnD6BTOaZeO3vdfoxml6QDIMDez fY00jZtc6gs6PokBhkHf5AuaTtyziq+7LNIKi+EP1WoT7Y63O3GqHwSn37i8a1OV9T3j XvWeV5QkniedLsLjZux+2bAdqHOIeVv1e8wQCzTroKVzgE0VixQfuJ9xAIXXNEo+fBog YI2odvdSdOr8aFe4JDwQZE1/sAglTUBRmuf0/+uQMNuzW/yAJbmZhoY2c79kRTVg7DiK /KTZroTqfDyB8rfoOoMp8H4Iaeit+BHba5Y/IigiI2yVny3TNhV4a1hyiMA4fuZk9LpC 8sTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=HkE7PgZzxlAabLS5GdFfEUunbVRUidOklEb/dM3CVaU=; b=U7WR3sb+BXOvfIEve3vr3Kyw3iMnoIxE+qT/pnVGxiVeZgt2etFweSCFOeMC371ePN eMEPC+grwZ5OhuOHYOQbFTkMxWewyYb6gHX43X58m5mY9Jar+KeLLulm339nIz0wTItc h4J+P+S1O6FlWnmmIN4X5TcrsBBy3+5vtcA5/wImnT3OxGhgnlr7lD/l2mKUpRPWSHwh RUSPZ1AlNf7gxdn0LB1k4hauJ3wU7Id7ZEMtHv1cicVXB2s3c0Df0leSV7aNAXk8tRXd vjf7DS4y6pxxrsDUeVvx0vhd0y1kga0dlzEaa/nycMezwqpJPrphT1yq32UFvdOQyPp8 T9gQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id r11si258890edc.362.2018.04.22.23.05.07; Sun, 22 Apr 2018 23:05:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id C26BFC21DF8; Mon, 23 Apr 2018 06:02:14 +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=RCVD_IN_DNSWL_BLOCKED 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 4F59AC21E30; Mon, 23 Apr 2018 06:00:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8C1D4C21D8E; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 9108CC21DFB for ; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 58027ADA9; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 23 Apr 2018 07:59:44 +0200 Message-Id: <20180423055950.78818-3-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180423055950.78818-1-agraf@suse.de> References: <20180423055950.78818-1-agraf@suse.de> Cc: Heinrich Schuchardt , schwab@suse.de, Greentime Hu Subject: [U-Boot] [PATCH v3 2/8] riscv: Enable function sections 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The linker can remove sections that are never addressed, so it makes a lot of sense to declare every function as an individual section. This reduces the output U-Boot code size by ~30kb for me. Signed-off-by: Alexander Graf Reviewed-by: Rick Chen --- arch/riscv/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk index 6b681c4286..69f4cf6ce8 100644 --- a/arch/riscv/config.mk +++ b/arch/riscv/config.mk @@ -29,5 +29,5 @@ CONFIG_STANDALONE_LOAD_ADDR = 0x00000000 \ -T $(srctree)/examples/standalone/riscv.lds PLATFORM_CPPFLAGS += -ffixed-gp -fpic -PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2 +PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2 -ffunction-sections LDFLAGS_u-boot += --gc-sections -static -pie From patchwork Mon Apr 23 05:59:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 133954 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp616997lji; Sun, 22 Apr 2018 23:03:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+1XkfNjLwmCQlqff/G++MO39jqd0/maRyrc48x7AHRgphTXp5wlDwyAFFTxn1txPZkP0nR X-Received: by 10.80.208.156 with SMTP id v28mr21401438edd.137.1524463380464; Sun, 22 Apr 2018 23:03:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524463380; cv=none; d=google.com; s=arc-20160816; b=F/MDP4lCDVidHV+NUxJVFaOTFZKdxQv88QLvXvu05257hzuUOL2H6yjGU7vQIeQbWy qItzhruL6ib+dQfL+IH9WMe+gogDeskNeSb7fJqfBfds/fr2GVTNygrkHDVcMUCG+qSA bHwmFXxvrJRAfCk/mg4vTiWjmj+H5BG5jHSqKPBR+AJxKTjUpCuNVi6vKpBdxJCfqVeI 9NuWt+xdfUv4pgEBBTCNtv8M0mo+/5KwJ4Awj6bzdxO7Odnx0A7h2LD3aLohp+DwsPhd juYA2bKmmolg9GAojcNKZcSsK4Wa5IWQct5hkB/nCZvV2TGXX7mssvlkKp+KMyPq+RSV 3w1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=F6RK0d5+jKb9NQy2HbmWWlQk/kGlRwj4sRP5s4QYB9M=; b=09zo6sht3vsH1cGymHwvQapRFq2Fy0D0mlxW63vea0HirNN1RoJ+fnissXfn2lxuu6 Zxn+9LM9rIUDVXBnDhy0bd4J2XgVxnLqTWcdo4tk99Dj7Yw8LhZSN/zic0v0uX+yw5vf 1zCth/j8erBgR+oinIEmMWByGi0S42ZMxuH//fgLw5smC/sv+74OHcT8MyY9GWvM25Aj EfBDEFij4YyEDMba01UXVZDFLqqCjHSYA0hB3R2tQ8zv5byzq7w8u4Z0Nu1oaE/nXbA1 jGWdr5tEyZnn8vmffXm+Co48qOwmzIuZtPrdSywQRWEdjUnRY036vzio87q7wSQPd5p7 l0Hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id m44si2501915edd.71.2018.04.22.23.03.00; Sun, 22 Apr 2018 23:03:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 0A3F5C21CB6; Mon, 23 Apr 2018 06:01:38 +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=RCVD_IN_DNSWL_BLOCKED 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 CAD85C21E1D; Mon, 23 Apr 2018 06:00:05 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5FAB9C21C6A; Mon, 23 Apr 2018 05:59:52 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id BCAC0C21DB5 for ; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 61228AE17; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 23 Apr 2018 07:59:45 +0200 Message-Id: <20180423055950.78818-4-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180423055950.78818-1-agraf@suse.de> References: <20180423055950.78818-1-agraf@suse.de> Cc: Heinrich Schuchardt , schwab@suse.de, Greentime Hu Subject: [U-Boot] [PATCH v3 3/8] riscv: Add EFI application infrastructure 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The hello world binary and a few selftests require to build EFI target binaries, not just the EFI host environment. This patch adds all required files to generate an EFI binary for RISC-V. Signed-off-by: Alexander Graf --- new in v2 v2 -> v3: - Add missing crt0 source --- arch/riscv/config.mk | 5 ++ arch/riscv/lib/Makefile | 11 +++ arch/riscv/lib/crt0_riscv_efi.S | 152 +++++++++++++++++++++++++++++++++++++ arch/riscv/lib/elf_riscv32_efi.lds | 70 +++++++++++++++++ arch/riscv/lib/elf_riscv64_efi.lds | 70 +++++++++++++++++ arch/riscv/lib/reloc_riscv_efi.c | 97 +++++++++++++++++++++++ 6 files changed, 405 insertions(+) create mode 100644 arch/riscv/lib/crt0_riscv_efi.S create mode 100644 arch/riscv/lib/elf_riscv32_efi.lds create mode 100644 arch/riscv/lib/elf_riscv64_efi.lds create mode 100644 arch/riscv/lib/reloc_riscv_efi.c diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk index 69f4cf6ce8..9175aa765d 100644 --- a/arch/riscv/config.mk +++ b/arch/riscv/config.mk @@ -19,10 +19,12 @@ endif ifdef CONFIG_32BIT PLATFORM_LDFLAGS += -m $(32bit-emul) +EFI_LDS := elf_riscv32_efi.lds endif ifdef CONFIG_64BIT PLATFORM_LDFLAGS += -m $(64bit-emul) +EFI_LDS := elf_riscv64_efi.lds endif CONFIG_STANDALONE_LOAD_ADDR = 0x00000000 \ @@ -31,3 +33,6 @@ CONFIG_STANDALONE_LOAD_ADDR = 0x00000000 \ PLATFORM_CPPFLAGS += -ffixed-gp -fpic PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2 -ffunction-sections LDFLAGS_u-boot += --gc-sections -static -pie + +EFI_CRT0 := crt0_riscv_efi.o +EFI_RELOC := reloc_riscv_efi.o diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile index 6d97aa2719..33f80ebdca 100644 --- a/arch/riscv/lib/Makefile +++ b/arch/riscv/lib/Makefile @@ -13,3 +13,14 @@ obj-$(CONFIG_CMD_GO) += boot.o obj-y += cache.o obj-y += interrupts.o obj-y += setjmp.o + +# For building EFI apps +CFLAGS_$(EFI_CRT0) := $(CFLAGS_EFI) +CFLAGS_REMOVE_$(EFI_CRT0) := $(CFLAGS_NON_EFI) + +CFLAGS_$(EFI_RELOC) := $(CFLAGS_EFI) +CFLAGS_REMOVE_$(EFI_RELOC) := $(CFLAGS_NON_EFI) + +extra-$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE) += $(EFI_CRT0) $(EFI_RELOC) +extra-$(CONFIG_CMD_BOOTEFI_SELFTEST) += $(EFI_CRT0) $(EFI_RELOC) +extra-$(CONFIG_EFI) += $(EFI_CRT0) $(EFI_RELOC) diff --git a/arch/riscv/lib/crt0_riscv_efi.S b/arch/riscv/lib/crt0_riscv_efi.S new file mode 100644 index 0000000000..498870e1be --- /dev/null +++ b/arch/riscv/lib/crt0_riscv_efi.S @@ -0,0 +1,152 @@ +/* + * crt0-efi-riscv.S - PE/COFF header for RISC-V EFI applications + * + * Copright (C) 2014 Linaro Ltd. + * Copright (C) 2018 Alexander Graf + * + * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause + * + * This file is inspired by arch/arm/lib/crt0_aarch64_efi.S + */ + +#include + +#if __riscv_xlen == 64 +#define SIZE_LONG 8 +#define SAVE_LONG(reg, idx) sd reg, (idx*SIZE_LONG)(sp) +#define LOAD_LONG(reg, idx) ld reg, (idx*SIZE_LONG)(sp) +#define PE_MACHINE 0x5064 +#else +#define SIZE_LONG 4 +#define SAVE_LONG(reg, idx) sw reg, (idx*SIZE_LONG)(sp) +#define LOAD_LONG(reg, idx) lw reg, (idx*SIZE_LONG)(sp) +#define PE_MACHINE 0x5032 +#endif + + + .section .text.head + + /* + * Magic "MZ" signature for PE/COFF + */ + .globl ImageBase +ImageBase: + .ascii "MZ" + .skip 58 /* 'MZ' + pad + offset == 64 */ + .long pe_header - ImageBase /* Offset to the PE header */ +pe_header: + .ascii "PE" + .short 0 +coff_header: + .short PE_MACHINE /* RISC-V 64/32-bit */ + .short 2 /* nr_sections */ + .long 0 /* TimeDateStamp */ + .long 0 /* PointerToSymbolTable */ + .long 1 /* NumberOfSymbols */ + .short section_table - optional_header /* SizeOfOptionalHeader */ + /* + * Characteristics: IMAGE_FILE_DEBUG_STRIPPED | + * IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_LINE_NUMS_STRIPPED + */ + .short 0x206 +optional_header: + .short 0x20b /* PE32+ format */ + .byte 0x02 /* MajorLinkerVersion */ + .byte 0x14 /* MinorLinkerVersion */ + .long _edata - _start /* SizeOfCode */ + .long 0 /* SizeOfInitializedData */ + .long 0 /* SizeOfUninitializedData */ + .long _start - ImageBase /* AddressOfEntryPoint */ + .long _start - ImageBase /* BaseOfCode */ + +extra_header_fields: + .quad 0 /* ImageBase */ + .long 0x20 /* SectionAlignment */ + .long 0x8 /* FileAlignment */ + .short 0 /* MajorOperatingSystemVersion */ + .short 0 /* MinorOperatingSystemVersion */ + .short 0 /* MajorImageVersion */ + .short 0 /* MinorImageVersion */ + .short 0 /* MajorSubsystemVersion */ + .short 0 /* MinorSubsystemVersion */ + .long 0 /* Win32VersionValue */ + + .long _edata - ImageBase /* SizeOfImage */ + + /* + * Everything before the kernel image is considered part of the header + */ + .long _start - ImageBase /* SizeOfHeaders */ + .long 0 /* CheckSum */ + .short IMAGE_SUBSYSTEM_EFI_APPLICATION /* Subsystem */ + .short 0 /* DllCharacteristics */ + .quad 0 /* SizeOfStackReserve */ + .quad 0 /* SizeOfStackCommit */ + .quad 0 /* SizeOfHeapReserve */ + .quad 0 /* SizeOfHeapCommit */ + .long 0 /* LoaderFlags */ + .long 0x6 /* NumberOfRvaAndSizes */ + + .quad 0 /* ExportTable */ + .quad 0 /* ImportTable */ + .quad 0 /* ResourceTable */ + .quad 0 /* ExceptionTable */ + .quad 0 /* CertificationTable */ + .quad 0 /* BaseRelocationTable */ + + /* Section table */ +section_table: + + /* + * The EFI application loader requires a relocation section + * because EFI applications must be relocatable. This is a + * dummy section as far as we are concerned. + */ + .ascii ".reloc" + .byte 0 + .byte 0 /* end of 0 padding of section name */ + .long 0 + .long 0 + .long 0 /* SizeOfRawData */ + .long 0 /* PointerToRawData */ + .long 0 /* PointerToRelocations */ + .long 0 /* PointerToLineNumbers */ + .short 0 /* NumberOfRelocations */ + .short 0 /* NumberOfLineNumbers */ + .long 0x42100040 /* Characteristics (section flags) */ + + + .ascii ".text" + .byte 0 + .byte 0 + .byte 0 /* end of 0 padding of section name */ + .long _edata - _start /* VirtualSize */ + .long _start - ImageBase /* VirtualAddress */ + .long _edata - _start /* SizeOfRawData */ + .long _start - ImageBase /* PointerToRawData */ + + .long 0 /* PointerToRelocations (0 for executables) */ + .long 0 /* PointerToLineNumbers (0 for executables) */ + .short 0 /* NumberOfRelocations (0 for executables) */ + .short 0 /* NumberOfLineNumbers (0 for executables) */ + .long 0xe0500020 /* Characteristics (section flags) */ + +_start: + addi sp, sp, -(SIZE_LONG * 3) + SAVE_LONG(a0, 0) + SAVE_LONG(a1, 1) + SAVE_LONG(ra, 2) + + lla a0, ImageBase + lla a1, _DYNAMIC + call _relocate + bne a0, zero, 0f + + LOAD_LONG(a1, 1) + LOAD_LONG(a0, 0) + call efi_main + + LOAD_LONG(ra, 2) + +0: addi sp, sp, (SIZE_LONG * 3) + ret diff --git a/arch/riscv/lib/elf_riscv32_efi.lds b/arch/riscv/lib/elf_riscv32_efi.lds new file mode 100644 index 0000000000..96d11985b0 --- /dev/null +++ b/arch/riscv/lib/elf_riscv32_efi.lds @@ -0,0 +1,70 @@ +/* + * U-Boot riscv32 EFI linker script + * + * SPDX-License-Identifier: BSD-2-Clause + * + * Modified from arch/arm/lib/elf_aarch64_efi.lds + */ + +OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv") +OUTPUT_ARCH(riscv) +ENTRY(_start) +SECTIONS +{ + .text 0x0 : { + _text = .; + *(.text.head) + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) + *(.srodata) + *(.rodata*) + . = ALIGN(16); + } + _etext = .; + _text_size = . - _text; + .dynamic : { *(.dynamic) } + .data : { + _data = .; + *(.sdata) + *(.data) + *(.data1) + *(.data.*) + *(.got.plt) + *(.got) + + /* + * The EFI loader doesn't seem to like a .bss section, so we + * stick it all into .data: + */ + . = ALIGN(16); + _bss = .; + *(.sbss) + *(.scommon) + *(.dynbss) + *(.bss) + *(.bss.*) + *(COMMON) + . = ALIGN(16); + _bss_end = .; + _edata = .; + } + .rela.dyn : { *(.rela.dyn) } + .rela.plt : { *(.rela.plt) } + .rela.got : { *(.rela.got) } + .rela.data : { *(.rela.data) *(.rela.data*) } + _data_size = . - _etext; + + . = ALIGN(4096); + .dynsym : { *(.dynsym) } + . = ALIGN(4096); + .dynstr : { *(.dynstr) } + . = ALIGN(4096); + .note.gnu.build-id : { *(.note.gnu.build-id) } + /DISCARD/ : { + *(.rel.reloc) + *(.eh_frame) + *(.note.GNU-stack) + } + .comment 0 : { *(.comment) } +} diff --git a/arch/riscv/lib/elf_riscv64_efi.lds b/arch/riscv/lib/elf_riscv64_efi.lds new file mode 100644 index 0000000000..25c863de8a --- /dev/null +++ b/arch/riscv/lib/elf_riscv64_efi.lds @@ -0,0 +1,70 @@ +/* + * U-Boot riscv64 EFI linker script + * + * SPDX-License-Identifier: BSD-2-Clause + * + * Modified from arch/arm/lib/elf_aarch64_efi.lds + */ + +OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv") +OUTPUT_ARCH(riscv) +ENTRY(_start) +SECTIONS +{ + .text 0x0 : { + _text = .; + *(.text.head) + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) + *(.srodata) + *(.rodata*) + . = ALIGN(16); + } + _etext = .; + _text_size = . - _text; + .dynamic : { *(.dynamic) } + .data : { + _data = .; + *(.sdata) + *(.data) + *(.data1) + *(.data.*) + *(.got.plt) + *(.got) + + /* + * The EFI loader doesn't seem to like a .bss section, so we + * stick it all into .data: + */ + . = ALIGN(16); + _bss = .; + *(.sbss) + *(.scommon) + *(.dynbss) + *(.bss) + *(.bss.*) + *(COMMON) + . = ALIGN(16); + _bss_end = .; + _edata = .; + } + .rela.dyn : { *(.rela.dyn) } + .rela.plt : { *(.rela.plt) } + .rela.got : { *(.rela.got) } + .rela.data : { *(.rela.data) *(.rela.data*) } + _data_size = . - _etext; + + . = ALIGN(4096); + .dynsym : { *(.dynsym) } + . = ALIGN(4096); + .dynstr : { *(.dynstr) } + . = ALIGN(4096); + .note.gnu.build-id : { *(.note.gnu.build-id) } + /DISCARD/ : { + *(.rel.reloc) + *(.eh_frame) + *(.note.GNU-stack) + } + .comment 0 : { *(.comment) } +} diff --git a/arch/riscv/lib/reloc_riscv_efi.c b/arch/riscv/lib/reloc_riscv_efi.c new file mode 100644 index 0000000000..d80ffc975c --- /dev/null +++ b/arch/riscv/lib/reloc_riscv_efi.c @@ -0,0 +1,97 @@ +/* reloc_riscv.c - position independent ELF shared object relocator + Copyright (C) 2018 Alexander Graf + Copyright (C) 2014 Linaro Ltd. + Copyright (C) 1999 Hewlett-Packard Co. + Contributed by David Mosberger . + + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of Hewlett-Packard Co. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include + +#include + +#if __riscv_xlen == 64 +#define Elf_Dyn Elf64_Dyn +#define Elf_Rela Elf64_Rela +#define ELF_R_TYPE ELF64_R_TYPE +#else +#define Elf_Dyn Elf32_Dyn +#define Elf_Rela Elf32_Rela +#define ELF_R_TYPE ELF32_R_TYPE +#endif + +efi_status_t _relocate(long ldbase, Elf_Dyn *dyn, efi_handle_t image, + struct efi_system_table *systab) +{ + long relsz = 0, relent = 0; + Elf_Rela *rel = 0; + unsigned long *addr; + int i; + + for (i = 0; dyn[i].d_tag != DT_NULL; ++i) { + switch (dyn[i].d_tag) { + case DT_RELA: + rel = (Elf_Rela *)((ulong)dyn[i].d_un.d_ptr + ldbase); + break; + case DT_RELASZ: + relsz = dyn[i].d_un.d_val; + break; + case DT_RELAENT: + relent = dyn[i].d_un.d_val; + break; + default: + break; + } + } + + if (!rel && relent == 0) + return EFI_SUCCESS; + + if (!rel || relent == 0) + return EFI_LOAD_ERROR; + + while (relsz > 0) { + /* apply the relocs */ + switch (ELF_R_TYPE(rel->r_info)) { + case R_RISCV_RELATIVE: + addr = (ulong *)(ldbase + rel->r_offset); + *addr = ldbase + rel->r_addend; + break; + default: + /* Panic */ + while (1) ; + } + rel = (Elf_Rela *)((char *)rel + relent); + relsz -= relent; + } + return EFI_SUCCESS; +} From patchwork Mon Apr 23 05:59:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 133950 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp614400lji; Sun, 22 Apr 2018 23:00:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/hXBlmYYUHKUSn/PPtZsRMVWfnh79Nva5qaL0pS+9EQ/IOSxJH+nesASI9uL2ktgUd2OB+ X-Received: by 10.80.181.130 with SMTP id a2mr26577906ede.113.1524463210235; Sun, 22 Apr 2018 23:00:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524463210; cv=none; d=google.com; s=arc-20160816; b=e6c603HsLYVV+nu24J584gxKuo/fFUiTaLEkw+BUQ5+lZUiygzbcEEvp3twV8MvjKZ JERtJC/nLF9cfOaNPrlJkZORcH17AiMDFKjwuxxyx9e/mH+UZ+HpxquhYiWd4QKQuaDD HnjeEf3DDXIGA1bOr3hT55oA9sGCiH/69XVamscufL6InsDOAQjccqAGnnebmV0XrsYX djS80UHR72d9HdMCrZ3xVvxVihjzPhrqDjDXz1tDhyw6xIVn0x4+XFpFo4QmyDCU1/zb 7PD+F55u+8I4CMBRzK6epz0K8LgDYyF9ZpSyrd7I/TfzctynSW1SOBjRhEFXh9iyXeJ8 jpZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=nubpHsVjoyXDlWDf2ClEQ7oY/3zaUgtJF0lPVvN9fyo=; b=TtAYm1hUX2r1cbaTkxO6FKNeO1b4ZbAXhOIuU59sC0mZCeC/F0Zr74O04K9RKDVepz g2i2IIgLMLx/1MDc561ukuPKTLJruR0A3DYZS7MAY7K4LNUJdMJLaqwyFO1iVjlWq7YD yI/+HX97Dfcltubmw/YJUsLY8pIkP74YOzyrXLspO/LrLhjjH694G3Ddz49Dkvgg6bJg oR6qkJvOLvTTeSKq5HFqPbZBxBn/1BiHlxC2WEzCNsRaDr3Iw4ZK/CShCUO6DBYHIvdL cQOopTZqucs+3Ispv+gO2IZXDW23KojK6DKxChuq0t27pnNm7rBxLA8ukGKVmrCFTv5o fKmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id j30si36148edc.316.2018.04.22.23.00.10; Sun, 22 Apr 2018 23:00:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id D163DC21E50; Mon, 23 Apr 2018 06:00:02 +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=RCVD_IN_DNSWL_BLOCKED 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 01D6EC21D8A; Mon, 23 Apr 2018 06:00:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E26F7C21DCA; Mon, 23 Apr 2018 05:59:52 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id CD65FC21D74 for ; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6FDCDAE73; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 23 Apr 2018 07:59:46 +0200 Message-Id: <20180423055950.78818-5-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180423055950.78818-1-agraf@suse.de> References: <20180423055950.78818-1-agraf@suse.de> Cc: Heinrich Schuchardt , schwab@suse.de, Greentime Hu Subject: [U-Boot] [PATCH v3 4/8] riscv: Add board_quiesce_devices stub 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch adds an empty stub for board_quiesce_devices() which allows boards to quiesce their devices before we boot into an OS in a platform agnostic way. Signed-off-by: Alexander Graf Reviewed-by: Rick Chen --- arch/riscv/include/asm/u-boot-riscv.h | 1 + arch/riscv/lib/bootm.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/arch/riscv/include/asm/u-boot-riscv.h b/arch/riscv/include/asm/u-boot-riscv.h index 18099cd260..0b6428b1ae 100644 --- a/arch/riscv/include/asm/u-boot-riscv.h +++ b/arch/riscv/include/asm/u-boot-riscv.h @@ -17,5 +17,6 @@ int cleanup_before_linux(void); /* board/.../... */ int board_init(void); +void board_quiesce_devices(void); #endif /* _U_BOOT_RISCV_H_ */ diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c index 9242fa891a..b80274adba 100644 --- a/arch/riscv/lib/bootm.c +++ b/arch/riscv/lib/bootm.c @@ -16,6 +16,10 @@ DECLARE_GLOBAL_DATA_PTR; +__weak void board_quiesce_devices(void) +{ +} + int arch_fixup_fdt(void *blob) { return 0; From patchwork Mon Apr 23 05:59:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 133955 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp618540lji; Sun, 22 Apr 2018 23:04:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx49vo9iQKQBTbCXPrXOgTCYrtPrlHUknMNq5iBZ6L+Yiw8fADWK8K9c5Pxb7lOU03JN1qOvG X-Received: by 10.80.147.13 with SMTP id m13mr26136436eda.77.1524463493502; Sun, 22 Apr 2018 23:04:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524463493; cv=none; d=google.com; s=arc-20160816; b=F82HfSGLRcfBc6qTz0MU/Fe29G3WKnxHPsOVN+n7w3+g5oVfrsa2gupkMCGiwPfwNG LsbreeUf6Uyl5a5xT4oiYBjKm5OjMLRTESWuF7BVCysc6BU7S3uAHQx4+mL5M8w3qQZ+ EItq9kU9YgG9JTl8lvtdepN3QwRb/iKcdursM4MhNAdhU/TXViTKD2beVeQBhHWhJpsK 1In20Ntjf4uN8FmXe1fqq6zOO2GszGgAhOtLNjhp33vG6qH5/Yz5P+zRU0I65NPtmQh5 YciRe5kps+/tx8d8xUm30Y5wZnP/rviEM0pmloTJx+4t5tuTZAu2P5C/dNvAi3tJhsdt jjlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=c4Hh2FYtgzpa9xq5L/AfFgsVJ14/BVeinvb9ERXYdzo=; b=So4MLjEZMadKgPDQnXYOpPtG9LuVfHq2slSt0gZc9bBDSxYXRjRzTfArcTreI5ST8a LQM/Zme/w+GJp2lFFJqW+1JyK9KNFpR8dfxBKNRqlASuvhwa68/0Hd+IpyVRYRaI2CTI FusJiE+7Vi0k9HJl1mxKIwIWVNDiohykLzSDyMigQflyPkQ9fFwMbUImTJeWEjcujtu7 BqzrE3XN7fd9ofXA3EGPAp/fS/AW+1WHOAqOmabDX69omffqJdWE5zi3D3cL+bG+u7Yt hj4GzVBNrJKSsVysaTeqhtFum8NHGBioj/W2BnRimmbuGqPX8jCDMtWhJN5BgGQ0K4vC QROA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id z41si6939941edb.370.2018.04.22.23.04.53; Sun, 22 Apr 2018 23:04:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 08418C21DDC; Mon, 23 Apr 2018 06:00:55 +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=RCVD_IN_DNSWL_BLOCKED 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 362E1C21DB6; Mon, 23 Apr 2018 06:00:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 32428C21DFA; Mon, 23 Apr 2018 05:59:52 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id D1710C21DB6 for ; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7599FAE80; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 23 Apr 2018 07:59:47 +0200 Message-Id: <20180423055950.78818-6-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180423055950.78818-1-agraf@suse.de> References: <20180423055950.78818-1-agraf@suse.de> Cc: Heinrich Schuchardt , schwab@suse.de, Greentime Hu Subject: [U-Boot] [PATCH v3 5/8] efi_loader: Use EFI_CACHELINE_SIZE in the image loader too 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" We were using our EFI_CACHELINE_SIZE define only in the runtime service code, but left the image loader to use plain CONFIG_SYS_CACHELINE_SIZE. This patch moves EFI_CACHELINE_SIZE into efi_loader.h and converts the image loader to use it. Signed-off-by: Alexander Graf Reviewed-by: Heinrich Schuchardt --- include/efi_loader.h | 7 +++++++ lib/efi_loader/efi_image_loader.c | 2 +- lib/efi_loader/efi_runtime.c | 7 ------- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 17f9d3d1ef..0b1b3df55a 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -76,6 +76,13 @@ const char *__efi_nesting_dec(void); ##__VA_ARGS__); \ }) +#ifdef CONFIG_SYS_CACHELINE_SIZE +#define EFI_CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE +#else +/* Just use the greatest cache flush alignment requirement I'm aware of */ +#define EFI_CACHELINE_SIZE 128 +#endif + extern struct efi_runtime_services efi_runtime_services; extern struct efi_system_table systab; diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c index d5fbba3138..2476a97a6a 100644 --- a/lib/efi_loader/efi_image_loader.c +++ b/lib/efi_loader/efi_image_loader.c @@ -290,7 +290,7 @@ void *efi_load_pe(void *efi, struct efi_loaded_image *loaded_image_info) /* Flush cache */ flush_cache((ulong)efi_reloc, - ALIGN(virt_size, CONFIG_SYS_CACHELINE_SIZE)); + ALIGN(virt_size, EFI_CACHELINE_SIZE)); invalidate_icache_all(); /* Populate the loaded image interface bits */ diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 8558124c0a..573a5d6ac1 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -30,13 +30,6 @@ static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void); static efi_status_t __efi_runtime EFIAPI efi_device_error(void); static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void); -#ifdef CONFIG_SYS_CACHELINE_SIZE -#define EFI_CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE -#else -/* Just use the greatest cache flush alignment requirement I'm aware of */ -#define EFI_CACHELINE_SIZE 128 -#endif - #if defined(CONFIG_ARM64) #define R_RELATIVE 1027 #define R_MASK 0xffffffffULL From patchwork Mon Apr 23 05:59:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 133957 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp619247lji; Sun, 22 Apr 2018 23:05:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx48J+XWYSh79eg8n3nCgSZgI3qCowd0h5VGARoM2Tt+nVJphH4GJ0RpmAGMKiJ64wIc5pImt X-Received: by 10.80.170.135 with SMTP id q7mr26477197edc.124.1524463542668; Sun, 22 Apr 2018 23:05:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524463542; cv=none; d=google.com; s=arc-20160816; b=qUZC3bWi/TI7ozEjztUOJJMIYV3jtMhK/ibWhiDXdsHMeSxDUkdSNZEyT5046s5shD JM+HZRm/7nWkknhEJSpPfHkTPxs00JBIdl//jqhTwDeyl4iGcgIe+QQ3Ny7lfYrRztcU d6ZzZ/1TZDxIyrrZkASUvE2f65dIsxn6ho5S/py+txZnZjW7gwPYS1Rhz5uyBL+qE24s GsFdsRwGUd17g3my1i/rrIqF/IsL/15CBcafRFuFbErgAB8wHyFs6J6GtKuOlpRBTnYw oTKVhMeZepI2OjMz2J6hLvi89eMQvaC62T+k9LimngPd6Xb7dRKJq7Mr9n+kANHHKenv Oqtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=IrTHxzkVCN8+z9+2qvr6/iX1wIt/APVlou4c/FACISY=; b=EAfCYLay9NRlY+AqywShnr+PD5g6TpdodeN7xsvrxzELjPEd/6TOnwesk+ZKb2JbFn sYG5Uhj5IpYHp29HqLNUMOAsu6LC+Bl6T1rOlxHSu4ZY3g3scCUIKJLzYOYcwMcQhn4H UGa/aUzrTSQbCvk7RHduq87IGcAq0lTFJ0DwuJWn4gUphFwptVvZaokMkHds0xyjuGZ7 x3FJz8u1sO28/9O3M6gSojI9Qdw07+/N16Ym2ER/i/NbEd2prbgircrdSCeERZ/vBfD6 Mp2TXYlp1m9kwPgS++3/iunWajcuKFcA8alPyvgBxqmcPwzzxIkgtVAh3+JiRsgFF519 7kkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id t5si3376231edt.292.2018.04.22.23.05.42; Sun, 22 Apr 2018 23:05:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 390ACC21DD9; Mon, 23 Apr 2018 06:02:46 +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=RCVD_IN_DNSWL_BLOCKED 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 57889C21E31; Mon, 23 Apr 2018 06:00:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BCF0CC21D74; Mon, 23 Apr 2018 05:59:52 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id D51B8C21BE5 for ; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 84FDCAE8F; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 23 Apr 2018 07:59:48 +0200 Message-Id: <20180423055950.78818-7-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180423055950.78818-1-agraf@suse.de> References: <20180423055950.78818-1-agraf@suse.de> Cc: Heinrich Schuchardt , schwab@suse.de, Greentime Hu Subject: [U-Boot] [PATCH v3 6/8] distro: Extend with RISC-V defines 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" While we don't have UEFI naming conventions for RISC-V file paths yet, we need to search for something. So let's copy the removable file paths from the RISC-V edk2 port. Also add the official VCI strings that contain the standardized RISC-V architecture ID fields. Signed-off-by: Alexander Graf Reviewed-by: Heinrich Schuchardt --- v1 -> v2: - Use edk2 default boot file names v2 -> v3: - Use official values for vci --- include/config_distro_bootcmd.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index f567cebd38..989b5556af 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -100,6 +100,10 @@ #define BOOTEFI_NAME "bootia32.efi" #elif defined(CONFIG_X86_RUN_64BIT) #define BOOTEFI_NAME "bootx64.efi" +#elif defined(CONFIG_CPU_RISCV_32) +#define BOOTEFI_NAME "bootriscv32.efi" +#elif defined(CONFIG_CPU_RISCV_64) +#define BOOTEFI_NAME "bootriscv64.efi" #endif #endif @@ -241,6 +245,7 @@ #if defined(CONFIG_CMD_DHCP) #if defined(CONFIG_EFI_LOADER) +/* http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml */ #if defined(CONFIG_ARM64) #define BOOTENV_EFI_PXE_ARCH "0xb" #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00011:UNDI:003000" @@ -251,6 +256,12 @@ /* Always assume we're running 64bit */ #define BOOTENV_EFI_PXE_ARCH "0x7" #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00007:UNDI:003000" +#elif defined(CONFIG_CPU_RISCV_32) +#define BOOTENV_EFI_PXE_ARCH "0x19" +#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00025:UNDI:003000" +#elif defined(CONFIG_CPU_RISCV_64) +#define BOOTENV_EFI_PXE_ARCH "0x1b" +#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00027:UNDI:003000" #else #error Please specify an EFI client identifier #endif From patchwork Mon Apr 23 05:59:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 133951 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp615025lji; Sun, 22 Apr 2018 23:00:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx49AZVSuGWq1PVmoHyfSwno85sGIadbJ9Go+3nCKQ1JmFzGMQ0Pfvc04Y1i8q/8TcqYNWu+0 X-Received: by 10.80.158.40 with SMTP id z37mr26644312ede.246.1524463247060; Sun, 22 Apr 2018 23:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524463247; cv=none; d=google.com; s=arc-20160816; b=loe/D3aA3gyD1oNPNyCgCRnWUxdBnrXGKRUxwbSTX/T1fMOXvdDI3J6cGy7ZyX/z1L ZEDRNwcnDi5iOQC4NyDp7gcIPfiC9rZy+xqKVOysjGtJ5UeSpXJuZdF8YCoIcVW7JMAE GlrVYc6ZY1FykUIFo+/zDsctK+O93sxLpu2QumjYZJPtkYknug51dzjbuSU1I8bAFMuS TjUUB8JQDTtLi7uiwxudfLvtqsqkAGgY7OLaj2wSQXrtBjcwKOTh+pJyMeFOUR81HJxZ t5VdpkXFuXnpi0C3XvZQ3Y+Xv8G+SuYd4ZddK0nnxXZOqlGyqk69GhMovrQaAjm72fs/ YP2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=m/49hZyaBWv8+T9KV58SXA4zMrUiuG5mBleY4wcmPr4=; b=var9ftO2Oi99ByMVnY3ggNHRYRb7POkjlouGJ6jVEfkG7IlWaP1jQ9uM9IzZgngZii S8+EK5q17mjlCqAexNywvGzWjz56oxH1AgGMoeQbmaKzONlghrB/ZdLI3s5u652ntdfy tiGnwdYq9KgIDnzk4mjLqEulggXz6vToYwG2cyfp3oNU2Hs83m9EvsVHEgh0Qnl/tKqC GLqAWbDkoGbiOKvAnYssWWqXj+I/PxBf3e/Pqu0+a4oriorBwLMXSg76sJmjsFt4Qpes 09Zfs5/y6QiFiaDhGgbPT+qe4HxvCPlphZ3l/McgLP+z866WsGAaWpDVCWE7Y5DJk4O7 QGVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id l48si1005290edd.186.2018.04.22.23.00.46; Sun, 22 Apr 2018 23:00:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 9C711C21D65; Mon, 23 Apr 2018 06:00:39 +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=RCVD_IN_DNSWL_BLOCKED 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 32D8BC21DFA; Mon, 23 Apr 2018 06:00:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 21E6CC21C6A; Mon, 23 Apr 2018 05:59:52 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id D6CDDC21DD7 for ; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8C8C6AE90; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 23 Apr 2018 07:59:49 +0200 Message-Id: <20180423055950.78818-8-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180423055950.78818-1-agraf@suse.de> References: <20180423055950.78818-1-agraf@suse.de> Cc: Heinrich Schuchardt , schwab@suse.de, Greentime Hu Subject: [U-Boot] [PATCH v3 7/8] riscv: nx25: Enable distro boot 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Distro boot allows for a common boot path on systems that allow distributions to easily boot from a default configuration. This patch enables distro boot for the nx25-ae250. Hopefully this can serve as a good example for new boards, so they enable it as well. Signed-off-by: Alexander Graf Reviewed-by: Rick Chen --- configs/nx25-ae250_defconfig | 1 + include/configs/nx25-ae250.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/configs/nx25-ae250_defconfig b/configs/nx25-ae250_defconfig index 4f9bd58f75..437083231b 100644 --- a/configs/nx25-ae250_defconfig +++ b/configs/nx25-ae250_defconfig @@ -37,3 +37,4 @@ CONFIG_DM_SPI=y CONFIG_ATCSPI200_SPI=y CONFIG_TIMER=y CONFIG_ATCPIT100_TIMER=y +CONFIG_DISTRO_DEFAULTS=y diff --git a/include/configs/nx25-ae250.h b/include/configs/nx25-ae250.h index 0e4c431cab..a90c75abc4 100644 --- a/include/configs/nx25-ae250.h +++ b/include/configs/nx25-ae250.h @@ -105,4 +105,21 @@ /* Increase max gunzip size */ #define CONFIG_SYS_BOOTM_LEN (64 << 20) +/* When we use RAM as ENV */ +#define CONFIG_ENV_SIZE 0x2000 + +/* Enable distro boot */ +#define BOOT_TARGET_DEVICES(func) \ + func(MMC, mmc, 0) \ + func(DHCP, dhcp, na) +#include + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "kernel_addr_r=0x00080000\0" \ + "pxefile_addr_r=0x01f00000\0" \ + "scriptaddr=0x01f00000\0" \ + "fdt_addr_r=0x02000000\0" \ + "ramdisk_addr_r=0x02800000\0" \ + BOOTENV + #endif /* __CONFIG_H */ From patchwork Mon Apr 23 05:59:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 133952 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp616089lji; Sun, 22 Apr 2018 23:01:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx49c+wjNcZLDSq7oGtOTt9RUvdfHPjhLZDPxKxOgw9icOSLevDE/FPRVd+cVbeQj5SKjUvAb X-Received: by 10.80.175.134 with SMTP id h6mr27025847edd.258.1524463314806; Sun, 22 Apr 2018 23:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524463314; cv=none; d=google.com; s=arc-20160816; b=N2ZmU8lpgB/y2dHj41ANh94zzbs1t2t36x4VRajbYgPiAuL9zbWAW6GyqwsnXVQdeP 8SSwPQl+Qy41/97YLZnfnlmQt0A1eH00pdzk3EVKmY1V/V++28ratldKQyj4k8u+/JVs AonqmPEMyz41lUojR7X1pz+COG+ecUAmGCeYv5IA2vWfoEZov0XrkqdEySzOE+ZKGyGI Hmi4BcPA4pOYYFGxcjrtwC3d1mqyiuq5RMfzJpFnRsiQnZaCD6/99KXeLDOsa35m8oLy xxEOEjm7MXNYbKNXrh9imcZ9GZD83mQZwj07qwDUnsnGVzhCmvOHiZoO0QQsvxkgNVhh FfNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=Sr6xbxBtDFG6vlhapqm0oQ/FzDT/Mx40yshrchE2Sxs=; b=T22NPOBtz0LUYvThJD5DGgR+4bBuddrtRkSi/lKTTVWS4verWO0ylqPwSfYfELU6do QlN9SDauoF0MQoBMS/j+WYfvzoejFs0BhchtkJKE48FlMENP93lJ/r4u2xm/DzZWlKvI qnlgdvL7of6XNz75r7Wf8lt6kUwfkAYOgK9BTa/v1dTeUBK2jlMumwJh+fb3iqE2QKIt DlU9dE/m+41IbjErxHwfJbfDJX15jOvTBOJA3DLJha7S4vs55/7Fol+xdum/8pD7+jaA wxKuCMIqY1imkE+nNkMosBO3P6Zfg/SXlWj5nqc6WMBff3PjnJWJO5nAc0KQi+u3DMG3 RDIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id h48si399832edh.427.2018.04.22.23.01.54; Sun, 22 Apr 2018 23:01:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 4C995C21D74; Mon, 23 Apr 2018 06:00:20 +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=RCVD_IN_DNSWL_BLOCKED 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 0A4F7C21DD7; Mon, 23 Apr 2018 06:00:01 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 11832C21D8E; Mon, 23 Apr 2018 05:59:52 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id D9FDCC21DAF for ; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A233AAE9F; Mon, 23 Apr 2018 05:59:51 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 23 Apr 2018 07:59:50 +0200 Message-Id: <20180423055950.78818-9-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180423055950.78818-1-agraf@suse.de> References: <20180423055950.78818-1-agraf@suse.de> Cc: Heinrich Schuchardt , schwab@suse.de, Greentime Hu Subject: [U-Boot] [PATCH v3 8/8] efi_loader: Enable RISC-V support 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" We have almost all pieces needed to support RISC-V UEFI binaries in place already. The only missing piece are ELF relocations for runtime code and data. This patch adds respective support in the linker script and the runtime relocation code. It also allows users to enable the EFI_LOADER configuration switch on RISC-V platforms. Signed-off-by: Alexander Graf --- v1 -> v2: - Enable hello world binary --- arch/riscv/cpu/nx25/u-boot.lds | 16 ++++++++++++++++ cmd/Kconfig | 2 +- lib/efi_loader/Kconfig | 2 +- lib/efi_loader/efi_runtime.c | 41 ++++++++++++++++++++++++++++++++++++----- 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/arch/riscv/cpu/nx25/u-boot.lds b/arch/riscv/cpu/nx25/u-boot.lds index 936fd779aa..508fa7e58d 100644 --- a/arch/riscv/cpu/nx25/u-boot.lds +++ b/arch/riscv/cpu/nx25/u-boot.lds @@ -38,6 +38,22 @@ SECTIONS KEEP(*(SORT(.u_boot_list*))); } + . = ALIGN(4); + + .efi_runtime : { + __efi_runtime_start = .; + *(efi_runtime_text) + *(efi_runtime_data) + __efi_runtime_stop = .; + } + + .efi_runtime_rel : { + __efi_runtime_rel_start = .; + *(.relaefi_runtime_text) + *(.relaefi_runtime_data) + __efi_runtime_rel_stop = .; + } + . = ALIGN(4); /DISCARD/ : { *(.rela.plt*) } diff --git a/cmd/Kconfig b/cmd/Kconfig index bc1d2f31c0..c9883a40e7 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -228,7 +228,7 @@ config CMD_BOOTEFI config CMD_BOOTEFI_HELLO_COMPILE bool "Compile a standard EFI hello world binary for testing" - depends on CMD_BOOTEFI && (ARM || X86) + depends on CMD_BOOTEFI && (ARM || X86 || RISCV) default y help This compiles a standard EFI hello world application with U-Boot so diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 83d75c4fdc..9de58bb012 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -1,6 +1,6 @@ config EFI_LOADER bool "Support running EFI Applications in U-Boot" - depends on (ARM || X86) && OF_LIBFDT + depends on (ARM || X86 || RISCV) && OF_LIBFDT # We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT # We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 573a5d6ac1..33bbc8d6cc 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -41,6 +41,25 @@ static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void); #include #define R_RELATIVE R_386_RELATIVE #define R_MASK 0xffULL +#elif defined(CONFIG_RISCV) +#include +#define R_RELATIVE R_RISCV_RELATIVE +#define R_MASK 0xffULL +#define IS_RELA 1 + +struct dyn_sym { + ulong foo1; + ulong addr; + u32 foo2; + u32 foo3; +}; +#ifdef CONFIG_CPU_RISCV_32 +#define R_ABSOLUTE R_RISCV_32 +#define SYM_INDEX 8 +#else +#define R_ABSOLUTE R_RISCV_64 +#define SYM_INDEX 32 +#endif #else #error Need to add relocation awareness #endif @@ -247,15 +266,27 @@ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map) p = (void*)((ulong)rel->offset - base) + gd->relocaddr; - if ((rel->info & R_MASK) != R_RELATIVE) { - continue; - } + debug("%s: rel->info=%#lx *p=%#lx rel->offset=%p\n", __func__, rel->info, *p, rel->offset); + switch (rel->info & R_MASK) { + case R_RELATIVE: #ifdef IS_RELA - newaddr = rel->addend + offset - CONFIG_SYS_TEXT_BASE; + newaddr = rel->addend + offset - CONFIG_SYS_TEXT_BASE; #else - newaddr = *p - lastoff + offset; + newaddr = *p - lastoff + offset; #endif + break; +#ifdef R_ABSOLUTE + case R_ABSOLUTE: { + ulong symidx = rel->info >> SYM_INDEX; + extern struct dyn_sym __dyn_sym_start[]; + newaddr = __dyn_sym_start[symidx].addr + offset; + break; + } +#endif + default: + continue; + } /* Check if the relocation is inside bounds */ if (map && ((newaddr < map->virtual_start) ||