Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54180C433F5 for ; Fri, 15 Oct 2021 01:53:44 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9520B611CC for ; Fri, 15 Oct 2021 01:53:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9520B611CC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5B5D0837FF; Fri, 15 Oct 2021 03:53:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.b="gv3lrCTq"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="RwgS3n5P"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E15C4837DA; Fri, 15 Oct 2021 03:53:20 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2B440837E1 for ; Fri, 15 Oct 2021 03:53:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 763F65C0118; Thu, 14 Oct 2021 21:53:13 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 14 Oct 2021 21:53:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=hq+rX7/EJRkIA VaN/3dDWB6LbwgALHweHj37/p4HfYg=; b=gv3lrCTqUlhx6sEdPJoSFksCF/Z78 5hbElWcZuXKIBqGVA4dUxIYc5OTbsY/ztZC/WDlXQxJ53y147T2JfSwQpdPzzY8Z BrI3oEZ9iCqSF4dwP7mQAnhVGu2VD5Jr/mfZLmzrLG6I+IMw0VS1Mg83MwCazSwc jofcKKVSQlrmOdBDlmsnzqkFJT6GiLuar8sXUdwdqW3DFwCeWCtDM8vuWUDjlj0u 4VV1xcDsXASeIOp7Vf0m2MmH4ZSGPuuC3FUeOpTTTwV+zu4D7W5/6W8SvNuJZRvr 1nmzvtTeEd0Vs/XeYcQDKPQusP0USQvoZOiMPnXmvdC+bW6YgFRE80PGA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=hq+rX7/EJRkIAVaN/3dDWB6LbwgALHweHj37/p4HfYg=; b=RwgS3n5P IkhsXvULG9fS3cPB2MyEgoa8oI1rsYv6kimXNWEamzLhGHVPUzvbQ87kRr/r1xbh 6vkSHWJWfgsMXOju4frunObdxDVisz021BixfhlgcdU04o38NSoxSIHDvO6VzAzU Tl7kwQCMs1+PsTe6y+xX/+Updp/kUCPRMF+uC1LSMPJhfyU8GYnkJkOoHSF4N3FL XsamDF2dF4aeFh73WqYQ8u+NKnjS4EJhjfcPhvpign6rCBbWFltEo0A7mphaHrI8 nerZn7e5s7nFZPFdRLvdSZwAa5gXfoIEbVwVF1yB9kYlN6dgHCWdzYjV9YdjEQ/5 tk6ABfidKGZnYQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddufedggeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpeduhfejfedvhffgfeehtefghfeiiefgfeehgfdvvdevfeegjeehjedv gfejheeuieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 14 Oct 2021 21:53:13 -0400 (EDT) From: Samuel Holland To: u-boot@lists.denx.de, Jagan Teki , Andre Przywara Cc: Icenowy Zheng , Samuel Holland Subject: [PATCH v3 3/4] mkimage: sunxi_egon: add support for riscv Date: Thu, 14 Oct 2021 20:53:06 -0500 Message-Id: <20211015015308.65265-4-samuel@sholland.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211015015308.65265-1-samuel@sholland.org> References: <20211015015308.65265-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Icenowy Zheng There's now a sun20i family in sunxi, which uses RISC-V CPU. Add support for making eGON.BT0 image for RISC-V. Reviewed-by: Andre Przywara Signed-off-by: Icenowy Zheng Signed-off-by: Samuel Holland --- (no changes since v1) tools/sunxi_egon.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/sunxi_egon.c b/tools/sunxi_egon.c index e1c945a12f..06e8d67ebc 100644 --- a/tools/sunxi_egon.c +++ b/tools/sunxi_egon.c @@ -30,6 +30,7 @@ static int egon_check_params(struct image_tool_params *params) */ switch (egon_get_arch(params)) { case IH_ARCH_ARM: + case IH_ARCH_RISCV: break; default: return EXIT_FAILURE; @@ -54,6 +55,10 @@ static int egon_verify_header(unsigned char *ptr, int image_size, if ((le32_to_cpu(header->b_instruction) & 0xff000000) != 0xea000000) return EXIT_FAILURE; break; + case IH_ARCH_RISCV: + if ((le32_to_cpu(header->b_instruction) & 0x00000fff) != 0x0000006f) + return EXIT_FAILURE; + break; default: return EXIT_FAILURE; /* Unknown architecture */ } @@ -115,6 +120,24 @@ static void egon_set_header(void *buf, struct stat *sbuf, int infd, value = 0xea000000 | (sizeof(struct boot_file_head) / 4 - 2); header->b_instruction = cpu_to_le32(value); break; + case IH_ARCH_RISCV: + /* + * Generate a RISC-V JAL instruction with rd=x0 + * (pseudo instruction J, jump without side effects). + * + * The following weird bit operation maps imm[20] + * to inst[31], imm[10:1] to inst[30:21], + * imm[11] to inst[20], imm[19:12] to inst[19:12], + * and imm[0] is dropped (because 1-byte RISC-V instruction + * is not allowed). + */ + value = 0x0000006f | + ((sizeof(struct boot_file_head) & 0x00100000) << 11) | + ((sizeof(struct boot_file_head) & 0x000007fe) << 20) | + ((sizeof(struct boot_file_head) & 0x00000800) << 9) | + ((sizeof(struct boot_file_head) & 0x000ff000) << 0); + header->b_instruction = cpu_to_le32(value); + break; } memcpy(header->magic, BOOT0_MAGIC, sizeof(header->magic)); -- 2.32.0