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

📄 os_mbox.lst

📁 ARM仿真案例
💻 LST
📖 第 1 页 / 共 5 页
字号:
    107          
    108          /*
    109          *********************************************************************************************************
    110          *                                         DELETE A MAIBOX
    111          *
    112          * Description: This function deletes a mailbox and readies all tasks pending on the mailbox.
    113          *
    114          * Arguments  : pevent        is a pointer to the event control block associated with the desired
    115          *                            mailbox.
    116          *
    117          *              opt           determines delete options as follows:
    118          *                            opt == OS_DEL_NO_PEND   Delete the mailbox ONLY if no task pending
    119          *                            opt == OS_DEL_ALWAYS    Deletes the mailbox even if tasks are waiting.
    120          *                                                    In this case, all the tasks pending will be readied.
    121          *
    122          *              err           is a pointer to an error code that can contain one of the following values:
    123          *                            OS_NO_ERR               The call was successful and the mailbox was deleted
    124          *                            OS_ERR_DEL_ISR          If you attempted to delete the mailbox from an ISR
    125          *                            OS_ERR_INVALID_OPT      An invalid option was specified
    126          *                            OS_ERR_TASK_WAITING     One or more tasks were waiting on the mailbox
    127          *                            OS_ERR_EVENT_TYPE       If you didn't pass a pointer to a mailbox
    128          *                            OS_ERR_PEVENT_NULL      If 'pevent' is a NULL pointer.
    129          *
    130          * Returns    : pevent        upon error
    131          *              (OS_EVENT *)0 if the mailbox was successfully deleted.
    132          *
    133          * Note(s)    : 1) This function must be used with care.  Tasks that would normally expect the presence of
    134          *                 the mailbox MUST check the return code of OSMboxPend().
    135          *              2) OSMboxAccept() callers will not know that the intended mailbox has been deleted!
    136          *              3) This call can potentially disable interrupts for a long time.  The interrupt disable
    137          *                 time is directly proportional to the number of tasks waiting on the mailbox.
    138          *              4) Because ALL tasks pending on the mailbox will be readied, you MUST be careful in
    139          *                 applications where the mailbox is used for mutual exclusion because the resource(s)
    140          *                 will no longer be guarded by the mailbox.
    141          *********************************************************************************************************
    142          */
    143          
    144          #if OS_MBOX_DEL_EN > 0

   \                                 In segment CODE, align 4, keep-with-next
    145          OS_EVENT  *OSMboxDel (OS_EVENT *pevent, INT8U opt, INT8U *err)
    146          {
   \                     OSMboxDel:
   \   00000000   F2B5               PUSH     {R1,R4-R7,LR}
   \   00000002   0400               MOVS     R4,R0
   \   00000004   1500               MOVS     R5,R2
    147          #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    148              OS_CPU_SR  cpu_sr;
    149          #endif    
    150              BOOLEAN    tasks_waiting;
    151          
    152          
    153              if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
   \   00000006   ....               LDR      R0,??DataTable7  ;; OSIntNesting
   \   00000008   0078               LDRB     R0,[R0, #+0]
   \   0000000A   0028               CMP      R0,#+0
   \   0000000C   01D0               BEQ      ??OSMboxDel_0
    154                  *err = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
   \   0000000E   8C20               MOVS     R0,#+140
   \   00000010   53E0               B.N      ??OSMboxDel_1
    155                  return (pevent);
    156              }
    157          #if OS_ARG_CHK_EN > 0
    158              if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
   \                     ??OSMboxDel_0:
   \   00000012   002C               CMP      R4,#+0
   \   00000014   03D1               BNE      ??OSMboxDel_2
    159                  *err = OS_ERR_PEVENT_NULL;
   \   00000016   0420               MOVS     R0,#+4
   \   00000018   2870               STRB     R0,[R5, #+0]
    160                  return (pevent);
   \   0000001A   0020               MOVS     R0,#+0
   \   0000001C   4FE0               B        ??OSMboxDel_3
    161              }
    162          #endif
    163              if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {       /* Validate event block type                */
   \                     ??OSMboxDel_2:
   \   0000001E   2078               LDRB     R0,[R4, #+0]
   \   00000020   0128               CMP      R0,#+1
   \   00000022   01D0               BEQ      ??OSMboxDel_4
    164                  *err = OS_ERR_EVENT_TYPE;
   \   00000024   0120               MOVS     R0,#+1
   \   00000026   48E0               B.N      ??OSMboxDel_1
    165                  return (pevent);
    166              }
    167              OS_ENTER_CRITICAL();
   \                     ??OSMboxDel_4:
   \   00000028   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
   \   0000002C   0600               MOVS     R6,R0
    168              if (pevent->OSEventGrp != 0x00) {                      /* See if any tasks waiting on mailbox      */
   \   0000002E   6078               LDRB     R0,[R4, #+1]
   \   00000030   0028               CMP      R0,#+0
   \   00000032   01D0               BEQ      ??OSMboxDel_5
    169                  tasks_waiting = TRUE;                              /* Yes                                      */
   \   00000034   0127               MOVS     R7,#+1
   \   00000036   00E0               B        ??OSMboxDel_6
    170              } else {
    171                  tasks_waiting = FALSE;                             /* No                                       */
   \                     ??OSMboxDel_5:
   \   00000038   0027               MOVS     R7,#+0
    172              }
    173              switch (opt) {
   \                     ??OSMboxDel_6:
   \   0000003A   6846               MOV      R0,SP
   \   0000003C   0078               LDRB     R0,[R0, #+0]
   \   0000003E   0028               CMP      R0,#+0
   \   00000040   02D0               BEQ      ??OSMboxDel_7
   \   00000042   0128               CMP      R0,#+1
   \   00000044   1ED0               BEQ      ??OSMboxDel_8
   \   00000046   34E0               B        ??OSMboxDel_9
    174                  case OS_DEL_NO_PEND:                               /* Delete mailbox only if no task waiting   */
    175                       if (tasks_waiting == FALSE) {
   \                     ??OSMboxDel_7:
   \   00000048   002F               CMP      R7,#+0
   \   0000004A   11D1               BNE      ??OSMboxDel_10
    176          #if OS_EVENT_NAME_SIZE > 1
    177                           pevent->OSEventName[0] = '?';             /* Unknown name                             */
   \   0000004C   3F20               MOVS     R0,#+63
   \   0000004E   2074               STRB     R0,[R4, #+16]
    178                           pevent->OSEventName[1] = OS_ASCII_NUL;
   \   00000050   0020               MOVS     R0,#+0
   \   00000052   6074               STRB     R0,[R4, #+17]
    179          #endif
    180                           pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
   \   00000054   2070               STRB     R0,[R4, #+0]
    181                           pevent->OSEventPtr  = OSEventFreeList;    /* Return Event Control Block to free list  */
   \   00000056   ....               LDR      R0,??DataTable6  ;; OSEventFreeList
   \   00000058   0068               LDR      R0,[R0, #+0]
   \   0000005A   6060               STR      R0,[R4, #+4]
    182                           pevent->OSEventCnt  = 0;
   \   0000005C   0020               MOVS     R0,#+0
   \   0000005E   6080               STRH     R0,[R4, #+2]
    183                           OSEventFreeList     = pevent;             /* Get next free event control block        */
   \   00000060   ....               LDR      R0,??DataTable6  ;; OSEventFreeList
   \   00000062   0460               STR      R4,[R0, #+0]
    184                           OS_EXIT_CRITICAL();
   \   00000064   3000               MOVS     R0,R6
   \   00000066   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    185                           *err                = OS_NO_ERR;
   \                     ??OSMboxDel_11:
   \   0000006A   0020               MOVS     R0,#+0
   \   0000006C   2870               STRB     R0,[R5, #+0]
    186                           return ((OS_EVENT *)0);                   /* Mailbox has been deleted                 */
   \   0000006E   26E0               B        ??OSMboxDel_3
    187                       } else {
    188                           OS_EXIT_CRITICAL();
   \                     ??OSMboxDel_10:
   \   00000070   3000               MOVS     R0,R6
   \   00000072   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    189                           *err                = OS_ERR_TASK_WAITING;
   \   00000076   0820               MOVS     R0,#+8
   \   00000078   1FE0               B.N      ??OSMboxDel_1
    190                           return (pevent);
    191                       }
    192          
    193                  case OS_DEL_ALWAYS:                                /* Always delete the mailbox                */
    194                       while (pevent->OSEventGrp != 0x00) {          /* Ready ALL tasks waiting for mailbox      */
    195                           OS_EventTaskRdy(pevent, (void *)0, OS_STAT_MBOX);
   \                     ??OSMboxDel_12:
   \   0000007A   0222               MOVS     R2,#+2
   \   0000007C   0021               MOVS     R1,#+0
   \   0000007E   2000               MOVS     R0,R4
   \   00000080   ........           _BLF     OS_EventTaskRdy,??OS_EventTaskRdy??rT
    196                       }
   \                     ??OSMboxDel_8:
   \   00000084   6078               LDRB     R0,[R4, #+1]
   \   00000086   0028               CMP      R0,#+0
   \   00000088   F7D1               BNE      ??OSMboxDel_12
    197          #if OS_EVENT_NAME_SIZE > 1
    198                       pevent->OSEventName[0] = '?';                 /* Unknown name                             */
   \   0000008A   3F20               MOVS     R0,#+63
   \   0000008C   2074               STRB     R0,[R4, #+16]
    199                       pevent->OSEventName[1] = OS_ASCII_NUL;
   \   0000008E   0020               MOVS     R0,#+0
   \   00000090   6074               STRB     R0,[R4, #+17]
    200          #endif
    201                       pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
   \   00000092   2070               STRB     R0,[R4, #+0]
    202                       pevent->OSEventPtr     = OSEventFreeList;     /* Return Event Control Block to free list  */
   \   00000094   ....               LDR      R0,??DataTable6  ;; OSEventFreeList
   \   00000096   0068               LDR      R0,[R0, #+0]
   \   00000098   6060               STR      R0,[R4, #+4]
    203                       pevent->OSEventCnt     = 0;
   \   0000009A   0020               MOVS     R0,#+0
   \   0000009C   6080               STRH     R0,[R4, #+2]
    204                       OSEventFreeList        = pevent;              /* Get next free event control block        */
   \   0000009E   ....               LDR      R0,??DataTable6  ;; OSEventFreeList
   \   000000A0   0460               STR      R4,[R0, #+0]
    205                       OS_EXIT_CRITICAL();
   \   000000A2   3000               MOVS     R0,R6
   \   000000A4   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    206                       if (tasks_waiting == TRUE) {                  /* Reschedule only if task(s) were waiting  */
   \   000000A8   012F               CMP      R7,#+1
   \   000000AA   DED1               BNE      ??OSMboxDel_11
    207                           OS_Sched();                               /* Find highest priority task ready to run  */
   \   000000AC   ........           _BLF     OS_Sched,??OS_Sched??rT
    208                       }
    209                       *err = OS_NO_ERR;
   \                     ??OSMboxDel_13:
   \   000000B0   DBE7               B.N      ??OSMboxDel_11
    210                       return ((OS_EVENT *)0);                       /* Mailbox has been deleted                 */
    211          
    212                  default:
    213                       OS_EXIT_CRITICAL();
   \                     ??OSMboxDel_9:

⌨️ 快捷键说明

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