Skip to content

Commit f7d5421

Browse files
authored
[libcpu][riscv] add a doc for wch saving the irq stack as stack-512 (#10063)
1 parent e0c8380 commit f7d5421

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

libcpu/risc-v/common/context_gcc.S

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ rt_hw_interrupt_enable:
4949
rt_hw_context_switch_to:
5050
la t0, __rt_rvstack
5151
#ifdef SOC_RISCV_FAMILY_CH32
52+
/*
53+
* if it is an assembly entry code, the SP offset value is determined by the assembly code,
54+
* but the C code is determined by the compiler, so we subtract 512 here as a reservation.
55+
* When entering the interrupt function of C code, the compiler automatically presses the stack
56+
* into the task stack. We can only change the SP value used by the calling function after switching
57+
* the interrupt stack.This problem can be solved by modifying the interrupt to the assembly entry,
58+
* and there is no need to reserve 512 bytes. You only need to switch the interrupt stack at the
59+
* beginning of the interrupt function
60+
*/
5261
addi t0, t0, -512 // for ch32
5362
#endif /* SOC_RISCV_FAMILY_CH32 */
5463
csrw mscratch,t0

0 commit comments

Comments
 (0)