📄 tct.s
字号:
;************************************************************************
;*
;* Copyright Mentor Graphics Corporation 2005
;* All Rights Reserved.
;*
;* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
;* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
;* SUBJECT TO LICENSE TERMS.
;*
;************************************************************************
;************************************************************************
;*
;* FILE NAME VERSION
;*
;* tct.s Nucleus PLUS\ARM926 DM320\Code Composer 1.15.1
;*
;* COMPONENT
;*
;* TC - Thread Control
;*
;* DESCRIPTION
;*
;* This file contains the target processor dependent routines for
;* performing target-dependent scheduling functions.
;*
;* GLOBAL FUNCTIONS
;*
;* *****************************
;* * GENERIC FUNCTIONS *
;* *****************************
;*
;* TCT_Control_Interrupts Enable / disable interrupts
;* TCT_Local_Control_Interrupts Local enable / disable ints
;* TCT_Restore_Interrupts Restore global interrupts
;* TCT_Build_Task_Stack Build initial task stack
;* TCT_Build_HISR_Stack Build initial HISR stack
;* TCT_Build_Signal_Frame Build signal handler frame
;* TCT_Check_Stack Check current stack
;* TCT_Schedule Schedule the next thread
;* TCT_Control_To_Thread Transfer control to a thread
;* TCT_Control_To_System Transfer control from thread
;* TCT_Signal_Exit Exit from signal handler
;* TCT_Current_Thread Returns a pointer to current
;* thread
;* TCT_Set_Execute_Task Sets TCD_Execute_Task under
;* protection from interrupts
;* TCT_Protect Protect critical section
;* TCT_Unprotect Unprotect critical section
;* TCT_Unprotect_Specific Release specific protection
;* TCT_Set_Current_Protect Set the thread's current
;* protection field
;* TCT_Protect_Switch Switch to protected thread
;* TCT_Schedule_Protected Schedule the protected thread
;* TCT_Interrupt_Context_Save Save interrupted context
;* TCT_Interrupt_Context_Restore Restore interrupted context
;* TCT_Activate_HISR Activate a HISR
;* TCT_HISR_Shell HISR execution shell
;*
;* *****************************
;* * TARGET SPECIFIC FUNCTIONS *
;* *****************************
;*
;* None
;*
;* LOCAL FUNCTIONS
;*
;* None
;*
;************************************************************************
;**********************************
;* INCLUDE ASSEMBLY CONSTANTS *
;**********************************
.include asm_defs.inc
;**********************************
;* EXTERNAL VARIABLE DECLARATIONS *
;**********************************
;extern TC_TCB *TCD_Execute_Task;
;extern TC_HCB *TCD_Execute_HISR;
;extern VOID *TCD_Current_Thread;
;extern VOID *TCD_System_Stack;
;extern INT TCD_Interrupt_Count;
;extern TC_HCB *TCD_Active_HISR_Heads[TC_HISR_PRIORITIES];
;extern TC_HCB *TCD_Active_HISR_Tails[TC_HISR_PRIORITIES];
;extern INT TCD_Interrupt_Level;
;extern UNSIGNED TMD_Time_Slice;
;extern INT TMD_Time_Slice_State;
.ref _TCD_Execute_Task
.ref _TCD_Execute_HISR
.ref _TCD_Current_Thread
.ref _TCD_System_Stack
.ref _TCD_Interrupt_Count
.ref _TCD_Active_HISR_Heads
.ref _TCD_Active_HISR_Tails
.ref _TCD_Interrupt_Level
.ref _TMD_Time_Slice
.ref _TMD_Time_Slice_State
;**********************************
;* EXTERNAL FUNCTION DECLARATIONS *
;**********************************
;extern VOID TCC_Task_Shell(VOID);
;extern VOID TCC_Signal_Shell(VOID);
;extern VOID ERC_System_Error(INT);
.ref _TCC_Task_Shell
.ref _TCC_Signal_Shell
.ref _ERC_System_Error
.if NU_TEST2_SUPPORT
.ref _Set_Suspend_Time
.endif
.if NU_TEST3_SUPPORT
.ref _Set_Context_Save_Start
.ref _Set_Context_Save_End
.ref _Set_Context_Restore_Start
.ref _Set_Context_Restore_End
.endif
.if NU_PROFILE_PLUS
.ref __NU_Idle_Hook
.ref __NU_Schedule_Task_Hook
.endif
;**********************************
;* GLOBAL VARIABLE DECLARATIONS *
;**********************************
; Define variable used to hold system stack limit. The stack limit is utilized
; by the ARM tools when the /swst switch is invoked. This will allow
; stack over-flows to be checked.
.def _TCT_System_Limit
.bss _TCT_System_Limit, 4, 4 ; Reserve 4-bytes with 4-byte alignment
.if NU_FIQ_SUPPORT
; Define variable used as flag to indicate when a "special" nested interrupt
; occurs. This situation occurs when an FIQ nests on top of an IRQ before
; the global interrupt count has been incremented. This flag is used to
; help correct context save/restore routines in this situation.
.bss TCT_Special_Nested, 4, 4 ; Reserve 4-bytes with 4-byte alignment
.endif
;**********************************
;* LOCAL VARIABLES *
;**********************************
.text
.align 4
; The following are local variables. ARM Architecture uses
; PC relative addressing, so all global data accessed must
; reside within close proximity (<4Kb in ARM, <1Kb in THUMB)
; to the instructions that access them.
; These are essentially pointers to global data.
.if NU_FIQ_SUPPORT
TCT_Special_Nested1
.word TCT_Special_Nested
.endif
TCT_System_Limit1
.word _TCT_System_Limit
TCT_Int_Level
.word _TCD_Interrupt_Level
TCT_Task_Shell
.word _TCC_Task_Shell
TCT_Signal_Shell
.word _TCC_Signal_Shell
TCT_Current_Thread1
.word _TCD_Current_Thread
TCT_Execute_HISR
.word _TCD_Execute_HISR
TCT_Execute_Task
.word _TCD_Execute_Task
TCT_Time_Slice
.word _TMD_Time_Slice
TCT_Slice_State
.word _TMD_Time_Slice_State
TCT_System_Stack
.word _TCD_System_Stack
TCT_Int_Count
.word _TCD_Interrupt_Count
TCT_HISR_Tails
.word _TCD_Active_HISR_Tails
TCT_HISR_Heads
.word _TCD_Active_HISR_Heads
TCT_HISR_Shell1
.word TCT_HISR_Shell
;************************************************************************
;*
;* FUNCTION
;*
;* TCT_Control_Interrupts
;*
;* DESCRIPTION
;*
;* This function enables and disables interrupts as specified by
;* the caller. Interrupts disabled by this call are left disabled
;* until the another call is made to enable them.
;*
;* CALLED BY
;*
;* Application
;*
;* CALLS
;*
;* None
;*
;* INPUTS
;*
;* r0 - New Interrupt Level
;*
;* OUTPUTS
;*
;* r0 - Old Interrupt Level
;*
;* REGISTERS MODIFIED
;*
;* r0, r1, r2, r3
;*
;* HISTORY
;*
;* NAME DATE REMARKS
;*
;* S. Nguyen 03/28/2005 Released version 1.15.1
;*
;************************************************************************
;INT TCT_Control_Interrupts(INT interrupt_level);
.def _TCT_Control_Interrupts
_TCT_Control_Interrupts
; Lock out all interrupts before any checking or changing
MRS r2,CPSR ; Pickup current CPSR
ORR r2,r2,#LOCKOUT ; Build lockout CPSR
MSR CPSR,r2 ; Lockout interrupts temporarily
; Obtain the current interrupt lockout posture.
LDR r1,TCT_Int_Level ; Pickup interrupt level
LDR r3,[r1] ; Pickup current interrupt lockout
; Setup new interrupt lockout posture.
BIC r2,r2,#LOCK_MSK ; Clear lockout mask
ORR r2,r2,r0 ; Set correct lock-out bits in CPSR
STR r0,[r1] ; Save current lockout
; Reenable interrupts for the specified lockout
MSR CPSR,r2 ; Setup new CPSR lockout bits
; Get old lock-out value in return register (r0)
AND r0,r3,#LOCK_MSK
; Return to caller
BX lr
;************************************************************************
;*
;* FUNCTION
;*
;* TCT_Local_Control_Interrupts
;*
;* DESCRIPTION
;*
;* This function enables and disables interrupts as specified by
;* the caller.
;*
;* CALLED BY
;*
;* Application
;*
;* CALLS
;*
;* None
;*
;* INPUTS
;*
;* r0 - New Interrupt Level
;*
;* OUTPUTS
;*
;* r0 - Old Interrupt Level
;*
;* REGISTERS MODIFIED
;*
;* r0, r2, r3
;*
;* HISTORY
;*
;* NAME DATE REMARKS
;*
;* S. Nguyen 03/28/2005 Released version 1.15.1
;*
;************************************************************************
;INT TCT_Local_Control_Interrupts(INT interrupt_level);
.def _TCT_Local_Control_Interrupts
_TCT_Local_Control_Interrupts
; Read in and save the old level
MRS r3,CPSR ; Pickup current CPSR
; Clear out the old level and set the new level
BIC r2,r3,#LOCK_MSK ; Clear all current interrupts bits
ORR r2,r2,r0 ; Build new CPSR with new lock-out bits
; Reenable interrupts for the specified lockout
MSR CPSR,r2
; Get old lock-out value in return register (r0)
AND r0,r3,#LOCK_MSK
; Return to caller
BX lr
;************************************************************************
;*
;* FUNCTION
;*
;* TCT_Restore_Interrupts
;*
;* DESCRIPTION
;*
;* This function restores interrupts to the specified value in
;* the global TCD_Interrupt_Level variable.
;*
;* CALLED BY
;*
;* Application
;*
;* CALLS
;*
;* None
;*
;* INPUTS
;*
;* None
;*
;* OUTPUTS
;*
;* None
;*
;* REGISTERS MODIFIED
;*
;* r0, r1, r2
;*
;* HISTORY
;*
;* NAME DATE REMARKS
;*
;* S. Nguyen 03/28/2005 Released version 1.15.1
;*
;************************************************************************
;VOID TCT_Restore_Interrupts(VOID);
.def _TCT_Restore_Interrupts
_TCT_Restore_Interrupts
; Lock-out all interrupts before any checking or changing
MRS r2,CPSR ; Pickup current CPSR
ORR r1,r2,#LOCKOUT ; Build lockout CPSR
MSR CPSR,r1 ; Lockout interrupts temporarily
; Obtain the current interrupt lockout posture.
BIC r2,r2,#LOCK_MSK ; Clear current interrupt levels
LDR r1,TCT_Int_Level ; Load address of TCD_Interrupt_Level
LDR r0,[r1] ; Pickup current interrupt lockout
ORR r2,r2,r0 ; Build new CPSR with appropriate
; interrupts locked out
; Setup new CPSR lockout bits
MSR CPSR,r2
; Return to caller
BX lr
;************************************************************************
;*
;* 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
;* TCC_Reset_Task
;*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -