diff options
| author | Nicholas Piggin <npiggin@gmail.com> | 2026-04-30 14:55:23 +1000 |
|---|---|---|
| committer | Anup Patel <anup@brainfault.org> | 2026-06-10 13:25:29 +0530 |
| commit | f7738cc1e5cea8cae6919810407a8903248ad497 (patch) | |
| tree | b843bd1a6570c4f5b647270939c071559c794915 | |
| parent | 8f1a6164f2b81fe08d67c09400d9f7b9019c58df (diff) | |
| download | opensbi-f7738cc1e5cea8cae6919810407a8903248ad497.tar.gz opensbi-f7738cc1e5cea8cae6919810407a8903248ad497.zip | |
lib: sbi: Add sbi_pmp_is_enabled() helper
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260430045528.420437-7-npiggin@gmail.com
Signed-off-by: Anup Patel <anup@brainfault.org>
| -rw-r--r-- | include/sbi/sbi_pmp.h | 1 | ||||
| -rw-r--r-- | lib/sbi/riscv_asm.c | 6 | ||||
| -rw-r--r-- | lib/sbi/sbi_pmp.c | 9 |
3 files changed, 11 insertions, 5 deletions
diff --git a/include/sbi/sbi_pmp.h b/include/sbi/sbi_pmp.h index c38dda55..ce00ec0c 100644 --- a/include/sbi/sbi_pmp.h +++ b/include/sbi/sbi_pmp.h @@ -14,6 +14,7 @@ struct pmp { }; typedef struct pmp pmp_t; +bool sbi_pmp_is_enabled(pmp_t *pmp); int sbi_pmp_encode(pmp_t *pmp, unsigned long prot, unsigned long addr, unsigned long log2len); int sbi_pmp_decode(pmp_t *pmp, unsigned long *prot, unsigned long *addr, diff --git a/lib/sbi/riscv_asm.c b/lib/sbi/riscv_asm.c index 6c1f2344..69b6aea1 100644 --- a/lib/sbi/riscv_asm.c +++ b/lib/sbi/riscv_asm.c @@ -353,11 +353,7 @@ int is_pmp_entry_mapped(unsigned long entry) if (hart_pmp_read(&pmp, entry) != SBI_OK) return false; - /* If address matching bits are non-zero, the entry is enable */ - if (pmp.cfg & PMP_A) - return true; - - return false; + return sbi_pmp_is_enabled(&pmp); } int pmp_set(unsigned int n, unsigned long prot, unsigned long addr, diff --git a/lib/sbi/sbi_pmp.c b/lib/sbi/sbi_pmp.c index bb8151c0..fd1a0fd0 100644 --- a/lib/sbi/sbi_pmp.c +++ b/lib/sbi/sbi_pmp.c @@ -28,6 +28,15 @@ static unsigned long ctz(unsigned long x) return ret; } +bool sbi_pmp_is_enabled(pmp_t *pmp) +{ + /* If address matching bits are non-zero, the entry is enable */ + if (pmp->cfg & PMP_A) + return true; + + return false; +} + int sbi_pmp_encode(pmp_t *pmp, unsigned long prot, unsigned long addr, unsigned long log2len) { |
