arch: riscv: pmp: simplify pmp region number computation
Simplify multiple ifdef case in computing region number. Also move these macros to core_pmp.c because they are only used in one file. Signed-off-by: Jim Shu <cwshu@andestech.com>
This commit is contained in:
parent
e3c8b4cae4
commit
b13dd54fb4
2 changed files with 22 additions and 45 deletions
|
@ -50,51 +50,6 @@
|
|||
#define PMP_CFG_CSR_NUM_FOR_STACK_GUARD 2
|
||||
#endif /* CONFIG_PMP_STACK_GUARD */
|
||||
|
||||
#ifdef CONFIG_PMP_POWER_OF_TWO_ALIGNMENT
|
||||
#ifdef CONFIG_USERSPACE
|
||||
#ifdef CONFIG_PMP_STACK_GUARD
|
||||
/*
|
||||
* 1 for interrupt stack guard: None
|
||||
* 1 for core state: R
|
||||
* 1 for program and read only data: RX
|
||||
* 1 for user thread stack: RW
|
||||
*/
|
||||
#define PMP_REGION_NUM_FOR_U_THREAD 4
|
||||
#else /* CONFIG_PMP_STACK_GUARD */
|
||||
/*
|
||||
* 1 for core state: R
|
||||
* 1 for program and read only data: RX
|
||||
* 1 for user thread stack: RW
|
||||
*/
|
||||
#define PMP_REGION_NUM_FOR_U_THREAD 3
|
||||
#endif /* CONFIG_PMP_STACK_GUARD */
|
||||
#define PMP_MAX_DYNAMIC_REGION (CONFIG_PMP_SLOT - PMP_REGION_NUM_FOR_U_THREAD)
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
|
||||
#else /* CONFIG_PMP_POWER_OF_TWO_ALIGNMENT */
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
#ifdef CONFIG_PMP_STACK_GUARD
|
||||
/*
|
||||
* 1 for interrupt stack guard: None
|
||||
* 1 for core state: R
|
||||
* 2 for program and read only data: RX
|
||||
* 2 for user thread stack: RW
|
||||
*/
|
||||
#define PMP_REGION_NUM_FOR_U_THREAD 6
|
||||
#else /* CONFIG_PMP_STACK_GUARD */
|
||||
/*
|
||||
* 1 for core state: R
|
||||
* 2 for program and read only data: RX
|
||||
* 2 for user thread stack: RW
|
||||
*/
|
||||
#define PMP_REGION_NUM_FOR_U_THREAD 5
|
||||
#endif /* CONFIG_PMP_STACK_GUARD */
|
||||
#define PMP_MAX_DYNAMIC_REGION ((CONFIG_PMP_SLOT - \
|
||||
PMP_REGION_NUM_FOR_U_THREAD) >> 1)
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
#endif /* CONFIG_PMP_POWER_OF_TWO_ALIGNMENT */
|
||||
|
||||
/*
|
||||
* The following structure defines the list of registers that need to be
|
||||
* saved/restored when a cooperative context switch occurs.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue