arch: riscv: option to init custom hw stacked esf members.
When RISCV_SOC_HAS_ISR_STACKING is used, it may be needed to initialize custom hw stacked esf members. Some initial values may need to be aligned with hw stacking mechanism to avoid any side effects. Signed-off-by: Łukasz Stępnicki <lukasz.stepnicki@nordicsemi.no>
This commit is contained in:
parent
8133f470dd
commit
9c574ed922
3 changed files with 16 additions and 0 deletions
|
@ -124,6 +124,11 @@ config RISCV_SOC_HAS_ISR_STACKING
|
|||
saved on the stack by the hardware, and the registers saved by the
|
||||
software macros. The structure must be called 'struct arch_esf'.
|
||||
|
||||
- SOC_ISR_STACKING_ESR_INIT: macro guarded by !_ASMLANGUAGE.
|
||||
Some hardware stacked registers should be initialized on init
|
||||
stack with proper values. This prevents from incorrect behavior
|
||||
on entry context switch when initial stack is restored.
|
||||
|
||||
config RISCV_SOC_HAS_CUSTOM_IRQ_HANDLING
|
||||
bool
|
||||
help
|
||||
|
|
|
@ -106,6 +106,10 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
|
|||
stack_init->soc_context = soc_esf_init;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RISCV_SOC_HAS_ISR_STACKING
|
||||
SOC_ISR_STACKING_ESR_INIT;
|
||||
#endif
|
||||
|
||||
thread->callee_saved.sp = (unsigned long)stack_init;
|
||||
|
||||
/* where to go when returning from z_riscv_switch() */
|
||||
|
|
|
@ -60,6 +60,13 @@
|
|||
|
||||
#endif /* DT_PROP(VPR_CPU, nordic_bus_width) == 64 */
|
||||
|
||||
/*
|
||||
* VPR stacked mcause needs to have proper value on initial stack.
|
||||
* Initial mret will restore this value.
|
||||
*/
|
||||
#define SOC_ISR_STACKING_ESR_INIT \
|
||||
stack_init->_mcause = 0;
|
||||
|
||||
#else /* _ASMLANGUAGE */
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue