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

📄 os_sem.lst

📁 ARM仿真案例
💻 LST
📖 第 1 页 / 共 4 页
字号:
##############################################################################
#                                                                            #
# IAR ARM ANSI C/C++ Compiler V4.40A/W32 EVALUATION    21/Jul/2006  16:23:28 #
# Copyright 1999-2005 IAR Systems. All rights reserved.                      #
# Time limited license: 22 days left                                         #
#                                                                            #
#    Cpu mode        =  interwork                                            #
#    Endian          =  little                                               #
#    Stack alignment =  4                                                    #
#    Source file     =  E:\Project\ucos-ii\leddisp\uCOS-II\os_sem.c          #
#    Command line    =  E:\Project\ucos-ii\leddisp\uCOS-II\os_sem.c -lCN     #
#                       E:\Project\ucos-ii\leddisp\Debug\List\ -lA           #
#                       E:\Project\ucos-ii\leddisp\Debug\List\ -o            #
#                       E:\Project\ucos-ii\leddisp\Debug\Obj\ -s9 --no_cse   #
#                       --no_unroll --no_inline --no_code_motion --no_tbaa   #
#                       --no_clustering --no_scheduling --debug --cpu_mode   #
#                       thumb --endian little --cpu ARM7TDMI-S               #
#                       --stack_align 4 --interwork -e --fpu None            #
#                       --dlib_config "e:\Program Files\IAR                  #
#                       Systems\Embedded Workbench 4.0                       #
#                       Evaluation\ARM\LIB\dl4tptinl8n.h" -I                 #
#                       E:\Project\ucos-ii\leddisp\ -I                       #
#                       E:\Project\ucos-ii\leddisp\App\ -I                   #
#                       E:\Project\ucos-ii\leddisp\ARM\ -I                   #
#                       E:\Project\ucos-ii\leddisp\BSP\ -I                   #
#                       E:\Project\ucos-ii\leddisp\uCOS-II\ -I "e:\Program   #
#                       Files\IAR Systems\Embedded Workbench 4.0             #
#                       Evaluation\ARM\INC\"                                 #
#    List file       =  E:\Project\ucos-ii\leddisp\Debug\List\os_sem.lst     #
#    Object file     =  E:\Project\ucos-ii\leddisp\Debug\Obj\os_sem.r79      #
#                                                                            #
#                                                                            #
##############################################################################

