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
This commit is contained in:
dzzxzz 2011-09-01 08:25:54 +00:00
parent 61d969f1b9
commit e8a462b5c7
3 changed files with 116 additions and 128 deletions

View File

@ -47,7 +47,7 @@ rt_hw_timer_handler:
JSR rt_tick_increase
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
POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore current task's registers

View File

@ -15,7 +15,7 @@
*
* For : Renesas M16C
* Toolchain : IAR's EW for M16C v3.401
*/
*/
RSEG CSTACK
@ -34,26 +34,24 @@
PUBLIC rt_hw_context_switch_interrupt
PUBLIC os_context_switch
rt_hw_interrupt_disable
rt_hw_interrupt_disable:
STC FLG, R0 ;fify 20100419
FCLR I
RTS
rt_hw_interrupt_enable
rt_hw_interrupt_enable:
LDC R0, FLG ;fify 20100419
RTS
.EVEN
os_context_switch:
PUSHM R0,R1,R2,R3,A0,A1,SB,FB
CMP.W #0,rt_thread_switch_interrput_flag
JEQ exit
MOV.W #0, rt_thread_switch_interrput_flag
MOV.W rt_interrupt_from_thread, A0
STC ISP, [A0]
MOV.W rt_interrupt_to_thread, A0
LDC [A0], ISP
exit
POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore registers from the new task's stack
REIT ; Return from interrup
@ -62,26 +60,22 @@ exit
* r0 --> to
* this fucntion is used to perform the first thread switch
*/
rt_hw_context_switch_to
rt_hw_context_switch_to:
MOV.W R0, A0
LDC [A0], ISP
POPM R0,R1,R2,R3,A0,A1,SB,FB
REIT
rt_hw_context_switch
CMP.W #1,rt_thread_switch_interrput_flag
JEQ jump1
MOV.W #1,rt_thread_switch_interrput_flag
rt_hw_context_switch:
MOV.W R0, rt_interrupt_from_thread
jump1
MOV.W R1, rt_interrupt_to_thread
INT #0
INT #0 ;software interrupt 0
RTS
rt_hw_context_switch_interrupt
CMP.W #1,rt_thread_switch_interrput_flag
rt_hw_context_switch_interrupt:
CMP.W #1, rt_thread_switch_interrput_flag
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
jump
MOV.W R1, rt_interrupt_to_thread

View File

@ -34,26 +34,24 @@
PUBLIC rt_hw_context_switch_interrupt
PUBLIC os_context_switch
rt_hw_interrupt_disable
rt_hw_interrupt_disable:
STC FLG, R0 ;fify 20100419
FCLR I
RTS
rt_hw_interrupt_enable
rt_hw_interrupt_enable:
LDC R0, FLG ;fify 20100419
RTS
.EVEN
os_context_switch:
PUSHM R0,R1,R2,R3,A0,A1,SB,FB
CMP.W #0,rt_thread_switch_interrput_flag
JEQ exit
MOV.W #0, rt_thread_switch_interrput_flag
MOV.W rt_interrupt_from_thread, A0
STC ISP, [A0]
MOV.W rt_interrupt_to_thread, A0
LDC [A0], ISP
exit
POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore registers from the new task's stack
REIT ; Return from interrup
@ -62,26 +60,22 @@ exit
* r0 --> to
* this fucntion is used to perform the first thread switch
*/
rt_hw_context_switch_to
rt_hw_context_switch_to:
MOV.W R0, A0
LDC [A0], ISP
POPM R0,R1,R2,R3,A0,A1,SB,FB
REIT
rt_hw_context_switch
CMP.W #1,rt_thread_switch_interrput_flag
JEQ jump1
MOV.W #1,rt_thread_switch_interrput_flag
rt_hw_context_switch:
MOV.W R0, rt_interrupt_from_thread
jump1
MOV.W R1, rt_interrupt_to_thread
INT #0
INT #0 ;software interrupt 0
RTS
rt_hw_context_switch_interrupt
CMP.W #1,rt_thread_switch_interrput_flag
rt_hw_context_switch_interrupt:
CMP.W #1, rt_thread_switch_interrput_flag
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
jump
MOV.W R1, rt_interrupt_to_thread