📄 tct.s
字号:
LDR r1,Int_Level ; Load address of TCD_Interrupt_Level
LDR r0,[r1, #0] ; Pickup current interrupt lockout
ORR r2,r2,r0 ; Build new CPSR with appropriate
; interrupts locked out
MSR CPSR_cxsf,r2 ; Setup new CPSR lockout bits
BX 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. */
;/* */
;/* 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 r2,[r0,#TC_STACK_START] ; Pickup the stack starting address
;
; /* Pickup the stack size. */
; REG_Stack_Size = task -> tc_stack_size;
;
LDR r1,[r0,#TC_STACK_SIZE] ; Pickup the stack size in bytes
;
; /* Calculate the stack ending address. */
; REG_Stack_End = REG_Stack_Base + REG_Stack_Size - 1;
;
ADD r3,r1,r2 ; Compute the beginning of stack
BIC r3,r3,#3 ; Insure word alignment
SUB r3,r3,#4 ; Reserve a word
;
; /* Save the stack ending address. */
; task -> tc_stack_end = REG_Stack_End;
;
STR r3,[r0,#TC_STACK_END] ; 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
; r0 Saved r0
; r1 Saved r1
; r2 Saved r2
; r3 Saved r3
; r4 Saved r4
; r5 Saved r5
; r6 Saved r6
; r7 Saved r7
; r8 Saved r8
; r9 Saved r9
; r10 Saved r10
; r11 Saved r11
; r12 Saved r12
; sp Saved sp
; lr Saved lr
; (Higher Address) Stack Bottom-> pc Saved pc
; */
;
LDR r2,Task_Shell ; Pickup address of shell entry
[ THUMB
BIC r2,r2,#1 ; Clear low bit
]
STR r2,[r3], #-4 ; Store entry address on stack
MOV r2,#0 ; Clear value for initial registers
STR r2,[r3], #-4 ; Store initial lr
ADD r2,r3,#&8 ; Compute initial sp
STR r2,[r3], #-4 ; Store initial sp (Stack Bottom)
STR r2,[r3], #-4 ; Store initial ip
STR r2,[r3], #-4 ; Store initial fp
LDR r2,[r0,#TC_STACK_START] ; Pickup the stack starting address
STR r2,[r3], #-4 ; Store initial r10
MOV r2,#0 ; Clear value for initial registers
STR r9,[r3], #-4 ; Store initial r9
STR r2,[r3], #-4 ; Store initial r8
STR r2,[r3], #-4 ; Store initial r7
STR r2,[r3], #-4 ; Store initial r6
STR r2,[r3], #-4 ; Store initial r5
STR r2,[r3], #-4 ; Store initial r4
STR r2,[r3], #-4 ; Store initial r3
STR r2,[r3], #-4 ; Store initial r2
STR r2,[r3], #-4 ; Store initial r1
STR r2,[r3], #-4 ; Store initial r0
MSR CPSR_f,r2 ; Clear the flags
MRS r2,CPSR ; Pickup the CPSR
BIC r2,r2,#LOCK_MSK ; Clear initial interrupt lockout
[ THUMB
ORR r2,r2,#&20 ; Set to THUMB state
]
STR r2,[r3], #-4 ; Store CPSR on the initial stack
MOV r2,#1 ; Build interrupt stack type (1)
STR r2,[r3, #0] ; Store stack type on the top
;
; /* Save the minimum amount of remaining stack memory. */
; task -> tc_stack_minimum = REG_Stack_Size - 72;
;
MOV r2,#72 ; Size of interrupt stack frame
SUB r1,r1,r2 ; Compute minimum available bytes
STR r1,[r0, #TC_STACK_MINIMUM] ; Save in minimum stack area
;
; /* Save the new stack pointer into the task's control block. */
; task -> tc_stack_pointer = (VOID *) Stack_Top;
;
STR r3,[r0, #TC_STACK_POINTER] ; Save stack pointer
BX lr ; Return to caller
;}
;
;
;
;/*************************************************************************/
;/* */
;/* FUNCTION */
;/* */
;/* TCT_Build_HISR_Stack */
;/* */
;/* DESCRIPTION */
;/* */
;/* This function builds an HISR stack frame that allows quick */
;/* scheduling of the HISR. */
;/* */
;/* 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 r2,[r0,#TC_STACK_START] ; Pickup the stack starting address
;
; /* Pickup the stack size. */
; REG_Stack_Size = hisr -> tc_stack_size;
;
LDR r1,[r0,#TC_STACK_SIZE] ; Pickup the stack size in bytes
;
; /* Calculate the stack ending address. */
; REG_Stack_End = REG_Stack_Base + REG_Stack_Size;
;
ADD r3,r1,r2 ; Compute the beginning of stack
BIC r3,r3,#3 ; Insure word alignment
SUB r3,r3,#4 ; Reserve a word
;
; /* Save the stack ending address. */
; hisr -> tc_stack_end = REG_Stack_End;
;
STR r3,[r0,#TC_STACK_END] ; Save the stack ending address
;
; /* Reference the HISR shell. */
; REG_Function_Ptr = (VOID *) TCT_HISR_Shell;
;
; /* Build an initial stack. This initial stack frame facilitates an
; solicited return to the TCT_HISR_Shell function, which in turn
; invokes the appropriate HISR. The initial HISR stack frame has the
; following format:
;
; (Lower Address) Stack Top -> 0 (Solicited stack type)
; !!FOR THUMB ONLY!! 0/0x20 Saved state mask
; r4 Saved r4
; r5 Saved r5
; r6 Saved r6
; r7 Saved r7
; r8 Saved r8
; r9 Saved r9
; r10 Saved r10
; r11 Saved r11
; r12 Saved r12
; (Higher Address) Stack Bottom-> pc Saved pc
; */
;
LDR r2,HISR_Shell ; Pickup address of shell entry
STR r2,[r3], #-4 ; Store entry address on stack
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -