MdePkg: Add CSR operation for LoongArch

Add CsrRead, CsrWrite and CsrXChg functions for LoongArch, and use them
to operate the CSR register of LoongArch architecture.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Co-authored-by: Bibo Mao <maobibo@loongson.cn>
Acked-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Chao Li
2023-10-16 11:43:40 +08:00
committed by Liming Gao
parent 414ad233a5
commit 0565a8e885
4 changed files with 550 additions and 0 deletions

View File

@@ -351,6 +351,51 @@ AsmReadStableCounter (
VOID
);
/**
CSR read operation.
@param[in] Select CSR read instruction select values.
@return The return value of csrrd instruction, return -1 means no CSR instruction
is found.
**/
UINTN
CsrRead (
IN UINT16 Select
);
/**
CSR write operation.
@param[in] Select CSR write instruction select values.
@param[in] Value The csrwr will write the value.
@return The return value of csrwr instruction, that is, store the old value of
the register, return -1 means no CSR instruction is found.
**/
UINTN
CsrWrite (
IN UINT16 Select,
IN UINTN Value
);
/**
CSR exchange operation.
@param[in] Select CSR exchange instruction select values.
@param[in] Value The csrxchg will write the value.
@param[in] Mask The csrxchg mask value.
@return The return value of csrxchg instruction, that is, store the old value of
the register, return -1 means no CSR instruction is found.
**/
UINTN
CsrXChg (
IN UINT16 Select,
IN UINTN Value,
IN UINTN Mask
);
#endif // defined (MDE_CPU_LOONGARCH64)
//