From patchwork Wed Apr 18 13:40:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 133628 Delivered-To: patch@linaro.org Received: by 10.46.84.18 with SMTP id i18csp5895560ljb; Wed, 18 Apr 2018 06:43:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+HTvm2Epkg8fpVGa1ZN0nOqIuTw8Vo68OXbxc18qrm1xvWHgBS74ZXWSDDTQxmI0bkifxb X-Received: by 10.80.134.154 with SMTP id r26mr2613253eda.64.1524059029686; Wed, 18 Apr 2018 06:43:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524059029; cv=none; d=google.com; s=arc-20160816; b=ZFQKf+dVwh3dljbdnqJaj72w0nGkjg1IZBNa7Fh/+Qj2epDmIKk4EorFCBgmrO/I7J QysANis77WfLJJcIlX6KvwzlPt1MZ9R9fbiwzCDN9kPxpv/fubz+4czNsgZZ6NQKMX5u pftecPwlhDVTz7w2JW9cVxN6AKKhy4O4ekAwcVK3N6fBqZK8CQ0iEgkuim4Ilt4PnzuM b5dgLkVcvztIdW7o0vTRyHe+a/Wjk2zzDaIT4vM6PQm2zcZYgxdbJrPeinLUF6biVBFw FOhvI7fis1U06b2B9T8Y+3E2vkMoEy3sizNBf1giep9RLCBd08HV+YTGMaiYLFWPiM3z bdQA== 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=LTrTIXaMK8b+GOeUJ4YMXU/yf4qXB5dvnHlp3BYFPPM=; b=C09q+w6EYf8dfPx6HocHFgyt48iQXqQGDnsQ6SqCP7rJq8wYW5w8uE0AnjW6MMiCk8 Fm2ndVQWn3KgtgP42egpaVF1RJVk3E82G2Y+fQRNqqV1iHcMqITOVmoH6Ni/3EkVBv0R lAeQL/bzJmDQoQiMJ2kGgHRtVmIib6NSu8DtwV2gGIlkRXogmDGkDF7f5NGdbqj9badk z0LeR7AubP6NKonAOAbNAACP70s1HnJbzh9pReKpdxJ43qkUukvI1Eo/FItgux7jaIt3 8VKQ/CmiXbRTF/Ps8t0IYubrkAJcB5f4HHYOo+dGWY94bhpoBBBAVUMMKiJMcOyshrxs T/0Q== 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 c1si876939edk.269.2018.04.18.06.43.49; Wed, 18 Apr 2018 06:43:49 -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 220C9C21E3B; Wed, 18 Apr 2018 13:41:32 +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 6ECD4C21EE4; Wed, 18 Apr 2018 13:40:39 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6CFCFC21C8B; Wed, 18 Apr 2018 13:40:34 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id D8478C21E30 for ; Wed, 18 Apr 2018 13:40:33 +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 4D98EAF59; Wed, 18 Apr 2018 13:40:33 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Wed, 18 Apr 2018 15:40:23 +0200 Message-Id: <20180418134030.55127-2-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180418134030.55127-1-agraf@suse.de> References: <20180418134030.55127-1-agraf@suse.de> Cc: Heinrich Schuchardt , Greentime Hu Subject: [U-Boot] [PATCH 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 --- arch/riscv/include/asm/setjmp.h | 24 ++++++++++++++++++ arch/riscv/lib/Makefile | 1 + arch/riscv/lib/setjmp.S | 54 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 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..37e8281aaa --- /dev/null +++ b/arch/riscv/include/asm/setjmp.h @@ -0,0 +1,24 @@ +/* + * (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 */ + u64 regs[13]; +}; + +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..55c5128163 --- /dev/null +++ b/arch/riscv/lib/setjmp.S @@ -0,0 +1,54 @@ +/* + * (C) 2018 Alexander Graf + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include + +.pushsection .text.setjmp, "ax" +ENTRY(setjmp) + /* Preserve all callee-saved registers and the SP */ + sd s0, 0(a0) + sd s1, 8(a0) + sd s2, 16(a0) + sd s3, 24(a0) + sd s4, 32(a0) + sd s5, 40(a0) + sd s6, 48(a0) + sd s7, 56(a0) + sd s8, 64(a0) + sd s9, 72(a0) + sd s10, 80(a0) + sd s11, 88(a0) + li a0, 0 + ret +ENDPROC(setjmp) +.popsection + +.pushsection .text.longjmp, "ax" +ENTRY(longjmp) + ld s0, 0(a0) + ld s1, 8(a0) + ld s2, 16(a0) + ld s3, 24(a0) + ld s4, 32(a0) + ld s5, 40(a0) + ld s6, 48(a0) + ld s7, 56(a0) + ld s8, 64(a0) + ld s9, 72(a0) + ld s10, 80(a0) + ld s11, 88(a0) + + /* 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