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

📄 os_core.lst

📁 在C8051F120内移植uCOS-II
💻 LST
📖 第 1 页 / 共 4 页
字号:
C51 COMPILER V8.08   OS_CORE                                                               04/13/2009 13:31:21 PAGE 1   


C51 COMPILER V8.08, COMPILATION OF MODULE OS_CORE
OBJECT MODULE PLACED IN OS_CORE.OBJ
COMPILER INVOKED BY: D:\Keil\C51\BIN\C51.EXE OS_CORE.C BROWSE DEBUG OBJECTEXTEND

line level    source

   1          /*
   2          *********************************************************************************************************
   3          *                                                uC/OS-II
   4          *                                          The Real-Time Kernel
   5          *                                             CORE FUNCTIONS
   6          *
   7          *                        (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
   8          *                                           All Rights Reserved
   9          *
  10          *                                                  V2.00
  11          *
  12          * File : OS_CORE.C
  13          * By   : Jean J. Labrosse
  14          *********************************************************************************************************
  15          */
  16          
  17          
  18          #define  OS_CORE_GLOBALS
  19          #include "INCLUDES.H"
  20          
  21          /*
  22          *********************************************************************************************************
  23          *                                         LOCAL GLOBAL VARIABLES
  24          *********************************************************************************************************
  25          */
  26                                                 
  27          static  INT8U  xdata      OSIntExitY;               /* Variable used by 'OSIntExit' to prevent using local
             -s */
  28          
  29          static  OS_STK xdata      OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE];       /* Idle       task stack            
             -  */
  30          
  31          #if     OS_TASK_STAT_EN
              static  OS_STK xdata      OSTaskStatStk[OS_TASK_STAT_STK_SIZE];      /* Statistics task stack             
             -  */
              #endif
  34          
  35          static  OS_TCB xdata      OSTCBTbl[OS_MAX_TASKS + OS_N_SYS_TASKS];   /* Table of TCBs                     
             -  */
  36          
  37          /*$PAGE*/
  38          /*
  39          *********************************************************************************************************
  40          *                              MAPPING TABLE TO MAP BIT POSITION TO BIT MASK
  41          *
  42          * Note: Index into table is desired bit position, 0..7
  43          *       Indexed value corresponds to bit mask
  44          *********************************************************************************************************
  45          */
  46          
  47          INT8U const code OSMapTbl[]   = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
  48          
  49          /*
  50          *********************************************************************************************************
  51          *                                       PRIORITY RESOLUTION TABLE
C51 COMPILER V8.08   OS_CORE                                                               04/13/2009 13:31:21 PAGE 2   

  52          *
  53          * Note: Index into table is bit pattern to resolve highest priority
  54          *       Indexed value corresponds to highest priority bit position (i.e. 0..7)
  55          *********************************************************************************************************
  56          */
  57          
  58          INT8U const code OSUnMapTbl[] = {
  59              0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  60              4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  61              5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  62              4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  63              6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  64              4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  65              5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  66              4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  67              7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  68              4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  69              5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  70              4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  71              6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  72              4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  73              5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  74              4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
  75          };
  76          
  77          /*$PAGE*/
  78          /*
  79          *********************************************************************************************************
  80          *                             MAKE TASK READY TO RUN BASED ON EVENT OCCURING
  81          *
  82          * Description: This function is called by other uC/OS-II services and is used to ready a task that was
  83          *              waiting for an event to occur.
  84          *
  85          * Arguments  : pevent    is a pointer to the event control block corresponding to the event.
  86          *
  87          *              msg       is a pointer to a message.  This pointer is used by message oriented services
  88          *                        such as MAILBOXEs and QUEUEs.  The pointer is not used when called by other
  89          *                        service functions.
  90          *
  91          *              msk       is a mask that is used to clear the status byte of the TCB.  For example,
  92          *                        OSSemPost() will pass OS_STAT_SEM, OSMboxPost() will pass OS_STAT_MBOX etc.
  93          *
  94          * Returns    : none
  95          *
  96          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
  97          *********************************************************************************************************
  98          */
  99          #if  (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN || OS_Sem_EN
 100          void  OSEventTaskRdy (OS_EVENT *pevent, void *msg, INT8U msk)reentrant
 101          {
 102   1          OS_TCB *ptcb;
 103   1          INT8U   x;
 104   1          INT8U   y;
 105   1          INT8U   bitx;
 106   1          INT8U   bity;
 107   1          INT8U   prio;
 108   1      
 109   1      
 110   1          y    = OSUnMapTbl[pevent->OSEventGrp];            /* Find highest prio. task waiting for message   */
 111   1          bity = OSMapTbl[y];
 112   1          x    = OSUnMapTbl[pevent->OSEventTbl[y]];
 113   1          bitx = OSMapTbl[x];
C51 COMPILER V8.08   OS_CORE                                                               04/13/2009 13:31:21 PAGE 3   

 114   1          prio = (INT8U)((y << 3) + x);                     /* Find priority of task getting the msg         */
 115   1          if ((pevent->OSEventTbl[y] &= ~bitx) == 0) {      /* Remove this task from the waiting list        */
 116   2              pevent->OSEventGrp &= ~bity;
 117   2          }
 118   1          ptcb                 =  OSTCBPrioTbl[prio];       /* Point to this task's OS_TCB                   */
 119   1          ptcb->OSTCBDly       =  0;                        /* Prevent OSTimeTick() from readying task       */
 120   1          ptcb->OSTCBEventPtr  = (OS_EVENT *)0;             /* Unlink ECB from this task                     */
 121   1      #if (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN
                  ptcb->OSTCBMsg       = msg;                       /* Send message directly to waiting task         */
              #else
 124   1          msg                  = msg;                       /* Prevent compiler warning if not used          */ 
             -   
 125   1      #endif    
 126   1          ptcb->OSTCBStat     &= ~msk;                      /* Clear bit associated with event type          */
 127   1          if (ptcb->OSTCBStat == OS_STAT_RDY) {             /* See if task is ready (could be susp'd)        */
 128   2              OSRdyGrp        |=  bity;                     /* Put task in the ready to run list             */
 129   2              OSRdyTbl[y]     |=  bitx;
 130   2          }
 131   1      }
 132          #endif
 133          /*$PAGE*/
 134          /*
 135          *********************************************************************************************************
 136          *                                   MAKE TASK WAIT FOR EVENT TO OCCUR
 137          *
 138          * Description: This function is called by other uC/OS-II services to suspend a task because an event has
 139          *              not occurred.
 140          *
 141          * Arguments  : pevent   is a pointer to the event control block for which the task will be waiting for.
 142          *
 143          * Returns    : none
 144          *
 145          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 146          *********************************************************************************************************
 147          */
 148          #if  (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN || OS_Sem_EN
 149          void  OSEventTaskWait (OS_EVENT *pevent)reentrant
 150          {
 151   1          OSTCBCur->OSTCBEventPtr = pevent;            /* Store pointer to event control block in TCB        */
 152   1          if ((OSRdyTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0) {      /* Task no longer ready      */
 153   2              OSRdyGrp &= ~OSTCBCur->OSTCBBitY;
 154   2          }
 155   1          pevent->OSEventTbl[OSTCBCur->OSTCBY] |= OSTCBCur->OSTCBBitX;          /* Put task in waiting list  */
 156   1          pevent->OSEventGrp                   |= OSTCBCur->OSTCBBitY;
 157   1      }
 158          #endif
 159          /*$PAGE*/
 160          /*
 161          *********************************************************************************************************
 162          *                              MAKE TASK READY TO RUN BASED ON EVENT TIMEOUT
 163          *
 164          * Description: This function is called by other uC/OS-II services to make a task ready to run because a
 165          *              timeout occurred.
 166          *
 167          * Arguments  : pevent   is a pointer to the event control block which is readying a task.
 168          *
 169          * Returns    : none
 170          *
 171          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 172          *********************************************************************************************************
 173          */
 174          #if  (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN || OS_Sem_EN
C51 COMPILER V8.08   OS_CORE                                                               04/13/2009 13:31:21 PAGE 4   

 175          void  OSEventTO (OS_EVENT *pevent)reentrant
 176          {
 177   1          if ((pevent->OSEventTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0) {
 178   2              pevent->OSEventGrp &= ~OSTCBCur->OSTCBBitY;
 179   2          }
 180   1          OSTCBCur->OSTCBStat     = OS_STAT_RDY;       /* Set status to ready                                */
 181   1          OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;     /* No longer waiting for event                        */
 182   1      }
 183          #endif
 184          /*$PAGE*/
 185          /*
 186          *********************************************************************************************************
 187          *                                 INITIALIZE EVENT CONTROL BLOCK'S WAIT LIST
 188          *
 189          * Description: This function is called by other uC/OS-II services to initialize the event wait list.
 190          *
 191          * Arguments  : pevent    is a pointer to the event control block allocated to the event.
 192          *
 193          * Returns    : none
 194          *
 195          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 196          *********************************************************************************************************
 197          */
 198          #if  (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN || OS_Sem_EN
 199          void  OSEventWaitListInit (OS_EVENT *pevent)reentrant
 200          {
 201   1          INT8U i;
 202   1          
 203   1          
 204   1          pevent->OSEventGrp = 0x00;                   /* No task waiting on event                           */
 205   1          for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
 206   2              pevent->OSEventTbl[i] = 0x00;
 207   2          }
 208   1      }
 209          #endif
 210          /*$PAGE*/
 211          /*
 212          *********************************************************************************************************
 213          *                                             INITIALIZATION
 214          *
 215          * Description: This function is used to initialize the internals of uC/OS-II and MUST be called prior to
 216          *              creating any uC/OS-II object and, prior to calling OSStart().
 217          *
 218          * Arguments  : none

⌨️ 快捷键说明

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