📄 tct.asm
字号:
RPTS 0
AND GIENOT,ST ;XIONGZHANGXUE
; LDI 0,IE ; Lockout interrupts
; NOP ; Interrupt lockout might not occur
; NOP ; for a few instructions
; AND GIENOT,ST ; Clear GIE bit in STatus register
;
; /* Determine if interrupts need to be enabled. */
;
LDI @_TCD_Interrupt_Level,IE ; Pickup global interrupt level
RETI ; Return, setting GIE bit in ST
;}
;
;
;/*************************************************************************/
;/* */
;/* 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 */
;/* */
;/* D. Foxall 02-07-1996 TMS320C30 version 1.0 */
;/* J. Trippi 03-11-1997 Modified for large memory model */
;/* */
;/*************************************************************************/
.global _TCT_Build_Task_Stack
_TCT_Build_Task_Stack:
;VOID TCT_Build_Task_Stack(TC_TCB *task)
;{
;
PUSH FP ; Save caller's frame pointer
LDI SP,FP ; Setup local frame
;
; /* register use: AR0 - task pointer (function argument)
; AR1 - task stack pointer
; R0, R1, R2 - temporary values */
;
.if NU_STACK
LDI *-FP(2),AR0 ; Pickup the task pointer
.else
LDI AR2,AR0
.endif
;
; /* Pickup the stack base. */
; stack_base = task -> tc_stack_start;
;
LDI *+AR0(TCB_STKSTART),AR1 ; Pickup start of stack area
;
; /* Pickup the stack size. */
; stack_size = task -> tc_stack_size;
;
LDI *+AR0(TCB_STKSIZE),R1 ; Pickup size of stack area
;
; /* Calculate the stack ending address. */
; stack_end = stack_base + stack_size - 1;
;
ADDI3 R1,AR1,R2 ; Calculate end of stack area
SUBI 1,R2
;
; /* Save the end of the stack area in the control block. */
; task -> tc_stack_end = stack_end;
;
STI R2,*+AR0(TCB_STKEND) ; Save end of stack area
;
; /* Save the minimum amount of remaining stack memory. */
; task -> tc_stack_minimum = stack_size - STKSAVSIZE;
;
SUBI STKSAVSIZE,R1
STI R1,*+AR0(TCB_STKMIN) ; Save minimum in control block
;
; /* Build the initial stack frame that facilitates an interrupt return
; to the thread. */
; /* Save current value of ST. */
;
.if NU_BIG
LDP @_TCT_Task_Shell_Addr ; Load Data Page Pointer
.endif
LDI @_TCT_Task_Shell_Addr,R0 ; All tasks have same entry point
STI R0,*AR1 ; Put task entry point on stack
LDI 0,R0
STI R0,*++AR1 ; Reserve space for AR0
STI R0,*++AR1 ; Reserve space for extra ret addr
STI R0,*++AR1 ; Reserve space for frame ptr AR3
RPTS 0 ; XIONGZHANGXUE
STI ST,*++AR1 ; Put current value of status reg
STI DP,*++AR1 ; Put current value of Data Page
LDI 0,R0 ; Clear R0
LDI REGSAVSIZE-2,R1 ; Init space on stack for
SUBI 1,R1 ; initial value of all registers
RPTS R1 ; R1 is repeat count - 1
STI R0,*++AR1 ; Repeat this instruction
LDI 1,R2
STI R2,*++AR1 ; Put interrupt stack type on stack
;
; /* Save the new stack pointer into the task's control block. */
; task -> tc_stack_pointer = AR1;
;
STI AR1,*+AR0(TCB_STKPTR) ; Save top of stack in TCB
;
; /* Return to the caller. */
LDI *-FP(1),R1
BD R1
LDI *FP,FP
NOP
SUBI 2,SP
*** B R1 ;BRANCH OCCURS
;}
;
;
;/*************************************************************************/
;/* */
;/* 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 */
;/* */
;/* D. Foxall 02-07-1996 TMS320C30 version 1.0 */
;/* J. Trippi 03-11-1997 Modified for large memory model */
;/* */
;/*************************************************************************/
.global _TCT_Build_HISR_Stack
_TCT_Build_HISR_Stack:
;VOID TCT_Build_HISR_Stack(TC_HCB *hisr)
;{
PUSH FP ; Save caller's frame pointer
LDI SP,FP ; Setup local frame
;
; /* register use: AR0 - HISR pointer (function argument)
; AR1 - HISR stack pointer
; R0, R1, R2 - temporary values */;
;
.if NU_STACK
LDI *-FP(2),AR0 ; Pickup the HISR pointer
.else
LDI AR2,AR0
.endif
;
; /* Pickup the stack base. */
; stack_base = hisr -> tc_stack_start;
;
LDI *+AR0(HCB_STKSTART),AR1 ; Pickup start of stack area
;
; /* Pickup the stack size. */
; stack_size = hisr -> tc_stack_size;
LDI *+AR0(HCB_STKSIZE),R1 ; Pickup size of stack area
;
; /* Calculate the stack ending address. */
; stack_end = stack_base + stack_size - 1;
;
ADDI R1,AR1,R2 ; Calculate end of stack area
SUBI 1,R2
;
; /* Save the end of the stack area in the control block. */
; hisr -> tc_stack_end = stack_end;
;
STI R2,*+AR0(HCB_STKEND) ; Save end of stack area
;
; /* Save the minimum amount of remaining stack memory. */
; hisr -> tc_stack_minimum = stack_size - MINSTKSAVSIZE;
;
SUBI MINSTKSAVSIZE,R1
STI R1,*+AR0(HCB_STKMIN) ; Save minimum in control block
;
; /* Build a solicited type of stack frame. */
;
.if NU_BIG
LDP @_TCT_HISR_Shell_Addr ; Load Data Page Pointer
.endif
LDI @_TCT_HISR_Shell_Addr,R0 ; All HISR's have same entry point
STI R0,*++AR1 ; Put HISR entry point on stack
LDI 0,R0 ; Clear R0
STI R0,*++AR1 ; Reserve space for frame ptr AR3
STI DP,*++AR1 ; Put current value of Data Page
LDI MINREGSAVSIZE-2,R1 ; Init space on stack for init value
SUBI 1,R1 ; of minimum context registers
RPTS R1 ; R1 is repeat count - 1
STI R0,*++AR1 ; Repeat this instruction
LDI 0,R2
STI R2,*++AR1 ; Put solicited stack type on stack
;
; /* Save the new stack pointer into the HISR's control block. */
; hisr -> tc_stack_pointer = AR1;
;
STI AR1,*+AR0(HCB_STKPTR) ; Save top of stack in HCB
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -