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

📄 os_core.lst

📁 基于51单片机UCOS移植
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V9.01   OS_CORE                                                               10/31/2012 17:19:07 PAGE 1   


C51 COMPILER V9.01, COMPILATION OF MODULE OS_CORE
OBJECT MODULE PLACED IN .\Output\OS_CORE.obj
COMPILER INVOKED BY: D:\keil c51完全版\an_zhuang_51\C51\BIN\C51.EXE uCOS-II\Src\OS_CORE.C LARGE BROWSE INCDIR(.\ucos-ii\
                    -inc\) DEBUG OBJECTEXTEND PRINT(.\Listing\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[]   = {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[] = {
  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 V9.01   OS_CORE                                                               10/31/2012 17:19:07 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          /*
  60          *********************************************************************************************************
  61          *                                       FUNCTION PROTOTYPES
  62          *********************************************************************************************************
  63          */
  64          static  void  OS_InitEventList(void);
  65          static  void  OS_InitMisc(void);
  66          static  void  OS_InitRdyList(void);
  67          static  void  OS_InitTaskIdle(void);
  68          static  void  OS_InitTaskStat(void);
  69          static  void  OS_InitTCBList(void);
  70          
  71          /*$PAGE*/
  72          /*
  73          *********************************************************************************************************
  74          *                                             INITIALIZATION
  75          *
  76          * Description: This function is used to initialize the internals of uC/OS-II and MUST be called prior to
  77          *              creating any uC/OS-II object and, prior to calling OSStart().
  78          *
  79          * Arguments  : none
  80          *
  81          * Returns    : none
  82          *********************************************************************************************************
  83          */
  84          
  85          void  OSInit (void) REENTRANT
  86          {
  87   1      #if OS_VERSION >= 204
  88   1          OSInitHookBegin();                                           /* Call port specific initialization code
             -   */
  89   1      #endif
  90   1      
  91   1          OS_InitMisc();                                               /* Initialize miscellaneous variables    
             -   */
  92   1      
  93   1          OS_InitRdyList();                                            /* Initialize the Ready List             
             -   */
  94   1          OS_InitTCBList();                                            /* Initialize the free list of OS_TCBs   
             -   */
  95   1          OS_InitEventList();                                          /* Initialize the free list of OS_EVENTs 
             -   */
  96   1      
  97   1      #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
                  OS_FlagInit();                                               /* Initialize the event flag structures  
             -   */
              #endif
 100   1      
 101   1      #if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0)
                  OS_MemInit();                                                /* Initialize the memory manager         
             -   */
              #endif
 104   1      
 105   1      #if (OS_Q_EN > 0) && (OS_MAX_QS > 0)
                  OS_QInit();                                                  /* Initialize the message queue structure
             -s  */
              #endif
 108   1      
C51 COMPILER V9.01   OS_CORE                                                               10/31/2012 17:19:07 PAGE 3   

 109   1          OS_InitTaskIdle();                                           /* Create the Idle Task                  
             -   */
 110   1      #if OS_TASK_STAT_EN > 0
                  OS_InitTaskStat();                                           /* Create the Statistic Task             
             -   */
              #endif
 113   1      
 114   1      #if OS_VERSION >= 204
 115   1          OSInitHookEnd();                                             /* Call port specific init. code         
             -   */
 116   1      #endif
 117   1      }
 118          /*$PAGE*/
 119          /*
 120          *********************************************************************************************************
 121          *                                              ENTER ISR
 122          *
 123          * Description: This function is used to notify uC/OS-II that you are about to service an interrupt
 124          *              service routine (ISR).  This allows uC/OS-II to keep track of interrupt nesting and thus
 125          *              only perform rescheduling at the last nested ISR.
 126          *
 127          * Arguments  : none
 128          *
 129          * Returns    : none
 130          *
 131          * Notes      : 1) This function should be called ith interrupts already disabled
 132          *              2) Your ISR can directly increment OSIntNesting without calling this function because
 133          *                 OSIntNesting has been declared 'global'.  
 134          *              3) You MUST still call OSIntExit() even though you increment OSIntNesting directly.
 135          *              4) You MUST invoke OSIntEnter() and OSIntExit() in pair.  In other words, for every call
 136          *                 to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
 137          *                 end of the ISR.
 138          *              5) You are allowed to nest interrupts up to 255 levels deep.
 139          *              6) I removed the OS_ENTER_CRITICAL() and OS_EXIT_CRITICAL() around the increment because
 140          *                 OSIntEnter() is always called with interrupts disabled.
 141          *********************************************************************************************************
 142          */
 143          
 144          void  OSIntEnter (void) REENTRANT
 145          {
 146   1          if (OSRunning == TRUE) {
 147   2              if (OSIntNesting < 255) {
 148   3                  OSIntNesting++;                      /* Increment ISR nesting level                        */
 149   3              }
 150   2          }
 151   1      }
 152          /*$PAGE*/
 153          /*
 154          *********************************************************************************************************
 155          *                                               EXIT ISR
 156          *
 157          * Description: This function is used to notify uC/OS-II that you have completed serviving an ISR.  When
 158          *              the last nested ISR has completed, uC/OS-II will call the scheduler to determine whether
 159          *              a new, high-priority task, is ready to run.
 160          *
 161          * Arguments  : none
 162          *
 163          * Returns    : none
 164          *
 165          * Notes      : 1) You MUST invoke OSIntEnter() and OSIntExit() in pair.  In other words, for every call
 166          *                 to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
 167          *                 end of the ISR.
C51 COMPILER V9.01   OS_CORE                                                               10/31/2012 17:19:07 PAGE 4   

 168          *              2) Rescheduling is prevented when the scheduler is locked (see OS_SchedLock())
 169          *********************************************************************************************************
 170          */
 171          
 172          void  OSIntExit (void) REENTRANT
 173          {
 174   1      #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
                  OS_CPU_SR  cpu_sr;
              #endif
 177   1          
 178   1          
 179   1          if (OSRunning == TRUE) {
 180   2              OS_ENTER_CRITICAL();
 181   2              if (OSIntNesting > 0) {                            /* Prevent OSIntNesting from wrapping       */
 182   3                  OSIntNesting--;
 183   3              }
 184   2              if ((OSIntNesting == 0) && (OSLockNesting == 0)) { /* Reschedule only if all ISRs complete ... */
 185   3                  OSIntExitY    = OSUnMapTbl[OSRdyGrp];          /* ... and not locked.                      */
 186   3                  OSPrioHighRdy = (INT8U)((OSIntExitY << 3) + OSUnMapTbl[OSRdyTbl[OSIntExitY]]);
 187   3                  if (OSPrioHighRdy != OSPrioCur) {              /* No Ctx Sw if current task is highest rdy */
 188   4                      OSTCBHighRdy  = OSTCBPrioTbl[OSPrioHighRdy];
 189   4                      OSCtxSwCtr++;                              /* Keep track of the number of ctx switches */
 190   4                      OSIntCtxSw();                              /* Perform interrupt level ctx switch       */
 191   4                  }
 192   3              }
 193   2              OS_EXIT_CRITICAL();
 194   2          }
 195   1      }
 196          /*$PAGE*/
 197          /*
 198          *********************************************************************************************************
 199          *                                          PREVENT SCHEDULING
 200          *
 201          * Description: This function is used to prevent rescheduling to take place.  This allows your application
 202          *              to prevent context switches until you are ready to permit context switching.
 203          *
 204          * Arguments  : none

⌨️ 快捷键说明

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