summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiang W <[email protected]>2022-03-16 00:22:38 +0800
committerAnup Patel <[email protected]>2022-03-27 08:52:19 +0530
commit2dfbd3c0e226c21b978e0a5a1c58893ee6679d15 (patch)
treef7cca3eeac48dc6744572a37c365d1c725bd262c
parent4998a712b2ab504eff306110879ee05af6050177 (diff)
lib: pmp_set/pmp_get moved errors from runtime to compile time
pmp_set/pmp_get calculates the location of the CSR register separately through conditional compilation. In the case of non-32-bit and 64-bit, we can report an error directly through #error without putting it at runtime Signed-off-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
-rw-r--r--lib/sbi/riscv_asm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/sbi/riscv_asm.c b/lib/sbi/riscv_asm.c
index 847bdba9..5eab1ed5 100644
--- a/lib/sbi/riscv_asm.c
+++ b/lib/sbi/riscv_asm.c
@@ -261,7 +261,7 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
pmpcfg_csr = (CSR_PMPCFG0 + (n >> 2)) & ~1;
pmpcfg_shift = (n & 7) << 3;
#else
- return SBI_ENOTSUPP;
+# error "Unexpected __riscv_xlen"
#endif
pmpaddr_csr = CSR_PMPADDR0 + n;
@@ -312,7 +312,7 @@ int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,
pmpcfg_csr = (CSR_PMPCFG0 + (n >> 2)) & ~1;
pmpcfg_shift = (n & 7) << 3;
#else
- return SBI_ENOTSUPP;
+# error "Unexpected __riscv_xlen"
#endif
pmpaddr_csr = CSR_PMPADDR0 + n;