Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nrf fromlist] arch: riscv: option to init custom hw stacked esf memb… #2432

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions arch/riscv/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,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
Expand Down
4 changes: 4 additions & 0 deletions arch/riscv/core/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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() */
Expand Down
7 changes: 7 additions & 0 deletions soc/nordic/common/vpr/soc_isr_stacking.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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;

Check notice on line 71 in soc/nordic/common/vpr/soc_isr_stacking.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

soc/nordic/common/vpr/soc_isr_stacking.h:71 -#define SOC_ISR_STACKING_ESR_INIT \ - stack_init->_mcause = 0; +#define SOC_ISR_STACKING_ESR_INIT stack_init->_mcause = 0;
#else /* _ASMLANGUAGE */

/*
Expand Down
Loading