📄 skd.ori
字号:
; *tcb_ptr; /* Pointer to task's TCB */
;{
;
;unsigned int *stack_pointer; /* pointer to the task stack*/
;
MOVE.L SKP_Ready_List_Ptr,A5 ; Task control block pointer
;
; /* Determine if a history entry is required. */
if NU_ENABLE_HISTORY=1
; DS_Make_History_Entry(NU_HIST_TASK_RESUMED, tcb_ptr -> sk_task_id,0);
MOVE.L #0,D0 ; Put 0 on the stack
MOVE.L D0,-(A7) ;
MOVE.L (A5),-(A7) ; Put Task ID on the stack
MOVE.L #2,D0 ;
MOVE.L D0,-(A7) ; Put NU_HIST_TASK_RESUMED on stack
BSR DS_Make_History_Entry ; Call the routine
; /* Fix for version 3.07 and later of the INTROL compiler
; * Called function pops parameters off stack
; */
; ADDA.L #12,A7 ; Re-adjust the stack
endif
;
; /* Determine if any task performance timer management must be
; done. */
if NU_ENABLE_TIMING=1
; DS_Stop_Performance_Timer(tcb_ptr -> sk_task_id,
; NU_READY_WAIT_TIME_TIMER);
MOVE.L #2,D0 ; Put NU_READY_WAIT_TIME_TIMER on
MOVE.L D0,-(A7) ; the stack
MOVE.L (A5),-(A7) ; Put Task ID on the stack
BSR DS_Stop_Performance_Timer ; Call the routine
; /* Fix for version 3.07 and later of the INTROL compiler
; * Called function pops parameters off stack
; */
; ADDQ.L #8,A7 ; Re-adjust the stack
; DS_Start_Performance_Timer(tcb_ptr -> sk_task_id,
; NU_EXECUTION_TIME_TIMER);
MOVE.L #0,D0 ; Put NU_EXECUTION_TIME_TIMER on
MOVE.L D0,-(A7) ; the stack
MOVE.L (A5),-(A7) ; Put Task ID on the stack
BSR DS_Start_Performance_Timer ; Call the routine
; /* Fix for version 3.07 and later of the INTROL compiler
; * Called function pops parameters off stack
; */
; ADDQ.L #8,A7 ; Re-adjust the stack
endif
;
; /* Save the current task ID. */
; SKP_Current_Task_ID = tcb_ptr -> sk_task_id;
;
MOVE.L (A5),SKP_Current_Task_ID
;
; /* Save the current tcb pointer. */
; SKP_Current_TCB_Ptr = tcb_ptr;
MOVE.L A5,SKP_Current_TCB_Ptr
;
; /* Determine if there is a time slice associated with this task. */
; if (tcb_ptr -> sk_time_slice > 0)
; {
; /* Call the clock routine to schedule a timer. */
TST.L $01C(A5)
BLE _No_Timer_Start
; CLD_Start_System_Timer(tcb_ptr -> sk_time_slice);
;
MOVE.L $01C(A5),-(A7)
BSR CLD_Start_System_Timer
; /* Fix for version 3.07 and later of the INTROL compiler
; * Called function pops parameters off stack
; */
; ADDQ.L #4,A7
_No_Timer_Start:
; }
;
; /* Increment the number of times scheduled counter. */
; tcb_ptr -> sk_scheduled++;
;
ADDQ.L #1,$0C(A5)
;
; /* Check for possible slicking of this task's stack. */
; if (*(tcb_ptr -> sk_stack_fence) != SK_STACK_PROTECT)
; {
;
; /* Something, usually the stack of task with a greater task ID
; has written over part of this tasks stack. Call the major
; system error handling routine. */
; MOVE.L $02C(A5),A1
; MOVE.L (A1),A0
; CMP.W #$01234,A0
; BEQ _No_Stack_Error
; IND_Major_System_Error(NU_TASK_STACK_SLICKED);
; PEA 6
; BSR IND_Major_System_Error
; ADDQ.L #4,A7
_No_Stack_Error:
; }
;
; /* Change over to the task's stack. */
MOVE.L $030(A5),A7 ; Get the task's stack
CMPI.W #0,(A7)+ ; Did the task give up control?
BNE SKD_Interrupt_Return ; If not, it was interrupted
;
; /* Pop off the saved information associated with the task. */
;
MOVEM.L (A7)+,D2-D7/A2-A6 ; Pick up saved registers
RTS ; Return normally to task
;
SKD_Interrupt_Return:
;
MOVEM.L (A7)+,D0-D7/A0-A6 ; Recover the task's registers
RTE ; Return to the task
; }
;} /* end of SKD_Control_To_Task */
;
;
;/************************************************************************/
;/* */
;/* FUNCTION "SKD_Leave_Task" */
;/* */
;/* */
;/* DESCRIPTION */
;/* */
;/* This function is used to transfer control from an application */
;/* task back to the executive. The main responsibility of this */
;/* function is to setup the stack in such a way to facilitate an */
;/* interrupt return later. */
;/* */
;/* AUTHOR */
;/* */
;/* William E. Lamie, Accelerated Technology */
;/* */
;/* CALLED FROM */
;/* */
;/* All task self-suspension instances */
;/* */
;/* ROUTINES CALLED */
;/* */
;/* SKD_Control_To_Executive Transfer control to exec */
;/* */
;/* INPUTS */
;/* */
;/* None */
;/* */
;/* OUTPUTS */
;/* */
;/* Task's Stack */
;/* */
;/************************************************************************/
;void SKD_Leave_Task()
;
;{
export SKD_Leave_Task
SKD_Leave_Task
;void SKD_Control_To_Executive();
;
; /* Build a normal return stack frame. */
;
MOVEM.L D2-D7/A2-A6,-(A7) ; Put non working registers on the
; stack
CLR.W -(A7) ; Indicate that the stack is a
; normal return type
; /* Save task's stack pointer. */
;
MOVE.L A7,SKD_Task_Stack_Ptr ; Save task's stack pointer
MOVE.L SKD_System_Stack_Ptr,A7 ; Switch over to system stack ptr
;
; /* Call "SKD_Control_To_Executive" to transfer control back to the
; executive. */
; SKD_Control_To_Executive();
;}
;
;
;
;/************************************************************************/
;/* */
;/* FUNCTION "SKD_Control_To_Executive" */
;/* */
;/* */
;/* DESCRIPTION */
;/* */
;/* This function is used to transfer control to the executive. */
;/* Once again, the exact actions required in this section are */
;/* dependent on the target system. Note that interrupts must be */
;/* locked out to call this routine and the task register saving */
;/* must have occurred in the interrupt handling routine or in */
;/* SKP_Leave_Task. */
;/* */
;/* AUTHOR */
;/* */
;/* William E. Lamie, Accelerated Technology */
;/* */
;/* CALLED FROM */
;/* */
;/* Interrupt routines */
;/* SKD_Leave_Task */
;/* */
;/* ROUTINES CALLED */
;/* */
;/* CLD_Stop_System_Timer Schedule a time slice timer */
;/* */
;/* INPUTS */
;/* */
;/* tcb_ptr Pointer to task information */
;/* */
;/* OUTPUTS */
;/* */
;/* *tcb_ptr Task's TCB */
;/* */
;/************************************************************************/
;void SKD_Control_To_Executive()
;
;{
export SKD_Control_To_Executive
SKD_Control_To_Executive
;
;struct SK_TASK_CONTROL_BLOCK_STRUCT
; *tcb_ptr; /* Pointer to task's TCB */
;
; /* Set up a pointer to the current task's TCB. */
; tcb_ptr = SKP_Current_TCB_Ptr;
MOVEA.L SKP_Current_TCB_Ptr,A5
;
; /* Clear the current TCB Ptr. */
; SKP_Current_TCB_Ptr = NU_NULL;
CLR.L SKP_Current_TCB_Ptr
;
; /* Determine if any task performance timer management must be
; done. */
if NU_ENABLE_TIMING=1
; DS_Stop_Performance_Timer(tcb_ptr -> sk_task_id,
; NU_EXECUTION_TIME_TIMER);
MOVE.L #0,D0 ; Put NU_EXECUTION_TIME_TIMER on
MOVE.L D0,-(A7) ; the stack
MOVE.L (A5),-(A7) ; Put Task ID on the stack
BSR DS_Stop_Performance_Timer ; Call the routine
; /* Fix for version 3.07 and later of the INTROL compiler
; * Called function pops parameters off stack
; */
; ADDQ.L #8,A7 ; Re-adjust the stack
;
; if (tcb_ptr -> sk_suspend == NU_READY)
; DS_Start_Performance_Timer(tcb_ptr -> sk_task_id,
; NU_READY_WAIT_TIME_TIMER);
CMPI.L #0,8(A5) ; Is the task still ready
BNE _Not_Ready ; No, skip the start of timer
MOVE.L #2,D0 ; Put NU_READY_WAIT_TIME_TIMER on
MOVE.L D0,-(A7) ; the stack
MOVE.L (A5),-(A7) ; Put Task ID on the stack
BSR DS_Start_Performance_Timer ; Call the routine
; /* Fix for version 3.07 and later of the INTROL compiler
; * Called function pops parameters off stack
; */
; ADDQ.L #8,A7 ; Re-adjust the stack
_Not_Ready:
endif
;
; /* Call the clock routine to de-schedule time slice timer. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -