From 72519786feac93b7c0f2a93149c20941afd8df19 Mon Sep 17 00:00:00 2001 From: Huaqi Fang <578567190@qq.com> Date: Thu, 22 Dec 2022 14:30:00 +0800 Subject: [PATCH] OS: Fix rt-thread task switch when swi triggered by other harts MCAUSE : 0x18000001 MDCAUSE: 0x1 MEPC : 0xdeadbeee MTVAL : 0xdeadbee8 HARTID : 3 ra: 0x0, tp: 0xfea007a0, t0: 0xdeadbeef, t1: 0xdeadbeef, t2: 0xdeadbeef, t3: 0xdeadbeef, t4: 0xdeadbeef, t5: 0xdeadbeef, t6: 0xdeadbeef a0: 0xdeadbeef, a1: 0xdeadbeef, a2: 0xdeadbeef, a3: 0xdeadbeef, a4: 0xdeadbeef, a5: 0xdeadbeef, a6: 0xdeadbeef, a7: 0xdeadbeef cause: 0x18000001, epc: 0xdeadbeee msubm: 0x80 Signed-off-by: Huaqi Fang <578567190@qq.com> --- OS/RTThread/libcpu/risc-v/nuclei/cpuport.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OS/RTThread/libcpu/risc-v/nuclei/cpuport.c b/OS/RTThread/libcpu/risc-v/nuclei/cpuport.c index 8a3bd993..d7abb94b 100644 --- a/OS/RTThread/libcpu/risc-v/nuclei/cpuport.c +++ b/OS/RTThread/libcpu/risc-v/nuclei/cpuport.c @@ -141,6 +141,11 @@ void xPortTaskSwitch(void) /* Clear Software IRQ, A MUST */ SysTimer_ClearSWIRQ(); rt_thread_switch_interrupt_flag = 0; + // make from thread to be to thread + // If there is another swi interrupt triggered by other harts + // not through rt_hw_context_switch or rt_hw_context_switch_interrupt + // the task switch should just do a same task save and restore + rt_interrupt_from_thread = rt_interrupt_to_thread; } void vPortSetupTimerInterrupt(void)