From fad909bd55b2a02a0a9d9b983c7e7877b0dbe6fd Mon Sep 17 00:00:00 2001 From: yby <1632443748@qq.com> Date: Mon, 17 Jul 2023 23:06:29 +0800 Subject: [PATCH] =?UTF-8?q?[libcpu][arc]=E4=BF=AE=E5=A4=8Darc=E6=9E=B6?= =?UTF-8?q?=E6=9E=84=E7=BA=BF=E7=A8=8B=E5=88=87=E6=8D=A2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libcpu/arc/em/contex_gcc_mw.S | 19 ++++++++++++------- libcpu/arc/em/cpuport.c | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/libcpu/arc/em/contex_gcc_mw.S b/libcpu/arc/em/contex_gcc_mw.S index 0f6fe48fd6a..5f608fb8289 100644 --- a/libcpu/arc/em/contex_gcc_mw.S +++ b/libcpu/arc/em/contex_gcc_mw.S @@ -9,7 +9,7 @@ .global rt_interrupt_enter; .global rt_interrupt_leave; -.global context_switch_reqflg; +.global rt_thread_switch_interrupt_flag; .global rt_interrupt_from_thread; .global rt_interrupt_to_thread; .global exc_nest_count; @@ -47,6 +47,7 @@ dispatcher: /* return routine when task dispatch happened in task context */ dispatch_r: RESTORE_NONSCRATCH_REGS + RESTORE_R0_TO_R12 j [blink] /* @@ -72,10 +73,13 @@ rt_hw_interrupt_enable: .global rt_hw_context_switch_interrupt .align 4 rt_hw_context_switch_interrupt: + ld r2, [rt_thread_switch_interrupt_flag] + breq r2, 1, _reswitch /* Check the flag, if it is 1, skip to reswitch */ + mov r2, 1 + st r2, [rt_thread_switch_interrupt_flag] st r0, [rt_interrupt_from_thread] +_reswitch: st r1, [rt_interrupt_to_thread] - mov r0, 1 - st r0, [context_switch_reqflg] j [blink] @@ -87,6 +91,7 @@ rt_hw_context_switch_interrupt: .global rt_hw_context_switch .align 4 rt_hw_context_switch: + SAVE_R0_TO_R12 SAVE_NONSCRATCH_REGS mov r2, dispatch_r push r2 @@ -189,7 +194,7 @@ ret_exc: lr r1, [AUX_IRQ_ACT] /* nest interrupt case */ brne r1, 0, ret_exc_1 - ld r0, [context_switch_reqflg] + ld r0, [rt_thread_switch_interrupt_flag] brne r0, 0, ret_exc_2 ret_exc_1: /* return from non-task context, interrupts or exceptions are nested */ EXCEPTION_EPILOGUE @@ -199,7 +204,7 @@ ret_exc_1: /* return from non-task context, interrupts or exceptions are nested ret_exc_2: /* clear dispatch request */ mov r0, 0 - st r0, [context_switch_reqflg] + st r0, [rt_thread_switch_interrupt_flag] SAVE_CALLEE_REGS /* save callee save registers */ @@ -304,7 +309,7 @@ ret_int: bclr r2, r1, r3 brne r2, 0, ret_int_1 - ld r0, [context_switch_reqflg] + ld r0, [rt_thread_switch_interrupt_flag] brne r0, 0, ret_int_2 ret_int_1: /* return from non-task context */ INTERRUPT_EPILOGUE @@ -313,7 +318,7 @@ ret_int_1: /* return from non-task context */ ret_int_2: /* clear dispatch request */ mov r0, 0 - st r0, [context_switch_reqflg] + st r0, [rt_thread_switch_interrupt_flag] /* interrupt return by SW */ lr r10, [AUX_IRQ_ACT] diff --git a/libcpu/arc/em/cpuport.c b/libcpu/arc/em/cpuport.c index 8befd509ab5..679e2e78eea 100644 --- a/libcpu/arc/em/cpuport.c +++ b/libcpu/arc/em/cpuport.c @@ -16,7 +16,7 @@ extern void start_r(void); -rt_uint32_t context_switch_reqflg; +rt_uint32_t rt_thread_switch_interrupt_flag; rt_uint32_t rt_interrupt_from_thread; rt_uint32_t rt_interrupt_to_thread; rt_uint32_t exc_nest_count;