From: "Andrei Warkentin" <andrei.warkentin@intel.com>
To: Sunil V L <sunilvl@ventanamicro.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>,
"Gao, Liming" <gaoliming@byosoft.com.cn>,
"Liu, Zhiguang" <zhiguang.liu@intel.com>
Subject: Re: [edk2-devel] [PATCH v2 2/4] MdePkg/BaseLib: RISC-V: Add function to update stimecmp register
Date: Tue, 9 Jan 2024 16:21:51 +0000 [thread overview]
Message-ID: <PH8PR11MB6856CA155ADCEC87ADBDC80D836A2@PH8PR11MB6856.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20240108113650.454940-3-sunilvl@ventanamicro.com>
Reviewed-by: Andrei Warkentin <andrei.warkentin@intel.com>
> -----Original Message-----
> From: Sunil V L <sunilvl@ventanamicro.com>
> Sent: Monday, January 8, 2024 5:37 AM
> To: devel@edk2.groups.io
> Cc: Sunil V L <sunilvl@ventanamicro.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>;
> Liu, Zhiguang <zhiguang.liu@intel.com>; Warkentin, Andrei
> <andrei.warkentin@intel.com>
> Subject: [PATCH v2 2/4] MdePkg/BaseLib: RISC-V: Add function to update
> stimecmp register
>
> 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 <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> Cc: Andrei Warkentin <andrei.warkentin@intel.com>
> Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
> ---
> 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/BaseLib.h
> index b71e47f41b7f..ca0d06c7f335 100644
> --- a/MdePkg/Include/Library/BaseLib.h
> +++ b/MdePkg/Include/Library/BaseLib.h
> @@ -191,6 +191,11 @@ RiscVReadTimer (
> VOID
> );
>
> +VOID
> +RiscVSetSupervisorTimeCompareRegister (
> + IN UINT64
> + );
> +
> VOID
> RiscVEnableTimerInterrupt (
> VOID
> diff --git a/MdePkg/Include/Register/RiscV64/RiscVEncoding.h
> b/MdePkg/Include/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
>
> +/* 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/BaseLib/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
> --
> 2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113459): https://edk2.groups.io/g/devel/message/113459
Mute This Topic: https://groups.io/mt/103595209/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-01-09 16:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-08 11:36 [edk2-devel] [PATCH v2 0/4] RISC-V: Add support for Sstc extension Sunil V L
2024-01-08 11:36 ` [edk2-devel] [PATCH v2 1/4] MdePkg.dec: RISC-V: Define override bit " Sunil V L
2024-01-09 16:21 ` Andrei Warkentin
2024-01-08 11:36 ` [edk2-devel] [PATCH v2 2/4] MdePkg/BaseLib: RISC-V: Add function to update stimecmp register Sunil V L
2024-01-09 16:21 ` Andrei Warkentin [this message]
2024-01-08 11:36 ` [edk2-devel] [PATCH v2 3/4] UefiCpuPkg/CpuTimerDxeRiscV64: Add support for Sstc Sunil V L
2024-01-08 13:00 ` Laszlo Ersek
2024-01-08 15:25 ` Dhaval Sharma
2024-01-09 16:22 ` Andrei Warkentin
2024-01-08 11:36 ` [edk2-devel] [PATCH v2 4/4] OvmfPkg/RiscVVirt: Override Sstc extension Sunil V L
2024-01-09 16:22 ` Andrei Warkentin
2024-01-11 12:57 ` [edk2-devel] [PATCH v2 0/4] RISC-V: Add support for " Sunil V L
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=PH8PR11MB6856CA155ADCEC87ADBDC80D836A2@PH8PR11MB6856.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox