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

📄 skd.ori

📁 NecluesRTX RTOS的源码
💻 ORI
📖 第 1 页 / 共 4 页
字号:
;            /* Return to the task.  */
;
;            /* Restore the task ID.  */
;            SKP_Current_Task_ID =  SKP_Current_TCB_Ptr -> sk_task_id;
;
        MOVE.L  SKP_Current_TCB_Ptr,A0     ; Pickup the TCB address
        MOVE.L  (A0),SKP_Current_Task_ID   ; Setup the task ID
;
;            /* Switch back to the task's stack.  */
;
        MOVE.L  SKD_Task_Stack_Ptr,A7      ; Recover the saved task SP
;
        ADDQ.L  #2,A7                       ; Position past stack type
        MOVEM.L (A7)+,D0-D7/A0-A6           ; Recover registers
        RTE                                 ; Return to task
;        }
;    }
;    else
;    {
_Return_To_Executive:
;
;        /* Interrupt in the executive...  Reset the System Stack pointer
;           and jump back into the scheduling loop.  */
;
        MOVEA.L SKD_System_Stack_Ptr,A7
        JMP     _SKP_Schedule_Loop
;     }
;}
;
;
;
;/************************************************************************/
;/*                                                                      */
;/*  FUNCTION                            "SKD_Check_For_Preemption"      */
;/*                                                                      */
;/*                                                                      */
;/*  DESCRIPTION                                                         */
;/*                                                                      */
;/*      This function is responsible for preemption conditions that     */
;/*      occur from a higher priority interrupt service routine while    */
;/*      processing in an interrupt service routine that does not        */
;/*      plan to use SKD_Interrupt_Context_Save/Restore.                 */
;/*                                                                      */
;/*                                                                      */
;/*  AUTHOR                                                              */
;/*                                                                      */
;/*      William E. Lamie,  Accelerated Technology                       */
;/*                                                                      */
;/*  CALLED FROM                                                         */
;/*                                                                      */
;/*      Interrupt handlers that have not called the context save/       */
;/*        restore routines that need to check for possible preemption   */
;/*        conditions                                                    */
;/*                                                                      */
;/*  ROUTINES CALLED                                                     */
;/*                                                                      */
;/*      SKD_Interrupt_Context_Save                                      */
;/*      SKD_Interrupt_Context_Restore                                   */
;/*                                                                      */
;/*  INPUTS                                                              */
;/*                                                                      */
;/*      None                                                            */
;/*                                                                      */
;/*  OUTPUTS                                                             */
;/*                                                                      */
;/*     Stack pointers                                                   */
;/*                                                                      */
;/************************************************************************/
;void  SKD_Check_For_Preemption()
;
;{
        export  SKD_Check_For_Preemption
SKD_Check_For_Preemption
;
; SKD_Check_For_Preemption assumes that the calling "bare-bones" interrupt
; service routine has restored all the registers it used and that the
; interrupt stack frame is at the top of the stack.  Use a "JMP" instruction
; to call this routine.
;
;    /* Check to see if a task was active.  */
;    if (SKP_Current_TCB_Ptr != NU_NULL)
;    {
;
;        /* Check for context switching.  */
        MOVE    SR,-(A7)                    ; Save the status registers
        ORI     #$0700,SR                   ; Lockout interrupts
        MOVEM.L D0/A0,-(A7)                 ; Save working registers
        MOVE.L  #$0700,D0                   ; Put interrupt level mask in D0
        AND.W   10(A7),D0                   ; Pickup the interrupted level 
        BNE     _Interrupt_Return           ; Normal interrupt return- This
                                            ; interrupt is nested!
        TST.L   SKP_Current_TCB_Ptr        ; Is current TCB pointer NULL?
        BEQ     _Interrupt_Return           ; Yes, just return- no task was
                                            ;   active!
;
;        if (SKP_Current_TCB_Ptr != SKP_Ready_List_Ptr)
;        {
;        
;            /* Call SKD_Interrupt_Context_Save/Restore to preempt the
;               current task.  */
;
        MOVE.L  SKP_Current_TCB_Ptr,A0     ; Pickup the TCB pointer
        MOVE.L  (A0),SKP_Current_Task_ID   ; Recover the current task ID
        CMPA.L  SKP_Ready_List_Ptr,A0      ; Is the head pointer different?
        BEQ     _Interrupt_Return           ; No, just return
        MOVE.L  8(A0),D0                    ; See if task was suspended
        BNE     SKD_Preempt                ; Transfer control to executive
        MOVE.L  24(A0),D0                   ; Yes, look at the preempt disable
        BNE     _Interrupt_Return           ; If disabled, just return
;
;            /* Preform context switch by calling the context save and restore
;               routines.  */
;            SKD_Interrupt_Context_Save();
;            SKD_Interrupt_Context_Restore();
;
SKD_Preempt:
        MOVEM.L (A7)+,D0/A0                 ; Recover working registers
        MOVE    (A7)+,SR                    ; Restore status register
        BSR     SKD_Interrupt_Context_Save
        JMP     SKD_Interrupt_Context_Restore
;
;        }
;        else
;        {
_Interrupt_Return
;
;            /* Return to the point of interrupt.  */
        MOVEM.L (A7)+,D0/A0                 ; Recover working registers
*	MOVE    (A7)+,SR                    ; Restore status register
	ADDQ.L	#$2,A7			; POP status register - BUG FIX ?
        RTE                                 ; Return to task
;        }
;    }
;}
;
;
;
;/************************************************************************/
;/*                                                                      */
;/*  FUNCTION                                "SKP_Schedule"              */
;/*                                                                      */
;/*                                                                      */
;/*  DESCRIPTION                                                         */
;/*                                                                      */
;/*      This function continually monitors the ready list pointer for   */
;/*      a value other than NULL.  When one is found, the task           */
;/*      associated with the first TCB on the list is started.           */
;/*                                                                      */
;/*  AUTHOR                                                              */
;/*                                                                      */
;/*      William E. Lamie,  Accelerated Technology                       */
;/*                                                                      */
;/*  CALLED FROM                                                         */
;/*                                                                      */
;/*      INP_Initialize                      High level initialization   */
;/*                                                                      */
;/*  ROUTINES CALLED                                                     */
;/*                                                                      */
;/*      IND_Set_Interrupt_Level             Turn interrupts on/off      */
;/*      SKD_Control_To_Task                 Transfer control to task    */
;/*                                                                      */
;/*  INPUTS                                                              */
;/*                                                                      */
;/*      SKP_Ready_List_Ptr                  Highest priority TCB ready  */
;/*                                                                      */
;/*  OUTPUTS                                                             */
;/*                                                                      */
;/*      Task given control                                              */
;/*                                                                      */
;/************************************************************************/
;void  SKP_Schedule()  */
;{  
;
;void              SKD_Control_To_Task();    /* Transfer control to task */
        export  SKP_Schedule
SKP_Schedule
;
;     /* Enable interrupts for scheduling loop. */
;     IND_Set_Interrupt_Level(NU_ENABLE_INTERRUPTS);
;
;     while (NU_FOREVER)  
;     {
_SKP_Schedule_Loop:
;
        MOVE      #$2000,SR                 ; Release interrupt lockout
;
_SKP_Keep_Checking:
;         /* Determine if a task is ready to go.  */
;         if (SKP_Ready_List_Ptr)
;         {
        MOVE.L    SKP_Ready_List_Ptr,D0    ; Pick up the ready list pointer
        CMPI.L    #0,D0                     ; Is the pointer NULL?
        BEQ       _SKP_Keep_Checking        ; Yes, just keep checking
;
;             /* Lockout interrupts in preparation to invoke task.  */
;             IND_Set_Interrupt_Level(NU_DISABLE_INTERRUPTS);
;
        MOVE      #$2700,SR                 ; Lockout interrupts
;
;             /* Transfer control to task.  */
;             SKD_Control_To_Task(SKP_Ready_List_Ptr);  
;
        JMP       SKD_Control_To_Task      ; Jump to control to task routine
;
;             /* Release interrupt for the scheduling loop.  */
;             IND_Set_Interrupt_Level(NU_ENABLE_INTERRUPTS);  */
;         }
;     }
;}
;
;
;
;/************************************************************************/
;/*                                                                      */
;/*  FUNCTION                                "SKP_Get_Task_ID"           */
;/*                                                                      */
;/*                                                                      */
;/*  DESCRIPTION                                                         */
;/*                                                                      */
;/*      This returns the currently executing task identification.       */
;/*                                                                      */
;/*  AUTHOR                                                              */
;/*                                                                      */
;/*      William E. Lamie,  Accelerated Technology                       */
;/*                                                                      */
;/*  CALLED FROM                                                         */
;/*                                                                      */
;/*      NU_*                                Nucleus user interface      */
;/*                                          routines                    */
;/*                                                                      */
;/*  ROUTINES CALLED                                                     */
;/*                                                                      */
;/*      None                                                            */
;/*                                                                      */
;/*  INPUTS                                                              */
;/*                                                                      */
;/*      None                                                            */
;/*                                                                      */
;/*  OUTPUTS                                                             */
;/*                                                                      */
;/*      return(SKP_Current_Task_ID)         Current task identity       */
;/*                                                                      */
;/************************************************************************/
;signed int  SKP_Get_Task_ID()
;{
        export  SKP_Get_Task_ID
SKP_Get_Task_ID
;
;     /* Return the current task ID.  */
;     return(SKP_Current_Task_ID);
        MOVE.L    SKP_Current_Task_ID,D0
        RTS
;}

⌨️ 快捷键说明

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