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

📄 os_q.s79

📁 ARM仿真案例
💻 S79
📖 第 1 页 / 共 5 页
字号:
??OSQDel_0:
        CMP      R4,#+0
        BNE      ??OSQDel_3
//  213         *err = OS_ERR_PEVENT_NULL;
        MOVS     R0,#+4
        B.N      ??OSQDel_1
//  214         return (pevent);
//  215     }
//  216 #endif
//  217     if (pevent->OSEventType != OS_EVENT_TYPE_Q) {          /* Validate event block type                */
??OSQDel_3:
        LDRB     R0,[R4, #+0]
        CMP      R0,#+2
        BEQ      ??OSQDel_4
//  218         *err = OS_ERR_EVENT_TYPE;
        MOVS     R0,#+1
        B.N      ??OSQDel_5
//  219         return (pevent);
//  220     }
//  221     OS_ENTER_CRITICAL();
??OSQDel_4:
        _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
        MOVS     R6,R0
//  222     if (pevent->OSEventGrp != 0x00) {                      /* See if any tasks waiting on queue        */
        LDRB     R0,[R4, #+1]
        CMP      R0,#+0
        BEQ      ??OSQDel_6
//  223         tasks_waiting = TRUE;                              /* Yes                                      */
        MOVS     R7,#+1
        B        ??OSQDel_7
//  224     } else {
//  225         tasks_waiting = FALSE;                             /* No                                       */
??OSQDel_6:
        MOVS     R7,#+0
//  226     }
//  227     switch (opt) {
??OSQDel_7:
        MOV      R0,SP
        LDRB     R0,[R0, #+0]
        CMP      R0,#+0
        BEQ      ??OSQDel_8
        CMP      R0,#+1
        BEQ      ??OSQDel_9
        B        ??OSQDel_10
//  228         case OS_DEL_NO_PEND:                               /* Delete queue only if no task waiting     */
//  229              if (tasks_waiting == FALSE) {
??OSQDel_8:
        CMP      R7,#+0
        BNE      ??OSQDel_11
//  230 #if OS_EVENT_NAME_SIZE > 1
//  231                  pevent->OSEventName[0] = '?';             /* Unknown name                             */
        MOVS     R0,#+63
        STRB     R0,[R4, #+16]
//  232                  pevent->OSEventName[1] = OS_ASCII_NUL;
        MOVS     R0,#+0
        STRB     R0,[R4, #+17]
//  233 #endif
//  234                  pq                     = (OS_Q *)pevent->OSEventPtr;  /* Return OS_Q to free list     */
        LDR      R0,[R4, #+4]
//  235                  pq->OSQPtr             = OSQFreeList;
        LDR      R1,??DataTable11  ;; OSQFreeList
        LDR      R1,[R1, #+0]
        STR      R1,[R0, #+0]
//  236                  OSQFreeList            = pq;
        LDR      R1,??DataTable11  ;; OSQFreeList
        STR      R0,[R1, #+0]
//  237                  pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
        MOVS     R0,#+0
        STRB     R0,[R4, #+0]
//  238                  pevent->OSEventPtr     = OSEventFreeList; /* Return Event Control Block to free list  */
        LDR      R0,??DataTable13  ;; OSEventFreeList
        LDR      R0,[R0, #+0]
        STR      R0,[R4, #+4]
//  239                  pevent->OSEventCnt     = 0;
        MOVS     R0,#+0
        STRH     R0,[R4, #+2]
//  240                  OSEventFreeList        = pevent;          /* Get next free event control block        */
        LDR      R0,??DataTable13  ;; OSEventFreeList
        STR      R4,[R0, #+0]
//  241                  OS_EXIT_CRITICAL();
        MOVS     R0,R6
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  242                  *err                   = OS_NO_ERR;
??OSQDel_12:
        MOVS     R0,#+0
        STRB     R0,[R5, #+0]
//  243                  return ((OS_EVENT *)0);                   /* Queue has been deleted                   */
        B        ??OSQDel_2
//  244              } else {
//  245                  OS_EXIT_CRITICAL();
??OSQDel_11:
        MOVS     R0,R6
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  246                  *err                   = OS_ERR_TASK_WAITING;
        MOVS     R0,#+8
        B.N      ??OSQDel_5
//  247                  return (pevent);
//  248              }
//  249 
//  250         case OS_DEL_ALWAYS:                                /* Always delete the queue                  */
//  251              while (pevent->OSEventGrp != 0x00) {          /* Ready ALL tasks waiting for queue        */
//  252                  OS_EventTaskRdy(pevent, (void *)0, OS_STAT_Q);
??OSQDel_13:
        MOVS     R2,#+4
        MOVS     R1,#+0
        MOVS     R0,R4
        _BLF     OS_EventTaskRdy,??OS_EventTaskRdy??rT
//  253              }
??OSQDel_9:
        LDRB     R0,[R4, #+1]
        CMP      R0,#+0
        BNE      ??OSQDel_13
//  254 #if OS_EVENT_NAME_SIZE > 1
//  255              pevent->OSEventName[0] = '?';                 /* Unknown name                             */
        MOVS     R0,#+63
        STRB     R0,[R4, #+16]
//  256              pevent->OSEventName[1] = OS_ASCII_NUL;
        MOVS     R0,#+0
        STRB     R0,[R4, #+17]
//  257 #endif
//  258              pq                     = (OS_Q *)pevent->OSEventPtr;   /* Return OS_Q to free list        */
        LDR      R0,[R4, #+4]
//  259              pq->OSQPtr             = OSQFreeList;
        LDR      R1,??DataTable11  ;; OSQFreeList
        LDR      R1,[R1, #+0]
        STR      R1,[R0, #+0]
//  260              OSQFreeList            = pq;
        LDR      R1,??DataTable11  ;; OSQFreeList
        STR      R0,[R1, #+0]
//  261              pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
        MOVS     R0,#+0
        STRB     R0,[R4, #+0]
//  262              pevent->OSEventPtr     = OSEventFreeList;     /* Return Event Control Block to free list  */
        LDR      R0,??DataTable13  ;; OSEventFreeList
        LDR      R0,[R0, #+0]
        STR      R0,[R4, #+4]
//  263              pevent->OSEventCnt     = 0;
        MOVS     R0,#+0
        STRH     R0,[R4, #+2]
//  264              OSEventFreeList        = pevent;              /* Get next free event control block        */
        LDR      R0,??DataTable13  ;; OSEventFreeList
        STR      R4,[R0, #+0]
//  265              OS_EXIT_CRITICAL();
        MOVS     R0,R6
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  266              if (tasks_waiting == TRUE) {                  /* Reschedule only if task(s) were waiting  */
        CMP      R7,#+1
        BNE      ??OSQDel_12
//  267                  OS_Sched();                               /* Find highest priority task ready to run  */
        _BLF     OS_Sched,??OS_Sched??rT
//  268              }
//  269              *err = OS_NO_ERR;
??OSQDel_14:
        B.N      ??OSQDel_12
//  270              return ((OS_EVENT *)0);                       /* Queue has been deleted                   */
//  271 
//  272         default:
//  273              OS_EXIT_CRITICAL();
??OSQDel_10:
        MOVS     R0,R6
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  274              *err = OS_ERR_INVALID_OPT;
        MOVS     R0,#+7
??OSQDel_5:
        STRB     R0,[R5, #+0]
//  275              return (pevent);
        MOVS     R0,R4
??OSQDel_2:
        ADD      SP,SP,#+4
        CFI CFA R13+20
        POP      {R4-R7}
        POP      {R1}
        BX       R1               ;; return
        CFI EndBlock cfiBlock5
//  276     }
//  277 }

        RSEG CODE:CODE:NOROOT(2)
        DATA
??DataTable11:
        DC32     OSQFreeList

        RSEG CODE:CODE:NOROOT(2)
        DATA
??DataTable13:
        DC32     OSEventFreeList

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock6 Using cfiCommon0
        CFI NoFunction
        ARM
??OSQFlush??rA:
        ADD      R12,PC,#+1
        BX       R12
        CFI EndBlock cfiBlock6
        REQUIRE OSQFlush
//  278 #endif
//  279 
//  280 /*$PAGE*/
//  281 /*
//  282 *********************************************************************************************************
//  283 *                                             FLUSH QUEUE
//  284 *
//  285 * Description : This function is used to flush the contents of the message queue.
//  286 *
//  287 * Arguments   : none
//  288 *
//  289 * Returns     : OS_NO_ERR           upon success
//  290 *               OS_ERR_EVENT_TYPE   If you didn't pass a pointer to a queue
//  291 *               OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer
//  292 *
//  293 * WARNING     : You should use this function with great care because, when to flush the queue, you LOOSE
//  294 *               the references to what the queue entries are pointing to and thus, you could cause
//  295 *               'memory leaks'.  In other words, the data you are pointing to that's being referenced
//  296 *               by the queue entries should, most likely, need to be de-allocated (i.e. freed).
//  297 *********************************************************************************************************
//  298 */
//  299 
//  300 #if OS_Q_FLUSH_EN > 0

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock7 Using cfiCommon1
        CFI Function OSQFlush
        THUMB
//  301 INT8U  OSQFlush (OS_EVENT *pevent)
//  302 {
OSQFlush:
        PUSH     {R4,LR}
        CFI ?RET Frame(CFA, -4)
        CFI R4 Frame(CFA, -8)
        CFI CFA R13+8
        MOVS     R4,R0
//  303 #if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
//  304     OS_CPU_SR  cpu_sr;
//  305 #endif
//  306     OS_Q      *pq;
//  307 
//  308 
//  309 #if OS_ARG_CHK_EN > 0
//  310     if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        BNE      ??OSQFlush_0
//  311         return (OS_ERR_PEVENT_NULL);
        MOVS     R0,#+4
        B        ??OSQFlush_1
//  312     }
//  313     if (pevent->OSEventType != OS_EVENT_TYPE_Q) {     /* Validate event block type                     */
??OSQFlush_0:
        LDRB     R0,[R4, #+0]
        CMP      R0,#+2
        BEQ      ??OSQFlush_2
//  314         return (OS_ERR_EVENT_TYPE);
        MOVS     R0,#+1
        B        ??OSQFlush_1
//  315     }
//  316 #endif
//  317     OS_ENTER_CRITICAL();
??OSQFlush_2:
        _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
//  318     pq             = (OS_Q *)pevent->OSEventPtr;      /* Point to queue storage structure              */
        LDR      R1,[R4, #+4]
//  319     pq->OSQIn      = pq->OSQStart;
        LDR      R2,[R1, #+4]
        STR      R2,[R1, #+12]
//  320     pq->OSQOut     = pq->OSQStart;
        STR      R2,[R1, #+16]
//  321     pq->OSQEntries = 0;
        MOVS     R2,#+0
        STRH     R2,[R1, #+22]
//  322     OS_EXIT_CRITICAL();
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  323     return (OS_NO_ERR);
        MOVS     R0,#+0
??OSQFlush_1:
        POP      {R4}
        POP      {R1}
        BX       R1               ;; return
        CFI EndBlock cfiBlock7
//  324 }

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock8 Using cfiCommon0
        CFI NoFunction
        ARM
??OSQPend??rA:
        ADD      R12,PC,#+1
        BX       R12
        CFI EndBlock cfiBlock8
        REQUIRE OSQPend
//  325 #endif
//  326 
//  327 /*$PAGE*/
//  328 /*
//  329 *********************************************************************************************************
//  330 *                                     PEND ON A QUEUE FOR A MESSAGE
//  331 *
//  332 * Description: This function waits for a message to be sent to a queue
//  333 *
//  334 * Arguments  : pevent        is a pointer to the event control block associated with the desired queue
//  335 *
//  336 *              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
//  337 *                            wait for a message to arrive at the queue up to the amount of time
//  338 *                            specified by this argument.  If you specify 0, however, your task will wait
//  339 *                            forever at the specified queue or, until a message arrives.
//  340 *
//  341 *              err           is a pointer to where an error message will be deposited.  Possible error
//  342 *                            messages are:
//  343 *
//  344 *                            OS_NO_ERR           The call was successful and your task received a
//  345 *                                                message.
//  346 *                            OS_TIMEOUT          A message was not received within the specified timeout
//  347 *                            OS_ERR_EVENT_TYPE   You didn't pass a pointer to a queue
//  348 *                            OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer

⌨️ 快捷键说明

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