]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/RiscV64/CpuScratch.S
MdePkg/BaseLib: RISC-V: Add few more helper functions
[mirror_edk2.git] / MdePkg / Library / BaseLib / RiscV64 / CpuScratch.S
diff --git a/MdePkg/Library/BaseLib/RiscV64/CpuScratch.S b/MdePkg/Library/BaseLib/RiscV64/CpuScratch.S
new file mode 100644 (file)
index 0000000..5492a50
--- /dev/null
@@ -0,0 +1,31 @@
+//------------------------------------------------------------------------------\r
+//\r
+// CPU scratch register related functions for RISC-V\r
+//\r
+// Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>\r
+//\r
+// SPDX-License-Identifier: BSD-2-Clause-Patent\r
+//\r
+//------------------------------------------------------------------------------\r
+\r
+#include <Register/RiscV64/RiscVImpl.h>\r
+\r
+.data\r
+.align 3\r
+.section .text\r
+\r
+//\r
+// Set Supervisor mode scratch.\r
+// @param a0 : Value set to Supervisor mode scratch\r
+//\r
+ASM_FUNC (RiscVSetSupervisorScratch)\r
+    csrw CSR_SSCRATCH, a0\r
+    ret\r
+\r
+//\r
+// Get Supervisor mode scratch.\r
+// @retval a0 : Value in Supervisor mode scratch\r
+//\r
+ASM_FUNC (RiscVGetSupervisorScratch)\r
+    csrr a0, CSR_SSCRATCH\r
+    ret\r