E:\Project\ucos-ii\leddisp\uCOS-II\os_sem.c
      1          /*
      2          *********************************************************************************************************
      3          *                                                uC/OS-II
      4          *                                          The Real-Time Kernel
      5          *                                          SEMAPHORE MANAGEMENT
      6          *
      7          *                          (c) Copyright 1992-2003, Jean J. Labrosse, Weston, FL
      8          *                                           All Rights Reserved
      9          *
     10          * File : OS_SEM.C
     11          * By   : Jean J. Labrosse
     12          *********************************************************************************************************
     13          */
     14          
     15          #ifndef  OS_MASTER_FILE
     16          #include <ucos_ii.h>
     17          #endif
     18          
     19          #if OS_SEM_EN > 0
     20          /*
     21          *********************************************************************************************************
     22          *                                           ACCEPT SEMAPHORE
     23          *
     24          * Description: This function checks the semaphore to see if a resource is available or, if an event
     25          *              occurred.  Unlike OSSemPend(), OSSemAccept() does not suspend the calling task if the
     26          *              resource is not available or the event did not occur.
     27          *
     28          * Arguments  : pevent     is a pointer to the event control block
     29          *
     30          * Returns    : >  0       if the resource is available or the event did not occur the semaphore is
     31          *                         decremented to obtain the resource.
     32          *              == 0       if the resource is not available or the event did not occur or,
     33          *                         if 'pevent' is a NULL pointer or,
     34          *                         if you didn't pass a pointer to a semaphore
     35          *********************************************************************************************************
     36          */
     37          
     38          #if OS_SEM_ACCEPT_EN > 0

   \                                 In segment CODE, align 4, keep-with-next
     39          INT16U  OSSemAccept (OS_EVENT *pevent)
     40          {
   \                     OSSemAccept:
   \   00000000   30B5               PUSH     {R4,R5,LR}
   \   00000002   0400               MOVS     R4,R0
     41          #if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
     42              OS_CPU_SR  cpu_sr;
     43          #endif    
     44              INT16U     cnt;
     45          
     46          
     47          #if OS_ARG_CHK_EN > 0
     48              if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
   \   00000004   01D1               BNE      ??OSSemAccept_0
     49                  return (0);
   \                     ??OSSemAccept_1:
   \   00000006   0020               MOVS     R0,#+0
   \   00000008   0CE0               B        ??OSSemAccept_2
     50              }
     51          #endif
     52              if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
   \                     ??OSSemAccept_0:
   \   0000000A   2078               LDRB     R0,[R4, #+0]
   \   0000000C   0328               CMP      R0,#+3
   \   0000000E   FAD1               BNE      ??OSSemAccept_1
     53                  return (0);
     54              }
     55              OS_ENTER_CRITICAL();
   \   00000010   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
     56              cnt = pevent->OSEventCnt;
   \   00000014   6588               LDRH     R5,[R4, #+2]
     57              if (cnt > 0) {                                    /* See if resource is available                  */
   \   00000016   2900               MOVS     R1,R5
   \   00000018   01D0               BEQ      ??OSSemAccept_3
     58                  pevent->OSEventCnt--;                         /* Yes, decrement semaphore and notify caller    */
   \   0000001A   691E               SUBS     R1,R5,#+1
   \   0000001C   6180               STRH     R1,[R4, #+2]
     59              }
     60              OS_EXIT_CRITICAL();
   \                     ??OSSemAccept_3:
   \   0000001E   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
     61              return (cnt);                                     /* Return semaphore count                        */
   \   00000022   2800               MOVS     R0,R5
   \                     ??OSSemAccept_2:
   \   00000024   30BC               POP      {R4,R5}
   \   00000026   02BC               POP      {R1}
   \   00000028   0847               BX       R1               ;; return
     62          }
     63          #endif    
     64          
     65          /*$PAGE*/
     66          /*
     67          *********************************************************************************************************
     68          *                                           CREATE A SEMAPHORE
     69          *
     70          * Description: This function creates a semaphore.
     71          *
     72          * Arguments  : cnt           is the initial value for the semaphore.  If the value is 0, no resource is
     73          *                            available (or no event has occurred).  You initialize the semaphore to a
     74          *                            non-zero value to specify how many resources are available (e.g. if you have
     75          *                            10 resources, you would initialize the semaphore to 10).
     76          *
     77          * Returns    : != (void *)0  is a pointer to the event control clock (OS_EVENT) associated with the
     78          *                            created semaphore
     79          *              == (void *)0  if no event control blocks were available
     80          *********************************************************************************************************
     81          */
     82          

   \                                 In segment CODE, align 4, keep-with-next
     83          OS_EVENT  *OSSemCreate (INT16U cnt)
     84          {
   \                     OSSemCreate:
   \   00000000   30B5               PUSH     {R4,R5,LR}
   \   00000002   0400               MOVS     R4,R0
     85          #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
     86              OS_CPU_SR  cpu_sr;
     87          #endif    
     88              OS_EVENT  *pevent;
     89          
     90          
     91              if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
   \   00000004   ....               LDR      R0,??DataTable7  ;; OSIntNesting
   \   00000006   0078               LDRB     R0,[R0, #+0]
   \   00000008   0028               CMP      R0,#+0
   \   0000000A   01D0               BEQ      ??OSSemCreate_0
     92                  return ((OS_EVENT *)0);                            /* ... can't CREATE from an ISR             */
   \   0000000C   0020               MOVS     R0,#+0
   \   0000000E   18E0               B        ??OSSemCreate_1
     93              }
     94              OS_ENTER_CRITICAL();
   \                     ??OSSemCreate_0:
   \   00000010   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
     95              pevent = OSEventFreeList;                              /* Get next free event control block        */
   \   00000014   ....               LDR      R1,??DataTable6  ;; OSEventFreeList
   \   00000016   0D68               LDR      R5,[R1, #+0]
     96              if (OSEventFreeList != (OS_EVENT *)0) {                /* See if pool of free ECB pool was empty   */
   \   00000018   002D               CMP      R5,#+0
   \   0000001A   01D0               BEQ      ??OSSemCreate_2
     97                  OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
   \   0000001C   6A68               LDR      R2,[R5, #+4]
   \   0000001E   0A60               STR      R2,[R1, #+0]
     98              }
     99              OS_EXIT_CRITICAL();
   \                     ??OSSemCreate_2:
   \   00000020   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    100              if (pevent != (OS_EVENT *)0) {                         /* Get an event control block               */
   \   00000024   002D               CMP      R5,#+0
   \   00000026   0BD0               BEQ      ??OSSemCreate_3
    101                  pevent->OSEventType    = OS_EVENT_TYPE_SEM;
   \   00000028   0320               MOVS     R0,#+3
   \   0000002A   2870               STRB     R0,[R5, #+0]
    102                  pevent->OSEventCnt     = cnt;                      /* Set semaphore value                      */
   \   0000002C   6C80               STRH     R4,[R5, #+2]
    103                  pevent->OSEventPtr     = (void *)0;                /* Unlink from ECB free list                */
   \   0000002E   0020               MOVS     R0,#+0
   \   00000030   6860               STR      R0,[R5, #+4]
    104          #if OS_EVENT_NAME_SIZE > 1
    105                  pevent->OSEventName[0] = '?';                      /* Unknown name                             */
   \   00000032   3F20               MOVS     R0,#+63
   \   00000034   2874               STRB     R0,[R5, #+16]
    106                  pevent->OSEventName[1] = OS_ASCII_NUL;
   \   00000036   0020               MOVS     R0,#+0
   \   00000038   6874               STRB     R0,[R5, #+17]
    107          #endif
    108                  OS_EventWaitListInit(pevent);                      /* Initialize to 'nobody waiting' on sem.   */
   \   0000003A   2800               MOVS     R0,R5
   \   0000003C   ........           _BLF     OS_EventWaitListInit,??OS_EventWaitListInit??rT
    109              }
    110              return (pevent);
   \                     ??OSSemCreate_3:
   \   00000040   2800               MOVS     R0,R5
   \                     ??OSSemCreate_1:
   \   00000042   30BC               POP      {R4,R5}
   \   00000044   02BC               POP      {R1}
   \   00000046   0847               BX       R1               ;; return
    111          }
    112          
    113          /*$PAGE*/
    114          /*
    115          *********************************************************************************************************
    116          *                                         DELETE A SEMAPHORE

⌨️ 快捷键说明

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