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

📄 os_cpu_c.lst

📁 uC/OS操作系统在51平台的移植代码
💻 LST
字号:
C51 COMPILER V6.20c  OS_CPU_C                                                              07/03/2002 08:51:26 PAGE 1   


C51 COMPILER V6.20c, COMPILATION OF MODULE OS_CPU_C
OBJECT MODULE PLACED IN ..\port\OS_CPU_C.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\port\OS_CPU_C.C LARGE ROM(COMPACT) OPTIMIZE(9,SIZE) REGFILE(..\out\EXEc5
                    -1.ORC) BROWSE INCDIR(.) DEBUG OBJECTEXTEND PRINT(..\out\OS_CPU_C.lst) SRC(..\out\OS_CPU_C.SRC) 

stmt level    source

   1          /*
   2          *********************************************************************************************************
   3          *                                               uC/OS-II
   4          *                                         The Real-Time Kernel
   5          *
   6          *                        (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
   7          *                                          All Rights Reserved
   8          *
   9          *
  10          *                                       80x86/80x88 Specific code
  11          *                                          LARGE MEMORY MODEL
  12          *
  13          * File : OS_CPU_C.C
  14          * By   : Jean J. Labrosse
  15          *
  16          *
  17          * Ported date:     MAY 29, 2002
  18          * By:              Junmin Zheng, China, (zhengjunm@263.net)
  19          * Target platform: Keil C51 V6.20
  20          *         
  21          *********************************************************************************************************
  22          */
  23          
  24          #define  OS_CPU_GLOBALS
  25          #include "..\mainfile\includes.h"
  26          #include "..\function\os_kcdef.h"
  27          /*
  28          *********************************************************************************************************
  29          *                                        INITIALIZE A TASK'S STACK
  30          *
  31          * Description: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the
  32          *              stack frame of the task being created.  This function is highly processor specific.
  33          *
  34          * Arguments  : task          is a pointer to the task code
  35          *
  36          *              pdata         is a pointer to a user supplied data area that will be passed to the task
  37          *                            when the task first executes.
  38          *
  39          *              ptos          is a pointer to the top of stack.  It is assumed that 'ptos' points to
  40          *                            a 'free' entry on the task stack.  If OS_STK_GROWTH is set to 1 then 
  41          *                            'ptos' will contain the HIGHEST valid address of the stack.  Similarly, if
  42          *                            OS_STK_GROWTH is set to 0, the 'ptos' will contains the LOWEST valid address
  43          *                            of the stack.
  44          *
  45          *              opt           specifies options that can be used to alter the behavior of OSTaskStkInit().
  46          *                            (see uCOS_II.H for OS_TASK_OPT_???).
  47          *
  48          * Returns    : Always returns the location of the new top-of-stack' once the processor registers have
  49          *              been placed on the stack in the proper order.
  50          *
  51          * Note(s)    : Interrupts are enabled when your task starts executing. You can change this by setting the
  52          *              PSW to 0x0002 instead.  In this case, interrupts would be disabled upon task startup.  The
  53          *              application code would be responsible for enabling interrupts at the beginning of the task
  54          *              code.  You will need to modify OSTaskIdle() and OSTaskStat() so that they enable 
C51 COMPILER V6.20c  OS_CPU_C                                                              07/03/2002 08:51:26 PAGE 2   

  55          *              interrupts.  Failure to do this will make your system crash!
  56          *********************************************************************************************************
  57          */
  58          
  59          /* The stack variable points to the start pointer in hardware stack and is defined in OS_CPU_A */
  60          extern idata unsigned char Stack[1];
  61          
  62          OS_STK *OSTaskStkInit (void (*task)(void *pd) KCREENTRANT, void * vd, OS_STK *ptos, INT16U opt) KCREENTRAN
             -T
  63          {   
  64   1      	INT8U * stk;
  65   1          opt    = opt;                           /* 'opt' is not used, prevent warning                      */
  66   1          stk    = (INT8U *) ptos;                /* Load stack pointer                                      */
  67   1      
  68   1      	stk				-= sizeof(INT16U);      /* The value should be loaded to PC    */
  69   1      	*(INT16U*)stk	 = (INT16U) task;       /* next time when this task is running */
  70   1      
  71   1      	stk				-= sizeof(INT16U);      /* The value should be loaded to PC    */
  72   1      	*(INT16U*)stk	 = (INT16U) task;       /* next time when this task is running */
  73   1      
  74   1      /* Following is the registers pushed into hardware stack */
  75   1      	*--stk			 = 'A';                 /* ACC */
  76   1      	*--stk			 = 'B';                 /* B   */
  77   1      	*--stk			 = 'L';                 /* DPL */
  78   1      	*--stk			 = 'H';                 /* DPH */
  79   1      	*--stk			 = PSW;					/* PSW */
  80   1      	*--stk			 = 0;                   /* R0  */
  81   1      
  82   1      	stk				-= sizeof(void *);      /* Keil C uses R1,R2,R3 to pass the */
  83   1      	*(void**)stk	 = vd;                  /* arguments of functions.          */
  84   1      
  85   1      	*--stk			 = 4;                   /* R4  */
  86   1      	*--stk			 = 5;                   /* R5  */
  87   1      	*--stk			 = 6;                   /* R6  */
  88   1      	*--stk			 = 7;                   /* R7  */
  89   1      
  90   1          *--stk           = 0x80;                /* IE, EA is enabled  */
  91   1      /*
  92   1          Next is calculating the hardware stack pointer.
  93   1      */
  94   1          *--stk			 = (INT8U) Stack-1    /* Initial value when main was called    */
  95   1      	                   +1                   /* IE */
  96   1      	                   +8                   /* R0-R7, eight registers was saved      */
  97   1                             +5                   /* PSW, ACC, B, DPH, DPL, five registers */
  98   1                             +sizeof(INT16U)      /* The PC value to be loaded             */
  99   1                             +sizeof(INT16U)      /* The PC value to be loaded             */
 100   1      					   ;
 101   1      
 102   1          return ((void *)stk);
 103   1      }
 104          
 105          
 106          
 107          void UserTickTimer(void) KCREENTRANT;
 108          
 109          /* OSTickISR can be writen in c language now, so it is more easy for user to write code for their own */
 110          void OSTickISR(void) KCREENTRANT interrupt 1 
 111          {
 112   1       
 113   1      #pragma ASM
 114   1      PUSH IE
 115   1      #pragma ENDASM
C51 COMPILER V6.20c  OS_CPU_C                                                              07/03/2002 08:51:26 PAGE 3   

 116   1      OSIntEnter();
 117   1      UserTickTimer();				
 118   1      OSTimeTick();					
 119   1      OSIntExit();
 120   1      #pragma ASM
 121   1      POP IE
 122   1      #pragma ENDASM		
 123   1      }
 124          
 125          /* If you want to write ISRs for your own, just do as OSTickISR() */
 126          
 127          /*$PAGE*/
 128          #if OS_CPU_HOOKS_EN
 129          
 130          
 131          /*
 132          *********************************************************************************************************
 133          *                                          TASK CREATION HOOK
 134          *
 135          * Description: This function is called when a task is created.
 136          *
 137          * Arguments  : ptcb   is a pointer to the task control block of the task being created.
 138          *
 139          * Note(s)    : 1) Interrupts are disabled during this call.
 140          *********************************************************************************************************
 141          */
 142          void OSTaskCreateHook (OS_TCB *ptcb) KCREENTRANT
 143          {
 144   1          ptcb = ptcb;                       /* Prevent compiler warning                                     */
 145   1      }
 146          
 147          
 148          /*
 149          *********************************************************************************************************
 150          *                                           TASK DELETION HOOK
 151          *
 152          * Description: This function is called when a task is deleted.
 153          *
 154          * Arguments  : ptcb   is a pointer to the task control block of the task being deleted.
 155          *
 156          * Note(s)    : 1) Interrupts are disabled during this call.
 157          *********************************************************************************************************
 158          */
 159          void OSTaskDelHook (OS_TCB *ptcb) KCREENTRANT
 160          {
 161   1          ptcb = ptcb;                       /* Prevent compiler warning                                     */
 162   1      }
 163          
 164          /*
 165          *********************************************************************************************************
 166          *                                           TASK SWITCH HOOK
 167          *
 168          * Description: This function is called when a task switch is performed.  This allows you to perform other
 169          *              operations during a context switch.
 170          *
 171          * Arguments  : none
 172          *
 173          * Note(s)    : 1) Interrupts are disabled during this call.
 174          *              2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that
 175          *                 will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the 
 176          *                 task being switched out (i.e. the preempted task).
 177          *********************************************************************************************************
C51 COMPILER V6.20c  OS_CPU_C                                                              07/03/2002 08:51:26 PAGE 4   

 178          */
 179          void OSTaskSwHook (void) KCREENTRANT
 180          {
 181   1      }
 182          
 183          /*
 184          *********************************************************************************************************
 185          *                                           STATISTIC TASK HOOK
 186          *
 187          * Description: This function is called every second by uC/OS-II's statistics task.  This allows your 
 188          *              application to add functionality to the statistics task.
 189          *
 190          * Arguments  : none
 191          *********************************************************************************************************
 192          */
 193          void OSTaskStatHook (void) KCREENTRANT
 194          {
 195   1      }
 196          
 197          /*
 198          *********************************************************************************************************
 199          *                                               TICK HOOK
 200          *
 201          * Description: This function is called every tick.
 202          *
 203          * Arguments  : none
 204          *
 205          * Note(s)    : 1) Interrupts may or may not be ENABLED during this call.
 206          *********************************************************************************************************
 207          */
 208          void OSTimeTickHook (void) KCREENTRANT
 209          {
 210   1      }
 211          
 212          #endif


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    366    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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