riscv/nuttsbi: revise PMP manipulation in NuttX SBI

Current NuttX SBI assumes empty PMP settings but that is not always
true, for example some bootloaders may have PMP entries locked before
handling over to NuttX. This patch revises it by not using hardcoded
PMP region number.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
This commit is contained in:
Yanfeng Liu 2024-03-07 17:49:30 +08:00 committed by Alan Carvalho de Assis
parent 522c5c0eac
commit cc389b1984
2 changed files with 4 additions and 2 deletions

View File

@ -160,6 +160,9 @@
__asm__ __volatile__("csrc " __STR(reg) ", %0" :: "rK"(bits)); \
})
#define riscv_append_pmp_region(a, b, s) \
riscv_config_pmp_region(riscv_next_free_pmp_region(), a, b, s)
#endif
/****************************************************************************

View File

@ -119,8 +119,7 @@ void sbi_start(void)
/* Open everything for PMP */
WRITE_CSR(pmpaddr0, -1);
WRITE_CSR(pmpcfg0, (PMPCFG_A_NAPOT | PMPCFG_R | PMPCFG_W | PMPCFG_X));
riscv_append_pmp_region(PMPCFG_A_NAPOT | PMPCFG_RWX_MASK, 0, -1);
/* Then jump to the S-mode start function */