rewrite 3 functions in context.asm for M16C port
rt_hw_context_switch() rt_hw_interrupt_disable() rt_hw_interrupt_enable() git-svn-id: https://rt-thread.googlecode.com/svn/trunk@654 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
bb3e4d4f6a
commit
005d4141d9
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
EXTERN rt_hw_timer_handler
|
EXTERN rt_hw_timer_handler
|
||||||
EXTERN rt_hw_uart0_receive_handler
|
EXTERN rt_hw_uart0_receive_handler
|
||||||
|
EXTERN os_context_switch
|
||||||
|
|
||||||
PUBLIC RelocatableVectTbl
|
PUBLIC RelocatableVectTbl
|
||||||
|
|
||||||
@ -30,7 +31,7 @@
|
|||||||
|
|
||||||
RelocatableVectTbl:
|
RelocatableVectTbl:
|
||||||
ORG 0
|
ORG 0
|
||||||
DC32 0 ; Vector 0: BRK
|
DC32 os_context_switch ; Vector 0: BRK
|
||||||
DC32 0 ; Vector 1: Reserved
|
DC32 0 ; Vector 1: Reserved
|
||||||
DC32 0 ; Vector 2: Reserved
|
DC32 0 ; Vector 2: Reserved
|
||||||
DC32 0 ; Vector 3: Reserved
|
DC32 0 ; Vector 3: Reserved
|
||||||
|
@ -10,15 +10,12 @@
|
|||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2010-04-09 fify the first version
|
* 2010-04-09 fify the first version
|
||||||
|
* 2010-04-19 fify rewrite rt_hw_interrupt_disable/enable fuction
|
||||||
*
|
*
|
||||||
* For : Renesas M16C
|
* For : Renesas M16C
|
||||||
* Toolchain : IAR's EW for M16C v3.401
|
* Toolchain : IAR's EW for M16C v3.401
|
||||||
*/
|
*/
|
||||||
|
|
||||||
;********************************************************************************************************
|
|
||||||
; PUBLIC FUNCTIONS
|
|
||||||
;********************************************************************************************************
|
|
||||||
|
|
||||||
RSEG CSTACK
|
RSEG CSTACK
|
||||||
|
|
||||||
RSEG ISTACK
|
RSEG ISTACK
|
||||||
@ -40,20 +37,36 @@
|
|||||||
PUBLIC rt_hw_context_switch_interrupt
|
PUBLIC rt_hw_context_switch_interrupt
|
||||||
PUBLIC rt_hw_timer_handler
|
PUBLIC rt_hw_timer_handler
|
||||||
PUBLIC rt_hw_uart0_receive_handler
|
PUBLIC rt_hw_uart0_receive_handler
|
||||||
|
PUBLIC os_context_switch
|
||||||
|
|
||||||
rt_hw_interrupt_disable
|
rt_hw_interrupt_disable
|
||||||
|
STC FLG, R0 ;fify 20100419
|
||||||
FCLR I
|
FCLR I
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
rt_hw_interrupt_enable
|
rt_hw_interrupt_enable
|
||||||
FSET I
|
LDC R0, FLG ;fify 20100419
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
;/*
|
.EVEN
|
||||||
; * void rt_hw_context_switch_to(rt_uint32 to);
|
os_context_switch:
|
||||||
; * r0 --> to
|
PUSHM R0,R1,R2,R3,A0,A1,SB,FB
|
||||||
; * this fucntion is used to perform the first thread switch
|
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
|
||||||
|
|
||||||
|
/*
|
||||||
|
* void rt_hw_context_switch_to(rt_uint32 to);
|
||||||
|
* 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
|
MOV.W R0, A0
|
||||||
LDC [A0], ISP
|
LDC [A0], ISP
|
||||||
@ -61,13 +74,14 @@ rt_hw_context_switch_to
|
|||||||
REIT
|
REIT
|
||||||
|
|
||||||
rt_hw_context_switch
|
rt_hw_context_switch
|
||||||
PUSHM R0,R1,R2,R3,A0,A1,SB,FB
|
CMP.W #1,rt_thread_switch_interrput_flag
|
||||||
MOV.W R0, A0
|
JEQ jump1
|
||||||
STC ISP, [A0]
|
MOV.W #1,rt_thread_switch_interrput_flag
|
||||||
MOV.W R1, A0
|
MOV.W R0, rt_interrupt_from_thread
|
||||||
LDC [A0], ISP
|
jump1
|
||||||
POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore all processor registers from the new task's stack
|
MOV.W R1, rt_interrupt_to_thread
|
||||||
REIT
|
INT #0
|
||||||
|
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
|
||||||
@ -86,7 +100,7 @@ rt_hw_context_switch_interrupt_do
|
|||||||
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
|
||||||
RTS ; Normal return
|
REIT
|
||||||
|
|
||||||
.EVEN
|
.EVEN
|
||||||
rt_hw_timer_handler:
|
rt_hw_timer_handler:
|
||||||
@ -98,7 +112,7 @@ rt_hw_timer_handler:
|
|||||||
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 registers from the new task's stack
|
POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore current task's registers
|
||||||
REIT ; Return from interrup
|
REIT ; Return from interrup
|
||||||
|
|
||||||
.EVEN
|
.EVEN
|
||||||
@ -111,7 +125,7 @@ rt_hw_uart0_receive_handler:
|
|||||||
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 registers from the new task's stack
|
POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore current task's registers
|
||||||
REIT ; Return from interrup
|
REIT ; Return from interrup
|
||||||
|
|
||||||
END
|
END
|
||||||
|
Loading…
x
Reference in New Issue
Block a user