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

📄 os_mbox.lst

📁 ARM仿真案例
💻 LST
📖 第 1 页 / 共 5 页
字号:
    213                       OS_EXIT_CRITICAL();
   \                     ??OSMboxDel_8:
   \   000000CA   3000               MOVS     R0,R6
   \   000000CC   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    214                       *err = OS_ERR_INVALID_OPT;
   \   000000D0   0720               MOVS     R0,#+7
   \   000000D2   2870               STRB     R0,[R5, #+0]
    215                       return (pevent);
   \   000000D4   2000               MOVS     R0,R4
   \                     ??OSMboxDel_1:
   \   000000D6   01B0               ADD      SP,SP,#+4
   \   000000D8   F0BC               POP      {R4-R7}
   \   000000DA   02BC               POP      {R1}
   \   000000DC   0847               BX       R1               ;; return
    216              }
    217          }
    218          #endif
    219          
    220          
    221          /*
    222          *********************************************************************************************************
    223          *                                      PEND ON MAILBOX FOR A MESSAGE
    224          *
    225          * Description: This function waits for a message to be sent to a mailbox
    226          *
    227          * Arguments  : pevent        is a pointer to the event control block associated with the desired mailbox
    228          *
    229          *              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
    230          *                            wait for a message to arrive at the mailbox up to the amount of time
    231          *                            specified by this argument.  If you specify 0, however, your task will wait
    232          *                            forever at the specified mailbox or, until a message arrives.
    233          *
    234          *              err           is a pointer to where an error message will be deposited.  Possible error
    235          *                            messages are:
    236          *
    237          *                            OS_NO_ERR           The call was successful and your task received a
    238          *                                                message.
    239          *                            OS_TIMEOUT          A message was not received within the specified timeout
    240          *                            OS_ERR_EVENT_TYPE   Invalid event type
    241          *                            OS_ERR_PEND_ISR     If you called this function from an ISR and the result
    242          *                                                would lead to a suspension.
    243          *                            OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer
    244          *
    245          * Returns    : != (void *)0  is a pointer to the message received
    246          *              == (void *)0  if no message was received or,
    247          *                            if 'pevent' is a NULL pointer or,
    248          *                            if you didn't pass the proper pointer to the event control block.
    249          *********************************************************************************************************
    250          */
    251          

   \                                 In segment CODE, align 4, keep-with-next
    252          void  *OSMboxPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
    253          {
   \                     OSMboxPend:
   \   00000000   F2B5               PUSH     {R1,R4-R7,LR}
   \   00000002   0400               MOVS     R4,R0
   \   00000004   1500               MOVS     R5,R2
    254          #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    255              OS_CPU_SR  cpu_sr;
    256          #endif    
    257              void      *msg;
    258          
    259          
    260              if (OSIntNesting > 0) {                           /* See if called from ISR ...                    */
   \   00000006   ....               LDR      R0,??DataTable10  ;; OSIntNesting
   \   00000008   0078               LDRB     R0,[R0, #+0]
   \   0000000A   0128               CMP      R0,#+1
   \   0000000C   03D3               BCC      ??OSMboxPend_0
    261                  *err = OS_ERR_PEND_ISR;                       /* ... can't PEND from an ISR                    */
   \   0000000E   0220               MOVS     R0,#+2
   \   00000010   2870               STRB     R0,[R5, #+0]
    262                  return ((void *)0);
   \   00000012   0020               MOVS     R0,#+0
   \   00000014   57E0               B        ??OSMboxPend_1
    263              }
    264          #if OS_ARG_CHK_EN > 0
    265              if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
   \                     ??OSMboxPend_0:
   \   00000016   002C               CMP      R4,#+0
   \   00000018   03D1               BNE      ??OSMboxPend_2
    266                  *err = OS_ERR_PEVENT_NULL;
   \   0000001A   0420               MOVS     R0,#+4
   \   0000001C   2870               STRB     R0,[R5, #+0]
    267                  return ((void *)0);
   \   0000001E   0020               MOVS     R0,#+0
   \   00000020   51E0               B        ??OSMboxPend_1
    268              }
    269          #endif
    270              if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {  /* Validate event block type                     */
   \                     ??OSMboxPend_2:
   \   00000022   2078               LDRB     R0,[R4, #+0]
   \   00000024   0128               CMP      R0,#+1
   \   00000026   03D0               BEQ      ??OSMboxPend_3
    271                  *err = OS_ERR_EVENT_TYPE;
   \   00000028   0120               MOVS     R0,#+1
   \   0000002A   2870               STRB     R0,[R5, #+0]
    272                  return ((void *)0);
   \   0000002C   0020               MOVS     R0,#+0
   \   0000002E   4AE0               B        ??OSMboxPend_1
    273              }
    274              OS_ENTER_CRITICAL();
   \                     ??OSMboxPend_3:
   \   00000030   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
   \   00000034   0600               MOVS     R6,R0
    275              msg = pevent->OSEventPtr;
   \   00000036   6768               LDR      R7,[R4, #+4]
    276              if (msg != (void *)0) {                           /* See if there is already a message             */
   \   00000038   002F               CMP      R7,#+0
   \   0000003A   08D0               BEQ      ??OSMboxPend_4
    277                  pevent->OSEventPtr = (void *)0;               /* Clear the mailbox                             */
   \   0000003C   0020               MOVS     R0,#+0
   \   0000003E   6060               STR      R0,[R4, #+4]
    278                  OS_EXIT_CRITICAL();
   \   00000040   3000               MOVS     R0,R6
   \   00000042   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    279                  *err = OS_NO_ERR;
   \   00000046   0020               MOVS     R0,#+0
   \   00000048   2870               STRB     R0,[R5, #+0]
    280                  return (msg);                                 /* Return the message received (or NULL)         */
   \   0000004A   3800               MOVS     R0,R7
   \   0000004C   3BE0               B        ??OSMboxPend_1
    281              }
    282              OSTCBCur->OSTCBStat |= OS_STAT_MBOX;              /* Message not available, task will pend         */
   \                     ??OSMboxPend_4:
   \   0000004E   2048               LDR      R0,??OSMboxPend_5  ;; OSTCBCur
   \   00000050   0068               LDR      R0,[R0, #+0]
   \   00000052   2C30               ADDS     R0,R0,#+44
   \   00000054   1E49               LDR      R1,??OSMboxPend_5  ;; OSTCBCur
   \   00000056   0968               LDR      R1,[R1, #+0]
   \   00000058   2C31               ADDS     R1,R1,#+44
   \   0000005A   0978               LDRB     R1,[R1, #+0]
   \   0000005C   0222               MOVS     R2,#+2
   \   0000005E   0A43               ORRS     R2,R2,R1
   \   00000060   0270               STRB     R2,[R0, #+0]
    283              OSTCBCur->OSTCBDly   = timeout;                   /* Load timeout in TCB                           */
   \   00000062   1B48               LDR      R0,??OSMboxPend_5  ;; OSTCBCur
   \   00000064   0068               LDR      R0,[R0, #+0]
   \   00000066   6946               MOV      R1,SP
   \   00000068   0988               LDRH     R1,[R1, #+0]
   \   0000006A   4185               STRH     R1,[R0, #+42]
    284              OS_EventTaskWait(pevent);                         /* Suspend task until event or timeout occurs    */
   \   0000006C   2000               MOVS     R0,R4
   \   0000006E   ........           _BLF     OS_EventTaskWait,??OS_EventTaskWait??rT
    285              OS_EXIT_CRITICAL();
   \   00000072   3000               MOVS     R0,R6
   \   00000074   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    286              OS_Sched();                                       /* Find next highest priority task ready to run  */
   \   00000078   ........           _BLF     OS_Sched,??OS_Sched??rT
    287              OS_ENTER_CRITICAL();
   \   0000007C   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
   \   00000080   0600               MOVS     R6,R0
    288              msg = OSTCBCur->OSTCBMsg;
   \   00000082   1348               LDR      R0,??OSMboxPend_5  ;; OSTCBCur
   \   00000084   0068               LDR      R0,[R0, #+0]
   \   00000086   076A               LDR      R7,[R0, #+32]
    289              if (msg != (void *)0) {                           /* See if we were given the message              */
   \   00000088   002F               CMP      R7,#+0
   \   0000008A   13D0               BEQ      ??OSMboxPend_6
    290                  OSTCBCur->OSTCBMsg      = (void *)0;          /* Yes, clear message received                   */
   \   0000008C   1048               LDR      R0,??OSMboxPend_5  ;; OSTCBCur
   \   0000008E   0068               LDR      R0,[R0, #+0]
   \   00000090   0021               MOVS     R1,#+0
   \   00000092   0162               STR      R1,[R0, #+32]
    291                  OSTCBCur->OSTCBStat     = OS_STAT_RDY;
   \   00000094   0E48               LDR      R0,??OSMboxPend_5  ;; OSTCBCur
   \   00000096   0068               LDR      R0,[R0, #+0]
   \   00000098   2C30               ADDS     R0,R0,#+44
   \   0000009A   0021               MOVS     R1,#+0
   \   0000009C   0170               STRB     R1,[R0, #+0]
    292                  OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;      /* No longer waiting for event                   */
   \   0000009E   0C48               LDR      R0,??OSMboxPend_5  ;; OSTCBCur
   \   000000A0   0068               LDR      R0,[R0, #+0]
   \   000000A2   0021               MOVS     R1,#+0
   \   000000A4   C161               STR      R1,[R0, #+28]
    293                  OS_EXIT_CRITICAL();
   \   000000A6   3000               MOVS     R0,R6
   \   000000A8   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    294                  *err                    = OS_NO_ERR;
   \   000000AC   0020               MOVS     R0,#+0
   \   000000AE   2870               STRB     R0,[R5, #+0]
    295                  return (msg);                                 /* Return the message received                   */
   \   000000B0   3800               MOVS     R0,R7
   \   000000B2   08E0               B        ??OSMboxPend_1
    296              }
    297              OS_EventTO(pevent);                               /* Timed out, Make task ready                    */
   \                     ??OSMboxPend_6:
   \   000000B4   2000               MOVS     R0,R4
   \   000000B6   ........           _BLF     OS_EventTO,??OS_EventTO??rT
    298              OS_EXIT_CRITICAL();
   \   000000BA   3000               MOVS     R0,R6
   \   000000BC   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    299              *err = OS_TIMEOUT;                                /* Indicate that a timeout occured               */
   \   000000C0   0A20               MOVS     R0,#+10
   \   000000C2   2870               STRB     R0,[R5, #+0]
    300              return ((void *)0);                               /* Return a NULL message                         */
   \   000000C4   0020               MOVS     R0,#+0
   \                     ??OSMboxPend_1:
   \   000000C6   01B0               ADD      SP,SP,#+4
   \   000000C8   F0BC               POP      {R4-R7}
   \   000000CA   02BC               POP      {R1}
   \   000000CC   0847               BX       R1               ;; return
   \   000000CE   C046               Nop      
   \                     ??OSMboxPend_5:
   \   000000D0   ........           DC32     OSTCBCur
    301          }
    302          
    303          /*
    304          *********************************************************************************************************
    305          *                                       POST MESSAGE TO A MAILBOX
    306          *
    307          * Description: This function sends a message to a mailbox
    308          *

⌨️ 快捷键说明

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