diff options
author | Dongyan Qian <dongyan0314@gmail.com> | 2024-07-16 23:29:22 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-07-17 19:33:57 +0000 |
commit | 0adc868b362873eb7c749f3ac6c38f9e293af10d (patch) | |
tree | 836a8c19f917c540a6b4cd5aebc3e706bdfb9209 | |
parent | 11c50d6ca10a1410c2db187078fa7139e29e3042 (diff) | |
download | edk2-0adc868b362873eb7c749f3ac6c38f9e293af10d.tar.gz edk2-0adc868b362873eb7c749f3ac6c38f9e293af10d.tar.bz2 edk2-0adc868b362873eb7c749f3ac6c38f9e293af10d.zip |
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>
-rw-r--r-- | MdePkg/Library/BaseLib/LoongArch64/AsmCsr.S | 9 | ||||
-rw-r--r-- | MdePkg/Library/BaseLib/LoongArch64/Csr.c | 7 |
2 files changed, 7 insertions, 9 deletions
diff --git a/MdePkg/Library/BaseLib/LoongArch64/AsmCsr.S b/MdePkg/Library/BaseLib/LoongArch64/AsmCsr.S index 3a879411f5..eb82724503 100644 --- a/MdePkg/Library/BaseLib/LoongArch64/AsmCsr.S +++ b/MdePkg/Library/BaseLib/LoongArch64/AsmCsr.S @@ -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
diff --git a/MdePkg/Library/BaseLib/LoongArch64/Csr.c b/MdePkg/Library/BaseLib/LoongArch64/Csr.c index f2ec80b38d..5a40bfede5 100644 --- a/MdePkg/Library/BaseLib/LoongArch64/Csr.c +++ b/MdePkg/Library/BaseLib/LoongArch64/Csr.c @@ -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
|