diff options
-rw-r--r-- | MdePkg/Include/Library/BaseLib.h | 5 | ||||
-rw-r--r-- | MdePkg/Include/Register/RiscV64/RiscVEncoding.h | 3 | ||||
-rw-r--r-- | MdePkg/Library/BaseLib/RiscV64/ReadTimer.S | 7 |
3 files changed, 15 insertions, 0 deletions
diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/BaseLib.h index b71e47f..ca0d06c 100644 --- a/MdePkg/Include/Library/BaseLib.h +++ b/MdePkg/Include/Library/BaseLib.h @@ -192,6 +192,11 @@ RiscVReadTimer ( );
VOID
+RiscVSetSupervisorTimeCompareRegister (
+ IN UINT64
+ );
+
+VOID
RiscVEnableTimerInterrupt (
VOID
);
diff --git a/MdePkg/Include/Register/RiscV64/RiscVEncoding.h b/MdePkg/Include/Register/RiscV64/RiscVEncoding.h index 2bde8db..8ccdea2 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 39a06ef..36781c2 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
|