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

📄 os_task.s79

📁 ARM仿真案例
💻 S79
📖 第 1 页 / 共 5 页
字号:
//  299             OS_EXIT_CRITICAL();
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  300             if (OSRunning == TRUE) {                           /* Find HPT if multitasking has started */
        LDR      R0,??DataTable22  ;; OSRunning
        LDRB     R0,[R0, #+0]
        CMP      R0,#+1
        BNE      ??OSTaskCreateExt_4
//  301                 OS_Sched();
        _BLF     OS_Sched,??OS_Sched??rT
        B        ??OSTaskCreateExt_4
//  302             }
//  303         } else {
//  304             OS_ENTER_CRITICAL();
??OSTaskCreateExt_3:
        _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
//  305             OSTCBPrioTbl[prio] = (OS_TCB *)0;                  /* Make this priority avail. to others  */
        LSLS     R1,R5,#+2
        LDR      R2,??DataTable23  ;; OSTCBPrioTbl
        MOVS     R3,#+0
        STR      R3,[R2, R1]
//  306             OS_EXIT_CRITICAL();
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  307         }
//  308         return (err);
??OSTaskCreateExt_4:
        MOVS     R0,R4
        B        ??OSTaskCreateExt_1
//  309     }
//  310     OS_EXIT_CRITICAL();
??OSTaskCreateExt_2:
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  311     return (OS_PRIO_EXIST);
        MOVS     R0,#+40
??OSTaskCreateExt_1:
        ADD      SP,SP,#+8
        CFI CFA R13+20
        POP      {R4-R7}
        POP      {R1}
        BX       R1               ;; return
        CFI EndBlock cfiBlock5
//  312 }

        RSEG CODE:CODE:NOROOT(2)
        DATA
??DataTable22:
        DC32     OSRunning

        RSEG CODE:CODE:NOROOT(2)
        DATA
??DataTable23:
        DC32     OSTCBPrioTbl

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock6 Using cfiCommon0
        CFI NoFunction
        ARM
??OSTaskDel??rA:
        ADD      R12,PC,#+1
        BX       R12
        CFI EndBlock cfiBlock6
        REQUIRE OSTaskDel
//  313 #endif
//  314 
//  315 /*
//  316 *********************************************************************************************************
//  317 *                                            DELETE A TASK
//  318 *
//  319 * Description: This function allows you to delete a task.  The calling task can delete itself by
//  320 *              its own priority number.  The deleted task is returned to the dormant state and can be
//  321 *              re-activated by creating the deleted task again.
//  322 *
//  323 * Arguments  : prio    is the priority of the task to delete.  Note that you can explicitely delete
//  324 *                      the current task without knowing its priority level by setting 'prio' to
//  325 *                      OS_PRIO_SELF.
//  326 *
//  327 * Returns    : OS_NO_ERR           if the call is successful
//  328 *              OS_TASK_DEL_IDLE    if you attempted to delete uC/OS-II's idle task
//  329 *              OS_PRIO_INVALID     if the priority you specify is higher that the maximum allowed
//  330 *                                  (i.e. >= OS_LOWEST_PRIO) or, you have not specified OS_PRIO_SELF.
//  331 *              OS_TASK_DEL_ERR     if the task you want to delete does not exist
//  332 *              OS_TASK_DEL_ISR     if you tried to delete a task from an ISR
//  333 *
//  334 * Notes      : 1) To reduce interrupt latency, OSTaskDel() 'disables' the task:
//  335 *                    a) by making it not ready
//  336 *                    b) by removing it from any wait lists
//  337 *                    c) by preventing OSTimeTick() from making the task ready to run.
//  338 *                 The task can then be 'unlinked' from the miscellaneous structures in uC/OS-II.
//  339 *              2) The function OS_Dummy() is called after OS_EXIT_CRITICAL() because, on most processors,
//  340 *                 the next instruction following the enable interrupt instruction is ignored.  
//  341 *              3) An ISR cannot delete a task.
//  342 *              4) The lock nesting counter is incremented because, for a brief instant, if the current
//  343 *                 task is being deleted, the current task would not be able to be rescheduled because it
//  344 *                 is removed from the ready list.  Incrementing the nesting counter prevents another task
//  345 *                 from being schedule.  This means that an ISR would return to the current task which is
//  346 *                 being deleted.  The rest of the deletion would thus be able to be completed.
//  347 *********************************************************************************************************
//  348 */
//  349 
//  350 #if OS_TASK_DEL_EN > 0

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock7 Using cfiCommon1
        CFI Function OSTaskDel
        THUMB
//  351 INT8U  OSTaskDel (INT8U prio)
//  352 {
OSTaskDel:
        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     R5,R0
//  353 #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
//  354     OS_CPU_SR     cpu_sr;
//  355 #endif
//  356 
//  357 #if OS_EVENT_EN > 0
//  358     OS_EVENT     *pevent;
//  359 #endif    
//  360 #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
//  361     OS_FLAG_NODE *pnode;
//  362 #endif
//  363     OS_TCB       *ptcb;
//  364 	INT8U         y;
//  365 
//  366 
//  367 
//  368     if (OSIntNesting > 0) {                                     /* See if trying to delete from ISR    */
        LDR      R0,??OSTaskDel_0  ;; OSIntNesting
        LDRB     R0,[R0, #+0]
        CMP      R0,#+0
        BEQ      ??OSTaskDel_1
//  369         return (OS_TASK_DEL_ISR);
        MOVS     R0,#+63
        B        ??OSTaskDel_2
//  370     }
//  371 #if OS_ARG_CHK_EN > 0
//  372     if (prio == OS_IDLE_PRIO) {                                 /* Not allowed to delete idle task     */
??OSTaskDel_1:
        CMP      R5,#+63
        BNE      ??OSTaskDel_3
//  373         return (OS_TASK_DEL_IDLE);
        MOVS     R0,#+61
        B        ??OSTaskDel_2
//  374     }
//  375     if (prio >= OS_LOWEST_PRIO && prio != OS_PRIO_SELF) {       /* Task priority valid ?               */
??OSTaskDel_3:
        BCC      ??OSTaskDel_4
        CMP      R5,#+255
        BEQ      ??OSTaskDel_4
//  376         return (OS_PRIO_INVALID);
        MOVS     R0,#+42
        B        ??OSTaskDel_2
//  377     }
//  378 #endif
//  379     OS_ENTER_CRITICAL();
??OSTaskDel_4:
        _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
        MOVS     R4,R0
//  380     if (prio == OS_PRIO_SELF) {                                 /* See if requesting to delete self    */
        CMP      R5,#+255
        BNE      ??OSTaskDel_5
//  381         prio = OSTCBCur->OSTCBPrio;                             /* Set priority to delete to current   */
        LDR      R0,??DataTable38  ;; OSTCBCur
        LDR      R0,[R0, #+0]
        ADDS     R0,R0,#+45
        LDRB     R5,[R0, #+0]
//  382     }
//  383     ptcb = OSTCBPrioTbl[prio];
??OSTaskDel_5:
        LSLS     R0,R5,#+2
        LDR      R1,??DataTable40  ;; OSTCBPrioTbl
        LDR      R6,[R1, R0]
//  384     if (ptcb != (OS_TCB *)0) {                                  /* Task to delete must exist           */
        CMP      R6,#+0
        BEQ      ??OSTaskDel_6
//  385 	    y            =  ptcb->OSTCBY;
        MOVS     R0,#+47
        LDRB     R1,[R6, R0]
//  386 		OSRdyTbl[y] &= ~ptcb->OSTCBBitX;
        LDR      R3,??DataTable44  ;; OSRdyTbl
        LDR      R7,??DataTable44  ;; OSRdyTbl
        LDRB     R2,[R7, R1]
        MOVS     R7,#+48
        LDRB     R7,[R6, R7]
        BICS     R2,R2,R7
        STRB     R2,[R3, R1]
//  387         if (OSRdyTbl[y] == 0x00) {                              /* Make task not ready                 */
        LDR      R2,??DataTable44  ;; OSRdyTbl
        LDRB     R0,[R2, R1]
        CMP      R0,#+0
        BNE      ??OSTaskDel_7
//  388             OSRdyGrp &= ~ptcb->OSTCBBitY;
        LDR      R0,??DataTable42  ;; OSRdyGrp
        LDR      R2,??DataTable42  ;; OSRdyGrp
        LDRB     R2,[R2, #+0]
        MOVS     R3,#+49
        LDRB     R3,[R6, R3]
        BICS     R2,R2,R3
        STRB     R2,[R0, #+0]
//  389         }
//  390 #if OS_EVENT_EN > 0
//  391         pevent = ptcb->OSTCBEventPtr;
??OSTaskDel_7:
        LDR      R2,[R6, #+28]
//  392         if (pevent != (OS_EVENT *)0) {                          /* If task is waiting on event         */
        CMP      R2,#+0
        BEQ      ??OSTaskDel_8
//  393 		    pevent->OSEventTbl[y] &= ~ptcb->OSTCBBitX;
        ADDS     R0,R2,R1
        ADDS     R3,R2,R1
        LDRB     R3,[R3, #+8]
        MOVS     R7,#+48
        LDRB     R7,[R6, R7]
        BICS     R3,R3,R7
        STRB     R3,[R0, #+8]
//  394             if (pevent->OSEventTbl[y] == 0) {                   /* ... remove task from ...            */
        LDRB     R0,[R0, #+8]
        CMP      R0,#+0
        BNE      ??OSTaskDel_8
//  395                 pevent->OSEventGrp &= ~ptcb->OSTCBBitY;         /* ... event ctrl block                */
        LDRB     R0,[R2, #+1]
        MOVS     R1,#+49
        LDRB     R1,[R6, R1]
        BICS     R0,R0,R1
        STRB     R0,[R2, #+1]
//  396             }
//  397         }
//  398 #endif
//  399 #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
//  400         pnode = ptcb->OSTCBFlagNode;
??OSTaskDel_8:
        LDR      R0,[R6, #+36]
//  401         if (pnode != (OS_FLAG_NODE *)0) {                       /* If task is waiting on event flag    */
        CMP      R0,#+0
        BEQ      ??OSTaskDel_9
//  402             OS_FlagUnlink(pnode);                               /* Remove from wait list               */
        _BLF     OS_FlagUnlink,??OS_FlagUnlink??rT
//  403         }
//  404 #endif
//  405         ptcb->OSTCBDly  = 0;                                    /* Prevent OSTimeTick() from updating  */
??OSTaskDel_9:
        MOVS     R0,#+0
        STRH     R0,[R6, #+42]
//  406         ptcb->OSTCBStat = OS_STAT_RDY;                          /* Prevent task from being resumed     */
        MOVS     R0,#+44
        MOVS     R1,#+0
        STRB     R1,[R6, R0]
//  407 		if (OSLockNesting < 255u) {
        LDR      R0,??OSTaskDel_0+0x4  ;; OSLockNesting
        LDRB     R0,[R0, #+0]
        CMP      R0,#+255
        BEQ      ??OSTaskDel_10
//  408             OSLockNesting++;
        LDR      R0,??OSTaskDel_0+0x4  ;; OSLockNesting
        LDR      R1,??OSTaskDel_0+0x4  ;; OSLockNesting
        LDRB     R1,[R1, #+0]
        ADDS     R1,R1,#+1
        STRB     R1,[R0, #+0]
//  409 		}
//  410         OS_EXIT_CRITICAL();                                     /* Enabling INT. ignores next instruc. */
??OSTaskDel_10:
        MOVS     R0,R4
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  411         OS_Dummy();                                             /* ... Dummy ensures that INTs will be */
        _BLF     OS_Dummy,??OS_Dummy??rT
//  412         OS_ENTER_CRITICAL();                                    /* ... disabled HERE!                  */
        _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
        MOVS     R4,R0
//  413 		if (OSLockNesting > 0) {
        LDR      R0,??OSTaskDel_0+0x4  ;; OSLockNesting
        LDRB     R0,[R0, #+0]
        CMP      R0,#+0
        BEQ      ??OSTaskDel_11
//  414             OSLockNesting--;
        LDR      R0,??OSTaskDel_0+0x4  ;; OSLockNesting
        LDR      R1,??OSTaskDel_0+0x4  ;; OSLockNesting
        LDRB     R1,[R1, #+0]
        SUBS     R1,R1,#+1
        STRB     R1,[R0, #+0]
//  415 		}
//  416         OSTaskDelHook(ptcb);                                    /* Call user defined hook              */
??OSTaskDel_11:
        MOVS     R0,R6
        _BLF     OSTaskDelHook,??OSTaskDelHook??rT
//  417         OSTaskCtr--;                                            /* One less task being managed         */
        LDR      R0,??DataTable32  ;; OSTaskCtr
        LDR      R1,??DataTable32  ;; OSTaskCtr
        LDRB     R1,[R1, #+0]
        SUBS     R1,R1,#+1
        STRB     R1,[R0, #+0]
//  418         OSTCBPrioTbl[prio] = (OS_TCB *)0;                       /* Clear old priority entry            */
        LSLS     R0,R5,#+2
        LDR      R1,??DataTable40  ;; OSTCBPrioTbl
        MOVS     R2,#+0
        STR      R2,[R1, R0]
//  419         if (ptcb->OSTCBPrev == (OS_TCB *)0) {                   /* Remove from TCB chain               */
        LDR      R0,[R6, #+24]
        CMP      R0,#+0
        BNE      ??OSTaskDel_12
//  420             ptcb->OSTCBNext->OSTCBPrev = (OS_TCB *)0;
        LDR      R0,[R6, #+20]
        STR      R2,[R0, #+24]
//  421             OSTCBList                  = ptcb->OSTCBNext;
        LDR      R0,??OSTaskDel_0+0x8  ;; OSTCBList
        LDR      R1,[R6, #+20]
        STR      R1,[R0, #+0]
        B        ??OSTaskDel_13
//  422         } else {
//  423             ptcb->OSTCBPrev->OSTCBNext = ptcb->OSTCBNext;
??OSTaskDel_12:

⌨️ 快捷键说明

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