From patchwork Fri Apr 18 14:09:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Forissier X-Patchwork-Id: 882309 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp831063wrs; Fri, 18 Apr 2025 07:11:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU9je6YbecfzB9eSU9mAzNMt9Bq9+jiMAEaWS/Vew6ABxvng5L4YxABFtIPwQz/fpJnASsQiQ==@linaro.org X-Google-Smtp-Source: AGHT+IFeOT8N9wzIn3O9ZbYZGCMkIyCkO8fBbKXN+mUFSLfsVoloE37x/q71yEElGsR4h5h2b8Ia X-Received: by 2002:a05:600c:3b8b:b0:43d:4686:5cfb with SMTP id 5b1f17b1804b1-4406ac5fb72mr20056145e9.27.1744985513604; Fri, 18 Apr 2025 07:11:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1744985513; cv=none; d=google.com; s=arc-20240605; b=AFgcsb/kTA0APdnWBAyEcMwqxF3prNaojwfPtE9EkbT+F0595gv0Cx1P4LZ2GK2cSz Ydkac0/DmHsX/IP30fbB2STiiMp9+dtTWuxi8GO4FOYoLIh1xwW6fGtmQwPMhVJ485GV bqEX1Ie0cMwTMQOa+GPHxuGWhTH6XEgKWuwNwzeUCLXy7/+rjPVzjnjNzkGlZGdHVwb/ J2z5OFgmyZ0tLK13/bsNmRUQ2FLVsthj9gLk0uAaqtNyA51BdQtQsJyBsNIfbpKKZHVJ WEebnBTzRuX+yEYQ8fgxGosS3spa4wROR4eHfTs/xMGtWQ8VAVndTMWV/2reK0p+siKT K3QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vjN9f8+RKUCM1bfAsnKFxh2T60ROTFd40n0Hwh5GyX0=; fh=g2milhPmMiAbN8655mDDXVEqK/JqClx9hMe7cuF2lBs=; b=TeiQ0Ttr8+MtutGXt5PiR0QQ69KQcjAmaeyZP8rQhYqh8A8J6mDmyTNBjprkmObDtz S8tum8aa2aumd3NKleF9+itcBwZcCVnqdNW8/e05DcXL/XDYCMv06lWbr7EhFG0iKN6E I5jGl6IBvrMjoXfJYSiIP7J5WoqMOjz8X2/WoaVDjWz1rU5tRMx/ThS1mPtF9Mrp+Y5y m10rqYfQYxM+N2we6lz2xzp3niu5YFic7tgG04sSCf8i51o2jpg20TFjRX72YZ67yuqo g5ydHu6qgIIXaoEQZjhOlpyFvlqfZOzGP1gMBCplfVkQGeBy2mDsWZ0ToToQRU/Vsf+L 9IzQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JimfCtRI; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 5b1f17b1804b1-4406d5ac022si9713255e9.29.2025.04.18.07.11.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Apr 2025 07:11:53 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JimfCtRI; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B491C8329B; Fri, 18 Apr 2025 16:11:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.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=linaro.org header.i=@linaro.org header.b="JimfCtRI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 592BC83287; Fri, 18 Apr 2025 16:11:37 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5C8C381F45 for ; Fri, 18 Apr 2025 16:11:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jerome.forissier@linaro.org Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4394a823036so10485375e9.0 for ; Fri, 18 Apr 2025 07:11:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1744985494; x=1745590294; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vjN9f8+RKUCM1bfAsnKFxh2T60ROTFd40n0Hwh5GyX0=; b=JimfCtRIAqWr8buAzsgg3bTcq9AvBdLJezOF/GrX+DoOwfOAH6dbx2yZGPF1gFfONk Cwb7gFi+U15upS8pgwFIOsrr3ReUNfO6fTentcF6u6uDS9PNfSfdOLmi5oNYrkKAqzm5 +qc5GLyzpNJH6ir9CXIA2VzCAsXgklemDTftL7UrUPBkwefYDlZQDE//R9PM0Z2hFNYn 2hgxf0C0tPYhowEh6vNpLOcvs+85xnCNpUuXvGFrMxwwqceeB8iYkIuJIqloKBfT/mGT 7PU5zRGhmFXNy64f0tQDatNnz2yYPAah6uVDE8QkFlmb4xJsSRBNg3SpHvGP0M0GX1bV kN6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744985494; x=1745590294; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vjN9f8+RKUCM1bfAsnKFxh2T60ROTFd40n0Hwh5GyX0=; b=EOJTUc6V+3kUnyRsK2TP7E4tDh++JbxapZzELDhbxzWLETN7yJxSmQhkRsjQ3NKswi N4X9s+a0sWCMnN3qg/sZ9OXeJzUhFf439fKDv5smwE/fR2MGWOcOPw1dqcWt0NwlBBTF yO6s7Li1KVtr3aez4/h5USr+xqVqV6YMWbcCYZnBs+bsOLbkpaZMKUH6yREtHMMJepTA YGPB8FPLXfgO5Q6KTzUGaChlLNgcn9vUcMIwlr4PSUqMtlZT1Ma3PwEL0oOiZb9SwtW3 YB2SopkW1cG3t0JJ35pD6qpRJEINQhALKuIryh+poqTupAZ76CS3rg64L/UXvpMNEO57 EMSQ== X-Gm-Message-State: AOJu0YxBgmEhZdzLGGj5C41SMDv4imfdEi6++1Ehc0/HTL3BIK0jWmmn JkL43C57j+WXpgYFhVhPto29OjcaPdKytJxoRjVdOwIDSk8NdQzO1j+g0kOZtlNX1dYNPyJcgu8 gm6tFmg== X-Gm-Gg: ASbGncs77+sA7qlbx5FZymvp09qkKqGm6pnIfTNVqtRMvVDbRGNt+kjyiRqwOCCcZG2 dmwZDaPX+ahy6zPNGMz8yRHc4JGbsIBL/LmB1FcmarZSXlgVAJmRaqIkS3BbebjOEmFEOpWBdyG loyblQe2JZC984uBG5iuk5CXGfibneLD5mel+NKxAzE/uvaLZAtU1pURXq3fwehM8Qv9ge8nrH2 I8UQl+acjcItSsCFri1ts2Cf95CHFudqFEgGsJ3++Hf5UnvY1X4U2HndAfbjQEpm3lKN9AAsCsl sYWKCVF5j3Yyh7W0a1Z/jC++M7xKJfXtVhAh/hQuY94OsQUuugprfGiNhG0t X-Received: by 2002:a05:6000:25e6:b0:39e:cbd2:9ad4 with SMTP id ffacd0b85a97d-39efba263e3mr2007719f8f.2.1744985494519; Fri, 18 Apr 2025 07:11:34 -0700 (PDT) Received: from builder.. ([2a01:e0a:3cb:7bb0:1526:5ffd:d63c:cc85]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4406d5bbcc3sm23734385e9.19.2025.04.18.07.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Apr 2025 07:11:34 -0700 (PDT) From: Jerome Forissier To: U-Boot mailing list Cc: Jerome Forissier , Andrew Goodbody , Heinrich Schuchardt , Ilias Apalodimas , Jiaxun Yang , Leo , Rick Chen , Simon Glass , Tom Rini , Yu-Chien Peter Lin Subject: [PATCH v6 03/17] riscv: add initjmp() Date: Fri, 18 Apr 2025 16:09:31 +0200 Message-ID: <20250418141114.2056981-4-jerome.forissier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250418141114.2056981-1-jerome.forissier@linaro.org> References: <20250418141114.2056981-1-jerome.forissier@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean Implement initjmp() for RISC-V, a non-standard extension to setjmp()/ longjmp() allowing to initialize a jump buffer with a function pointer and a stack pointer. This will be useful to later introduce threads. With this new function it becomes possible to longjmp() to a particular function pointer (rather than to a point previously reached during program execution as is the case with setjmp()), and with a custom stack. Both things are needed to spin off a new thread. Then the usual setjmp()/longjmp() pair is enough to save and restore a context, i.e., switch thread. Signed-off-by: Jerome Forissier --- (no changes since v1) arch/Kconfig | 1 + arch/riscv/lib/setjmp.S | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/arch/Kconfig b/arch/Kconfig index 7a3141e92b3..aa60c5ff03c 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -153,6 +153,7 @@ config RISCV bool "RISC-V architecture" select CREATE_ARCH_SYMLINK select HAVE_SETJMP + select HAVE_INITJMP select SUPPORT_ACPI select SUPPORT_LITTLE_ENDIAN select SUPPORT_OF_CONTROL diff --git a/arch/riscv/lib/setjmp.S b/arch/riscv/lib/setjmp.S index 99d6195827e..9e1f3d5749b 100644 --- a/arch/riscv/lib/setjmp.S +++ b/arch/riscv/lib/setjmp.S @@ -59,3 +59,14 @@ ENTRY(longjmp) ret ENDPROC(longjmp) .popsection + +.pushsection .text.initjmp, "ax" +ENTRY(initjmp) + /* a1: entry point address, a2: stack base, a3: stack size */ + add a2, a2, a3 + STORE_IDX(a1, 12) + STORE_IDX(a2, 13) + li a0, 0 + ret +ENDPROC(initjmp) +.popsection