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

📄 os_q.s79

📁 ARM仿真案例
💻 S79
📖 第 1 页 / 共 5 页
字号:
//   64         return ((void *)0);
        MOVS     R0,#+0
        B        ??OSQAccept_2
//   65     }
//   66 #endif
//   67     if (pevent->OSEventType != OS_EVENT_TYPE_Q) {/* Validate event block type                          */
??OSQAccept_0:
        LDRB     R0,[R5, #+0]
        CMP      R0,#+2
        BEQ      ??OSQAccept_3
//   68         *err = OS_ERR_EVENT_TYPE;
        MOVS     R0,#+1
        B.N      ??OSQAccept_1
//   69         return ((void *)0);
//   70     }
//   71     OS_ENTER_CRITICAL();
??OSQAccept_3:
        _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
//   72     pq = (OS_Q *)pevent->OSEventPtr;             /* Point at queue control block                       */
        LDR      R1,[R5, #+4]
//   73     if (pq->OSQEntries > 0) {                    /* See if any messages in the queue                   */
        LDRH     R2,[R1, #+22]
        CMP      R2,#+0
        BEQ      ??OSQAccept_4
//   74         msg = *pq->OSQOut++;                     /* Yes, extract oldest message from the queue         */
        LDR      R2,[R1, #+16]
        ADDS     R3,R2,#+4
        STR      R3,[R1, #+16]
        LDR      R5,[R2, #+0]
//   75         pq->OSQEntries--;                        /* Update the number of entries in the queue          */
        LDRH     R2,[R1, #+22]
        SUBS     R2,R2,#+1
        STRH     R2,[R1, #+22]
//   76         if (pq->OSQOut == pq->OSQEnd) {          /* Wrap OUT pointer if we are at the end of the queue */
        MOVS     R2,R3
        LDR      R3,[R1, #+8]
        CMP      R2,R3
        BNE      ??OSQAccept_5
//   77             pq->OSQOut = pq->OSQStart;
        LDR      R2,[R1, #+4]
        STR      R2,[R1, #+16]
//   78         }
//   79         *err = OS_NO_ERR;
??OSQAccept_5:
        MOVS     R1,#+0
        B        ??OSQAccept_6
//   80     } else {
//   81         *err = OS_Q_EMPTY;
??OSQAccept_4:
        MOVS     R1,#+31
//   82         msg  = (void *)0;                        /* Queue is empty                                     */
        MOVS     R5,#+0
??OSQAccept_6:
        STRB     R1,[R4, #+0]
//   83     }
//   84     OS_EXIT_CRITICAL();
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//   85     return (msg);                                /* Return message received (or NULL)                  */
        MOVS     R0,R5
??OSQAccept_2:
        POP      {R4,R5}
        POP      {R1}
        BX       R1               ;; return
        CFI EndBlock cfiBlock1
//   86 }

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock2 Using cfiCommon0
        CFI NoFunction
        ARM
??OSQCreate??rA:
        ADD      R12,PC,#+1
        BX       R12
        CFI EndBlock cfiBlock2
        REQUIRE OSQCreate
//   87 #endif
//   88 /*$PAGE*/
//   89 /*
//   90 *********************************************************************************************************
//   91 *                                        CREATE A MESSAGE QUEUE
//   92 *
//   93 * Description: This function creates a message queue if free event control blocks are available.
//   94 *
//   95 * Arguments  : start         is a pointer to the base address of the message queue storage area.  The
//   96 *                            storage area MUST be declared as an array of pointers to 'void' as follows
//   97 *
//   98 *                            void *MessageStorage[size]
//   99 *
//  100 *              size          is the number of elements in the storage area
//  101 *
//  102 * Returns    : != (OS_EVENT *)0  is a pointer to the event control clock (OS_EVENT) associated with the
//  103 *                                created queue
//  104 *              == (OS_EVENT *)0  if no event control blocks were available or an error was detected
//  105 *********************************************************************************************************
//  106 */
//  107 

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock3 Using cfiCommon1
        CFI Function OSQCreate
        THUMB
//  108 OS_EVENT  *OSQCreate (void **start, INT16U size)
//  109 {
OSQCreate:
        PUSH     {R4-R7,LR}
        CFI ?RET Frame(CFA, -4)
        CFI R7 Frame(CFA, -8)
        CFI R6 Frame(CFA, -12)
        CFI R5 Frame(CFA, -16)
        CFI R4 Frame(CFA, -20)
        CFI CFA R13+20
        MOVS     R4,R0
        MOVS     R5,R1
//  110 #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
//  111     OS_CPU_SR  cpu_sr;
//  112 #endif
//  113     OS_EVENT  *pevent;
//  114     OS_Q      *pq;
//  115 
//  116 
//  117     if (OSIntNesting > 0) {                      /* See if called from ISR ...                         */
        LDR      R0,??DataTable14  ;; OSIntNesting
        LDRB     R0,[R0, #+0]
        CMP      R0,#+0
        BEQ      ??OSQCreate_0
//  118         return ((OS_EVENT *)0);                  /* ... can't CREATE from an ISR                       */
        MOVS     R0,#+0
        B        ??OSQCreate_1
//  119     }
//  120     OS_ENTER_CRITICAL();
??OSQCreate_0:
        _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
//  121     pevent = OSEventFreeList;                    /* Get next free event control block                  */
        LDR      R1,??DataTable13  ;; OSEventFreeList
        LDR      R6,[R1, #+0]
//  122     if (OSEventFreeList != (OS_EVENT *)0) {      /* See if pool of free ECB pool was empty             */
        CMP      R6,#+0
        BEQ      ??OSQCreate_2
//  123         OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
        LDR      R2,[R6, #+4]
        STR      R2,[R1, #+0]
//  124     }
//  125     OS_EXIT_CRITICAL();
??OSQCreate_2:
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  126     if (pevent != (OS_EVENT *)0) {               /* See if we have an event control block              */
        CMP      R6,#+0
        BEQ      ??OSQCreate_3
//  127         OS_ENTER_CRITICAL();
        _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
//  128         pq = OSQFreeList;                        /* Get a free queue control block                     */
        LDR      R1,??DataTable11  ;; OSQFreeList
        LDR      R7,[R1, #+0]
//  129         if (pq != (OS_Q *)0) {                   /* Were we able to get a queue control block ?        */
        CMP      R7,#+0
        BEQ      ??OSQCreate_4
//  130             OSQFreeList            = OSQFreeList->OSQPtr; /* Yes, Adjust free list pointer to next free*/
        LDR      R2,[R7, #+0]
        STR      R2,[R1, #+0]
//  131             OS_EXIT_CRITICAL();
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  132             pq->OSQStart           = start;               /*      Initialize the queue                 */
        STR      R4,[R7, #+4]
//  133             pq->OSQEnd             = &start[size];
        LSLS     R0,R5,#+2
        ADDS     R0,R4,R0
        STR      R0,[R7, #+8]
//  134             pq->OSQIn              = start;
        STR      R4,[R7, #+12]
//  135             pq->OSQOut             = start;
        STR      R4,[R7, #+16]
//  136             pq->OSQSize            = size;
        STRH     R5,[R7, #+20]
//  137             pq->OSQEntries         = 0;
        MOVS     R0,#+0
        STRH     R0,[R7, #+22]
//  138             pevent->OSEventType    = OS_EVENT_TYPE_Q;
        MOVS     R0,#+2
        STRB     R0,[R6, #+0]
//  139             pevent->OSEventCnt     = 0;
        MOVS     R0,#+0
        STRH     R0,[R6, #+2]
//  140             pevent->OSEventPtr     = pq;
        STR      R7,[R6, #+4]
//  141 #if OS_EVENT_NAME_SIZE > 1
//  142             pevent->OSEventName[0] = '?';                  /* Unknown name                             */
        MOVS     R0,#+63
        STRB     R0,[R6, #+16]
//  143             pevent->OSEventName[1] = OS_ASCII_NUL;
        MOVS     R0,#+0
        STRB     R0,[R6, #+17]
//  144 #endif
//  145             OS_EventWaitListInit(pevent);                 /*      Initalize the wait list              */
        MOVS     R0,R6
        _BLF     OS_EventWaitListInit,??OS_EventWaitListInit??rT
        B        ??OSQCreate_3
//  146         } else {
//  147             pevent->OSEventPtr = (void *)OSEventFreeList; /* No,  Return event control block on error  */
??OSQCreate_4:
        LDR      R1,??DataTable13  ;; OSEventFreeList
        LDR      R1,[R1, #+0]
        STR      R1,[R6, #+4]
//  148             OSEventFreeList    = pevent;
        LDR      R1,??DataTable13  ;; OSEventFreeList
        STR      R6,[R1, #+0]
//  149             OS_EXIT_CRITICAL();
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  150             pevent = (OS_EVENT *)0;
        MOVS     R6,#+0
//  151         }
//  152     }
//  153     return (pevent);
??OSQCreate_3:
        MOVS     R0,R6
??OSQCreate_1:
        POP      {R4-R7}
        POP      {R1}
        BX       R1               ;; return
        CFI EndBlock cfiBlock3
//  154 }

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock4 Using cfiCommon0
        CFI NoFunction
        ARM
??OSQDel??rA:
        ADD      R12,PC,#+1
        BX       R12
        CFI EndBlock cfiBlock4
        REQUIRE OSQDel
//  155 /*$PAGE*/
//  156 /*
//  157 *********************************************************************************************************
//  158 *                                        DELETE A MESSAGE QUEUE
//  159 *
//  160 * Description: This function deletes a message queue and readies all tasks pending on the queue.
//  161 *
//  162 * Arguments  : pevent        is a pointer to the event control block associated with the desired
//  163 *                            queue.
//  164 *
//  165 *              opt           determines delete options as follows:
//  166 *                            opt == OS_DEL_NO_PEND   Delete the queue ONLY if no task pending
//  167 *                            opt == OS_DEL_ALWAYS    Deletes the queue even if tasks are waiting.
//  168 *                                                    In this case, all the tasks pending will be readied.
//  169 *
//  170 *              err           is a pointer to an error code that can contain one of the following values:
//  171 *                            OS_NO_ERR               The call was successful and the queue was deleted
//  172 *                            OS_ERR_DEL_ISR          If you tried to delete the queue from an ISR
//  173 *                            OS_ERR_INVALID_OPT      An invalid option was specified
//  174 *                            OS_ERR_TASK_WAITING     One or more tasks were waiting on the queue
//  175 *                            OS_ERR_EVENT_TYPE       If you didn't pass a pointer to a queue
//  176 *                            OS_ERR_PEVENT_NULL      If 'pevent' is a NULL pointer.
//  177 *
//  178 * Returns    : pevent        upon error
//  179 *              (OS_EVENT *)0 if the queue was successfully deleted.
//  180 *
//  181 * Note(s)    : 1) This function must be used with care.  Tasks that would normally expect the presence of
//  182 *                 the queue MUST check the return code of OSQPend().
//  183 *              2) OSQAccept() callers will not know that the intended queue has been deleted unless
//  184 *                 they check 'pevent' to see that it's a NULL pointer.
//  185 *              3) This call can potentially disable interrupts for a long time.  The interrupt disable
//  186 *                 time is directly proportional to the number of tasks waiting on the queue.
//  187 *              4) Because ALL tasks pending on the queue will be readied, you MUST be careful in
//  188 *                 applications where the queue is used for mutual exclusion because the resource(s)
//  189 *                 will no longer be guarded by the queue.
//  190 *              5) If the storage for the message queue was allocated dynamically (i.e. using a malloc()
//  191 *                 type call) then your application MUST release the memory storage by call the counterpart
//  192 *                 call of the dynamic allocation scheme used.  If the queue storage was created statically
//  193 *                 then, the storage can be reused.
//  194 *********************************************************************************************************
//  195 */
//  196 
//  197 #if OS_Q_DEL_EN > 0

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock5 Using cfiCommon1
        CFI Function OSQDel
        THUMB
//  198 OS_EVENT  *OSQDel (OS_EVENT *pevent, INT8U opt, INT8U *err)
//  199 {
OSQDel:
        PUSH     {R1,R4-R7,LR}
        CFI ?RET Frame(CFA, -4)
        CFI R7 Frame(CFA, -8)
        CFI R6 Frame(CFA, -12)
        CFI R5 Frame(CFA, -16)
        CFI R4 Frame(CFA, -20)
        CFI CFA R13+24
        MOVS     R4,R0
        MOVS     R5,R2
//  200 #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
//  201     OS_CPU_SR  cpu_sr;
//  202 #endif
//  203     BOOLEAN    tasks_waiting;
//  204     OS_Q      *pq;
//  205 
//  206 
//  207     if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        LDR      R0,??DataTable14  ;; OSIntNesting
        LDRB     R0,[R0, #+0]
        CMP      R0,#+0
        BEQ      ??OSQDel_0
//  208         *err = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
        MOVS     R0,#+140
??OSQDel_1:
        STRB     R0,[R5, #+0]
//  209         return ((OS_EVENT *)0);
        MOVS     R0,#+0
        B        ??OSQDel_2
//  210     }
//  211 #if OS_ARG_CHK_EN > 0
//  212     if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */

⌨️ 快捷键说明

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