⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tct.s

📁 test file nucleus source
💻 S
📖 第 1 页 / 共 5 页
字号:
;************************************************************************
;*
;*               Copyright Mentor Graphics Corporation 2003
;*                         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\Integrator\ADS 1.14.9 
;*
;*  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

    IF NU_MMU_MODE
    
    INCLUDE ../MMU/mmu_defs.inc             ; MMU macros
    
    ENDIF
;**********************************
;* 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;

    IMPORT          TCD_Execute_Task
    IMPORT          TCD_Execute_HISR
    IMPORT          TCD_Current_Thread
    IMPORT          TCD_System_Stack
    IMPORT          TCD_Interrupt_Count
    IMPORT          TCD_Active_HISR_Heads
    IMPORT          TCD_Active_HISR_Tails
    IMPORT          TCD_Interrupt_Level
    IMPORT          TMD_Time_Slice
    IMPORT          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);

    IMPORT          TCC_Task_Shell
    IMPORT          TCC_Signal_Shell
    IMPORT          ERC_System_Error

    IF NU_MMU_MODE
    
    IMPORT  MMT_Invalidate_TLB
    IMPORT  MMT_Set_Translation_Table
    IMPORT  CCT_Invalidate_Cache
    IMPORT  msd_kernel_module
    
    ENDIF

    IF NU_MODULE_SUPPORT
    
    IMPORT  msd_current_module
    
    ENDIF


    IF INCLUDE_PROVIEW

    IMPORT          _NU_Idle_Hook
    IMPORT          _NU_Schedule_Task_Hook

    ENDIF
    
    IF  NU_TEST2_SUPPORT

    IMPORT          Set_Suspend_Time

    ENDIF

    IF  NU_TEST3_SUPPORT

    IMPORT          Set_Context_Save_Start
    IMPORT          Set_Context_Save_End
    IMPORT          Set_Context_Restore_Start
    IMPORT          Set_Context_Restore_End

    ENDIF
    
;**********************************
;* GLOBAL VARIABLE DECLARATIONS   *
;**********************************
    AREA    TCT_Data, DATA, NOINIT

    ; Define variable used to hold system stack limit.  The stack limit is utilized
    ; by the ARM tools when the /swst switch is involked.  This will allow
    ; stack over-flows to be checked.

    EXPORT  TCT_System_Limit
TCT_System_Limit
    DCD     0

    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.

TCT_Special_Nested
    DCD     0

    ENDIF

;**********************************
;* LOCAL VARIABLES                *
;**********************************
    AREA    TCT_local_data, CODE

    ; 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
    DCD     TCT_Special_Nested

    ENDIF

TCT_System_Limit1
    DCD     TCT_System_Limit

TCT_Int_Level
    DCD     TCD_Interrupt_Level

TCT_Task_Shell
    DCD     TCC_Task_Shell

TCT_Signal_Shell
    DCD     TCC_Signal_Shell

TCT_Current_Thread1
    DCD     TCD_Current_Thread

TCT_Execute_HISR
    DCD     TCD_Execute_HISR

TCT_Execute_Task
    DCD     TCD_Execute_Task

TCT_Time_Slice
    DCD     TMD_Time_Slice

TCT_Slice_State
    DCD     TMD_Time_Slice_State

TCT_System_Stack
    DCD     TCD_System_Stack

TCT_Int_Count
    DCD     TCD_Interrupt_Count

TCT_HISR_Tails
    DCD     TCD_Active_HISR_Tails

TCT_HISR_Heads
    DCD     TCD_Active_HISR_Heads

    IF NU_MODULE_SUPPORT
Current_Module
    DCD     msd_current_module
    ENDIF

    IF NU_MMU_MODE
Kernel_Module
    DCD     msd_kernel_module
    ENDIF

    AREA    TCT_Code, CODE, READONLY
;************************************************************************
;*
;*  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
;*
;************************************************************************
;INT    TCT_Control_Interrupts(INT interrupt_level);

    EXPORT  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_cxsf,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

    ; Renable interrupts for the specified lockout

    MSR     CPSR_cxsf,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
;*
;*      Driscoll, D     01/24/2003      Released Version 1.14.1
;************************************************************************
;INT    TCT_Local_Control_Interrupts(INT interrupt_level);

    EXPORT  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

    ; renable interrupts for the specified lockout

    MSR     CPSR_cxsf,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
;*
;*      Driscoll, D     01/24/2003      Released Version 1.14.1
;************************************************************************
;VOID   TCT_Restore_Interrupts(VOID);

    EXPORT  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_cxsf,r1                    ; Lockout interrupts temporarily

    ; Obtain the current interrupt lockout posture.

    BIC     r2,r2,#LOCK_MSK                 ; Clear current interrupt levels

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -