📄 tct.s
字号:
;
; /* lock out all interrupts before any checking or changing */
;
; /* Obtain the current interrupt lockout posture. */
;
; /* reload the level base on the TCD_Interrupt_Level variable */
;
;
MRS a2,CPSR ; Pickup current CPSR
MOV a3,a2 ; save the CPSR value
ORR a2,a2,#LOCKOUT ; Build lockout CPSR
MSR CPSR_cxsf,a2 ; Lockout interrupts temporarily
BIC a3,a3,#LOCK_MSK ; Clear current interrupt levels
LDR a2,[pc, #Int_Level-.-8] ; Load address of TCD_Interrupt_Level
LDR a1,[a2, #0] ; Pickup current interrupt lockout
ORR a3,a3,a1 ; Build new CPSR with appropriate
; interrupts locked out
MSR CPSR_cxsf,a3 ; Setup new CPSR lockout bits
[ THUMB
BX lr ; Return to caller
|
MOV pc,lr ; Return to caller
]
;}
;
;
;
;/*************************************************************************/
;/* */
;/* FUNCTION */
;/* */
;/* TCT_Build_Task_Stack */
;/* */
;/* DESCRIPTION */
;/* */
;/* This function builds an initial stack frame for a task. The */
;/* initial stack contains information concerning initial values of */
;/* registers and the task's point of entry. Furthermore, the */
;/* initial stack frame is in the same form as an interrupt stack */
;/* frame. */
;/* */
;/* AUTHOR */
;/* */
;/* William E. Lamie, Accelerated Technology, Inc. */
;/* */
;/* CALLED BY */
;/* */
;/* TCC_Create_Task Create a new task */
;/* TCC_Reset_Task Reset the specified task */
;/* */
;/* CALLS */
;/* */
;/* None */
;/* */
;/* INPUTS */
;/* */
;/* task Task control block pointer */
;/* */
;/* OUTPUTS */
;/* */
;/* None */
;/* */
;/* HISTORY */
;/* */
;/* NAME DATE REMARKS */
;/* */
;/* W. Lamie 02-15-1994 Created initial version 1.0 */
;/* D. Lamie 02-15-1994 Verified version 1.0 */
;/* */
;/*************************************************************************/
;VOID TCT_Build_Task_Stack(TC_TCB *task)
;{
EXPORT TCT_Build_Task_Stack
TCT_Build_Task_Stack
;
; /* Pickup the stack base. */
; REG_Stack_Base = (BYTE_PTR) task -> tc_stack_start;
;
LDR a3,[a1,#&24] ; Pickup the stack starting address
;
; /* Pickup the stack size. */
; REG_Stack_Size = task -> tc_stack_size;
;
LDR a2,[a1,#&30] ; Pickup the stack size in bytes
;
; /* Calculate the stack ending address. */
; REG_Stack_End = REG_Stack_Base + REG_Stack_Size - 1;
;
ADD a4,a2,a3 ; Compute the beginning of stack
BIC a4,a4,#3 ; Insure word alignment
SUB a4,a4,#4 ; Reserve a word
;
; /* Save the stack ending address. */
; task -> tc_stack_end = REG_Stack_End;
;
STR a4,[a1,#&28] ; Save the stack ending address
;
; /* Reference the task shell. */
; REG_Function_Ptr = (VOID *) TCC_Task_Shell;
;
; /* Build an initial stack. This initial stack frame facilitates an
; interrupt return to the TCC_Task_Shell function, which in turn
; invokes the application task. The initial stack frame has the
; following format:
;
; (Lower Address) Stack Top -> 1 (Interrupt stack type)
; CPSR Saved CPSR
; a1 Saved a1
; a2 Saved a2
; a3 Saved a3
; a4 Saved a4
; v1 Saved v1
; v2 Saved v2
; v3 Saved v3
; v4 Saved v4
; v5 Saved v5
; v6/sb Saved v6/sl
; v7/sl Saved v7/sl
; fp Saved fp
; ip Saved ip
; sp Saved sp
; lr Saved lr
; (Higher Address) Stack Bottom-> pc Saved pc
; */
;
LDR a3,[pc, #Task_Shell-.-8] ; Pickup address of shell entry
[ THUMB
BIC a3,a3,#1 ; Clear low bit
]
STR a3,[a4], #-4 ; Store entry address on stack
MOV a3,#0 ; Clear value for initial registers
STR a3,[a4], #-4 ; Store initial lr
ADD a3,a4,#&8 ; Compute initial sp
STR a3,[a4], #-4 ; Store initial sp (Stack Bottom)
STR a3,[a4], #-4 ; Store initial ip
STR a3,[a4], #-4 ; Store initial fp
LDR a3,[a1,#&24] ; Pickup the stack starting address
STR a3,[a4], #-4 ; Store initial v7/sl
MOV a3,#0 ; Clear value for initial registers
STR a3,[a4], #-4 ; Store initial v6/sb
STR a3,[a4], #-4 ; Store initial v5
STR a3,[a4], #-4 ; Store initial v4
STR a3,[a4], #-4 ; Store initial v3
STR a3,[a4], #-4 ; Store initial v2
STR a3,[a4], #-4 ; Store initial v1
STR a3,[a4], #-4 ; Store initial a4
STR a3,[a4], #-4 ; Store initial a3
STR a3,[a4], #-4 ; Store initial a2
STR a3,[a4], #-4 ; Store initial a1
MSR CPSR_f,a3 ; Clear the flags
MRS a3,CPSR ; Pickup the CPSR
BIC a3,a3,#LOCK_MSK ; Clear initial interrupt lockout
[ THUMB
ORR a3,a3,#&20 ; Set to THUMB state
]
STR a3,[a4], #-4 ; Store CPSR on the initial stack
MOV a3,#1 ; Build interrupt stack type (1)
STR a3,[a4, #0] ; Store stack type on the top
;
; /* Save the minimum amount of remaining stack memory. */
; task -> tc_stack_minimum = REG_Stack_Size - 72;
;
MOV a3,#72 ; Size of interrupt stack frame
SUB a2,a2,a3 ; Compute minimum available bytes
STR a2,[a1, #&34] ; Save in minimum stack area
;
; /* Save the new stack pointer into the task's control block. */
; task -> tc_stack_pointer = (VOID *) Stack_Top;
;
STR a4,[a1, #&2C] ; Save stack pointer
[ THUMB
BX lr ; Return to caller
|
MOV pc,lr ; Return to caller
]
;}
;
;
;
;/*************************************************************************/
;/* */
;/* FUNCTION */
;/* */
;/* TCT_Build_HISR_Stack */
;/* */
;/* DESCRIPTION */
;/* */
;/* This function builds an HISR stack frame that allows quick */
;/* scheduling of the HISR. */
;/* */
;/* AUTHOR */
;/* */
;/* William E. Lamie, Accelerated Technology, Inc. */
;/* */
;/* CALLED BY */
;/* */
;/* TCC_Create_HISR Create HISR function */
;/* */
;/* CALLS */
;/* */
;/* None */
;/* */
;/* INPUTS */
;/* */
;/* hisr HISR control block pointer */
;/* */
;/* OUTPUTS */
;/* */
;/* None */
;/* */
;/* HISTORY */
;/* */
;/* NAME DATE REMARKS */
;/* */
;/* W. Lamie 02-15-1994 Created initial version 1.0 */
;/* D. Lamie 02-15-1994 Verified version 1.0 */
;/* */
;/*************************************************************************/
;VOID TCT_Build_HISR_Stack(TC_HCB *hisr)
;{
EXPORT TCT_Build_HISR_Stack
TCT_Build_HISR_Stack
;
; /* Pickup the stack base. */
; REG_Stack_Base = (BYTE_PTR) hisr -> tc_stack_start;
;
LDR a3,[a1,#&24] ; Pickup the stack starting address
;
; /* Pickup the stack size. */
; REG_Stack_Size = hisr -> tc_stack_size;
;
LDR a2,[a1,#&30] ; Pickup the stack size in bytes
;
; /* Calculate the stack ending address. */
; REG_Stack_End = REG_Stack_Base + REG_Stack_Size;
;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -