MdePkg/BaseLib: Optimize LOONGARCH64 csr usage

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4812

When the Select is out of support, use method break exception
instead of method return -1, avoid unknown errors caused by untimely
detection.

Cc: Chao Li <lichao@loongson.cn>
Signed-off-by: Dongyan Qian <qiandongyan@loongson.cn>
This commit is contained in:
Dongyan Qian 2024-07-16 23:29:22 +08:00 committed by mergify[bot]
parent 11c50d6ca1
commit 0adc868b36
2 changed files with 7 additions and 9 deletions

View File

@ -100,8 +100,7 @@ DirMapCsrRd:
jirl $zero, $t0, 0
ReadSelNumErr:
addi.d $a0, $zero, -1
jirl $zero, $ra, 0
break 0
BasicCsrRead:
CsrSel = LOONGARCH_CSR_CRMD
@ -230,8 +229,7 @@ DirMapCsrWr:
jirl $zero, $t0, 0
WriteSelNumErr:
addi.d $a0, $zero, -1
jirl $zero, $ra, 0
break 0
BasicCsrWrite:
CsrSel = LOONGARCH_CSR_CRMD
@ -368,8 +366,7 @@ DirMapCsrXchg:
jirl $zero, $t0, 0
XchgSelNumErr:
addi.d $a0, $zero, -1
jirl $zero, $ra, 0
break 0
BasicCsrXchange:
CsrSel = LOONGARCH_CSR_CRMD

View File

@ -29,7 +29,8 @@ AsmCsrXChg (
@param[in] Select CSR read instruction select values.
@return The return value of csrrd instruction, return -1 means Select is out of support.
@return The return value of csrrd instruction,
if a break exception is triggered, the Select is out of support.
**/
UINTN
EFIAPI
@ -47,7 +48,7 @@ CsrRead (
@param[in, out] 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 Select is out of support.
the register, if a break exception is triggered, the Select is out of support.
**/
UINTN
EFIAPI
@ -67,7 +68,7 @@ CsrWrite (
@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 Select is out of support.
the register, if a break exception is triggered, the Select is out of support.
**/
UINTN
EFIAPI