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>
This commit is contained in:
Nicholas Piggin
2026-04-30 14:55:23 +10:00
committed by Anup Patel
parent 8f1a6164f2
commit f7738cc1e5
3 changed files with 11 additions and 5 deletions
+1
View File
@@ -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,
+1 -5
View File
@@ -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,
+9
View File
@@ -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)
{