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

📄 os_core.lst

📁 uCOS 嵌入式操作系统的改进版,增加了网络通讯.
💻 LST
📖 第 1 页 / 共 5 页
字号:
 220          /*
 221          *********************************************************************************************************
 222          *                         GET THE NAME OF A SEMAPHORE, MUTEX, MAILBOX or QUEUE
 223          *
 224          * Description: This function is used to obtain the name assigned to a semaphore, mutex, mailbox or queue.
 225          *
 226          * Arguments  : pevent    is a pointer to the event group.  'pevent' can point either to a semaphore,
 227          *                        a mutex, a mailbox or a queue.  Where this function is concerned, the actual
 228          *                        type is irrelevant.
 229          *
 230          *              pname     is a pointer to an ASCII string that will receive the name of the semaphore,
 231          *                        mutex, mailbox or queue.  The string must be able to hold at least 
 232          *                        OS_EVENT_NAME_SIZE characters.
 233          *
 234          *              err       is a pointer to an error code that can contain one of the following values:
 235          *
 236          *                        OS_NO_ERR                  if the name was copied to 'pname'
 237          *                        OS_ERR_EVENT_TYPE          if 'pevent' is not pointing to the proper event 
 238          *                                                   control block type.
 239          *                        OS_ERR_PNAME_NULL          You passed a NULL pointer for 'pname'
 240          *                        OS_ERR_PEVENT_NULL         if you passed a NULL pointer for 'pevent'
C51 COMPILER V7.06   OS_CORE                                                               07/18/2003 11:05:56 PAGE 5   

 241          *
 242          * Returns    : The length of the string or 0 if the 'pevent' is a NULL pointer.
 243          *********************************************************************************************************
 244          */
 245          
 246          #if OS_EVENT_NAME_SIZE > 0
 247          INT8U  OSEventNameGet (OS_EVENT *pevent, char *pname, INT8U *err) reentrant //using 0
 248          {
 249   1      #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
 250   1          OS_CPU_SR  cpu_sr;
 251   1      #endif
 252   1          INT8U      len;
 253   1      
 254   1      
 255   1          OS_ENTER_CRITICAL();
 256   1      #if OS_ARG_CHK_EN > 0
 257   1          if (pevent == (OS_EVENT *)0) {               /* Is 'pevent' a NULL pointer?                        */
 258   2              OS_EXIT_CRITICAL();                      /* Yes                                                */
 259   2              *err = OS_ERR_PEVENT_NULL;
 260   2              return (0);
 261   2          }
 262   1          if (pname == (char *)0) {                    /* Is 'pname' a NULL pointer?                         */
 263   2              OS_EXIT_CRITICAL();                      /* Yes                                                */
 264   2              *err = OS_ERR_PNAME_NULL;
 265   2              return (0);
 266   2          }
 267   1      #endif
 268   1          switch (pevent->OSEventType) {
 269   2              case OS_EVENT_TYPE_SEM:
 270   2              case OS_EVENT_TYPE_MUTEX:
 271   2              case OS_EVENT_TYPE_MBOX:
 272   2              case OS_EVENT_TYPE_Q:
 273   2                   break;
 274   2      
 275   2              default:
 276   2                   OS_EXIT_CRITICAL();
 277   2                   *err = OS_ERR_EVENT_TYPE;
 278   2                   return (0);
 279   2          }
 280   1          (void)strcpy(pname, pevent->OSEventName);    /* Yes, copy name from OS_EVENT                       */
 281   1          len  = strlen(pname);
 282   1          OS_EXIT_CRITICAL();
 283   1          *err = OS_NO_ERR;
 284   1          return (len);
 285   1      }
 286          #endif
 287          
 288          /*$PAGE*/
 289          /*
 290          *********************************************************************************************************
 291          *                         ASSIGN A NAME TO A SEMAPHORE, MUTEX, MAILBOX or QUEUE
 292          *
 293          * Description: This function assigns a name to a semaphore, mutex, mailbox or queue.
 294          *
 295          * Arguments  : pevent    is a pointer to the event group.  'pevent' can point either to a semaphore,
 296          *                        a mutex, a mailbox or a queue.  Where this function is concerned, it doesn't
 297          *                        matter the actual type.
 298          *
 299          *              pname     is a pointer to an ASCII string that will be used as the name of the semaphore,
 300          *                        mutex, mailbox or queue.  The string must be able to hold at least 
 301          *                        OS_EVENT_NAME_SIZE characters.
 302          *
C51 COMPILER V7.06   OS_CORE                                                               07/18/2003 11:05:56 PAGE 6   

 303          *              err       is a pointer to an error code that can contain one of the following values:
 304          *
 305          *                        OS_NO_ERR                  if the requested task is resumed
 306          *                        OS_ERR_EVENT_TYPE          if 'pevent' is not pointing to the proper event 
 307          *                                                   control block type.
 308          *                        OS_ERR_PNAME_NULL          You passed a NULL pointer for 'pname'
 309          *                        OS_ERR_PEVENT_NULL         if you passed a NULL pointer for 'pevent'
 310          *
 311          * Returns    : None
 312          *********************************************************************************************************
 313          */
 314          
 315          #if OS_EVENT_NAME_SIZE > 0
 316          void  OSEventNameSet (OS_EVENT *pevent, char *pname, INT8U *err) reentrant //using 0
 317          {
 318   1      #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
 319   1          OS_CPU_SR  cpu_sr;
 320   1      #endif
 321   1          INT8U      len;
 322   1      
 323   1      
 324   1          OS_ENTER_CRITICAL();
 325   1      #if OS_ARG_CHK_EN > 0
 326   1          if (pevent == (OS_EVENT *)0) {               /* Is 'pevent' a NULL pointer?                        */
 327   2              OS_EXIT_CRITICAL();                      /* Yes                                                */
 328   2              *err = OS_ERR_PEVENT_NULL;
 329   2              return;
 330   2          }
 331   1          if (pname == (char *)0) {                    /* Is 'pname' a NULL pointer?                         */
 332   2              OS_EXIT_CRITICAL();                      /* Yes                                                */
 333   2              *err = OS_ERR_PNAME_NULL;
 334   2              return;
 335   2          }
 336   1      #endif
 337   1          switch (pevent->OSEventType) {
 338   2              case OS_EVENT_TYPE_SEM:
 339   2              case OS_EVENT_TYPE_MUTEX:
 340   2              case OS_EVENT_TYPE_MBOX:
 341   2              case OS_EVENT_TYPE_Q:
 342   2                   break;
 343   2      
 344   2              default:
 345   2                   OS_EXIT_CRITICAL();
 346   2                   *err = OS_ERR_EVENT_TYPE;
 347   2                   return;
 348   2          }
 349   1          len = strlen(pname);                         /* Can we fit the string in the storage area?         */
 350   1          if (len > (OS_EVENT_NAME_SIZE - 1)) {        /* No                                                 */
 351   2              OS_EXIT_CRITICAL();
 352   2              *err = OS_ERR_EVENT_NAME_TOO_LONG;
 353   2              return;
 354   2          } 
 355   1          (void)strcpy(pevent->OSEventName, pname);    /* Yes, copy name to the event control block          */
 356   1          OS_EXIT_CRITICAL();
 357   1          *err = OS_NO_ERR;
 358   1      }
 359          #endif
 360          
 361          /*$PAGE*/
 362          /*
 363          *********************************************************************************************************
 364          *                                             INITIALIZATION
C51 COMPILER V7.06   OS_CORE                                                               07/18/2003 11:05:56 PAGE 7   

 365          *
 366          * Description: This function is used to initialize the internals of uC/OS-II and MUST be called prior to
 367          *              creating any uC/OS-II object and, prior to calling OSStart().
 368          *
 369          * Arguments  : none
 370          *
 371          * Returns    : none
 372          *********************************************************************************************************
 373          */
 374          
 375          void  OSInit (void) reentrant //using 0
 376          {
 377   1      #if OS_VERSION >= 204
 378   1          OSInitHookBegin();                                           /* Call port specific initialization code
             -   */
 379   1      #endif
 380   1      
 381   1          OS_InitMisc();                                               /* Initialize miscellaneous variables    
             -   */
 382   1      
 383   1          OS_InitRdyList();                                            /* Initialize the Ready List             
             -   */
 384   1      
 385   1          OS_InitTCBList();                                            /* Initialize the free list of OS_TCBs   
             -   */
 386   1      
 387   1          OS_InitEventList();                                          /* Initialize the free list of OS_EVENTs 
             -   */
 388   1      
 389   1      #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
 390   1          OS_FlagInit();                                               /* Initialize the event flag structures  
             -   */
 391   1      #endif
 392   1      
 393   1      #if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0)
 394   1          OS_MemInit();                                                /* Initialize the memory manager         
             -   */
 395   1      #endif
 396   1      
 397   1      #if (OS_Q_EN > 0) && (OS_MAX_QS > 0)
 398   1          OS_QInit();                                                  /* Initialize the message queue structure
             -s  */
 399   1      #endif
 400   1      
 401   1          OS_InitTaskIdle();                                           /* Create the Idle Task                  
             -   */
 402   1      #if OS_TASK_STAT_EN > 0
                  OS_InitTaskStat();                                           /* Create the Statistic Task             
             -   */
              #endif
 405   1      
 406   1      #if OS_VERSION >= 204
 407   1          OSInitHookEnd();                                             /* Call port specific init. code         
             -   */
 408   1      #endif
 409   1      }
 410          /*$PAGE*/
 411          /*
 412          *********************************************************************************************************
 413          *                                              ENTER ISR
 414          *
 415          * Description: This function is used to notify uC/OS-II that you are about to service an interrupt
C51 COMPILER V7.06   OS_CORE                                                               07/18/2003 11:05:56 PAGE 8   

 416          *              service routine (ISR).  This allows uC/OS-II to keep track of interrupt nesting and thus
 417          *              only perform rescheduling at the last nested ISR.
 418          *
 419          * Arguments  : none
 420          *
 421          * Returns    : none
 422          *
 423          * Notes      : 1) This function should be called ith interrupts already disabled
 424          *              2) Your ISR can directly increment OSIntNesting without calling this function because
 425          *                 OSIntNesting has been declared 'global'.  
 426          *              3) You MUST still call OSIntExit() even though you increment OSIntNesting directly.
 427          *              4) You MUST invoke OSIntEnter() and OSIntExit() in pair.  In other words, for every call
 428          *                 to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
 429          *                 end of the ISR.
 430          *              5) You are allowed to nest interrupts up to 255 levels deep.
 431          *              6) I removed the OS_ENTER_CRITICAL() and OS_EXIT_CRITICAL() around the increment because
 432          *                 OSIntEnter() is always called with interrupts disabled.
 433          *********************************************************************************************************
 434          */
 435          

⌨️ 快捷键说明

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