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

📄 os_mutex.lst

📁 ARM仿真案例
💻 LST
📖 第 1 页 / 共 5 页
字号:
##############################################################################
#                                                                            #
# IAR ARM ANSI C/C++ Compiler V4.40A/W32 EVALUATION    21/Jul/2006  17:17:42 #
# 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\counter\uCOS-II\os_mutex.c        #
#    Command line    =  E:\Project\ucos-ii\counter\uCOS-II\os_mutex.c -lCN   #
#                       E:\Project\ucos-ii\counter\Debug\List\ -lA           #
#                       E:\Project\ucos-ii\counter\Debug\List\ -o            #
#                       E:\Project\ucos-ii\counter\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\counter\ -I                       #
#                       E:\Project\ucos-ii\counter\App\ -I                   #
#                       E:\Project\ucos-ii\counter\BSP\ -I                   #
#                       E:\Project\ucos-ii\counter\ARM\ -I                   #
#                       E:\Project\ucos-ii\counter\uCOS-II\ -I "E:\Program   #
#                       Files\IAR Systems\Embedded Workbench 4.0             #
#                       Evaluation\ARM\INC\"                                 #
#    List file       =  E:\Project\ucos-ii\counter\Debug\List\os_mutex.lst   #
#    Object file     =  E:\Project\ucos-ii\counter\Debug\Obj\os_mutex.r79    #
#                                                                            #
#                                                                            #
##############################################################################

