[RFC PATCH 23/23] lib: sbi: pmp: document NA4/NAPOT-only helpers
Yu-Chien Peter Lin
peter.lin at sifive.com
Mon Nov 30 02:11:47 PST 2026
sbi_pmp_range_matches(), sbi_pmp_encode() and sbi_pmp_decode()
handle only NA4 and NAPOT entries, not TOR. Document this
limitation.
Also document parameter and return value descriptions for
sbi_pmp_encode() and sbi_pmp_decode().
Signed-off-by: Yu-Chien Peter Lin <peter.lin at sifive.com>
---
include/sbi/sbi_pmp.h | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/include/sbi/sbi_pmp.h b/include/sbi/sbi_pmp.h
index 6354b4c0..b5703cd1 100644
--- a/include/sbi/sbi_pmp.h
+++ b/include/sbi/sbi_pmp.h
@@ -41,6 +41,8 @@ bool sbi_pmp_addr_matches(unsigned long actual, unsigned long expected,
/**
* Check whether a PMP entry encodes the requested address range.
*
+ * Only NA4 and NAPOT entries are supported; TOR is not.
+ *
* @param pmp PMP entry to check
* @param addr_mask mask of implemented PMP address bits
* @param base requested range base address
@@ -50,8 +52,31 @@ bool sbi_pmp_addr_matches(unsigned long actual, unsigned long expected,
bool sbi_pmp_range_matches(const pmp_t *pmp, unsigned long addr_mask,
unsigned long base, unsigned long log2len);
+/**
+ * Encode a PMP entry for the given protection, address and log2 length.
+ *
+ * Only NA4 and NAPOT entries are supported; TOR is not.
+ *
+ * @param pmp PMP entry to encode
+ * @param prot protection to encode
+ * @param addr base address to encode
+ * @param log2len log2 of the range length
+ * @return SBI_OK on success, SBI_EINVAL on invalid parameters
+ */
int sbi_pmp_encode(pmp_t *pmp, unsigned long prot, unsigned long addr,
unsigned long log2len);
+
+/**
+ * Decode a PMP entry into protection, base address and log2 length.
+ *
+ * Only NA4 and NAPOT entries are supported; TOR is not.
+ *
+ * @param pmp PMP entry to decode
+ * @param prot pointer to decoded protection
+ * @param addr pointer to decoded base address
+ * @param log2len pointer to decoded log2 length
+ * @return SBI_OK on success, SBI_EINVAL on invalid parameters
+ */
int sbi_pmp_decode(pmp_t *pmp, unsigned long *prot, unsigned long *addr,
unsigned long *log2len);
--
2.43.7
More information about the opensbi
mailing list