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

📄 tct.s

📁 Nucleus实时操作系统是Accelerater Technology公司开发的嵌入式RTOS产品,Nucleus的核心是一个实时的多任务内核——Nucleus PLUS
💻 S
📖 第 1 页 / 共 5 页
字号:
;/*         NAME            DATE                    REMARKS               */
;/*                                                                       */
;/*      W. Lamie        07-15-1993      Created initial version 1.0      */
;/*      D. Lamie        07-15-1993      Verified version 1.0             */
;/*                                                                       */
;/*************************************************************************/
        XDEF    _TCT_Build_Signal_Frame
_TCT_Build_Signal_Frame:
;VOID  TCT_Build_Signal_Frame(TC_TCB *task)
;{
;
        MOVEA.L 4(A7),A1                    ; Point at thread control block
;
;    /* Pickup the stack pointer.  */
;    REG_Stack_Ptr =  (BYTE_PTR) task -> tc_stack_pointer;
        MOVEA.L 44(A1),A0                   ; Point at the task's stack
;    
;    /* Build a signal stack.  */
        CLR.L   D0                          ; Clear D0 for initial reg values
        MOVE.L  D0,-(A0)                    ; Put a NULL return address on the
                                            ;   stack.  This is primarily for
                                            ;   source level debuggers
        MOVE.L  #_TCC_Signal_Shell,D1       ; All HISRs have same entry point
        MOVE.L  D1,-(A0)                    ; Put HISR entry point on stack
        MOVE.L  D0,-(A0)                    ; Place initial A6 on the stack
        MOVE.L  A5,-(A0)                    ; Place initial A5 on the stack
        MOVE.L  D0,-(A0)                    ; Place initial A4 on the stack
        MOVE.L  D0,-(A0)                    ; Place initial A3 on the stack
        MOVE.L  D0,-(A0)                    ; Place initial A2 on the stack
        MOVE.L  D0,-(A0)                    ; Place initial D7 on the stack
        MOVE.L  D0,-(A0)                    ; Place initial D6 on the stack
        MOVE.L  D0,-(A0)                    ; Place initial D5 on the stack
        MOVE.L  D0,-(A0)                    ; Place initial D4 on the stack
        MOVE.L  D0,-(A0)                    ; Place initial D3 on the stack
        MOVE.L  D0,-(A0)                    ; Place initial D2 on the stack
                                            ; D0 contains 0, which is indicates
                                            ;   a solicited stack type
        MOVE.W  D0,-(A0)                    ; Place stack type on the stack
;    
;    /* Save the new stack pointer into the task's control block.  */
;    task -> tc_stack_pointer =  (VOID *) REG_Stack_Ptr;
        MOVE.L  A0,44(A1)                   ; Save in the thread control block
        RTS                                 ; 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.                                           */
;/*                                                                       */
;/* AUTHOR                                                                */
;/*                                                                       */
;/*      William E. Lamie, Accelerated Technology, Inc.                   */
;/*                                                                       */
;/* 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        07-15-1993      Created initial version 1.0      */
;/*      D. Lamie        07-15-1993      Verified version 1.0             */
;/*                                                                       */
;/*************************************************************************/
        XDEF    _TCT_Check_Stack
_TCT_Check_Stack:
;UNSIGNED  TCT_Check_Stack(void)
;{
;
;TC_TCB         *thread;
;UNSIGNED       remaining;
;
;    /* Pickup the current task/HISR pointer.  */
;    thread =  (TC_TCB *) TCD_Current_Thread;
;
;    /* Determine if there is a current thread.  */
;    if (thread)
;    {
;
        MOVE.L  _TCD_Current_Thread,D0      ; Pickup current thread pointer
        BEQ     _TCT_No_Stack_Check         ; If task or HISR, skip stack check
        MOVEA.L D0,A0                       ; Point at the thread control block
;
;        /* 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))
        MOVE.L  A7,D0                       ; Pickup the stack pointer
        CMP.L   36(A0),D0                   ; Compare with end of stack addr
        BCS     _TCT_Stack_Overflow         ; Stack overflow condition
        CMP.L   40(A0),D0                   ; Compare with start of stack addr
        BLS     _TCT_No_Stack_Overflow      ; If within limits, no overflow
;
;            /* Stack overflow condition exits.  */
;            ERC_System_Error(NU_STACK_OVERFLOW);
_TCT_Stack_Overflow:
        PEA     3                           ; Put NU_STACK_OVERFLOW on stack
        BSR     _ERC_System_Error           ; Call system error handler
;
_TCT_No_Stack_Overflow:
;
;        /* Calculate the amount of available space on the stack.  */
;        remaining =  (BYTE_PTR) thread -> tc_stack_pointer -
;                          (BYTE_PTR) thread -> tc_stack_start;
        SUB.L   36(A0),D0                   ; Calculate the remaining amount of
                                            ;   stack space
;
;        /* Determine if there is enough memory on the stack to save all of the
;           registers.  */
;        if (remaining < 40)
        CMPI.L  #40,D0                      ; Compare with a minimal amount of
                                            ;   stack space to save context
        BGT     _TCT_Min_Available          ; If remaining is greater, all is
                                            ;   still okay
;
;            /* Stack overflow condition is about to happen.  */
;            ERC_System_Error(NU_STACK_OVERFLOW);
        PEA     3                           ; Put NU_STACK_OVERFLOW on stack
        BSR     _ERC_System_Error           ; Call system error handler
_TCT_Min_Available:
;
;        /* Determine if this is a new minimum amount of stack space.  */
;        if (remaining < thread -> tc_stack_minimum)
        CMP.L   52(A0),D0                   ; Determine if a new minimum has
                                            ;   been found
        BCC     _TCT_Stack_Check_Finished   ; No, stack checking is finished
;
;            /* Save the new stack minimum.  */
;            thread -> tc_stack_minimum =  remaining;
        MOVE.L  D0,52(A0)                   ; Save new minimum
        BRA     _TCT_Stack_Check_Finished   ; Finished
;
;    }
;    else
_TCT_No_Stack_Check:
;
;        /* Set the remaining bytes to 0.  */
;        remaining =  0;
        CLR.L   D0                          ; Clear return value
_TCT_Stack_Check_Finished:
;
;    /* Return the remaining number of bytes on the stack.  */
;    return(remaining);
        RTS                                 ; Return to caller
;}
;
;
;
;/*************************************************************************/
;/*                                                                       */
;/* FUNCTION                                                              */
;/*                                                                       */
;/*      TCC_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.                                                          */
;/*                                                                       */
;/* AUTHOR                                                                */
;/*                                                                       */
;/*      William E. Lamie, Accelerated Technology, Inc.                   */
;/*                                                                       */
;/* CALLED BY                                                             */
;/*                                                                       */
;/*      INC_Initialize                      Main initialization routine  */
;/*                                                                       */
;/* CALLS                                                                 */
;/*                                                                       */
;/*      TCT_Control_To_Thread               Transfer control to a thread */
;/*                                                                       */
;/* INPUTS                                                                */
;/*                                                                       */
;/*      TCD_Execute_Task                    Pointer to task to execute   */
;/*                                                                       */
;/* OUTPUTS                                                               */
;/*                                                                       */
;/*      None                                                             */
;/*                                                                       */
;/* HISTORY                                                               */
;/*                                                                       */
;/*         NAME            DATE                    REMARKS               */
;/*                                                                       */
;/*      W. Lamie        07-15-1993      Created initial version 1.0      */
;/*      D. Lamie        07-15-1993      Verified version 1.0             */
;/*                                                                       */
;/*************************************************************************/
        XDEF    _TCT_Schedule
_TCT_Schedule:
;VOID  TCT_Schedule(void)
;{
;
;    /* Restore interrupts according to the value contained in 
;       TCD_Interrupt_Level.  */
;
        MOVE.W  SR,D0                       ; Pickup current SR
        AND.W   #$F8FF,D0                   ; Clear the interrupt lockout
        OR.W    _TCD_Interrupt_Level+2,D0   ; Or-in the interrupt enable level

⌨️ 快捷键说明

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