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

📄 os_sem.lst

📁 IARSOURCECODE是基于LPC2478嵌入式软件IAR EWARM V4.42的应用实例代码
💻 LST
📖 第 1 页 / 共 5 页
字号:
   \   00000024   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
    107              pevent = OSEventFreeList;                              /* Get next free event control block        */
   \   00000028   ........           LDR      R1,??DataTable9  ;; OSEventFreeList
   \   0000002C   005091E5           LDR      R5,[R1, #+0]
    108              if (OSEventFreeList != (OS_EVENT *)0) {                /* See if pool of free ECB pool was empty   */
   \   00000030   ........           LDR      R1,??DataTable9  ;; OSEventFreeList
   \   00000034   001091E5           LDR      R1,[R1, #+0]
   \   00000038   000051E3           CMP      R1,#+0
   \   0000003C   0400000A           BEQ      ??OSSemCreate_2
    109                  OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
   \   00000040   ........           LDR      R1,??DataTable9  ;; OSEventFreeList
   \   00000044   ........           LDR      R2,??DataTable9  ;; OSEventFreeList
   \   00000048   002092E5           LDR      R2,[R2, #+0]
   \   0000004C   042092E5           LDR      R2,[R2, #+4]
   \   00000050   002081E5           STR      R2,[R1, #+0]
    110              }
    111              OS_EXIT_CRITICAL();
   \                     ??OSSemCreate_2:
   \   00000054   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
    112              if (pevent != (OS_EVENT *)0) {                         /* Get an event control block               */
   \   00000058   000055E3           CMP      R5,#+0
   \   0000005C   0A00000A           BEQ      ??OSSemCreate_3
    113                  pevent->OSEventType    = OS_EVENT_TYPE_SEM;
   \   00000060   0300A0E3           MOV      R0,#+3
   \   00000064   0000C5E5           STRB     R0,[R5, #+0]
    114                  pevent->OSEventCnt     = cnt;                      /* Set semaphore value                      */
   \   00000068   B840C5E1           STRH     R4,[R5, #+8]
    115                  pevent->OSEventPtr     = (void *)0;                /* Unlink from ECB free list                */
   \   0000006C   0000A0E3           MOV      R0,#+0
   \   00000070   040085E5           STR      R0,[R5, #+4]
    116          #if OS_EVENT_NAME_SIZE > 1
    117                  pevent->OSEventName[0] = '?';                      /* Unknown name                             */
   \   00000074   3F00A0E3           MOV      R0,#+63
   \   00000078   0F00C5E5           STRB     R0,[R5, #+15]
    118                  pevent->OSEventName[1] = OS_ASCII_NUL;
   \   0000007C   0000A0E3           MOV      R0,#+0
   \   00000080   1000C5E5           STRB     R0,[R5, #+16]
    119          #endif
    120                  OS_EventWaitListInit(pevent);                      /* Initialize to 'nobody waiting' on sem.   */
   \   00000084   0500B0E1           MOVS     R0,R5
   \   00000088   ........           _BLF     OS_EventWaitListInit,??OS_EventWaitListInit??rA
    121              }
    122              return (pevent);
   \                     ??OSSemCreate_3:
   \   0000008C   0500B0E1           MOVS     R0,R5
   \                     ??OSSemCreate_1:
   \   00000090   3080BDE8           POP      {R4,R5,PC}       ;; return
    123          }
    124          
    125          /*$PAGE*/
    126          /*
    127          *********************************************************************************************************
    128          *                                         DELETE A SEMAPHORE
    129          *
    130          * Description: This function deletes a semaphore and readies all tasks pending on the semaphore.
    131          *
    132          * Arguments  : pevent        is a pointer to the event control block associated with the desired
    133          *                            semaphore.
    134          *
    135          *              opt           determines delete options as follows:
    136          *                            opt == OS_DEL_NO_PEND   Delete semaphore ONLY if no task pending
    137          *                            opt == OS_DEL_ALWAYS    Deletes the semaphore even if tasks are waiting.
    138          *                                                    In this case, all the tasks pending will be readied.
    139          *
    140          *              err           is a pointer to an error code that can contain one of the following values:
    141          *                            OS_ERR_NONE             The call was successful and the semaphore was deleted
    142          *                            OS_ERR_DEL_ISR          If you attempted to delete the semaphore from an ISR
    143          *                            OS_ERR_INVALID_OPT      An invalid option was specified
    144          *                            OS_ERR_TASK_WAITING     One or more tasks were waiting on the semaphore
    145          *                            OS_ERR_EVENT_TYPE       If you didn't pass a pointer to a semaphore
    146          *                            OS_ERR_PEVENT_NULL      If 'pevent' is a NULL pointer.
    147          *
    148          * Returns    : pevent        upon error
    149          *              (OS_EVENT *)0 if the semaphore was successfully deleted.
    150          *
    151          * Note(s)    : 1) This function must be used with care.  Tasks that would normally expect the presence of
    152          *                 the semaphore MUST check the return code of OSSemPend().
    153          *              2) OSSemAccept() callers will not know that the intended semaphore has been deleted unless
    154          *                 they check 'pevent' to see that it's a NULL pointer.
    155          *              3) This call can potentially disable interrupts for a long time.  The interrupt disable
    156          *                 time is directly proportional to the number of tasks waiting on the semaphore.
    157          *              4) Because ALL tasks pending on the semaphore will be readied, you MUST be careful in
    158          *                 applications where the semaphore is used for mutual exclusion because the resource(s)
    159          *                 will no longer be guarded by the semaphore.
    160          *********************************************************************************************************
    161          */
    162          
    163          #if OS_SEM_DEL_EN > 0

   \                                 In segment CODE, align 4, keep-with-next
    164          OS_EVENT  *OSSemDel (OS_EVENT *pevent, INT8U opt, INT8U *err)
    165          {
   \                     OSSemDel:
   \   00000000   F0412DE9           PUSH     {R4-R8,LR}
   \   00000004   0040B0E1           MOVS     R4,R0
   \   00000008   0160B0E1           MOVS     R6,R1
   \   0000000C   0250B0E1           MOVS     R5,R2
    166              BOOLEAN    tasks_waiting;
    167              OS_EVENT  *pevent_return;
    168          #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    169              OS_CPU_SR  cpu_sr = 0;
   \   00000010   0070A0E3           MOV      R7,#+0
    170          #endif
    171          
    172          
    173          
    174          #if OS_ARG_CHK_EN > 0
    175              if (err == (INT8U *)0) {                               /* Validate 'err'                           */
   \   00000014   000055E3           CMP      R5,#+0
   \   00000018   0100001A           BNE      ??OSSemDel_0
    176                  return (pevent);
   \   0000001C   0400B0E1           MOVS     R0,R4
   \   00000020   5E0000EA           B        ??OSSemDel_1
    177              }
    178              if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
   \                     ??OSSemDel_0:
   \   00000024   000054E3           CMP      R4,#+0
   \   00000028   0300001A           BNE      ??OSSemDel_2
    179                  *err = OS_ERR_PEVENT_NULL;
   \   0000002C   0400A0E3           MOV      R0,#+4
   \   00000030   0000C5E5           STRB     R0,[R5, #+0]
    180                  return (pevent);
   \   00000034   0400B0E1           MOVS     R0,R4
   \   00000038   580000EA           B        ??OSSemDel_1
    181              }
    182          #endif
    183              if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
   \                     ??OSSemDel_2:
   \   0000003C   0000D4E5           LDRB     R0,[R4, #+0]
   \   00000040   030050E3           CMP      R0,#+3
   \   00000044   0300000A           BEQ      ??OSSemDel_3
    184                  *err = OS_ERR_EVENT_TYPE;
   \   00000048   0100A0E3           MOV      R0,#+1
   \   0000004C   0000C5E5           STRB     R0,[R5, #+0]
    185                  return (pevent);
   \   00000050   0400B0E1           MOVS     R0,R4
   \   00000054   510000EA           B        ??OSSemDel_1
    186              }
    187              if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
   \                     ??OSSemDel_3:
   \   00000058   ........           LDR      R0,??DataTable10  ;; OSIntNesting
   \   0000005C   0000D0E5           LDRB     R0,[R0, #+0]
   \   00000060   010050E3           CMP      R0,#+1
   \   00000064   0300003A           BCC      ??OSSemDel_4
    188                  *err = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
   \   00000068   0F00A0E3           MOV      R0,#+15
   \   0000006C   0000C5E5           STRB     R0,[R5, #+0]
    189                  return (pevent);
   \   00000070   0400B0E1           MOVS     R0,R4
   \   00000074   490000EA           B        ??OSSemDel_1
    190              }
    191              OS_ENTER_CRITICAL();
   \                     ??OSSemDel_4:
   \   00000078   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
   \   0000007C   0070B0E1           MOVS     R7,R0
    192              if (pevent->OSEventGrp != 0) {                         /* See if any tasks waiting on semaphore    */
   \   00000080   0A00D4E5           LDRB     R0,[R4, #+10]
   \   00000084   000050E3           CMP      R0,#+0
   \   00000088   0100000A           BEQ      ??OSSemDel_5
    193                  tasks_waiting = OS_TRUE;                           /* Yes                                      */
   \   0000008C   0180A0E3           MOV      R8,#+1
   \   00000090   000000EA           B        ??OSSemDel_6
    194              } else {
    195                  tasks_waiting = OS_FALSE;                          /* No                                       */
   \                     ??OSSemDel_5:
   \   00000094   0080A0E3           MOV      R8,#+0
    196              }
    197              switch (opt) {
   \                     ??OSSemDel_6:
   \   00000098   000056E3           CMP      R6,#+0
   \   0000009C   0200000A           BEQ      ??OSSemDel_7
   \   000000A0   010056E3           CMP      R6,#+1
   \   000000A4   1F00000A           BEQ      ??OSSemDel_8
   \   000000A8   370000EA           B        ??OSSemDel_9
    198                  case OS_DEL_NO_PEND:                               /* Delete semaphore only if no task waiting */
    199                       if (tasks_waiting == OS_FALSE) {
   \                     ??OSSemDel_7:
   \   000000AC   000058E3           CMP      R8,#+0
   \   000000B0   1200001A           BNE      ??OSSemDel_10
    200          #if OS_EVENT_NAME_SIZE > 1
    201                           pevent->OSEventName[0] = '?';             /* Unknown name                             */
   \   000000B4   3F00A0E3           MOV      R0,#+63
   \   000000B8   0F00C4E5           STRB     R0,[R4, #+15]
    202                           pevent->OSEventName[1] = OS_ASCII_NUL;
   \   000000BC   0000A0E3           MOV      R0,#+0
   \   000000C0   1000C4E5           STRB     R0,[R4, #+16]
    203          #endif
    204                           pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
   \   000000C4   0000A0E3           MOV      R0,#+0
   \   000000C8   0000C4E5           STRB     R0,[R4, #+0]
    205                           pevent->OSEventPtr     = OSEventFreeList; /* Return Event Control Block to free list  */
   \   000000CC   ........           LDR      R0,??DataTable9  ;; OSEventFreeList
   \   000000D0   000090E5           LDR      R0,[R0, #+0]
   \   000000D4   040084E5           STR      R0,[R4, #+4]
    206                           pevent->OSEventCnt     = 0;
   \   000000D8   0000A0E3           MOV      R0,#+0
   \   000000DC   B800C4E1           STRH     R0,[R4, #+8]
    207                           OSEventFreeList        = pevent;          /* Get next free event control block        */
   \   000000E0   ........           LDR      R0,??DataTable9  ;; OSEventFreeList
   \   000000E4   004080E5           STR      R4,[R0, #+0]
    208                           OS_EXIT_CRITICAL();
   \   000000E8   0700B0E1           MOVS     R0,R7
   \   000000EC   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
    209                           *err                   = OS_ERR_NONE;
   \   000000F0   0000A0E3           MOV      R0,#+0
   \   000000F4   0000C5E5           STRB     R0,[R5, #+0]
    210                           pevent_return          = (OS_EVENT *)0;   /* Semaphore has been deleted               */
   \   000000F8   0040A0E3           MOV      R4,#+0

⌨️ 快捷键说明

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