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

📄 os_mutex.lst

📁 ARM仿真案例
💻 LST
📖 第 1 页 / 共 5 页
字号:
   \   00000100   2000               MOVS     R0,R4
   \                     ??OSMutexDel_1:
   \   00000102   01B0               ADD      SP,SP,#+4
   \   00000104   F0BC               POP      {R4-R7}
   \   00000106   02BC               POP      {R1}
   \   00000108   0847               BX       R1               ;; return
    286              }
    287          }
    288          #endif
    289          
    290          /*$PAGE*/
    291          /*
    292          *********************************************************************************************************
    293          *                                  PEND ON MUTUAL EXCLUSION SEMAPHORE
    294          *
    295          * Description: This function waits for a mutual exclusion semaphore.
    296          *
    297          * Arguments  : pevent        is a pointer to the event control block associated with the desired
    298          *                            mutex.
    299          *
    300          *              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
    301          *                            wait for the resource up to the amount of time specified by this argument.
    302          *                            If you specify 0, however, your task will wait forever at the specified
    303          *                            mutex or, until the resource becomes available.
    304          *
    305          *              err           is a pointer to where an error message will be deposited.  Possible error
    306          *                            messages are:
    307          *                               OS_NO_ERR          The call was successful and your task owns the mutex
    308          *                               OS_TIMEOUT         The mutex was not available within the specified time.
    309          *                               OS_ERR_EVENT_TYPE  If you didn't pass a pointer to a mutex
    310          *                               OS_ERR_PEVENT_NULL 'pevent' is a NULL pointer
    311          *                               OS_ERR_PEND_ISR    If you called this function from an ISR and the result
    312          *                                                  would lead to a suspension.
    313          *
    314          * Returns    : none
    315          *
    316          * Note(s)    : 1) The task that owns the Mutex MUST NOT pend on any other event while it owns the mutex.
    317          *              2) You MUST NOT change the priority of the task that owns the mutex
    318          *********************************************************************************************************
    319          */

   \                                 In segment CODE, align 4, keep-with-next
    320          void  OSMutexPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
    321          {
   \                     OSMutexPend:
   \   00000000   F2B5               PUSH     {R1,R4-R7,LR}
   \   00000002   0400               MOVS     R4,R0
   \   00000004   1500               MOVS     R5,R2
    322          #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    323              OS_CPU_SR  cpu_sr;
    324          #endif    
    325              INT8U      pip;                                        /* Priority Inheritance Priority (PIP)      */
    326              INT8U      mprio;                                      /* Mutex owner priority                     */
    327              BOOLEAN    rdy;                                        /* Flag indicating task was ready           */
    328              OS_TCB    *ptcb;
    329              OS_EVENT  *pevent2;
    330              INT8U      y;
    331          
    332          
    333              if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
   \   00000006   ....               LDR      R0,??DataTable17  ;; OSIntNesting
   \   00000008   0078               LDRB     R0,[R0, #+0]
   \   0000000A   0128               CMP      R0,#+1
   \   0000000C   02D3               BCC      ??OSMutexPend_0
    334                  *err = OS_ERR_PEND_ISR;                            /* ... can't PEND from an ISR               */
   \   0000000E   0220               MOVS     R0,#+2
   \   00000010   2870               STRB     R0,[R5, #+0]
    335                  return;
   \   00000012   FAE0               B        ??OSMutexPend_1
    336              }
    337          #if OS_ARG_CHK_EN > 0
    338              if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
   \                     ??OSMutexPend_0:
   \   00000014   002C               CMP      R4,#+0
   \   00000016   02D1               BNE      ??OSMutexPend_2
    339                  *err = OS_ERR_PEVENT_NULL;
   \   00000018   0420               MOVS     R0,#+4
   \   0000001A   2870               STRB     R0,[R5, #+0]
    340                  return;
   \   0000001C   F5E0               B        ??OSMutexPend_1
    341              }
    342          #endif
    343              if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) {      /* Validate event block type                */
   \                     ??OSMutexPend_2:
   \   0000001E   2078               LDRB     R0,[R4, #+0]
   \   00000020   0428               CMP      R0,#+4
   \   00000022   02D0               BEQ      ??OSMutexPend_3
    344                  *err = OS_ERR_EVENT_TYPE;
   \   00000024   0120               MOVS     R0,#+1
   \   00000026   2870               STRB     R0,[R5, #+0]
    345                  return;
   \   00000028   EFE0               B        ??OSMutexPend_1
    346              }
    347              OS_ENTER_CRITICAL();								   /* Is Mutex available?                      */
   \                     ??OSMutexPend_3:
   \   0000002A   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
   \   0000002E   0600               MOVS     R6,R0
    348              if ((INT8U)(pevent->OSEventCnt & OS_MUTEX_KEEP_LOWER_8) == OS_MUTEX_AVAILABLE) {
   \   00000030   6088               LDRH     R0,[R4, #+2]
   \   00000032   0006               LSLS     R0,R0,#+24       ;; ZeroExtS R0,R0,#+24,#+24
   \   00000034   000E               LSRS     R0,R0,#+24
   \   00000036   FF28               CMP      R0,#+255
   \   00000038   14D1               BNE      ??OSMutexPend_4
    349                  pevent->OSEventCnt &= OS_MUTEX_KEEP_UPPER_8;       /* Yes, Acquire the resource                */
   \   0000003A   6088               LDRH     R0,[R4, #+2]
   \   0000003C   FF21               MOVS     R1,#+255
   \   0000003E   0902               LSLS     R1,R1,#+8        ;; #+65280
   \   00000040   0140               ANDS     R1,R1,R0
   \   00000042   6180               STRH     R1,[R4, #+2]
    350                  pevent->OSEventCnt |= OSTCBCur->OSTCBPrio;         /*      Save priority of owning task        */
   \   00000044   6088               LDRH     R0,[R4, #+2]
   \   00000046   ....               LDR      R1,??DataTable38  ;; OSTCBCur
   \   00000048   0968               LDR      R1,[R1, #+0]
   \   0000004A   2D31               ADDS     R1,R1,#+45
   \   0000004C   0978               LDRB     R1,[R1, #+0]
   \   0000004E   0143               ORRS     R1,R1,R0
   \   00000050   6180               STRH     R1,[R4, #+2]
    351                  pevent->OSEventPtr  = (void *)OSTCBCur;            /*      Point to owning task's OS_TCB       */
   \   00000052   ....               LDR      R0,??DataTable38  ;; OSTCBCur
   \   00000054   0068               LDR      R0,[R0, #+0]
   \   00000056   6060               STR      R0,[R4, #+4]
    352                  OS_EXIT_CRITICAL();
   \   00000058   3000               MOVS     R0,R6
   \   0000005A   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    353                  *err  = OS_NO_ERR;
   \   0000005E   0020               MOVS     R0,#+0
   \   00000060   2870               STRB     R0,[R5, #+0]
    354                  return;
   \   00000062   D2E0               B        ??OSMutexPend_1
    355              }
    356              pip   = (INT8U)(pevent->OSEventCnt >> 8);                     /* No, Get PIP from mutex            */
   \                     ??OSMutexPend_4:
   \   00000064   6088               LDRH     R0,[R4, #+2]
   \   00000066   0004               LSLS     R0,R0,#+16       ;; ZeroExtS R0,R0,#+16,#+16
   \   00000068   000C               LSRS     R0,R0,#+16
   \   0000006A   000A               LSRS     R0,R0,#+8
    357              mprio = (INT8U)(pevent->OSEventCnt & OS_MUTEX_KEEP_LOWER_8);  /*     Get priority of mutex owner   */
   \   0000006C   6288               LDRH     R2,[R4, #+2]
    358              ptcb  = (OS_TCB *)(pevent->OSEventPtr);                       /*     Point to TCB of mutex owner   */
   \   0000006E   6168               LDR      R1,[R4, #+4]
    359              if (ptcb->OSTCBPrio != pip && mprio > OSTCBCur->OSTCBPrio) {  /*     Need to promote prio of owner?*/
   \   00000070   2D23               MOVS     R3,#+45
   \   00000072   CB5C               LDRB     R3,[R1, R3]
   \   00000074   0006               LSLS     R0,R0,#+24       ;; ZeroExtS R0,R0,#+24,#+24
   \   00000076   000E               LSRS     R0,R0,#+24
   \   00000078   8342               CMP      R3,R0
   \   0000007A   ....               BNE      .+5
   \   0000007C   93E0               B        ??OSMutexPend_5
   \   0000007E   ....               LDR      R3,??DataTable38  ;; OSTCBCur
   \   00000080   1B68               LDR      R3,[R3, #+0]
   \   00000082   2D33               ADDS     R3,R3,#+45
   \   00000084   1B78               LDRB     R3,[R3, #+0]
   \   00000086   1206               LSLS     R2,R2,#+24       ;; ZeroExtS R2,R2,#+24,#+24
   \   00000088   120E               LSRS     R2,R2,#+24
   \   0000008A   9342               CMP      R3,R2
   \   0000008C   ....               BCC      .+5
   \   0000008E   8AE0               B        ??OSMutexPend_5
    360                  y = ptcb->OSTCBY;                          
   \   00000090   2F22               MOVS     R2,#+47
   \   00000092   8A5C               LDRB     R2,[R1, R2]
    361                  if ((OSRdyTbl[y] & ptcb->OSTCBBitX) != 0x00) {            /*     See if mutex owner is ready   */
   \   00000094   1206               LSLS     R2,R2,#+24       ;; ZeroExtS R2,R2,#+24,#+24
   \   00000096   120E               LSRS     R2,R2,#+24
   \   00000098   ....               LDR      R3,??DataTable46  ;; OSRdyTbl
   \   0000009A   9B5C               LDRB     R3,[R3, R2]
   \   0000009C   3027               MOVS     R7,#+48
   \   0000009E   CF5D               LDRB     R7,[R1, R7]
   \   000000A0   3B42               TST      R3,R7
   \   000000A2   19D0               BEQ      ??OSMutexPend_6
    362                      OSRdyTbl[y] &= ~ptcb->OSTCBBitX;                      /*     Yes, Remove owner from Rdy ...*/
   \   000000A4   1206               LSLS     R2,R2,#+24       ;; ZeroExtS R2,R2,#+24,#+24
   \   000000A6   120E               LSRS     R2,R2,#+24
   \   000000A8   ....               LDR      R3,??DataTable46  ;; OSRdyTbl
   \   000000AA   9C46               MOV      R12,R3
   \   000000AC   1206               LSLS     R2,R2,#+24       ;; ZeroExtS R2,R2,#+24,#+24
   \   000000AE   120E               LSRS     R2,R2,#+24
   \   000000B0   ....               LDR      R3,??DataTable46  ;; OSRdyTbl
   \   000000B2   9F5C               LDRB     R7,[R3, R2]
   \   000000B4   3023               MOVS     R3,#+48
   \   000000B6   CB5C               LDRB     R3,[R1, R3]
   \   000000B8   9F43               BICS     R7,R7,R3
   \   000000BA   6346               MOV      R3,R12
   \   000000BC   9F54               STRB     R7,[R3, R2]
    363                      if (OSRdyTbl[y] == 0x00) {                            /*          ... list at current prio */
   \   000000BE   ....               LDR      R3,??DataTable46  ;; OSRdyTbl
   \   000000C0   9A5C               LDRB     R2,[R3, R2]
   \   000000C2   002A               CMP      R2,#+0
   \   000000C4   06D1               BNE      ??OSMutexPend_7
    364                          OSRdyGrp &= ~ptcb->OSTCBBitY;
   \   000000C6   ....               LDR      R2,??DataTable60  ;; OSRdyGrp
   \   000000C8   ....               LDR      R3,??DataTable60  ;; OSRdyGrp
   \   000000CA   1B78               LDRB     R3,[R3, #+0]
   \   000000CC   3127               MOVS     R7,#+49
   \   000000CE   CF5D               LDRB     R7,[R1, R7]
   \   000000D0   BB43               BICS     R3,R3,R7
   \   000000D2   1370               STRB     R3,[R2, #+0]
    365                      }
    366                      rdy = TRUE;
   \                     ??OSMutexPend_7:
   \   000000D4   0122               MOVS     R2,#+1
   \   000000D6   17E0               B        ??OSMutexPend_8
    367                  } else {

⌨️ 快捷键说明

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