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

📄 os_q.lst

📁 针对STM32F103的UCOS移植
💻 LST
📖 第 1 页 / 共 5 页
字号:
    316          * WARNING     : You should use this function with great care because, when to flush the queue, you LOOSE
    317          *               the references to what the queue entries are pointing to and thus, you could cause
    318          *               'memory leaks'.  In other words, the data you are pointing to that's being referenced
    319          *               by the queue entries should, most likely, need to be de-allocated (i.e. freed).
    320          *********************************************************************************************************
    321          */
    322          
    323          #if OS_Q_FLUSH_EN > 0

   \                                 In segment CODE, align 4, keep-with-next
    324          INT8U  OSQFlush (OS_EVENT *pevent)
    325          {
   \                     OSQFlush:
   \   00000000   10B5               PUSH     {R4,LR}
   \   00000002   0400               MOVS     R4,R0
    326              OS_Q      *pq;
    327          #if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    328              OS_CPU_SR  cpu_sr = 0;
    329          #endif
    330          
    331          
    332          
    333          #if OS_ARG_CHK_EN > 0
    334              if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
   \   00000004   01D1               BNE.N    ??OSQFlush_0
    335                  return (OS_ERR_PEVENT_NULL);
   \   00000006   0420               MOVS     R0,#+4
   \   00000008   10BD               POP      {R4,PC}
    336              }
    337              if (pevent->OSEventType != OS_EVENT_TYPE_Q) {     /* Validate event block type                     */
   \                     ??OSQFlush_0:
   \   0000000A   2078               LDRB     R0,[R4, #+0]
   \   0000000C   0228               CMP      R0,#+2
   \   0000000E   01D0               BEQ.N    ??OSQFlush_1
    338                  return (OS_ERR_EVENT_TYPE);
   \   00000010   0120               MOVS     R0,#+1
   \   00000012   10BD               POP      {R4,PC}
    339              }
    340          #endif
    341              OS_ENTER_CRITICAL();
   \                     ??OSQFlush_1:
   \   00000014   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
    342              pq             = (OS_Q *)pevent->OSEventPtr;      /* Point to queue storage structure              */
   \   00000018   6168               LDR      R1,[R4, #+4]
    343              pq->OSQIn      = pq->OSQStart;
   \   0000001A   4A68               LDR      R2,[R1, #+4]
   \   0000001C   CA60               STR      R2,[R1, #+12]
    344              pq->OSQOut     = pq->OSQStart;
   \   0000001E   0A61               STR      R2,[R1, #+16]
    345              pq->OSQEntries = 0;
   \   00000020   0022               MOVS     R2,#+0
   \   00000022   CA82               STRH     R2,[R1, #+22]
    346              OS_EXIT_CRITICAL();
   \   00000024   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    347              return (OS_ERR_NONE);
   \   00000028   0020               MOVS     R0,#+0
   \   0000002A   10BD               POP      {R4,PC}          ;; return
    348          }
    349          #endif
    350          
    351          /*$PAGE*/
    352          /*
    353          *********************************************************************************************************
    354          *                                     PEND ON A QUEUE FOR A MESSAGE
    355          *
    356          * Description: This function waits for a message to be sent to a queue
    357          *
    358          * Arguments  : pevent        is a pointer to the event control block associated with the desired queue
    359          *
    360          *              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
    361          *                            wait for a message to arrive at the queue up to the amount of time
    362          *                            specified by this argument.  If you specify 0, however, your task will wait
    363          *                            forever at the specified queue or, until a message arrives.
    364          *
    365          *              perr          is a pointer to where an error message will be deposited.  Possible error
    366          *                            messages are:
    367          *
    368          *                            OS_ERR_NONE         The call was successful and your task received a
    369          *                                                message.
    370          *                            OS_ERR_TIMEOUT      A message was not received within the specified 'timeout'.
    371          *                            OS_ERR_PEND_ABORT   The wait on the queue was aborted.
    372          *                            OS_ERR_EVENT_TYPE   You didn't pass a pointer to a queue
    373          *                            OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer
    374          *                            OS_ERR_PEND_ISR     If you called this function from an ISR and the result
    375          *                                                would lead to a suspension.
    376          *                            OS_ERR_PEND_LOCKED  If you called this function with the scheduler is locked
    377          *
    378          * Returns    : != (void *)0  is a pointer to the message received
    379          *              == (void *)0  if you received a NULL pointer message or,
    380          *                            if no message was received or,
    381          *                            if 'pevent' is a NULL pointer or,
    382          *                            if you didn't pass a pointer to a queue.
    383          *
    384          * Note(s)    : As of V2.60, this function allows you to receive NULL pointer messages.
    385          *********************************************************************************************************
    386          */
    387          

   \                                 In segment CODE, align 4, keep-with-next
    388          void  *OSQPend (OS_EVENT *pevent, INT16U timeout, INT8U *perr)
    389          {
   \                     OSQPend:
   \   00000000   2DE9F047           PUSH     {R4-R10,LR}
   \   00000004   8046               MOV      R8,R0
   \   00000006   8946               MOV      R9,R1
   \   00000008   1400               MOVS     R4,R2
    390              void      *pmsg;
    391              OS_Q      *pq;
    392              INT8U      pend_stat;
    393          #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    394              OS_CPU_SR  cpu_sr = 0;
    395          #endif
    396          
    397          
    398          
    399          #if OS_ARG_CHK_EN > 0
    400              if (perr == (INT8U *)0) {                    /* Validate 'perr'                                    */
   \   0000000A   02D1               BNE.N    ??OSQPend_0
    401                  return ((void *)0);
   \                     ??OSQPend_1:
   \   0000000C   0020               MOVS     R0,#+0
   \                     ??OSQPend_2:
   \   0000000E   BDE8F087           POP      {R4-R10,PC}      ;; return
    402              }
    403              if (pevent == (OS_EVENT *)0) {               /* Validate 'pevent'                                  */
   \                     ??OSQPend_0:
   \   00000012   0028               CMP      R0,#+0
   \   00000014   02D1               BNE.N    ??OSQPend_3
    404                  *perr = OS_ERR_PEVENT_NULL;
   \   00000016   0420               MOVS     R0,#+4
   \   00000018   2070               STRB     R0,[R4, #+0]
   \   0000001A   F7E7               B.N      ??OSQPend_1
    405                  return ((void *)0);
    406              }
    407              if (pevent->OSEventType != OS_EVENT_TYPE_Q) {/* Validate event block type                          */
   \                     ??OSQPend_3:
   \   0000001C   98F80000           LDRB     R0,[R8, #+0]
   \   00000020   0228               CMP      R0,#+2
   \   00000022   02D0               BEQ.N    ??OSQPend_4
    408                  *perr = OS_ERR_EVENT_TYPE;
   \   00000024   0120               MOVS     R0,#+1
   \   00000026   2070               STRB     R0,[R4, #+0]
   \   00000028   F0E7               B.N      ??OSQPend_1
    409                  return ((void *)0);
    410              }
    411          #endif
    412              if (OSIntNesting > 0) {                      /* See if called from ISR ...                         */
   \                     ??OSQPend_4:
   \   0000002A   ....               LDR.N    R0,??DataTable6  ;; OSIntNesting
   \   0000002C   0078               LDRB     R0,[R0, #+0]
   \   0000002E   0028               CMP      R0,#+0
   \   00000030   02D0               BEQ.N    ??OSQPend_5
    413                  *perr = OS_ERR_PEND_ISR;                 /* ... can't PEND from an ISR                         */
   \   00000032   0220               MOVS     R0,#+2
   \   00000034   2070               STRB     R0,[R4, #+0]
   \   00000036   E9E7               B.N      ??OSQPend_1
    414                  return ((void *)0);
    415              }
    416              if (OSLockNesting > 0) {                     /* See if called with scheduler locked ...            */
   \                     ??OSQPend_5:
   \   00000038   2E48               LDR.N    R0,??OSQPend_6   ;; OSLockNesting
   \   0000003A   0078               LDRB     R0,[R0, #+0]
   \   0000003C   0028               CMP      R0,#+0
   \   0000003E   02D0               BEQ.N    ??OSQPend_7
    417                  *perr = OS_ERR_PEND_LOCKED;              /* ... can't PEND when locked                         */
   \   00000040   0D20               MOVS     R0,#+13
   \   00000042   2070               STRB     R0,[R4, #+0]
   \   00000044   E2E7               B.N      ??OSQPend_1
    418                  return ((void *)0);
    419              }
    420              OS_ENTER_CRITICAL();
   \                     ??OSQPend_7:
   \   00000046   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
   \   0000004A   0500               MOVS     R5,R0
    421              pq = (OS_Q *)pevent->OSEventPtr;             /* Point at queue control block                       */
   \   0000004C   D8F80400           LDR      R0,[R8, #+4]
    422              if (pq->OSQEntries > 0) {                    /* See if any messages in the queue                   */
   \   00000050   0026               MOVS     R6,#+0
   \   00000052   C18A               LDRH     R1,[R0, #+22]
   \   00000054   0029               CMP      R1,#+0
   \   00000056   14D0               BEQ.N    ??OSQPend_8
    423                  pmsg = *pq->OSQOut++;                    /* Yes, extract oldest message from the queue         */
   \   00000058   0169               LDR      R1,[R0, #+16]
   \   0000005A   0A00               MOVS     R2,R1
   \   0000005C   121D               ADDS     R2,R2,#+4
   \   0000005E   0261               STR      R2,[R0, #+16]
   \   00000060   0968               LDR      R1,[R1, #+0]
   \   00000062   8A46               MOV      R10,R1
    424                  pq->OSQEntries--;                        /* Update the number of entries in the queue          */
   \   00000064   C18A               LDRH     R1,[R0, #+22]
   \   00000066   491E               SUBS     R1,R1,#+1
   \   00000068   C182               STRH     R1,[R0, #+22]
    425                  if (pq->OSQOut == pq->OSQEnd) {          /* Wrap OUT pointer if we are at the end of the queue */
   \   0000006A   1146               MOV      R1,R2
   \   0000006C   8268               LDR      R2,[R0, #+8]
   \   0000006E   9142               CMP      R1,R2
   \   00000070   01D1               BNE.N    ??OSQPend_9
    426                      pq->OSQOut = pq->OSQStart;
   \   00000072   4168               LDR      R1,[R0, #+4]
   \   00000074   0161               STR      R1,[R0, #+16]
    427                  }
    428                  OS_EXIT_CRITICAL();
   \                     ??OSQPend_9:
   \   00000076   2800               MOVS     R0,R5
   \   00000078   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT

⌨️ 快捷键说明

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