mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 15:31:22 +01:00
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 <cfu@mips.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com> Link: https://lore.kernel.org/r/20250614172756.153902-1-apatel@ventanamicro.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user