tct.s

来自「nuclues plus 源代码程序」· S 代码 · 共 1,126 行 · 第 1/5 页

S
1,126
字号
        cli                                 ; Otherwise, enable interrupts
_TCT_Int_Control_Done:
        xgdy                                ; Return previous interrupt lockout
        rts                                 ; Return to caller
;}    
;
;
;/*************************************************************************/
;/*                                                                       */
;/* FUNCTION                                                              */
;/*                                                                       */
;/*      TCT_Local_Control_Interrupts                                     */
;/*                                                                       */
;/* DESCRIPTION                                                           */
;/*                                                                       */
;/*      This function enables and disables interrupts as specified by    */
;/*      the caller.  Interrupts disabled by this call local to the       */
;/*      caller.                                                          */
;/*                                                                       */
;/* AUTHOR                                                                */
;/*                                                                       */
;/*      William E. Lamie, Accelerated Technology, Inc.                   */
;/*                                                                       */
;/* CALLED BY                                                             */
;/*                                                                       */
;/*      Application                                                      */
;/*                                                                       */
;/* CALLS                                                                 */
;/*                                                                       */
;/*      None                                                             */
;/*                                                                       */
;/* INPUTS                                                                */
;/*                                                                       */
;/*      new_level                           New interrupt enable level   */
;/*                                                                       */
;/* OUTPUTS                                                               */
;/*                                                                       */
;/*      old_level                           Previous interrupt enable    */
;/*                                            level                      */
;/*                                                                       */
;/* HISTORY                                                               */
;/*                                                                       */
;/*         NAME            DATE                    REMARKS               */
;/*                                                                       */
;/*      K. Homer        03-01-1994      Created initial version 1.1      */
;/*      D. Lamie        03-18-1994      Verified version 1.1             */
;/*                                                                       */
;/*************************************************************************/
        .public  _TCT_Local_Control_Interrupts
_TCT_Local_Control_Interrupts:
;
;    /* Save the old level and setup the new level.  */
;
        tpa                                 ; Move ccr into a-accumulator
        sei                                 ; Lockout interrupts while the 
                                            ; checking int posture           
        bita    #10H                        ; Test the I flag of ccr
        bne	_TCT_Local_Control_Disabled ; to set up return value
        clra				    ; old level indicates enable
        bra	_TCT_Local_Control_Cont	    ; 
_TCT_Local_Control_Disabled:
        ldaa     #1   			    ; old level indicates disable
_TCT_Local_Control_Cont:
;
;    /* Determine if interrupts need to be enabled.  */
        tstb				    ; check new level
        bne      _TCT_Local_Control_Return
        cli                                 ; Enable interrupts
_TCT_Local_Control_Return:
        tab				    ; move old level to LSB of D
        clra				    ; clear MSB of D for return
        rts                                 ; Return to caller
;}
;
;
;/*************************************************************************/
;/*                                                                       */
;/* FUNCTION                                                              */
;/*                                                                       */
;/*      TCT_Restore_Interrupts                                           */
;/*                                                                       */
;/* DESCRIPTION                                                           */
;/*                                                                       */
;/*      This function restores the interrupt lockout posture to that of  */
;/*      the global setting.                                              */
;/*                                                                       */
;/* AUTHOR                                                                */
;/*                                                                       */
;/*      William E. Lamie, Accelerated Technology, Inc.                   */
;/*                                                                       */
;/* CALLED BY                                                             */
;/*                                                                       */
;/*      Application                                                      */
;/*                                                                       */
;/* CALLS                                                                 */
;/*                                                                       */
;/*      None                                                             */
;/*                                                                       */
;/* INPUTS                                                                */
;/*                                                                       */
;/*      None                                                             */
;/*                                                                       */
;/* OUTPUTS                                                               */
;/*                                                                       */
;/*      None                                                             */
;/*                                                                       */
;/* HISTORY                                                               */
;/*                                                                       */
;/*         NAME            DATE                    REMARKS               */
;/*                                                                       */
;/*      K. Homer        03-01-1994      Created initial version 1.1      */
;/*      D. Lamie        03-18-1994      Verified version 1.1             */
;/*                                                                       */
;/*************************************************************************/
        .public  _TCT_Restore_Interrupts
_TCT_Restore_Interrupts:
;
;    /* Save the old level and setup the new level.  */
;
        sei                                 ; Lockout interrupts while the 
                                            ;   new interrupts are setup
;
;    /* Determine if interrupts need to be enabled.  */
        ldy     _TCD_Interrupt_Level        ; Pickup current interrupt lockout
        bne     _TCT_Restore_Return
        cli                                 ; Enable interrupts
_TCT_Restore_Return:
        rts                                 ; Return to caller
;}
;
;
;
;/*************************************************************************/
;/*                                                                       */
;/* 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               */
;/*                                                                       */
;/*      W. Lamie        06-01-1993      Created initial version 1.0      */
;/*      D. Lamie        06-01-1993      Verified version 1.0             */
;/*                                                                       */
;/*************************************************************************/
;VOID  TCT_Build_Task_Stack(TC_TCB *task)
;{
        .public _TCT_Build_Task_Stack
_TCT_Build_Task_Stack:
                                            ; Note: D contains the task ptr
        pshx                                ; Save x on the stack
;
;    /* Pickup the stack base.  */
;    REG_Stack_Base =  (BYTE_PTR) task -> tc_stack_start;
;
        xgdy                                ; Move task pointer to Y
        ldd     30,y                        ; Pickup the start of the stack
;    
;    /* Pickup the stack size.  */
;    REG_Stack_Size =  task -> tc_stack_size;
;    
;    /* Calculate the stack ending address.  */
;    task -> tc_stack_end =  REG_Stack_Base + REG_Stack_Size - 1;
;
        addd    38,y                        ; Calculate the last address of the
                                            ;   stack area
        subd    #1                          ; Subtract 1 for size
        std     32,y                        ; Store in control block
;    
;    /* Build an initial stack.  */
;    
        subd    #11                         ; Position to top of stack frame
        xgdx                                ; Put stack pointer into IX
        clra                                ; Clear D
        clrb                                ; 
        std     10,x                        ; Place a NULL at the bottom of the
                                            ;   stack
        ldd     #_TCC_Task_Shell            ; Build entry point into the task
        std     8,x                         ; Place it on the stack
        clra                                ; Build clear value for initial 
        clrb                                ;   values of registers
        std     6,x                         ; Place initial IY on the stack
        std     4,x                         ; Place initial IX on the stack
        std     2,x                         ; Place initial B:A on the stack
        ldaa    #INIT_CCR                   ; Build initial CCR
        staa    1,x                         ; Place initial CCR on the stack
        ldaa    #1                          ; Build interrupt stack type
        staa    0,x                         ; Place stack type on the stack
;
;    /* Save the new stack pointer into the task's control block.  */
;    task -> tc_stack_pointer =  (VOID *) (REG_Stack_End);
;
        stx     34,y                        ; Store stack pointer in TCB
;    
;    /* Save the minimum amount of remaining stack memory.  */
;    task -> tc_stack_minimum =  REG_Stack_Size - 12;

⌨️ 快捷键说明

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