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

📄 skd.ori

📁 NecluesRTX RTOS的源码
💻 ORI
📖 第 1 页 / 共 4 页
字号:
;/************************************************************************/
;/*                                                                      */
;/*          Copyright 1990-1992 by Accelerated Technology               */
;/*                                                                      */
;/*  PROPRIETARY RIGHTS of Accelerated Technology are involved in the    */
;/*  subject matter of this material.  All manufacturing, reproduction,  */
;/*  use, and sales rights pertaining to this subject matter are         */
;/*  governed by the license agreement.  The buyer or recipient of this  */
;/*  package, implicitly accepts the terms of the license.               */
;/*                                                                      */
;/************************************************************************/
;
;/************************************************************************/
;/*                                                                      */
;/*  FILE DESCRIPTION                                                    */
;/*                                                                      */
;/*  This file contains target dependent routines that help coordinate   */
;/*  the execution of competing application tasks.  These routines are   */
;/*  designed to be invoked through other nucleus executive routines.    */
;/*                                                                      */
;/*  ROUTINES                                                            */
;/*                                                                      */
;/*      SKD_Init_Stack                      Task stack initialization   */
;/*      SKD_Control_To_Task                 Transfer control to an      */
;/*                                          application task            */
;/*      SKD_Control_To_Executive            Transfer control to         */
;/*                                          executive                   */
;/*      SKD_Leave_Task                      Task initiated transfer to  */
;/*                                          executive                   */
;/*      SKD_Interrupt_Context_Save          Save the current context    */
;/*      SKD_Interrupt_Context_Restore       Restore the current context */
;/*      SKD_Check_For_Preemption (68xxx)    Special ISR preemption check*/
;/*      SKP_Schedule    (68xxx ports)       Main nucleus scheduling loop*/
;/*      SKP_Get_Task_ID (68xxx ports)       Get current task ID         */
;/*                                                                      */
;/*  NOTES                                                               */
;/*                                                                      */
;/*      None                                                            */
;/*                                                                      */
;/************************************************************************/
;/* Define processor - CPU32 */
        OPT     cpu_cpu32

;/* Define necessary include files.  */
;
;#include            "nu_defs.h"             /* General constants        */
;#include            "sk_defs.h"             /* Data structure defns     */
;#include            "cl_extr.h"             /* Clock routine definitions*/
;#include            "in_extr.h"             /* System error and ints    */
;#include            "ds_extr.h"             /* Development support      */
;
;
;/* Define the conditional assembly directives.  */
NU_ENABLE_TIMING        EQU   0             ; Disable = 0, Enable = 1
NU_ENABLE_HISTORY       EQU   0             ; Disable = 0, Enable = 1
;
;/* Externally define global data structures to the scheduler.  */
;
;/* The pointer "SKP_Ready_List_Ptr" is used to point to the chain of ready
;    TCBs.  If this pointer is NULL, there are no tasks ready for execution. */
;
;
;extern struct SK_TASK_CONTROL_BLOCK_STRUCT  *SKP_Ready_List_Ptr;
;
        import  SKP_Ready_List_Ptr
;
;/* The pointer "SKP_Current_TCB_Ptr" is used to point to the currently
;   executing task's TCB.  If this pointer is NULL, nothing is active. */
;
;extern struct SK_TASK_CONTROL_BLOCK_STRUCT  *SKP_Current_TCB_Ptr;
;
        import  SKP_Current_TCB_Ptr
;
;/* The signed variable "SKP_Current_Task_ID" contains the ID of the task
;   currently executing or the value assigned to NO_TASKS.  */
;
;extern signed int  SKP_Current_Task_ID;
;
        import  SKP_Current_Task_ID
;
;/* Externally define various global symbols.  */
;
        import  CLD_Stop_System_Timer
        import  CLD_Start_System_Timer
        import  IND_Major_System_Error
        if      NU_ENABLE_HISTORY=1
        import  DS_Make_History_Entry
        endif
        if      NU_ENABLE_TIMING=1
        import  DS_Stop_Performance_Timer
        import  DS_Start_Performance_Timer
        endif    
;
;/* Define the various stack save variables.  */
;
;unsigned int       SKD_Task_Stack_Ptr;
        SECTION .bss
        export  SKD_Task_Stack_Ptr
SKD_Task_Stack_Ptr     
        DS.L    1
;unsigned int       SKD_System_Stack_Ptr;
        export  SKD_System_Stack_Ptr
SKD_System_Stack_Ptr   
        DS.L    1
;unsigned char      SKD_Interrupt_Level[16];
; This array of bytes contains information about the interrupt nesting at
; each level.  The first 8 bytes represent the number of nested interrupts
; at that level (maximum of 256).  The next 8 bytes provide a flag that 
; indicates whether or not a stack pointer switch took place.  All of the
; elements are initialized to 0 by IND_Initialize.
        export  SKD_Interrupt_Level
SKD_Interrupt_Level    
        DS.L    4
;unsigned short     SKD_Save_SR;
SKD_Save_SR            
        DS.W    1
