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

📄 os_sem.lst

📁 lpc2478开发板基于IAR编译器移植ucos实验例程
💻 LST
📖 第 1 页 / 共 5 页
字号:
    112              if (pevent != (OS_EVENT *)0) {                         /* Get an event control block               */
   \   00000068   000055E3           CMP      R5,#+0
   \   0000006C   0A00000A           BEQ      ??OSSemCreate_3
    113                  pevent->OSEventType    = OS_EVENT_TYPE_SEM;
   \   00000070   0300A0E3           MOV      R0,#+3
   \   00000074   0000C5E5           STRB     R0,[R5, #+0]
    114                  pevent->OSEventCnt     = cnt;                      /* Set semaphore value                      */
   \   00000078   B840C5E1           STRH     R4,[R5, #+8]
    115                  pevent->OSEventPtr     = (void *)0;                /* Unlink from ECB free list                */
   \   0000007C   0000A0E3           MOV      R0,#+0
   \   00000080   040085E5           STR      R0,[R5, #+4]
    116          #if OS_EVENT_NAME_SIZE > 1
    117                  pevent->OSEventName[0] = '?';                      /* Unknown name                             */
   \   00000084   3F00A0E3           MOV      R0,#+63
   \   00000088   0F00C5E5           STRB     R0,[R5, #+15]
    118                  pevent->OSEventName[1] = OS_ASCII_NUL;
   \   0000008C   0000A0E3           MOV      R0,#+0
   \   00000090   1000C5E5           STRB     R0,[R5, #+16]
    119          #endif
    120                  OS_EventWaitListInit(pevent);                      /* Initialize to 'nobody waiting' on sem.   */
   \   00000094   0500B0E1           MOVS     R0,R5
   \   00000098   ........           _BLF     OS_EventWaitListInit,??OS_EventWaitListInit??rA
    121              }
    122              return (pevent);
   \                     ??OSSemCreate_3:
   \   0000009C   0500B0E1           MOVS     R0,R5
   \                     ??OSSemCreate_1:
   \   000000A0   7080BDE8           POP      {R4-R6,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   F0432DE9           PUSH     {R4-R9,LR}
   \   00000004   0090B0E1           MOVS     R9,R0
   \   00000008   0140B0E1           MOVS     R4,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   0000A0E3           MOV      R0,#+0
   \   00000014   0080B0E1           MOVS     R8,R0
    170          #endif
    171          
    172          
    173          
    174          #if OS_ARG_CHK_EN > 0
    175              if (err == (INT8U *)0) {                               /* Validate 'err'                           */
   \   00000018   000055E3           CMP      R5,#+0
   \   0000001C   0100001A           BNE      ??OSSemDel_0
    176                  return (pevent);
   \   00000020   0900B0E1           MOVS     R0,R9
   \   00000024   660000EA           B        ??OSSemDel_1
    177              }
    178              if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
   \                     ??OSSemDel_0:
   \   00000028   000059E3           CMP      R9,#+0
   \   0000002C   0300001A           BNE      ??OSSemDel_2
    179                  *err = OS_ERR_PEVENT_NULL;
   \   00000030   0400A0E3           MOV      R0,#+4
   \   00000034   0000C5E5           STRB     R0,[R5, #+0]
    180                  return (pevent);
   \   00000038   0900B0E1           MOVS     R0,R9
   \   0000003C   600000EA           B        ??OSSemDel_1
    181              }
    182          #endif
    183              if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
   \                     ??OSSemDel_2:
   \   00000040   0000D9E5           LDRB     R0,[R9, #+0]
   \   00000044   030050E3           CMP      R0,#+3
   \   00000048   0300000A           BEQ      ??OSSemDel_3
    184                  *err = OS_ERR_EVENT_TYPE;
   \   0000004C   0100A0E3           MOV      R0,#+1
   \   00000050   0000C5E5           STRB     R0,[R5, #+0]
    185                  return (pevent);
   \   00000054   0900B0E1           MOVS     R0,R9
   \   00000058   590000EA           B        ??OSSemDel_1
    186              }
    187              if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
   \                     ??OSSemDel_3:
   \   0000005C   ........           LDR      R0,??DataTable10  ;; OSIntNesting
   \   00000060   0000D0E5           LDRB     R0,[R0, #+0]
   \   00000064   010050E3           CMP      R0,#+1
   \   00000068   0300003A           BCC      ??OSSemDel_4
    188                  *err = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
   \   0000006C   0F00A0E3           MOV      R0,#+15
   \   00000070   0000C5E5           STRB     R0,[R5, #+0]
    189                  return (pevent);
   \   00000074   0900B0E1           MOVS     R0,R9
   \   00000078   510000EA           B        ??OSSemDel_1
    190              }
    191              OS_ENTER_CRITICAL();
   \                     ??OSSemDel_4:
   \   0000007C   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
   \   00000080   0080B0E1           MOVS     R8,R0
    192              if (pevent->OSEventGrp != 0) {                         /* See if any tasks waiting on semaphore    */
   \   00000084   0A00D9E5           LDRB     R0,[R9, #+10]
   \   00000088   000050E3           CMP      R0,#+0
   \   0000008C   0200000A           BEQ      ??OSSemDel_5
    193                  tasks_waiting = OS_TRUE;                           /* Yes                                      */
   \   00000090   0100A0E3           MOV      R0,#+1
   \   00000094   0060B0E1           MOVS     R6,R0
   \   00000098   010000EA           B        ??OSSemDel_6
    194              } else {
    195                  tasks_waiting = OS_FALSE;                          /* No                                       */
   \                     ??OSSemDel_5:
   \   0000009C   0000A0E3           MOV      R0,#+0
   \   000000A0   0060B0E1           MOVS     R6,R0
    196              }
    197              switch (opt) {
   \                     ??OSSemDel_6:
   \   000000A4   0400B0E1           MOVS     R0,R4
   \   000000A8   000050E3           CMP      R0,#+0
   \   000000AC   0200000A           BEQ      ??OSSemDel_7
   \   000000B0   010050E3           CMP      R0,#+1
   \   000000B4   1C00000A           BEQ      ??OSSemDel_8
   \   000000B8   3B0000EA           B        ??OSSemDel_9
    198                  case OS_DEL_NO_PEND:                               /* Delete semaphore only if no task waiting */
    199                       if (tasks_waiting == OS_FALSE) {
   \                     ??OSSemDel_7:
   \   000000BC   000056E3           CMP      R6,#+0
   \   000000C0   1300001A           BNE      ??OSSemDel_10
    200          #if OS_EVENT_NAME_SIZE > 1
    201                           pevent->OSEventName[0] = '?';             /* Unknown name                             */
   \   000000C4   3F00A0E3           MOV      R0,#+63
   \   000000C8   0F00C9E5           STRB     R0,[R9, #+15]
    202                           pevent->OSEventName[1] = OS_ASCII_NUL;
   \   000000CC   0000A0E3           MOV      R0,#+0
   \   000000D0   1000C9E5           STRB     R0,[R9, #+16]
    203          #endif
    204                           pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
   \   000000D4   0000A0E3           MOV      R0,#+0
   \   000000D8   0000C9E5           STRB     R0,[R9, #+0]
    205                           pevent->OSEventPtr     = OSEventFreeList; /* Return Event Control Block to free list  */
   \   000000DC   ........           LDR      R0,??DataTable9  ;; OSEventFreeList
   \   000000E0   000090E5           LDR      R0,[R0, #+0]
   \   000000E4   040089E5           STR      R0,[R9, #+4]
    206                           pevent->OSEventCnt     = 0;
   \   000000E8   0000A0E3           MOV      R0,#+0
   \   000000EC   B800C9E1           STRH     R0,[R9, #+8]
    207                           OSEventFreeList        = pevent;          /* Get next free event control block        */
   \   000000F0   ........           LDR      R0,??DataTable9  ;; OSEventFreeList
   \   000000F4   009080E5           STR      R9,[R0, #+0]
    208                           OS_EXIT_CRITICAL();
   \   000000F8   0800B0E1           MOVS     R0,R8
   \   000000FC   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
    209                           *err                   = OS_ERR_NONE;
   \   00000100   0000A0E3           MOV      R0,#+0
   \   00000104   0000C5E5           STRB     R0,[R5, #+0]
    210                           pevent_return          = (OS_EVENT *)0;   /* Semaphore has been deleted               */
   \   00000108   0000A0E3           MOV      R0,#+0
   \   0000010C   0070B0E1           MOVS     R7,R0
   \   00000110   2A0000EA           B        ??OSSemDel_11
    211                       } else {
    212                           OS_EXIT_CRITICAL();
   \                     ??OSSemDel_10:
   \   00000114   0800B0E1           MOVS     R0,R8
   \   00000118   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
    213                           *err                   = OS_ERR_TASK_WAITING;
   \   0000011C   4900A0E3           MOV      R0,#+73
   \   00000120   0000C5E5           STRB     R0,[R5, #+0]
    214                           pevent_return          = pevent;
   \   00000124   0970B0E1           MOVS     R7,R9
   \   00000128   240000EA           B        ??OSSemDel_11
    215                       }
    216                       break;
    217          
    218                  case OS_DEL_ALWAYS:                                /* Always delete the semaphore              */
    219                       while (pevent->OSEventGrp != 0) {             /* Ready ALL tasks waiting for semaphore    */

⌨️ 快捷键说明

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