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

📄 os_mutex.lst

📁 IAR project for MSP430 and uC/OS. All configured to start filling with tasks.
💻 LST
📖 第 1 页 / 共 5 页
字号:
   \   0150  8C430000          MOV     #0,OSTCBPrioTbl(R12)    
    240                           pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
   \   0154  CB430000          MOV.B   #0,0(R11)       
    241                           pevent->OSEventPtr  = OSEventFreeList;    /* Return Event Control Block to free list  */
   \   0158  9B420000          MOV     &OSEventFreeList,4(R11) 
   \   015C  0400
    242                           OSEventFreeList     = pevent;
   \   015E  824B0000          MOV     R11,&OSEventFreeList    
    243                           OS_EXIT_CRITICAL();
   \   0162  32D2              EINT            
    244                           *err = OS_NO_ERR;
   \   0164  C8430000          MOV.B   #0,0(R8)        
    245                           return ((OS_EVENT *)0);                   /* Mutex has been deleted                   */
   \   0168  0C43              MOV     #0,R12  
    246                       } else {
   \   016A  2C3C              JMP     (?0094) 
   \   016C            ?0086:
    247                           OS_EXIT_CRITICAL();
   \   016C  32D2              EINT            
    248                           *err = OS_ERR_TASK_WAITING;
   \   016E  F8420000          MOV.B   #8,0(R8)        
    249                           return (pevent);
   \   0172  0C4B              MOV     R11,R12 
    250                       }
   \   0174  273C              JMP     (?0094) 
   \   0176            ?0087:
    251          
    252                  case OS_DEL_ALWAYS:                                /* Always delete the mutex                  */
    253                       while (pevent->OSEventGrp != 0x00) {          /* Ready ALL tasks waiting for mutex        */
   \   0176  CB930100          CMP.B   #0,1(R11)       
   \   017A  0824              JEQ     (?0088) 
    254                           OS_EventTaskRdy(pevent, (void *)0, OS_STAT_MUTEX);
   \   017C  70121000          PUSH.B  #16     
   \   0180  0E43              MOV     #0,R14  
   \   0182  0C4B              MOV     R11,R12 
   \   0184  B0120000          CALL    #OS_EventTaskRdy        
   \   0188  2153              ADD     #2,SP   
   \   018A  F53F              JMP     (?0087) 
   \   018C            ?0088:
    255                       }
    256                       pip                 = (INT8U)(pevent->OSEventCnt >> 8);
   \   018C  1C4B0200          MOV     2(R11),R12      
   \   0190  8C10              SWPB    R12     
   \   0192  7CF3              AND.B   #-1,R12 
    257                       OSTCBPrioTbl[pip]   = (OS_TCB *)0;            /* Free up the PIP                          */
   \   0194  0C5C              ADD     R12,R12 
   \   0196  8C430000          MOV     #0,OSTCBPrioTbl(R12)    
    258                       pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
   \   019A  CB430000          MOV.B   #0,0(R11)       
    259                       pevent->OSEventPtr  = OSEventFreeList;        /* Return Event Control Block to free list  */
   \   019E  9B420000          MOV     &OSEventFreeList,4(R11) 
   \   01A2  0400
    260                       OSEventFreeList     = pevent;                 /* Get next free event control block        */
   \   01A4  824B0000          MOV     R11,&OSEventFreeList    
    261                       OS_EXIT_CRITICAL();
   \   01A8  32D2              EINT            
    262                       if (tasks_waiting == TRUE) {                  /* Reschedule only if task(s) were waiting  */
   \   01AA  5A93              CMP.B   #1,R10  
   \   01AC  0220              JNE     (?0092) 
    263                           OS_Sched();                               /* Find highest priority task ready to run  */
   \   01AE  B0120000          CALL    #OS_Sched       
   \   01B2            ?0092:
    264                       }
    265                       *err = OS_NO_ERR;
   \   01B2  C8430000          MOV.B   #0,0(R8)        
    266                       return ((OS_EVENT *)0);                       /* Mutex has been deleted                   */
   \   01B6  0C43              MOV     #0,R12  
    267          
    268                  default:
   \   01B8  053C              JMP     (?0094) 
   \   01BA            ?0093:
    269                       OS_EXIT_CRITICAL();
   \   01BA  32D2              EINT            
    270                       *err = OS_ERR_INVALID_OPT;
   \   01BC  F8400700          MOV.B   #7,0(R8)        
   \   01C0  0000
    271                       return (pevent);
   \   01C2  0C4B              MOV     R11,R12 
    272              }
   \   01C4            ?0094:
   \   01C4  3841              POP     R8      
   \   01C6  3B41              POP     R11     
   \   01C8  3A41              POP     R10     
   \   01CA  3041              RET             
   \   01CC            ?0083:
    273          }
   \   01CC            OSMutexPend:
    274          #endif
    275          
    276          /*$PAGE*/
    277          /*
    278          *********************************************************************************************************
    279          *                                  PEND ON MUTUAL EXCLUSION SEMAPHORE
    280          *
    281          * Description: This function waits for a mutual exclusion semaphore.
    282          *
    283          * Arguments  : pevent        is a pointer to the event control block associated with the desired
    284          *                            mutex.
    285          *
    286          *              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
    287          *                            wait for the resource up to the amount of time specified by this argument.
    288          *                            If you specify 0, however, your task will wait forever at the specified
    289          *                            mutex or, until the resource becomes available.
    290          *
    291          *              err           is a pointer to where an error message will be deposited.  Possible error
    292          *                            messages are:
    293          *                               OS_NO_ERR          The call was successful and your task owns the mutex
    294          *                               OS_TIMEOUT         The mutex was not available within the specified time.
    295          *                               OS_ERR_EVENT_TYPE  If you didn't pass a pointer to a mutex
    296          *                               OS_ERR_PEVENT_NULL 'pevent' is a NULL pointer
    297          *                               OS_ERR_PEND_ISR    If you called this function from an ISR and the result
    298          *                                                  would lead to a suspension.
    299          *
    300          * Returns    : none
    301          *
    302          * Note(s)    : 1) The task that owns the Mutex MUST NOT pend on any other event while it owns the mutex.
    303          *              2) You MUST NOT change the priority of the task that owns the mutex
    304          *********************************************************************************************************
    305          */
    306          void  OSMutexPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
    307          {
   \   01CC  0A12              PUSH    R10     
   \   01CE  0B12              PUSH    R11     
   \   01D0  0812              PUSH    R8      
   \   01D2  0A4C              MOV     R12,R10 
   \   01D4  1B410800          MOV     8(SP),R11       
    308          #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    309              OS_CPU_SR  cpu_sr;
    310          #endif    
    311              INT8U      pip;                                        /* Priority Inheritance Priority (PIP)      */
    312              INT8U      mprio;                                      /* Mutex owner priority                     */
    313              BOOLEAN    rdy;                                        /* Flag indicating task was ready           */
    314              OS_TCB    *ptcb;
    315          
    316          
    317              if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
   \   01D8  C2930000          CMP.B   #0,&OSIntNesting        
   \   01DC  0324              JEQ     (?0096) 
    318                  *err = OS_ERR_PEND_ISR;                            /* ... can't PEND from an ISR               */
   \   01DE  EB430000          MOV.B   #2,0(R11)       
    319                  return;
    320              }
   \   01E2  963C              JMP     (?0116) 
   \   01E4            ?0096:
    321          #if OS_ARG_CHK_EN > 0
    322              if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
   \   01E4  0A93              CMP     #0,R10  
   \   01E6  0320              JNE     (?0098) 
    323                  *err = OS_ERR_PEVENT_NULL;
   \   01E8  EB420000          MOV.B   #4,0(R11)       
    324                  return;
    325              }
   \   01EC  913C              JMP     (?0116) 
   \   01EE            ?0098:
    326              if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) {      /* Validate event block type                */
   \   01EE  6C42              MOV.B   #4,R12  
   \   01F0  6C9A              CMP.B   @R10,R12        
   \   01F2  0324              JEQ     (?0100) 
    327                  *err = OS_ERR_EVENT_TYPE;
   \   01F4  DB430000          MOV.B   #1,0(R11)       
    328                  return;
    329              }
   \   01F8  8B3C              JMP     (?0116) 
   \   01FA            ?0100:
    330          #endif
    331              OS_ENTER_CRITICAL();                                                                   /* Is Mutex available?                      */
   \   01FA  32C2              DINT            
    332              if ((INT8U)(pevent->OSEventCnt & OS_MUTEX_KEEP_LOWER_8) == OS_MUTEX_AVAILABLE) {
   \   01FC  1C4A0200          MOV     2(R10),R12      
   \   0200  7CF3              AND.B   #255,R12        
   \   0202  7C93              CMP.B   #255,R12        
   \   0204  1020              JNE     (?0102) 
    333                  pevent->OSEventCnt &= OS_MUTEX_KEEP_UPPER_8;       /* Yes, Acquire the resource                */
   \   0206  BAF000FF          AND     #65280,2(R10)   
   \   020A  0200
    334                  pevent->OSEventCnt |= OSTCBCur->OSTCBPrio;         /*      Save priority of owning task        */
   \   020C  1C420000          MOV     &OSTCBCur,R12   
   \   0210  5C4C1D00          MOV.B   29(R12),R12     
   \   0214  8ADC0200          BIS     R12,2(R10)      
    335                  pevent->OSEventPtr  = (void *)OSTCBCur;            /*      Point to owning task's OS_TCB       */
   \   0218  9A420000          MOV     &OSTCBCur,4(R10)        
   \   021C  0400
    336                  OS_EXIT_CRITICAL();
   \   021E  32D2              EINT            
    337                  *err  = OS_NO_ERR;
   \   0220  CB430000          MOV.B   #0,0(R11)       
    338                  return;
    339              }
   \   0224  753C              JMP     (?0116) 
   \   0226            ?0102:
    340              pip   = (INT8U)(pevent->OSEventCnt >> 8);                     /* No, Get PIP from mutex            */
   \   0226  1C4A0200          MOV     2(R10),R12      
   \   022A  8C10              SWPB    R12     
   \   022C  7CF3              AND.B   #-1,R12 
    341              mprio = (INT8U)(pevent->OSEventCnt & OS_MUTEX_KEEP_LOWER_8);  /*     Get priority of mutex owner   */
   \   022E  1F4A0200          MOV     2(R10),R15      
   \   0232  7FF3              AND.B   #255,R15        
    342              ptcb  = (OS_TCB *)(pevent->OSEventPtr);                       /*     Point to TCB of mutex owner   */
   \   0234  1D4A0400          MOV     4(R10),R13      
    343              if (ptcb->OSTCBPrio != pip && mprio > OSTCBCur->OSTCBPrio) {  /*     Need to promote prio of owner?*/
   \   0238  5C9D1D00          CMP.B   29(R13),R12     
   \   023C  4424              JEQ     (?0104) 
   \   023E  18420000          MOV     &OSTCBCur,R8    
   \   0242  C89F1D00          CMP.B   R15,29(R8)      
   \   0246  3F2C              JC      (?0104) 
    344                  if ((OSRdyTbl[ptcb->OSTCBY] & ptcb->OSTCBBitX) != 0x00) { /*     See if mutex owner is ready   */
   \   0248  5F4D1F00          MOV.B   31(R13),R15     
   \   024C  DDBF0000          BIT.B   OSRdyTbl(R15),32(R13)   
   \   0250  2000
   \   0252  1124              JEQ     (?0108) 
    345                                                                            /*     Yes, Remove owner from Rdy ...*/
    346                                                                            /*          ... list at current prio */
    347                      if ((OSRdyTbl[ptcb->OSTCBY] &= ~ptcb->OSTCBBitX) == 0x00) {
   \   0254  5F4D1F00          MOV.B   31(R13),R15     
   \   0258  584D2000          MOV.B   32(R13),R8      
   \   025C  78E3              XOR.B   #-1,R8  
   \   025E  CFF80000          AND.B   R8,OSRdyTbl(R15)        
   \   0262  CF930000          CMP.B   #0,OSRdyTbl(R15)        
   \   0266  0520              JNE     (?0110) 
    348                          OSRdyGrp &= ~ptcb->OSTCBBitY;
   \   0268  5F4D2100          MOV.B   33(R13),R15     

⌨️ 快捷键说明

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