提交 e8a462b5 编写于 作者: D dzzxzz

optimize porting for M16C

void rt_hw_context_switch(rt_uint32_t from, rt_uint32_t to);

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1688 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 61d969f1
...@@ -15,55 +15,55 @@ ...@@ -15,55 +15,55 @@
* Toolchain : IAR's EW for M16C v3.401 * Toolchain : IAR's EW for M16C v3.401
*/ */
PUBLIC rt_hw_timer_handler PUBLIC rt_hw_timer_handler
PUBLIC rt_hw_uart0_receive_handler PUBLIC rt_hw_uart0_receive_handler
EXTERN rt_thread_switch_interrput_flag EXTERN rt_thread_switch_interrput_flag
EXTERN rt_interrupt_from_thread EXTERN rt_interrupt_from_thread
EXTERN rt_interrupt_to_thread EXTERN rt_interrupt_to_thread
EXTERN rt_interrupt_enter EXTERN rt_interrupt_enter
EXTERN rt_interrupt_leave EXTERN rt_interrupt_leave
EXTERN rt_tick_increase EXTERN rt_tick_increase
EXTERN u0rec_handler EXTERN u0rec_handler
RSEG CSTACK RSEG CSTACK
RSEG ISTACK RSEG ISTACK
RSEG CODE:CODE:NOROOT(2) RSEG CODE:CODE:NOROOT(2)
rt_hw_context_switch_interrupt_do rt_hw_context_switch_interrupt_do
MOV.W #0, rt_thread_switch_interrput_flag MOV.W #0, rt_thread_switch_interrput_flag
MOV.W rt_interrupt_from_thread, A0 MOV.W rt_interrupt_from_thread, A0
STC ISP, [A0] STC ISP, [A0]
MOV.W rt_interrupt_to_thread, A0 MOV.W rt_interrupt_to_thread, A0
LDC [A0], ISP LDC [A0], ISP
POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore all processor registers from the new task's stack POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore all processor registers from the new task's stack
REIT REIT
.EVEN .EVEN
rt_hw_timer_handler: rt_hw_timer_handler:
PUSHM R0,R1,R2,R3,A0,A1,SB,FB ; Save current task's registers PUSHM R0,R1,R2,R3,A0,A1,SB,FB ; Save current task's registers
JSR rt_interrupt_enter JSR rt_interrupt_enter
JSR rt_tick_increase JSR rt_tick_increase
JSR rt_interrupt_leave JSR rt_interrupt_leave
CMP.W #1,rt_thread_switch_interrput_flag CMP.W #1, rt_thread_switch_interrput_flag
JEQ rt_hw_context_switch_interrupt_do JEQ rt_hw_context_switch_interrupt_do
POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore current task's registers POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore current task's registers
REIT ; Return from interrup REIT ; Return from interrup
.EVEN .EVEN
rt_hw_uart0_receive_handler: rt_hw_uart0_receive_handler:
PUSHM R0,R1,R2,R3,A0,A1,SB,FB ; Save current task's registers PUSHM R0,R1,R2,R3,A0,A1,SB,FB ; Save current task's registers
JSR rt_interrupt_enter JSR rt_interrupt_enter
JSR u0rec_handler JSR u0rec_handler
JSR rt_interrupt_leave JSR rt_interrupt_leave
CMP.W #1, rt_thread_switch_interrput_flag CMP.W #1, rt_thread_switch_interrput_flag
JEQ rt_hw_context_switch_interrupt_do JEQ rt_hw_context_switch_interrupt_do
POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore current task's registers POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore current task's registers
REIT ; Return from interrup REIT ; Return from interrup
END END
...@@ -15,76 +15,70 @@ ...@@ -15,76 +15,70 @@
* *
* For : Renesas M16C * For : Renesas M16C
* Toolchain : IAR's EW for M16C v3.401 * Toolchain : IAR's EW for M16C v3.401
*/ */
RSEG CSTACK RSEG CSTACK
RSEG ISTACK RSEG ISTACK
RSEG CODE(1) RSEG CODE(1)
EXTERN rt_thread_switch_interrput_flag EXTERN rt_thread_switch_interrput_flag
EXTERN rt_interrupt_from_thread EXTERN rt_interrupt_from_thread
EXTERN rt_interrupt_to_thread EXTERN rt_interrupt_to_thread
PUBLIC rt_hw_interrupt_disable PUBLIC rt_hw_interrupt_disable
PUBLIC rt_hw_interrupt_enable PUBLIC rt_hw_interrupt_enable
PUBLIC rt_hw_context_switch_to PUBLIC rt_hw_context_switch_to
PUBLIC rt_hw_context_switch PUBLIC rt_hw_context_switch
PUBLIC rt_hw_context_switch_interrupt PUBLIC rt_hw_context_switch_interrupt
PUBLIC os_context_switch PUBLIC os_context_switch
rt_hw_interrupt_disable rt_hw_interrupt_disable:
STC FLG, R0 ;fify 20100419 STC FLG, R0 ;fify 20100419
FCLR I FCLR I
RTS RTS
rt_hw_interrupt_enable rt_hw_interrupt_enable:
LDC R0, FLG ;fify 20100419 LDC R0, FLG ;fify 20100419
RTS RTS
.EVEN .EVEN
os_context_switch: os_context_switch:
PUSHM R0,R1,R2,R3,A0,A1,SB,FB PUSHM R0,R1,R2,R3,A0,A1,SB,FB
CMP.W #0,rt_thread_switch_interrput_flag
JEQ exit MOV.W rt_interrupt_from_thread, A0
MOV.W #0, rt_thread_switch_interrput_flag STC ISP, [A0]
MOV.W rt_interrupt_from_thread, A0 MOV.W rt_interrupt_to_thread, A0
STC ISP, [A0] LDC [A0], ISP
MOV.W rt_interrupt_to_thread, A0
LDC [A0], ISP POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore registers from the new task's stack
exit REIT ; Return from interrup
POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore registers from the new task's stack
REIT ; Return from interrup
/* /*
* void rt_hw_context_switch_to(rt_uint32 to); * void rt_hw_context_switch_to(rt_uint32 to);
* r0 --> to * r0 --> to
* this fucntion is used to perform the first thread switch * this fucntion is used to perform the first thread switch
*/ */
rt_hw_context_switch_to rt_hw_context_switch_to:
MOV.W R0, A0 MOV.W R0, A0
LDC [A0], ISP LDC [A0], ISP
POPM R0,R1,R2,R3,A0,A1,SB,FB POPM R0,R1,R2,R3,A0,A1,SB,FB
REIT REIT
rt_hw_context_switch rt_hw_context_switch:
CMP.W #1,rt_thread_switch_interrput_flag MOV.W R0, rt_interrupt_from_thread
JEQ jump1 MOV.W R1, rt_interrupt_to_thread
MOV.W #1,rt_thread_switch_interrput_flag INT #0 ;software interrupt 0
MOV.W R0, rt_interrupt_from_thread
jump1
MOV.W R1, rt_interrupt_to_thread
INT #0
RTS RTS
rt_hw_context_switch_interrupt rt_hw_context_switch_interrupt:
CMP.W #1,rt_thread_switch_interrput_flag CMP.W #1, rt_thread_switch_interrput_flag
JEQ jump JEQ jump
MOV.W #1,rt_thread_switch_interrput_flag MOV.W #1, rt_thread_switch_interrput_flag
MOV.W R0, rt_interrupt_from_thread MOV.W R0, rt_interrupt_from_thread
jump jump
MOV.W R1, rt_interrupt_to_thread MOV.W R1, rt_interrupt_to_thread
RTS RTS
END END
...@@ -17,74 +17,68 @@ ...@@ -17,74 +17,68 @@
* Toolchain : IAR's EW for M16C v3.401 * Toolchain : IAR's EW for M16C v3.401
*/ */
RSEG CSTACK RSEG CSTACK
RSEG ISTACK RSEG ISTACK
RSEG CODE(1) RSEG CODE(1)
EXTERN rt_thread_switch_interrput_flag EXTERN rt_thread_switch_interrput_flag
EXTERN rt_interrupt_from_thread EXTERN rt_interrupt_from_thread
EXTERN rt_interrupt_to_thread EXTERN rt_interrupt_to_thread
PUBLIC rt_hw_interrupt_disable PUBLIC rt_hw_interrupt_disable
PUBLIC rt_hw_interrupt_enable PUBLIC rt_hw_interrupt_enable
PUBLIC rt_hw_context_switch_to PUBLIC rt_hw_context_switch_to
PUBLIC rt_hw_context_switch PUBLIC rt_hw_context_switch
PUBLIC rt_hw_context_switch_interrupt PUBLIC rt_hw_context_switch_interrupt
PUBLIC os_context_switch PUBLIC os_context_switch
rt_hw_interrupt_disable rt_hw_interrupt_disable:
STC FLG, R0 ;fify 20100419 STC FLG, R0 ;fify 20100419
FCLR I FCLR I
RTS RTS
rt_hw_interrupt_enable rt_hw_interrupt_enable:
LDC R0, FLG ;fify 20100419 LDC R0, FLG ;fify 20100419
RTS RTS
.EVEN .EVEN
os_context_switch: os_context_switch:
PUSHM R0,R1,R2,R3,A0,A1,SB,FB PUSHM R0,R1,R2,R3,A0,A1,SB,FB
CMP.W #0,rt_thread_switch_interrput_flag
JEQ exit MOV.W rt_interrupt_from_thread, A0
MOV.W #0, rt_thread_switch_interrput_flag STC ISP, [A0]
MOV.W rt_interrupt_from_thread, A0 MOV.W rt_interrupt_to_thread, A0
STC ISP, [A0] LDC [A0], ISP
MOV.W rt_interrupt_to_thread, A0
LDC [A0], ISP POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore registers from the new task's stack
exit REIT ; Return from interrup
POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore registers from the new task's stack
REIT ; Return from interrup
/* /*
* void rt_hw_context_switch_to(rt_uint32 to); * void rt_hw_context_switch_to(rt_uint32 to);
* r0 --> to * r0 --> to
* this fucntion is used to perform the first thread switch * this fucntion is used to perform the first thread switch
*/ */
rt_hw_context_switch_to rt_hw_context_switch_to:
MOV.W R0, A0 MOV.W R0, A0
LDC [A0], ISP LDC [A0], ISP
POPM R0,R1,R2,R3,A0,A1,SB,FB POPM R0,R1,R2,R3,A0,A1,SB,FB
REIT REIT
rt_hw_context_switch rt_hw_context_switch:
CMP.W #1,rt_thread_switch_interrput_flag MOV.W R0, rt_interrupt_from_thread
JEQ jump1 MOV.W R1, rt_interrupt_to_thread
MOV.W #1,rt_thread_switch_interrput_flag INT #0 ;software interrupt 0
MOV.W R0, rt_interrupt_from_thread
jump1
MOV.W R1, rt_interrupt_to_thread
INT #0
RTS RTS
rt_hw_context_switch_interrupt rt_hw_context_switch_interrupt:
CMP.W #1,rt_thread_switch_interrput_flag CMP.W #1, rt_thread_switch_interrput_flag
JEQ jump JEQ jump
MOV.W #1,rt_thread_switch_interrput_flag MOV.W #1, rt_thread_switch_interrput_flag
MOV.W R0, rt_interrupt_from_thread MOV.W R0, rt_interrupt_from_thread
jump jump
MOV.W R1, rt_interrupt_to_thread MOV.W R1, rt_interrupt_to_thread
RTS RTS
END END
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册