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

📄 os_core.lst

📁 ucos v2.62 安装程序 附带已移植到C8051F020的UCOS源码
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V8.05a   OS_CORE                                                              04/11/2007 16:19:49 PAGE 1   


C51 COMPILER V8.05a, COMPILATION OF MODULE OS_CORE
OBJECT MODULE PLACED IN ..\Output\os_core.obj
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE ..\SOURCE\os_core.c LARGE BROWSE INCDIR(..\app;..\Main;..\Por
                    -t;..\SOURCE) DEBUG OBJECTEXTEND PRINT(..\Output\os_core.lst) OBJECT(..\Output\os_core.obj)

line level    source

   1          /*
   2          *********************************************************************************************************
   3          *                                                uC/OS-II
   4          *                                          The Real-Time Kernel
   5          *                                             CORE FUNCTIONS
   6          *
   7          *                          (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
   8          *                                           All Rights Reserved
   9          *
  10          * File : OS_CORE.C
  11          * By   : Jean J. Labrosse
  12          *********************************************************************************************************
  13          */
  14          
  15          #ifndef  OS_MASTER_FILE
  16          #define  OS_GLOBALS
  17          #include "includes.h"
  18          #endif
  19          
  20          /*
  21          *********************************************************************************************************
  22          *                              MAPPING TABLE TO MAP BIT POSITION TO BIT MASK
  23          *
  24          * Note: Index into table is desired bit position, 0..7
  25          *       Indexed value corresponds to bit mask
  26          *********************************************************************************************************
  27          */
  28          
  29          INT8U  const  OSMapTbl[8]   = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
  30          
  31          /*
  32          *********************************************************************************************************
  33          *                                       PRIORITY RESOLUTION TABLE
  34          *
  35          * Note: Index into table is bit pattern to resolve highest priority
  36          *       Indexed value corresponds to highest priority bit position (i.e. 0..7)
  37          *********************************************************************************************************
  38          */
  39          
  40          INT8U  const  OSUnMapTbl[256] = {
  41              0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x00 to 0x0F                             */
  42              4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x10 to 0x1F                             */
  43              5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x20 to 0x2F                             */
  44              4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x30 to 0x3F                             */
  45              6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x40 to 0x4F                             */
  46              4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x50 to 0x5F                             */
  47              5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x60 to 0x6F                             */
  48              4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x70 to 0x7F                             */
  49              7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x80 to 0x8F                             */
  50              4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x90 to 0x9F                             */
  51              5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0xA0 to 0xAF                             */
  52              4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0xB0 to 0xBF                             */
  53              6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0xC0 to 0xCF                             */
  54              4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0xD0 to 0xDF                             */
C51 COMPILER V8.05a   OS_CORE                                                              04/11/2007 16:19:49 PAGE 2   

  55              5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0xE0 to 0xEF                             */
  56              4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0        /* 0xF0 to 0xFF                             */
  57          };
  58          
  59          /*$PAGE*/
  60          /*
  61          *********************************************************************************************************
  62          *                                       FUNCTION PROTOTYPES
  63          *********************************************************************************************************
  64          */
  65          static  void  OS_InitEventList(void);
  66          static  void  OS_InitMisc(void);
  67          static  void  OS_InitRdyList(void);
  68          static  void  OS_InitTaskIdle(void);
  69          #if OS_TASK_STAT_EN > 0
              static  void  OS_InitTaskStat(void);
              #endif
  72          static  void  OS_InitTCBList(void);
  73          
  74          /*$PAGE*/
  75          /*
  76          *********************************************************************************************************
  77          *                         GET THE NAME OF A SEMAPHORE, MUTEX, MAILBOX or QUEUE
  78          *
  79          * Description: This function is used to obtain the name assigned to a semaphore, mutex, mailbox or queue.
  80          *
  81          * Arguments  : pevent    is a pointer to the event group.  'pevent' can point either to a semaphore,
  82          *                        a mutex, a mailbox or a queue.  Where this function is concerned, the actual
  83          *                        type is irrelevant.
  84          *
  85          *              pname     is a pointer to an ASCII string that will receive the name of the semaphore,
  86          *                        mutex, mailbox or queue.  The string must be able to hold at least 
  87          *                        OS_EVENT_NAME_SIZE characters.
  88          *
  89          *              err       is a pointer to an error code that can contain one of the following values:
  90          *
  91          *                        OS_NO_ERR                  if the name was copied to 'pname'
  92          *                        OS_ERR_EVENT_TYPE          if 'pevent' is not pointing to the proper event 
  93          *                                                   control block type.
  94          *                        OS_ERR_PNAME_NULL          You passed a NULL pointer for 'pname'
  95          *                        OS_ERR_PEVENT_NULL         if you passed a NULL pointer for 'pevent'
  96          *
  97          * Returns    : The length of the string or 0 if the 'pevent' is a NULL pointer.
  98          *********************************************************************************************************
  99          */
 100          
 101          #if OS_EVENT_NAME_SIZE > 0
              INT8U  OSEventNameGet (OS_EVENT *pevent, char *pname, INT8U *err)
              {
              #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
                  OS_CPU_SR  cpu_sr;
              #endif
                  INT8U      len;
              
              
                  OS_ENTER_CRITICAL();
              #if OS_ARG_CHK_EN > 0
                  if (pevent == (OS_EVENT *)0) {               /* Is 'pevent' a NULL pointer?                        */
                      OS_EXIT_CRITICAL();                      /* Yes                                                */
                      *err = OS_ERR_PEVENT_NULL;
                      return (0);
                  }
C51 COMPILER V8.05a   OS_CORE                                                              04/11/2007 16:19:49 PAGE 3   

                  if (pname == (char *)0) {                    /* Is 'pname' a NULL pointer?                         */
                      OS_EXIT_CRITICAL();                      /* Yes                                                */
                      *err = OS_ERR_PNAME_NULL;
                      return (0);
                  }
              #endif
                  switch (pevent->OSEventType) {
                      case OS_EVENT_TYPE_SEM:
                      case OS_EVENT_TYPE_MUTEX:
                      case OS_EVENT_TYPE_MBOX:
                      case OS_EVENT_TYPE_Q:
                           break;
              
                      default:
                           OS_EXIT_CRITICAL();
                           *err = OS_ERR_EVENT_TYPE;
                           return (0);
                  }
                  (void)strcpy(pname, pevent->OSEventName);    /* Yes, copy name from OS_EVENT                       */
                  len  = strlen(pname);
                  OS_EXIT_CRITICAL();
                  *err = OS_NO_ERR;
                  return (len);
              }
              #endif
 142          
 143          /*$PAGE*/
 144          /*
 145          *********************************************************************************************************
 146          *                         ASSIGN A NAME TO A SEMAPHORE, MUTEX, MAILBOX or QUEUE
 147          *
 148          * Description: This function assigns a name to a semaphore, mutex, mailbox or queue.
 149          *
 150          * Arguments  : pevent    is a pointer to the event group.  'pevent' can point either to a semaphore,
 151          *                        a mutex, a mailbox or a queue.  Where this function is concerned, it doesn't
 152          *                        matter the actual type.
 153          *
 154          *              pname     is a pointer to an ASCII string that will be used as the name of the semaphore,
 155          *                        mutex, mailbox or queue.  The string must be able to hold at least 
 156          *                        OS_EVENT_NAME_SIZE characters.
 157          *
 158          *              err       is a pointer to an error code that can contain one of the following values:
 159          *
 160          *                        OS_NO_ERR                  if the requested task is resumed
 161          *                        OS_ERR_EVENT_TYPE          if 'pevent' is not pointing to the proper event 
 162          *                                                   control block type.
 163          *                        OS_ERR_PNAME_NULL          You passed a NULL pointer for 'pname'
 164          *                        OS_ERR_PEVENT_NULL         if you passed a NULL pointer for 'pevent'
 165          *
 166          * Returns    : None
 167          *********************************************************************************************************
 168          */
 169          
 170          #if OS_EVENT_NAME_SIZE > 0
              void  OSEventNameSet (OS_EVENT *pevent, char *pname, INT8U *err)
              {
              #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
                  OS_CPU_SR  cpu_sr;
              #endif
                  INT8U      len;
              
              
C51 COMPILER V8.05a   OS_CORE                                                              04/11/2007 16:19:49 PAGE 4   

                  OS_ENTER_CRITICAL();
              #if OS_ARG_CHK_EN > 0
                  if (pevent == (OS_EVENT *)0) {               /* Is 'pevent' a NULL pointer?                        */
                      OS_EXIT_CRITICAL();                      /* Yes                                                */
                      *err = OS_ERR_PEVENT_NULL;
                      return;
                  }
                  if (pname == (char *)0) {                    /* Is 'pname' a NULL pointer?                         */
                      OS_EXIT_CRITICAL();                      /* Yes                                                */
                      *err = OS_ERR_PNAME_NULL;
                      return;
                  }
              #endif
                  switch (pevent->OSEventType) {
                      case OS_EVENT_TYPE_SEM:
                      case OS_EVENT_TYPE_MUTEX:
                      case OS_EVENT_TYPE_MBOX:
                      case OS_EVENT_TYPE_Q:
                           break;
              
                      default:
                           OS_EXIT_CRITICAL();
                           *err = OS_ERR_EVENT_TYPE;
                           return;
                  }
                  len = strlen(pname);                         /* Can we fit the string in the storage area?         */
                  if (len > (OS_EVENT_NAME_SIZE - 1)) {        /* No                                                 */
                      OS_EXIT_CRITICAL();
                      *err = OS_ERR_EVENT_NAME_TOO_LONG;
                      return;
                  } 
                  (void)strcpy(pevent->OSEventName, pname);    /* Yes, copy name to the event control block          */
                  OS_EXIT_CRITICAL();
                  *err = OS_NO_ERR;
              }
              #endif
 215          
 216          /*$PAGE*/
 217          /*
 218          *********************************************************************************************************
 219          *                                             INITIALIZATION
 220          *
 221          * Description: This function is used to initialize the internals of uC/OS-II and MUST be called prior to
 222          *              creating any uC/OS-II object and, prior to calling OSStart().

⌨️ 快捷键说明

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