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

📄 tct.s

📁 基于OMAP1510的Nucleus移植代码
💻 S
📖 第 1 页 / 共 5 页
字号:
    NOP
    .state32
    B   _TCT_Build_Signal_Frame

        .def    _TCT_Build_Signal_Frame
_TCT_Build_Signal_Frame

    ; Pickup the stack pointer. 
;    REG_Stack_Ptr =  (BYTE_PTR) task -> tc_stack_pointer;

        LDR     r3,[r0,#2ch]                ; Pickup the current stack pointer

    ; Reference the Signal shell. 
;    REG_Function_Ptr =  (VOID *) TCC_Signal_Shell;

; Build a signal stack.  This signal stack frame facilitates an 
; solicited return to the TCC_Signal_Shell function, which in turn 
; invokes the appropriate signal handler.  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/sb   Saved r9/sl
;                                               r10/sl   Saved r10/sl
;                                               fp      Saved fp
;                                               r12      Saved r12
;               (Higher Address) Stack Bottom-> r15      Saved r15
   

        LDR     r2,Signal_Shell             ; Pickup address of shell entry

        .if THUMB
        
        BIC     r2,r2,#1                    ; Clear low bit
         
        .endif

        SUB     r3,r3,#4
        STR     r2,[r3], #-4                ; Store entry address on stack
        ADD     r2,r3,#4h                   ; Compute initial r13
        STR     r2,[r3], #-4                ; Store initial r12
        STR     r2,[r3], #-4                ; Store initial fp
        LDR     r2,[r0,#24h]                ; Pickup the stack starting address
        STR     r2,[r3], #-4                ; Store initial r10/sl
        MOV     r2,#0                       ; Clear value for initial registers
        STR     r2,[r3], #-4                ; Store initial r9/sb
        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

        .if THUMB
         
         MOV     r1,#20h                    ; Get initial state mask
         STR     r1,[r3], #-4               ; Store initial state mask  
         
        .endif

        STR     r2,[r3, #0]                 ; Store solicited stack type on the
                                            ; top of the stack 

    ; Save the new stack pointer into the task's control block. 
;    task -> tc_stack_pointer =  (VOID *) (REG_Stack_Ptr - REG_Stack_Size);

        STR     r3,[r0, #2Ch]               ; Save stack pointer

        BX      r14                         ; Return to caller

;}

;************************************************************************
;*                                                                       
;* FUNCTION                                                              
;*                                                                       
;*      TCT_Check_Stack                                                  
;*                                                                       
;* DESCRIPTION                                                           
;*                                                                       
;*      This function checks the current stack for overflow conditions.  
;*      Additionally, this function keeps track of the minimum amount    
;*      of stack space for the calling thread and returns the current    
;*      available stack space.                                           
;*                                                                       
;* CALLED BY                                                             
;*                                                                       
;*      TCC_Send_Signals                    Send signals to a task       
;*                                                                       
;* CALLS                                                                 
;*                                                                       
;*      ERC_System_Error                    System error handler         
;*                                                                       
;* INPUTS                                                                
;*                                                                       
;*      None                                                             
;*                                                                       
;* OUTPUTS                                                               
;*                                                                       
;*      available bytes in stack                                         
;*                                                                       
;* HISTORY                                                               
;*                                                                       
;*         NAME            DATE                    REMARKS               
;*                                                                       
;*      W. Lamie        02-15-1994      Created initial version 1.0      
;*      D. Lamie        02-15-1994      Verified version 1.0             
;*                                                                       
;************************************************************************
;UNSIGNED  TCT_Check_Stack(void)
;{
    .def    $TCT_Check_Stack
$TCT_Check_Stack                            ; Dual-state interworking veneer
    .state16
    BX  r15
    NOP
    .state32
    B   _TCT_Check_Stack

        .def    _TCT_Check_Stack
_TCT_Check_Stack

;TC_TCB         *thread;
;UNSIGNED       remaining;

    ; Pickup the current task/HISR pointer. 
;    thread =  (TC_TCB *) TCD_Current_Thread;

        LDR     r0,Current_Thread           ; Pickup address of thread pointer
        LDR     r0,[r0,#0]                  ; Pickup thread pointer

    ; Determine if there is a current thread. 
;    if (thread)
;    {

        CMP     r0,#0                       ; Determine if a thread is active
        MOV     r3,#0                       ; Default remaining value
        BEQ     TCT_Skip_Stack_Check        ; If NU_NULL, skip stack checking

        ; Determine if the stack pointers are out of range. 
;        if ((thread -> tc_stack_pointer < thread -> tc_stack_start) ||
;            (thread -> tc_stack_pointer > thread -> tc_stack_end))

        LDR     r2,[r0,#24h]                ; Pickup start of stack area
        CMP     r13,r2                      ; Compare with current stack ptr
        BLT     TCT_Stack_Range_Error       ; If less, stack is out of range
        LDR     r1,[r0,#28h]                ; Pickup end of stack area
        CMP     r13,r1                      ; Compare with current stack ptr
        BLE     TCT_Stack_Range_Okay        ; If less, stack range is okay

            ; Stack overflow condition exits. 
;            ERC_System_Error(NU_STACK_OVERFLOW);

TCT_Stack_Range_Error:

        STR     r14,[r13, #4]!              ; Store r14 on the stack
        MOV     r0,#3                       ; Build NU_STACK_OVERFLOW code
        .if THUMB
        
        LDR     r3,System_Error             ; Call system error handler.  Note:
        BX      r3                          ; control is not returned!
                                            ; Examine stack to find return
                                            ; address of this routine.
        .else
         
        BL      System_Error                ; Call system error handler.  Note:
                                            ; control is not returned!  
                                            ; Examine stack to find return 
                                            ; address of this routine.
        .endif
TCT_Stack_Range_Okay:

    ; Calculate the amount of available space on the stack. 
;    remaining =  (BYTE_PTR) thread -> tc_stack_pointer -
;                        (BYTE_PTR) thread -> tc_stack_start;

        SUB     r3,r13,r2                   ; Calculate remaining stack size

    ; Determine if there is enough memory on the stack to save all of the
    ; registers. 
;    if (remaining < 80)

        CMP     r3,#80                      ; Is there enough room for an 
                                            ; interrupt frame?
        BCS     TCT_No_Stack_Error          ; If so, no stack overflow yet

            ; Stack overflow condition is about to happen. 
;            ERC_System_Error(NU_STACK_OVERFLOW);

        STR     r14,[r13, #4]!              ; Store r14 on the stack
        MOV     r0,#3                       ; Build NU_STACK_OVERFLOW code

        .if THUMB
         
        LDR     r3,System_Error             ; Call system error handler.  Note:
        BX      r3                          ; control is not returned!
                                            ; Examine stack to find return
                                            ; address of this routine.
        .else
         
        BL      System_Error                ; Call system error handler.  Note:
                                            ; control is not returned!  
                                            ; Examine stack to find return 
                                            ; address of this routine.
        .endif

TCT_No_Stack_Error:

    ; Determine if this is a new minimum amount of stack space. 
;    if (remaining < thread -> tc_stack_minimum)

        LDR     r2,[r0,#34h]
        CMP     r3,r2
        STRCC   r3,[r0,#34h]

        ; Save the new stack minimum. 
;       thread -> tc_stack_minimum =  remaining;
;    }
;    else

        ; Set the remaining bytes to 0. 
;        remaining =  0;

    ; Return the remaining number of bytes on the stack. 
;    return(remaining);

TCT_Skip_Stack_Check:
        MOV     r0,r3                       ; Return remaining bytes

        BX      r14                         ; Return to caller

;}

;************************************************************************
;*                                                                       
;* FUNCTION                                                              
;*                                                                       
;*      TCT_Schedule                                                     
;*                                                                       
;* DESCRIPTION                                                           
;*                                                                       
;*      This function waits for a thread to become ready.  Once a thread 
;*      is ready, this function initiates a transfer of control to that  
;*      thread.                                                          
;*                                                                       
;* CALLED BY                                                             
;*                                                                       
;*      INC_Initialize                      Main initialization routine  
;*                                                                       

⌨️ 快捷键说明

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