[RFC PATCH 19/23] lib: sbi: hart_pmp: export sbi_hart_pmp_read()
Yu-Chien Peter Lin
peter.lin at sifive.com
Mon Nov 30 02:11:43 PST 2026
Rename static hart_pmp_read() to sbi_hart_pmp_read() and declare it
in sbi_hart_pmp.h because the SiFive PMP provider needs to read back
locked entries to detect conflicts. Register-access behavior is
unchanged.
Signed-off-by: Yu-Chien Peter Lin <peter.lin at sifive.com>
---
include/sbi/sbi_hart_pmp.h | 3 +++
lib/sbi/sbi_hart_pmp.c | 14 +++++++-------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/include/sbi/sbi_hart_pmp.h b/include/sbi/sbi_hart_pmp.h
index bf91072d..13281450 100644
--- a/include/sbi/sbi_hart_pmp.h
+++ b/include/sbi/sbi_hart_pmp.h
@@ -10,6 +10,9 @@
#include <sbi/sbi_types.h>
#include <sbi/sbi_pmp.h>
+/* Raw PMP config and address register access */
+int sbi_hart_pmp_read(pmp_t *pmp, unsigned int n);
+
/* Verified PMP writes, masked by the implemented address width */
int sbi_hart_pmp_write_verified(unsigned int n, const pmp_t *pmp);
int sbi_hart_pmp_set_verified(unsigned int n, unsigned long prot,
diff --git a/lib/sbi/sbi_hart_pmp.c b/lib/sbi/sbi_hart_pmp.c
index 1e88be73..d14c575c 100644
--- a/lib/sbi/sbi_hart_pmp.c
+++ b/lib/sbi/sbi_hart_pmp.c
@@ -18,7 +18,7 @@
#include <sbi/sbi_tlb.h>
#include <sbi/riscv_asm.h>
-static int hart_pmp_read(pmp_t *pmp, unsigned int n)
+int sbi_hart_pmp_read(pmp_t *pmp, unsigned int n)
{
int pmpcfg_csr, pmpcfg_shift, pmpaddr_csr;
unsigned long cfgmask;
@@ -82,7 +82,7 @@ int sbi_hart_pmp_disable(unsigned int n)
pmp_t pmp;
int rc;
- rc = hart_pmp_read(&pmp, n);
+ rc = sbi_hart_pmp_read(&pmp, n);
if (rc)
return rc;
@@ -102,7 +102,7 @@ int sbi_hart_pmp_write_verified(unsigned int n, const pmp_t *pmp)
if (rc)
return rc;
- rc = hart_pmp_read(&actual, n);
+ rc = sbi_hart_pmp_read(&actual, n);
if (rc)
return rc;
@@ -128,7 +128,7 @@ int sbi_hart_pmp_set_verified(unsigned int n, unsigned long prot,
if (rc)
return rc;
- rc = hart_pmp_read(&pmp, n);
+ rc = sbi_hart_pmp_read(&pmp, n);
if (rc)
return rc;
@@ -148,7 +148,7 @@ int sbi_hart_pmp_disable_verified(unsigned int n)
if (rc)
return rc;
- rc = hart_pmp_read(&pmp, n);
+ rc = sbi_hart_pmp_read(&pmp, n);
if (rc)
return rc;
@@ -159,7 +159,7 @@ bool sbi_hart_is_pmp_enabled(unsigned int n)
{
pmp_t pmp;
- if (hart_pmp_read(&pmp, n) != SBI_OK)
+ if (sbi_hart_pmp_read(&pmp, n) != SBI_OK)
return false;
return sbi_pmp_is_enabled(&pmp);
@@ -184,7 +184,7 @@ int sbi_hart_pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *add
pmp_t pmp;
int rc;
- rc = hart_pmp_read(&pmp, n);
+ rc = sbi_hart_pmp_read(&pmp, n);
if (rc)
return rc;
--
2.43.7
More information about the opensbi
mailing list