From nobody Mon Feb 9 23:16:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93404+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93404+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1662550627; cv=none; d=zohomail.com; s=zohoarc; b=ewFnfb5Hjd/AW2ICoscjL9g9DDj6F+TRVzM6FYDTtkiTqtYw7EUrQvFb6yX5PrYOApgCyaZTwRKGA+D2M7Q5foo3C/2YhgkQoDWJHSkJA9Qcpcfbd/Q4cHD/jGoJTbob23E6RwV5yfKP290DDNgVNQLpj6eolIbfnyEuaU0eAa4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662550627; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=xNzUYL8mDQSy1CGs/hG5RxIrjrcbzy4xNdCmmSmKvJw=; b=VXaxymtPmbZ9jQVf661Es1h0Wtd8zwhoD7Ix/PxEwNrk52Swluhg+v7Z4M+qgGpNLMRuGuhhcrCYDBF6ZqmC5Bf5VgEy8jaVvYfCc2lwcjWlAgoaz/yD3b59grMoDunSVNHxkMqSkaSIEQIGMKXzajUujy1yi9uHkqVKXu8lbPY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93404+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1662550627495322.20280048530026; Wed, 7 Sep 2022 04:37:07 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 3h28YY1788612xVUYg7kaWBz; Wed, 07 Sep 2022 04:37:07 -0700 X-Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by mx.groups.io with SMTP id smtpd.web09.6627.1662550626589889765 for ; Wed, 07 Sep 2022 04:37:06 -0700 X-Received: by mail-pj1-f54.google.com with SMTP id pj10so3812635pjb.2 for ; Wed, 07 Sep 2022 04:37:06 -0700 (PDT) X-Gm-Message-State: G1Q45vKbMidQ7CNRbTuZx2lIx1787277AA= X-Google-Smtp-Source: AA6agR5cUwEL+zVeJqI/XaILtjdpWKKpbAN4bxgowwr8XTxOPl9U9QvvsFbGioLfzFReABCl4Qi2Lg== X-Received: by 2002:a17:90b:17ce:b0:1f4:d068:5722 with SMTP id me14-20020a17090b17ce00b001f4d0685722mr29411072pjb.28.1662550625968; Wed, 07 Sep 2022 04:37:05 -0700 (PDT) X-Received: from localhost.localdomain ([49.206.11.92]) by smtp.gmail.com with ESMTPSA id 8-20020a17090a000800b001fd77933fb3sm10797230pja.17.2022.09.07.04.37.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Sep 2022 04:37:05 -0700 (PDT) From: "Sunil V L" To: devel@edk2.groups.io Cc: Jian J Wang , Liming Gao , Eric Dong , Ray Ni , Rahul Kumar , Debkumar De , Catharine West , Daniel Schaefer , Abner Chang , Leif Lindholm , Andrew Fish , Ard Biesheuvel , Heinrich Schuchardt , Anup Patel , Sunil V L Subject: [edk2-devel] [RFC PATCH V2 06/19] MdePkg/BaseLib: RISC-V: Add generic CPU related functions Date: Wed, 7 Sep 2022 17:06:13 +0530 Message-Id: <20220907113626.540065-7-sunilvl@ventanamicro.com> In-Reply-To: <20220907113626.540065-1-sunilvl@ventanamicro.com> References: <20220907113626.540065-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sunilvl@ventanamicro.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662550627; bh=AUZ3HbhtOalWmHPw8oyLVyvPmBfjofgpCbgt32cap+4=; h=Cc:Date:From:Reply-To:Subject:To; b=M0DTg1DM187HPm5l8iedrsejpAvP/Ww165qT42euVX2d7/sqm+Vhxs2bG2VFopG43pE W8S04ti/0Rdm5x3qlSrGFf03HPA2X2+jzyKa534U65ZI/KOSF1LjhTb1hezrFZ/hwDor5 +ziAxj68HwR15FsReJBNcNkEfgkBQUzHirI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662550628456100001 Content-Type: text/plain; charset="utf-8" EDK2 in S-mode needs to use SSCRATCH register. Implement functions to set/get the SSCRATCH register. Signed-off-by: Sunil V L --- MdePkg/Library/BaseLib/BaseLib.inf | 1 + MdePkg/Include/Library/BaseLib.h | 10 ++++++ MdePkg/Library/BaseLib/RiscV64/CpuGen.S | 33 ++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/MdePkg/Library/BaseLib/BaseLib.inf b/MdePkg/Library/BaseLib/Ba= seLib.inf index 6be5be9428f2..5429329e39b0 100644 --- a/MdePkg/Library/BaseLib/BaseLib.inf +++ b/MdePkg/Library/BaseLib/BaseLib.inf @@ -401,6 +401,7 @@ [Sources.RISCV64] RiscV64/RiscVCpuPause.S | GCC RiscV64/RiscVInterrupt.S | GCC RiscV64/FlushCache.S | GCC + RiscV64/CpuGen.S | GCC =20 [Packages] MdePkg/MdePkg.dec diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/Base= Lib.h index a6f9a194ef1c..a742de61a442 100644 --- a/MdePkg/Include/Library/BaseLib.h +++ b/MdePkg/Include/Library/BaseLib.h @@ -150,6 +150,16 @@ typedef struct { =20 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8 =20 +VOID +RiscVSetSupervisorScratch ( + UINT64 + ); + +UINT64 +RiscVGetSupervisorScratch ( + VOID + ); + #endif // defined (MDE_CPU_RISCV64) =20 // diff --git a/MdePkg/Library/BaseLib/RiscV64/CpuGen.S b/MdePkg/Library/BaseL= ib/RiscV64/CpuGen.S new file mode 100644 index 000000000000..d11929cf3233 --- /dev/null +++ b/MdePkg/Library/BaseLib/RiscV64/CpuGen.S @@ -0,0 +1,33 @@ +//------------------------------------------------------------------------= ------ +// +// Generic CPU related functions for RISC-V +// +// Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All righ= ts reserved.
+// Copyright (c) 2022, Ventana Micro Systems Inc. All rights reserved.
+// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +//------------------------------------------------------------------------= ------ + +#include +#include + +.data +.align 3 +.section .text + +// +// Set Supervisor mode scratch. +// @param a0 : Value set to Supervisor mode scratch +// +ASM_FUNC (RiscVSetSupervisorScratch) + csrrw a1, CSR_SSCRATCH, a0 + ret + +// +// Get Supervisor mode scratch. +// @retval a0 : Value in Supervisor mode scratch +// +ASM_FUNC (RiscVGetSupervisorScratch) + csrr a0, CSR_SSCRATCH + ret --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93404): https://edk2.groups.io/g/devel/message/93404 Mute This Topic: https://groups.io/mt/93522701/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-