From nobody Sun Feb 8 18:29:35 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+113094+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+113094+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1704290350; cv=none; d=zohomail.com; s=zohoarc; b=W8h8/0Tyoxsn8Xs2v+amFBvKWvLgChSN/LKfJSYVoTsoCDw9T3SN85nZgFfUPDi5lO3FjTxrn8W+rxwO+HBNyAKPT/Fm4KML/qbR3CwNXfJ+deAjihFamHwt+7WXpDEDdutOE9vMil+nMLelr+0tMmbZJuy+tQv/+rXBwwnTdVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704290350; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=rmMRLmu6BAAi2wzBIxPHfdGW64X/WAHjYOVFBApIKZg=; b=SnWrOsKyOJsIxoF2/y5JXtSbhmylAAZ0V4sbOHuvp71lcDB8Pcpi9Ymh/HCEzsOut+eljURS0eB9QPnKMhcc+d5XqRGUIt8Fia6llaW0FwtOUlaRLaNFAP36dpbsk6ja3PskUUvaJdtuoK6Wrz3JKgAPOgEZz9zyC710/auIrSs= 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+113094+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1704290350316394.5824326495788; Wed, 3 Jan 2024 05:59:10 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=dihytsI8OmHOnSDPJdQtVU+ub+Q1VgVHk0bryfbV+v4=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1704290350; v=1; b=K8c4WnJ0jlPGEEZBE4FoijOIbiiwUK1LAvu3BDqPJuv70/8csDW3DST+ummxk4WXfwKziPY+ wHlRkck1YwwU9NLER15lAOZbozeGpWmtuSSj1r+OM7/BY3GdJgn+ssmdVeMR8kytJ5ipH+4/dbM MIrPYfqcB/fgPtSwjutoBtLc= X-Received: by 127.0.0.2 with SMTP id O5pJYY1788612x0F6AJybsCS; Wed, 03 Jan 2024 05:59:10 -0800 X-Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by mx.groups.io with SMTP id smtpd.web10.17859.1704290349430462077 for ; Wed, 03 Jan 2024 05:59:09 -0800 X-Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-7b7fdde8b98so519988539f.1 for ; Wed, 03 Jan 2024 05:59:09 -0800 (PST) X-Gm-Message-State: gJtQ7utczMPEa4UYaOit9ihHx1787277AA= X-Google-Smtp-Source: AGHT+IHqGT6ltqv2pdQpAR52GDYbUoj1/sbmfiwNlnMW7glNaIPfE2VVQlR/2fj0qWVXWITwpvYEeQ== X-Received: by 2002:a05:6602:158f:b0:7b7:c981:1002 with SMTP id e15-20020a056602158f00b007b7c9811002mr27999434iow.19.1704290347923; Wed, 03 Jan 2024 05:59:07 -0800 (PST) X-Received: from sunil-laptop.dc1.ventanamicro.com ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id w6-20020a056638378600b0046dcaba1adesm1213393jal.62.2024.01.03.05.59.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 05:59:07 -0800 (PST) From: "Sunil V L" To: devel@edk2.groups.io Cc: Sunil V L , Michael D Kinney , Liming Gao , Zhiguang Liu , Andrei Warkentin Subject: [edk2-devel] [PATCH 2/4] MdePkg/BaseLib: RISC-V: Add function to update stimecmp register Date: Wed, 3 Jan 2024 19:28:47 +0530 Message-Id: <20240103135849.127251-3-sunilvl@ventanamicro.com> In-Reply-To: <20240103135849.127251-1-sunilvl@ventanamicro.com> References: <20240103135849.127251-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk 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 List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1704290351474100001 Content-Type: text/plain; charset="utf-8" stimecmp is a CSR supported only when Sstc extension is supported by the platform. This register can be used to set the timer interrupt directly in S-mode instead of going via SBI call. Add a function to update this register. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Andrei Warkentin Signed-off-by: Sunil V L --- MdePkg/Include/Library/BaseLib.h | 5 +++++ MdePkg/Include/Register/RiscV64/RiscVEncoding.h | 3 +++ MdePkg/Library/BaseLib/RiscV64/ReadTimer.S | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/Base= Lib.h index b71e47f41b7f..ca0d06c7f335 100644 --- a/MdePkg/Include/Library/BaseLib.h +++ b/MdePkg/Include/Library/BaseLib.h @@ -191,6 +191,11 @@ RiscVReadTimer ( VOID ); =20 +VOID +RiscVSetSupervisorTimeCompareRegister ( + IN UINT64 + ); + VOID RiscVEnableTimerInterrupt ( VOID diff --git a/MdePkg/Include/Register/RiscV64/RiscVEncoding.h b/MdePkg/Inclu= de/Register/RiscV64/RiscVEncoding.h index 2bde8db478ff..8ccdea2f4fcd 100644 --- a/MdePkg/Include/Register/RiscV64/RiscVEncoding.h +++ b/MdePkg/Include/Register/RiscV64/RiscVEncoding.h @@ -96,6 +96,9 @@ /* Supervisor Protection and Translation */ #define CSR_SATP 0x180 =20 +/* Sstc extension */ +#define CSR_STIMECMP 0x14D + /* Trap/Exception Causes */ #define CAUSE_MISALIGNED_FETCH 0x0 #define CAUSE_FETCH_ACCESS 0x1 diff --git a/MdePkg/Library/BaseLib/RiscV64/ReadTimer.S b/MdePkg/Library/Ba= seLib/RiscV64/ReadTimer.S index 39a06efa51ef..36781c29c0b9 100644 --- a/MdePkg/Library/BaseLib/RiscV64/ReadTimer.S +++ b/MdePkg/Library/BaseLib/RiscV64/ReadTimer.S @@ -21,3 +21,10 @@ ASM_FUNC (RiscVReadTimer) csrr a0, CSR_TIME ret + +// +// Set Supervisor Time Compare Register +// +ASM_FUNC (RiscVSetSupervisorTimeCompareRegister) + csrw CSR_STIMECMP, a0 + ret --=20 2.34.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 (#113094): https://edk2.groups.io/g/devel/message/113094 Mute This Topic: https://groups.io/mt/103501841/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-