E:\Project\ucos-ii\counter\uCOS-II\os_mutex.c
      1          /*
      2          *********************************************************************************************************
      3          *                                                uC/OS-II
      4          *                                          The Real-Time Kernel
      5          *                                  MUTUAL EXCLUSION SEMAPHORE MANAGEMENT
      6          *
      7          *                          (c) Copyright 1992-2003, Jean J. Labrosse, Weston, FL
      8          *                                           All Rights Reserved
      9          *
     10          * File : OS_MUTEX.C
     11          * By   : Jean J. Labrosse
     12          *********************************************************************************************************
     13          */
     14          
     15          #ifndef  OS_MASTER_FILE
     16          #include <ucos_ii.h>
     17          #endif
     18          
     19          /*
     20          *********************************************************************************************************
     21          *                                            LOCAL CONSTANTS
     22          *********************************************************************************************************
     23          */
     24          
     25          #define  OS_MUTEX_KEEP_LOWER_8   0x00FF
     26          #define  OS_MUTEX_KEEP_UPPER_8   0xFF00
     27          
     28          #define  OS_MUTEX_AVAILABLE      0x00FF
     29          
     30          
     31          #if OS_MUTEX_EN > 0
     32          /*
     33          *********************************************************************************************************
     34          *                                   ACCEPT MUTUAL EXCLUSION SEMAPHORE
     35          *
     36          * Description: This  function checks the mutual exclusion semaphore to see if a resource is available.
     37          *              Unlike OSMutexPend(), OSMutexAccept() does not suspend the calling task if the resource is
     38          *              not available or the event did not occur.
     39          *
     40          * Arguments  : pevent     is a pointer to the event control block
     41          *
     42          *              err        is a pointer to an error code which will be returned to your application:
     43          *                            OS_NO_ERR          if the call was successful.
     44          *                            OS_ERR_EVENT_TYPE  if 'pevent' is not a pointer to a mutex
     45          *                            OS_ERR_PEVENT_NULL 'pevent' is a NULL pointer
     46          *                            OS_ERR_PEND_ISR     if you called this function from an ISR
     47          *
     48          * Returns    : == 1       if the resource is available, the mutual exclusion semaphore is acquired
     49          *              == 0       a) if the resource is not available
     50          *                         b) you didn't pass a pointer to a mutual exclusion semaphore
     51          *                         c) you called this function from an ISR
     52          *
     53          * Warning(s) : This function CANNOT be called from an ISR because mutual exclusion semaphores are
     54          *              intended to be used by tasks only.
     55          *********************************************************************************************************
     56          */
     57          
     58          #if OS_MUTEX_ACCEPT_EN > 0

   \                                 In segment CODE, align 4, keep-with-next
     59          INT8U  OSMutexAccept (OS_EVENT *pevent, INT8U *err)
     60          {
   \                     OSMutexAccept:
   \   00000000   30B5               PUSH     {R4,R5,LR}
   \   00000002   0500               MOVS     R5,R0
   \   00000004   0C00               MOVS     R4,R1
     61          #if OS_CRITICAL_METHOD == 3                            /* Allocate storage for CPU status register     */
     62              OS_CPU_SR  cpu_sr;
     63          #endif    
     64              
     65              
     66              if (OSIntNesting > 0) {                            /* Make sure it's not called from an ISR        */
   \   00000006   ....               LDR      R0,??DataTable6  ;; OSIntNesting
   \   00000008   0078               LDRB     R0,[R0, #+0]
   \   0000000A   0028               CMP      R0,#+0
   \   0000000C   03D0               BEQ      ??OSMutexAccept_0
     67                  *err = OS_ERR_PEND_ISR;
   \   0000000E   0220               MOVS     R0,#+2
   \                     ??OSMutexAccept_1:
   \   00000010   2070               STRB     R0,[R4, #+0]
     68                  return (0);
   \   00000012   0020               MOVS     R0,#+0
   \   00000014   2AE0               B        ??OSMutexAccept_2
     69              }
     70          #if OS_ARG_CHK_EN > 0
     71              if (pevent == (OS_EVENT *)0) {                     /* Validate 'pevent'                            */
   \                     ??OSMutexAccept_0:
   \   00000016   002D               CMP      R5,#+0
   \   00000018   01D1               BNE      ??OSMutexAccept_3
     72                  *err = OS_ERR_PEVENT_NULL;
   \   0000001A   0420               MOVS     R0,#+4
   \   0000001C   F8E7               B.N      ??OSMutexAccept_1
     73                  return (0);
     74              }
     75          #endif                                                     
     76              if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) {  /* Validate event block type                    */
   \                     ??OSMutexAccept_3:
   \   0000001E   2878               LDRB     R0,[R5, #+0]
   \   00000020   0428               CMP      R0,#+4
   \   00000022   03D0               BEQ      ??OSMutexAccept_4
     77                  *err = OS_ERR_EVENT_TYPE;
   \   00000024   0120               MOVS     R0,#+1
   \   00000026   2070               STRB     R0,[R4, #+0]
     78                  return (0);
   \   00000028   0020               MOVS     R0,#+0
   \   0000002A   1FE0               B        ??OSMutexAccept_2
     79              }
     80              OS_ENTER_CRITICAL();							   /* Get value (0 or 1) of Mutex                  */
   \                     ??OSMutexAccept_4:
   \   0000002C   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
     81              if ((pevent->OSEventCnt & OS_MUTEX_KEEP_LOWER_8) == OS_MUTEX_AVAILABLE) {     
   \   00000030   6988               LDRH     R1,[R5, #+2]
   \   00000032   0906               LSLS     R1,R1,#+24
   \   00000034   090E               LSRS     R1,R1,#+24
   \   00000036   FF29               CMP      R1,#+255
   \   00000038   14D1               BNE      ??OSMutexAccept_5
     82                  pevent->OSEventCnt &= OS_MUTEX_KEEP_UPPER_8;   /*      Mask off LSByte (Acquire Mutex)         */
   \   0000003A   6988               LDRH     R1,[R5, #+2]
   \   0000003C   FF22               MOVS     R2,#+255
   \   0000003E   1202               LSLS     R2,R2,#+8        ;; #+65280
   \   00000040   0A40               ANDS     R2,R2,R1
   \   00000042   6A80               STRH     R2,[R5, #+2]
     83                  pevent->OSEventCnt |= OSTCBCur->OSTCBPrio;     /*      Save current task priority in LSByte    */
   \   00000044   1100               MOVS     R1,R2
   \   00000046   ....               LDR      R2,??DataTable2  ;; OSTCBCur
   \   00000048   1268               LDR      R2,[R2, #+0]
   \   0000004A   2D32               ADDS     R2,R2,#+45
   \   0000004C   1278               LDRB     R2,[R2, #+0]
   \   0000004E   0A43               ORRS     R2,R2,R1
   \   00000050   6A80               STRH     R2,[R5, #+2]
     84                  pevent->OSEventPtr  = (void *)OSTCBCur;        /*      Link TCB of task owning Mutex           */
   \   00000052   ....               LDR      R1,??DataTable2  ;; OSTCBCur
   \   00000054   0968               LDR      R1,[R1, #+0]
   \   00000056   6960               STR      R1,[R5, #+4]
     85                  OS_EXIT_CRITICAL();
   \   00000058   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
     86                  *err = OS_NO_ERR;
   \   0000005C   0020               MOVS     R0,#+0
   \   0000005E   2070               STRB     R0,[R4, #+0]
     87                  return (1);
   \   00000060   0120               MOVS     R0,#+1
   \   00000062   03E0               B        ??OSMutexAccept_2
     88              }
     89              OS_EXIT_CRITICAL();
   \                     ??OSMutexAccept_5:
   \   00000064   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
     90              *err = OS_NO_ERR;
   \   00000068   0020               MOVS     R0,#+0
   \   0000006A   2070               STRB     R0,[R4, #+0]
     91              return (0);
   \                     ??OSMutexAccept_2:
   \   0000006C   30BC               POP      {R4,R5}
   \   0000006E   02BC               POP      {R1}
   \   00000070   0847               BX       R1               ;; return
     92          }
     93          #endif                                                     
     94          
     95          /*$PAGE*/
     96          /*
     97          *********************************************************************************************************
     98          *                                  CREATE A MUTUAL EXCLUSION SEMAPHORE
     99          *
    100          * Description: This function creates a mutual exclusion semaphore.
    101          *
    102          * Arguments  : prio          is the priority to use when accessing the mutual exclusion semaphore.  In
    103          *                            other words, when the semaphore is acquired and a higher priority task
    104          *                            attempts to obtain the semaphore then the priority of the task owning the
    105          *                            semaphore is raised to this priority.  It is assumed that you will specify
    106          *                            a priority that is LOWER in value than ANY of the tasks competing for the

⌨️ 快捷键说明

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