summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChao-ying Fu <[email protected]>2025-06-14 22:57:56 +0530
committerAnup Patel <[email protected]>2025-06-17 09:34:01 +0530
commit13abda516928a8823e6b7b65b0a29bb338484227 (patch)
treec4756e1bbbcf41d309e5481c819b9ff0b1171cf7 /include
parent324021423d063702a5cb2d4207a3a9c4e999549f (diff)
lib: sbi_platform: Add platform specific pmp_set() and pmp_disable()
Allow platforms to implement platform specific PMP setup and PMP disable functions which are called before actual PMP CSRs are configured. Also, implement pmp_set() and pmp_disable() for MIPS P8700. Signed-off-by: Chao-ying Fu <[email protected]> Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
Diffstat (limited to 'include')
-rw-r--r--include/sbi/sbi_platform.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h
index 08ece320..c6d30080 100644
--- a/include/sbi/sbi_platform.h
+++ b/include/sbi/sbi_platform.h
@@ -142,6 +142,13 @@ struct sbi_platform_operations {
/** platform specific handler to fixup store fault */
int (*emulate_store)(int wlen, unsigned long addr,
union sbi_ldst_data in_val);
+
+ /** platform specific pmp setup on current HART */
+ void (*pmp_set)(unsigned int n, unsigned long flags,
+ unsigned long prot, unsigned long addr,
+ unsigned long log2len);
+ /** platform specific pmp disable on current HART */
+ void (*pmp_disable)(unsigned int n);
};
/** Platform default per-HART stack size for exception/interrupt handling */
@@ -644,6 +651,38 @@ static inline int sbi_platform_emulate_store(const struct sbi_platform *plat,
return SBI_ENOTSUPP;
}
+/**
+ * Platform specific PMP setup on current HART
+ *
+ * @param plat pointer to struct sbi_platform
+ * @param n index of the pmp entry
+ * @param flags domain memregion flags
+ * @param prot attribute of the pmp entry
+ * @param addr address of the pmp entry
+ * @param log2len size of the pmp entry as power-of-2
+ */
+static inline void sbi_platform_pmp_set(const struct sbi_platform *plat,
+ unsigned int n, unsigned long flags,
+ unsigned long prot, unsigned long addr,
+ unsigned long log2len)
+{
+ if (plat && sbi_platform_ops(plat)->pmp_set)
+ sbi_platform_ops(plat)->pmp_set(n, flags, prot, addr, log2len);
+}
+
+/**
+ * Platform specific PMP disable on current HART
+ *
+ * @param plat pointer to struct sbi_platform
+ * @param n index of the pmp entry
+ */
+static inline void sbi_platform_pmp_disable(const struct sbi_platform *plat,
+ unsigned int n)
+{
+ if (plat && sbi_platform_ops(plat)->pmp_disable)
+ sbi_platform_ops(plat)->pmp_disable(n);
+}
+
#endif
#endif