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

📄 tct.s

📁 mcf5307实验源代码
💻 S
📖 第 1 页 / 共 5 页
字号:
;/*      None                                                             */
;/*                                                                       */
;/* INPUTS                                                                */
;/*                                                                       */
;/*      thread                              Thread control block pointer */
;/*                                                                       */
;/* OUTPUTS                                                               */
;/*                                                                       */
;/*      None                                                             */
;/*                                                                       */
;/* HISTORY                                                               */
;/*                                                                       */
;/*         NAME            DATE                    REMARKS               */
;/*                                                                       */
;/*      B. Sellew       02-21-1997      Created and verified version 1.0 */                                               */
;/*                                                                       */
;/*************************************************************************/
        XDEF    _TCT_Control_To_Thread
_TCT_Control_To_Thread:
;VOID  TCT_Control_To_Thread(TC_TCB *thread)
;{
;
;    /* Setup the current thread pointer.  */
;    TCD_Current_Thread =  (VOID *) thread;
;
        MOVEA.L D0,A0                       ; Put thread pointer in A0
        MOVE.L  D0,_TCD_Current_Thread      ; Setup the current thread ptr
;
;    /* Increment the thread scheduled counter.  */
;    thread -> tc_scheduled++;
;
        ADDQ.L  #1,28(A0)                   ; Increment the scheduled count
;
;    /* Check for time slice option.  */
;    if (thread -> tc_cur_time_slice)
;    {
        TST.L   32(A0)                      ; Pickup time slice value
        BEQ.S   _TCT_No_Start_TS            ; If zero, don't start time slice
;
;        /* Start a time slice.  */
;        TMD_Time_Slice =        thread -> tc_cur_time_slice;
;        TMD_Time_Slice_State =  0;
;
	MOVE.L	D0,-(A7)                    ; Otherwise, start time slice
	MOVE.L	32(A0),D0                   ;   by setting up the timer 
	MOVE.L	D0,_TMD_Time_Slice          ;   parameters
	MOVE.L	(A7)+,D0
        CLR.L   _TMD_Time_Slice_State
;    }
;
_TCT_No_Start_TS:
;
;    /* Pickup the stack pointer and resume the thread.  */
;    REG_Stack_Ptr =  thread -> tc_stack_pointer;
;
        MOVE.L  44(A0),A7                   ; Switch to thread's stack
;         
;     /* Pop off the saved information associated with the thread. After we
;        determine which type of stack is present.  A 1 on the top of the 
;        stack indicates an interrupt stack, while a 0 on the top of the
;        stack indicates a solicited type of stack.  */
;
	TST.W	(A7)+                       ; Determine the type of stack
        BNE     _TCT_Interrupt_Return       ; If not 0, an interrupt stack
                                            ;   is present
	MOVEM.L	(A7),D2-D7/A2-A6            ; Recover registers preserved 
	LEA.L	44(A7),A7
        MOVE.W  SR,D0                       ; Pickup current SR
	AND.L	#$0000F8FF,D0               ; Clear the interrupt lockout
	OR.L	_TCD_Interrupt_Level,D0     ; Or-in the interrupt enable level
        MOVE.W  D0,SR                       ; Setup SR with interrupt level
        RTS                                 ; Return to thread
;        
_TCT_Interrupt_Return:
;        
;     /* Remember that the interrupt level that is restored must represent
;        the interrupt level in TCD_Interrupt_Level.  */
;
	MOVE.W	66(A7),D0	             ; Get saved SR of the thread
	AND.L	#$0000F8FF,D0                ; Clear the interrupt level 
	OR.L	_TCD_Interrupt_Level,D0      ; Or-in the interrupt enable level
	MOVE.W	D0,66(A7)	             ; Setup the interrupt SR
	MOVEM.L	(A7),D0-D7/A0-A6             ; Recover all registers
	LEA.L	60(A7),A7
        ADDQ.L  #4,A7                        ; Skip unused space
        RTE                                  ; Return from interrupt
;
;}
;
;/*************************************************************************/
;/*                                                                       */
;/* FUNCTION                                                              */
;/*                                                                       */
;/*      TCT_Control_To_System                                            */
;/*                                                                       */
;/* DESCRIPTION                                                           */
;/*                                                                       */
;/*      This function returns control from a thread to the system.  Note */
;/*      that this service is called in a solicited manner, i.e. it is    */
;/*      not called from an interrupt thread.  Registers required by the  */
;/*      compiler to be preserved across function boundaries are saved by */
;/*      this routine.  Note that this is usually a sub-set of the total  */
;/*      number of available registers.                                   */
;/*                                                                       */
;/* AUTHOR                                                                */
;/*                                                                       */
;/*      Barry Sellew, Accelerated Technology, Inc.                       */
;/*                                                                       */
;/* CALLED BY                                                             */
;/*                                                                       */
;/*      Other Components                                                 */
;/*                                                                       */
;/* CALLS                                                                 */
;/*                                                                       */
;/*      TCT_Schedule                        Schedule the next thread     */
;/*                                                                       */
;/* INPUTS                                                                */
;/*                                                                       */
;/*      None                                                             */
;/*                                                                       */
;/* OUTPUTS                                                               */
;/*                                                                       */
;/*      None                                                             */
;/*                                                                       */
;/* HISTORY                                                               */
;/*                                                                       */
;/*         NAME            DATE                    REMARKS               */
;/*                                                                       */
;/*      B. Sellew       02-21-1997      Created and verified version 1.0 */                                               */
;/*                                                                       */
;/*************************************************************************/
        XDEF    _TCT_Control_To_System