;
;
;
;/************************************************************************/
;/*                                                                      */
;/*  FUNCTION                                "SKD_Init_Stack"            */
;/*                                                                      */
;/*                                                                      */
;/*  DESCRIPTION                                                         */
;/*                                                                      */
;/*      This function is used to setup the application stack and stack  */
;/*      pointer(s) in a manner that will accommodate the format for     */
;/*      task invocation in "SKD_Control_To_Task."                       */
;/*                                                                      */
;/*  AUTHOR                                                              */
;/*                                                                      */
;/*      William E. Lamie,  Accelerated Technology                       */
;/*                                                                      */
;/*  CALLED FROM                                                         */
;/*                                                                      */
;/*      SKP_Schedule                        The scheduler               */
;/*                                                                      */
;/*  ROUTINES CALLED                                                     */
;/*                                                                      */
;/*      None                                                            */
;/*                                                                      */
;/*  INPUTS                                                              */
;/*                                                                      */
;/*      tcb_ptr                             Pointer to task information */
;/*                                                                      */
;/*  OUTPUTS                                                             */
;/*                                                                      */
;/*     *tcb_ptr                             Task's TCB                  */
;/*      task's stack                                                    */
;/*                                                                      */
;/************************************************************************/
;void  SKD_Init_Stack(tcb_ptr)
;
;struct SK_TASK_CONTROL_BLOCK_STRUCT
        SECTION .text
        export  SKD_Init_Stack
SKD_Init_Stack
;                  *tcb_ptr;                 /* Pointer to task's TCB    */
;{
;
        MOVE.L  4(A7),A1                    ; Move TCB pointer into A5
;
;    /* Pickup the stack base.  */
;    unsigned_ptr =  (unsigned int *)  tcb_ptr -> sk_stack_base;

        MOVE.L  $028(A1),A0
;    
;    /* Position stack pointer to the last available unsigned word address
;       in the stack.  */
;    unsigned_ptr =  unsigned_ptr + tcb_ptr -> sk_stack_size - 1;
        MOVE.L  A0,D0
        MOVE.L  $024(A1),D1
        LSL.L   #2,D1
        ADD.L   D1,D0
        SUBQ.L  #--4,D0
        MOVE.L  D0,A0
;    
;    /* Build the initial stack frame that facilitates an interrupt return
;       to the application.  Note that this is an interrupt stack frame. 
;       Tasks that return voluntarily do not save D0,D1,A0, and A1.  */
        MOVE.L  #$0064,D0                   ; Vector Offeset of Interrupt 0
        MOVE.W  D0,-(A0)                    ; Place it on the stack - 16bits
        MOVE.L  $020(A1),D0                 ; Pick up the task's address
        MOVE.L  D0,-(A0)                    ; Place address on the stack
        MOVE.L  #$2000,D0                   ; Status register for the task
        MOVE.W  D0,-(A0)                    ; Place Status register on stack
        MOVE.L  #0,D0                       ; Clear D0, for all registers clr
        MOVE.L  D0,-(A0)                    ; Place A6 on stack
        MOVE.L  D0,-(A0)                    ; Place A5 on stack
        MOVE.L  D0,-(A0)                    ; Place A4 on stack
        MOVE.L  D0,-(A0)                    ; Place A3 on stack
        MOVE.L  D0,-(A0)                    ; Place A2 on stack
        MOVE.L  D0,-(A0)                    ; Place A1 on stack
        MOVE.L  D0,-(A0)                    ; Place A0 on stack
        MOVE.L  D0,-(A0)                    ; Place D7 on stack
        MOVE.L  D0,-(A0)                    ; Place D6 on stack
        MOVE.L  D0,-(A0)                    ; Place D5 on stack
        MOVE.L  D0,-(A0)                    ; Place D4 on stack
        MOVE.L  D0,-(A0)                    ; Place D3 on stack
        MOVE.L  D0,-(A0)                    ; Place D2 on stack
        MOVE.L  D0,-(A0)                    ; Place D1 on stack
        MOVE.L  D0,-(A0)                    ; Place D0 on stack
        MOVE.W  #1,-(A0)                    ; A 1 on the stack indicate an 
                                            ; interrupt task context stack
;    
;       /* Save the final stack pointer.  */
        MOVE.L  A0,$030(A1)                 ; Save the top of the stack ptr
;    /* Fix for version 3.07 and later of the INTROL compiler
;     * Return and pop parameters off stack
;     */
        RTD #$4
;       RTS
;}                                           /* end of SKD_Init_Stack    */
;
;
;/************************************************************************/
;/*                                                                      */
;/*  FUNCTION                                "SKD_Control_To_Task"       */
;/*                                                                      */
;/*                                                                      */
;/*  DESCRIPTION                                                         */
;/*                                                                      */
;/*      This function is used to transfer control to application        */
;/*      tasks in a manner that will facilitate return back to the       */
;/*      executive after a suspension.  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.   */
;/*                                                                      */
;/*  AUTHOR                                                              */
;/*                                                                      */
;/*      William E. Lamie,  Accelerated Technology                       */
;/*                                                                      */
;/*  CALLED FROM                                                         */
;/*                                                                      */
;/*      SKP_Schedule                        The scheduler               */
;/*                                                                      */
;/*  ROUTINES CALLED                                                     */
;/*                                                                      */
;/*      CLD_Start_System_Timer              Schedule a time slice timer */
;/*                                                                      */
;/*  INPUTS                                                              */
;/*                                                                      */
;/*      tcb_ptr                             Pointer to task information */
;/*                                                                      */
;/*  OUTPUTS                                                             */
;/*                                                                      */
;/*     tcb -> sk_scheduled                  Number of task schedules    */
;/*     SKP_Current_Task_ID                  Current executing task ID   */
;/*                                                                      */
;/************************************************************************/
;void  SKD_Control_To_Task(tcb_ptr)
;
;struct SK_TASK_CONTROL_BLOCK_STRUCT
        export  SKD_Control_To_Task
SKD_Control_To_Task

⌨️ 快捷键说明

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