From nobody Mon Feb 9 19:26:31 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+93382+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+93382+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1662549123; cv=none; d=zohomail.com; s=zohoarc; b=OG+P9NTP1shqVhhtrFqFoublcdCL/agFnBm5gnN58L47OnVU0aS2q3x8OPoFfhS+4H6bPwy0/WYt+7mVlOWajQk7m1v4Ngqmnk3QhNC7fokMoBVVGMKTCiMVWAguE4KxgrTapZoFtv8wscRxe1pJq8e7IogBqRuGA8k87AsyLFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662549123; 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=81iUAKCPr/kJ5kBJUy0rzkvzzwnp6q3H+ZPy5UuP90k=; b=GFrmXn1XNZrZrzFTr+8mrHKwiiEW7K2QbiJ+bSP4hN5He8Kus8SQ8+SXNYoSNezyk71VnEbBkI0o4bnkiepzUPcktKsKFbOIKj+CmNEITttrbYyx7jp/yqpmJORReaniNobpNgK1bsxfklDAdxWgo4pIsE8eTMF7geSHbNvCsvE= 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+93382+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1662549123962160.20957932624833; Wed, 7 Sep 2022 04:12:03 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id iXxIYY1788612xwOaYztthVk; Wed, 07 Sep 2022 04:12:03 -0700 X-Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by mx.groups.io with SMTP id smtpd.web10.6313.1662549122987684154 for ; Wed, 07 Sep 2022 04:12:03 -0700 X-Received: by mail-pj1-f43.google.com with SMTP id p1-20020a17090a2d8100b0020040a3f75eso9476857pjd.4 for ; Wed, 07 Sep 2022 04:12:02 -0700 (PDT) X-Gm-Message-State: RNhalPBZ9MdxzFCfamqnotKDx1787277AA= X-Google-Smtp-Source: AA6agR486ubiFL95sOqEGL26Ah0vYsSiPObJhMY32zLZ0LJ3WVbejVMbkkfNFpWVvsm5Lo+PwDTmaw== X-Received: by 2002:a17:90b:2708:b0:200:22d2:6768 with SMTP id px8-20020a17090b270800b0020022d26768mr3460228pjb.73.1662549122289; Wed, 07 Sep 2022 04:12:02 -0700 (PDT) X-Received: from localhost.localdomain ([49.206.11.92]) by smtp.gmail.com with ESMTPSA id y5-20020aa79ae5000000b0052b84ca900csm12208518pfp.62.2022.09.07.04.11.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Sep 2022 04:12:01 -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 16:41:12 +0530 Message-Id: <20220907111125.539698-7-sunilvl@ventanamicro.com> In-Reply-To: <20220907111125.539698-1-sunilvl@ventanamicro.com> References: <20220907111125.539698-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=1662549123; bh=nDS4t5bYszze6tP99Ghma6cMzhA5FrSX2ncIuK4yk8M=; h=Cc:Date:From:Reply-To:Subject:To; b=MbEOctmNXLnmyPBYd13E1fV16ZSrBvrf11eYVptg1AxyQeq2+QJ8z7OOtyw1dM1eOKx Sd+wf40o0dtFsv4QX0TOMe/5va3OPAG6k4QfWcAAXFmwOzViocHU7/075iJ7zKEpFirpP PpOaMSR1GK7FJAcEFqJCLAEfwtHvwh/2DAw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662549124374100001 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 (#93382): https://edk2.groups.io/g/devel/message/93382 Mute This Topic: https://groups.io/mt/93522320/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-