_TCT_Control_To_System:
;VOID  TCT_Control_To_System(void)
;{
;
;    /* Lockout interrupts.  */
;
	MOVE.W	#LOCKOUT,SR                  ; Lockout interrupts
;    
;    /* Save a minimal context of the thread.  */
;
	LEA.L	-44(A7),A7
	MOVEM.L	D2-D7/A2-A6,(A7)            ; Save D2-D7 and A2-A6
        CLR.W   -(A7)                       ; Solicited type of stack
;
;    /* Setup a pointer to the thread control block.  */
;    REG_Thread_Ptr =  (TC_TCB *) TCD_Current_Thread;
;
        MOVEA.L _TCD_Current_Thread,A0      ; Thread pointer in A0
;
;    /* Clear the current thread control block pointer.  */
;    TCD_Current_Thread =  NU_NULL;
;
        CLR.L   _TCD_Current_Thread         ; Clear the current thread
;    
;    /* Check to see if a time slice is active.  If so, copy the original time
;       slice into the current time slice field of the task's control block. */
;    if (TMD_Time_Slice_State == 0)
;    {
        TST.L   _TMD_Time_Slice_State       ; Is a time slice active?
        BNE.S   _TCT_No_TS_Active_1         ; If non-zero, not active
;
;        /* Insure that the next time the task runs it gets a fresh time 
;           slice.  */
;       REG_Thread_Ptr -> tc_cur_time_slice =  REG_Thread_Ptr -> tc_time_slice;
;
        MOVE.L  64(A0),D0                   ; Pickup a fresh time slice value
        MOVE.L  D0,32(A0)                   ; Reset task's time slice
;
;        /* Clear any active time slice by setting the state to NOT_ACTIVE.  */
;        TMD_Time_Slice_State =  1;
;       
	MOVE.L	D0,-(A7)                    ; Disable time slice
	MOVE.L	#1,D0
	MOVE.L	D0,_TMD_Time_Slice_State
	MOVE.L	(A7)+,D0
;    }
;
_TCT_No_TS_Active_1:
;
;    /* Save off the current stack pointer in the control block.  */
;    REG_Thread_Ptr -> tc_stack_pointer =  (VOID *) REG_Stack_Ptr;
;
        MOVE.L  A7,44(A0)                   ; Save the thread's stack pointer
;
;    /* Clear the task's current protection.  */
;    (REG_Thread_Ptr -> tc_current_protect) -> tc_tcb_pointer =  NU_NULL;
;    REG_Thread_Ptr -> tc_current_protect =  NU_NULL;
;
        MOVEA.L 56(A0),A1                   ; Pickup the protection pointer
        CLR.L   (A1)                        ; Clear the protection
        CLR.L   56(A0)                      ; Clear the protection pointer
;
;    /* Switch to the system stack.  */
;    REG_Stack_Ptr =  TCD_System_Stack;
;
        MOVEA.L _TCD_System_Stack,A7        ; Switch to the system stack
;
;    /* Finished, return to the scheduling loop.  */
;
        BRA     _TCT_Schedule               ; Jump back to the scheduler
;
;}
;
;/*************************************************************************/
;/*                                                                       */
;/* FUNCTION                                                              */
;/*                                                                       */
;/*      TCT_Signal_Exit                                                  */
;/*                                                                       */
;/* DESCRIPTION                                                           */
;/*                                                                       */
;/*      This function exits from a signal handler.  The primary purpose  */
;/*      of this function is to clear the scheduler protection and switch */
;/*      the stack pointer back to the normal task's stack pointer.       */
;/*                                                                       */
;/* AUTHOR                                                                */
;/*                                                                       */
;/*      Barry Sellew, Accelerated Technology, Inc.                       */
;/*                                                                       */
;/* CALLED BY                                                             */
;/*                                                                       */
;/*      TCC_Signal_Shell                    Signal handling shell func   */
;/*                                                                       */
;/* CALLS                                                                 */
;/*                  

⌨️ 快捷键说明

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