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

📄 os_task.s79

📁 ARM仿真案例
💻 S79
📖 第 1 页 / 共 5 页
字号:
        LDR      R1,[R6, #+20]
        STR      R1,[R0, #+20]
//  424             ptcb->OSTCBNext->OSTCBPrev = ptcb->OSTCBPrev;
        LDR      R0,[R6, #+20]
        LDR      R1,[R6, #+24]
        STR      R1,[R0, #+24]
//  425         }
//  426         ptcb->OSTCBNext   = OSTCBFreeList;                      /* Return TCB to free TCB list         */
??OSTaskDel_13:
        LDR      R0,??OSTaskDel_0+0xC  ;; OSTCBFreeList
        LDR      R0,[R0, #+0]
        STR      R0,[R6, #+20]
//  427         OSTCBFreeList     = ptcb;
        LDR      R0,??OSTaskDel_0+0xC  ;; OSTCBFreeList
        STR      R6,[R0, #+0]
//  428 #if OS_TASK_NAME_SIZE > 1
//  429         ptcb->OSTCBTaskName[0] = '?';                           /* Unknown name                        */
        MOVS     R0,#+72
        MOVS     R1,#+63
        STRB     R1,[R6, R0]
//  430         ptcb->OSTCBTaskName[1] = OS_ASCII_NUL;
        ADDS     R6,R6,#+73
        STRB     R2,[R6, #+0]
//  431 #endif
//  432         OS_EXIT_CRITICAL();
        MOVS     R0,R4
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  433         OS_Sched();                                             /* Find new highest priority task      */
        _BLF     OS_Sched,??OS_Sched??rT
//  434         return (OS_NO_ERR);
        MOVS     R0,#+0
        B        ??OSTaskDel_2
//  435     }
//  436     OS_EXIT_CRITICAL();
??OSTaskDel_6:
        MOVS     R0,R4
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  437     return (OS_TASK_DEL_ERR);
        MOVS     R0,#+60
??OSTaskDel_2:
        POP      {R4-R7}
        POP      {R1}
        BX       R1               ;; return
        Nop      
        DATA
??OSTaskDel_0:
        DC32     OSIntNesting
        DC32     OSLockNesting
        DC32     OSTCBList
        DC32     OSTCBFreeList
        CFI EndBlock cfiBlock7
//  438 }

        RSEG CODE:CODE:NOROOT(2)
        DATA
??DataTable32:
        DC32     OSTaskCtr

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock8 Using cfiCommon0
        CFI NoFunction
        ARM
??OSTaskDelReq??rA:
        ADD      R12,PC,#+1
        BX       R12
        CFI EndBlock cfiBlock8
        REQUIRE OSTaskDelReq
//  439 #endif
//  440 
//  441 /*
//  442 *********************************************************************************************************
//  443 *                                    REQUEST THAT A TASK DELETE ITSELF
//  444 *
//  445 * Description: This function is used to:
//  446 *                   a) notify a task to delete itself.
//  447 *                   b) to see if a task requested that the current task delete itself.
//  448 *              This function is a little tricky to understand.  Basically, you have a task that needs
//  449 *              to be deleted however, this task has resources that it has allocated (memory buffers,
//  450 *              semaphores, mailboxes, queues etc.).  The task cannot be deleted otherwise these
//  451 *              resources would not be freed.  The requesting task calls OSTaskDelReq() to indicate that
//  452 *              the task needs to be deleted.  Deleting of the task is however, deferred to the task to
//  453 *              be deleted.  For example, suppose that task #10 needs to be deleted.  The requesting task
//  454 *              example, task #5, would call OSTaskDelReq(10).  When task #10 gets to execute, it calls
//  455 *              this function by specifying OS_PRIO_SELF and monitors the returned value.  If the return
//  456 *              value is OS_TASK_DEL_REQ, another task requested a task delete.  Task #10 would look like
//  457 *              this:
//  458 *
//  459 *                   void Task(void *p_arg)
//  460 *                   {
//  461 *                       .
//  462 *                       .
//  463 *                       while (1) {
//  464 *                           OSTimeDly(1);
//  465 *                           if (OSTaskDelReq(OS_PRIO_SELF) == OS_TASK_DEL_REQ) {
//  466 *                               Release any owned resources;
//  467 *                               De-allocate any dynamic memory;
//  468 *                               OSTaskDel(OS_PRIO_SELF);
//  469 *                           }
//  470 *                       }
//  471 *                   }
//  472 *
//  473 * Arguments  : prio    is the priority of the task to request the delete from
//  474 *
//  475 * Returns    : OS_NO_ERR          if the task exist and the request has been registered
//  476 *              OS_TASK_NOT_EXIST  if the task has been deleted.  This allows the caller to know whether
//  477 *                                 the request has been executed.
//  478 *              OS_TASK_DEL_IDLE   if you requested to delete uC/OS-II's idle task
//  479 *              OS_PRIO_INVALID    if the priority you specify is higher that the maximum allowed
//  480 *                                 (i.e. >= OS_LOWEST_PRIO) or, you have not specified OS_PRIO_SELF.
//  481 *              OS_TASK_DEL_REQ    if a task (possibly another task) requested that the running task be
//  482 *                                 deleted.
//  483 *********************************************************************************************************
//  484 */
//  485 
//  486 #if OS_TASK_DEL_EN > 0

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock9 Using cfiCommon1
        CFI Function OSTaskDelReq
        THUMB
//  487 INT8U  OSTaskDelReq (INT8U prio)
//  488 {
OSTaskDelReq:
        PUSH     {R4,LR}
        CFI ?RET Frame(CFA, -4)
        CFI R4 Frame(CFA, -8)
        CFI CFA R13+8
        MOVS     R4,R0
//  489 #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
//  490     OS_CPU_SR  cpu_sr;
//  491 #endif
//  492     BOOLEAN    stat;
//  493     INT8U      err;
//  494     OS_TCB    *ptcb;
//  495 
//  496 
//  497 #if OS_ARG_CHK_EN > 0
//  498     if (prio == OS_IDLE_PRIO) {                                 /* Not allowed to delete idle task     */
        CMP      R4,#+63
        BNE      ??OSTaskDelReq_0
//  499         return (OS_TASK_DEL_IDLE);
        MOVS     R0,#+61
        B        ??OSTaskDelReq_1
//  500     }
//  501     if (prio >= OS_LOWEST_PRIO) {						        /* Task priority valid ?               */
??OSTaskDelReq_0:
        BCC      ??OSTaskDelReq_2
//  502         if (prio != OS_PRIO_SELF) {                       
        CMP      R4,#+255
        BEQ      ??OSTaskDelReq_2
//  503             return (OS_PRIO_INVALID);
        MOVS     R0,#+42
        B        ??OSTaskDelReq_1
//  504 		}
//  505     }
//  506 #endif
//  507     if (prio == OS_PRIO_SELF) {                                 /* See if a task is requesting to ...  */
??OSTaskDelReq_2:
        CMP      R4,#+255
        BNE      ??OSTaskDelReq_3
//  508         OS_ENTER_CRITICAL();                                    /* ... this task to delete itself      */
        _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
//  509         stat = OSTCBCur->OSTCBDelReq;                           /* Return request status to caller     */
        LDR      R1,??DataTable38  ;; OSTCBCur
        LDR      R1,[R1, #+0]
        ADDS     R1,R1,#+50
        LDRB     R4,[R1, #+0]
//  510         OS_EXIT_CRITICAL();
        B.N      ??OSTaskDelReq_4
//  511         return (stat);
//  512     }
//  513     OS_ENTER_CRITICAL();
??OSTaskDelReq_3:
        _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
//  514     ptcb = OSTCBPrioTbl[prio];
        LSLS     R1,R4,#+2
        LDR      R2,??DataTable40  ;; OSTCBPrioTbl
        LDR      R1,[R2, R1]
//  515     if (ptcb != (OS_TCB *)0) {                                  /* Task to delete must exist           */
        CMP      R1,#+0
        BEQ      ??OSTaskDelReq_5
//  516         ptcb->OSTCBDelReq = OS_TASK_DEL_REQ;                    /* Set flag indicating task to be DEL. */
        ADDS     R1,R1,#+50
        MOVS     R2,#+62
        STRB     R2,[R1, #+0]
//  517         err               = OS_NO_ERR;
        MOVS     R4,#+0
        B        ??OSTaskDelReq_4
//  518     } else {
//  519         err               = OS_TASK_NOT_EXIST;                  /* Task must be deleted                */
??OSTaskDelReq_5:
        MOVS     R4,#+11
//  520     }
//  521     OS_EXIT_CRITICAL();
??OSTaskDelReq_4:
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  522     return (err);
        MOVS     R0,R4
??OSTaskDelReq_1:
        POP      {R4}
        POP      {R1}
        BX       R1               ;; return
        CFI EndBlock cfiBlock9
//  523 }

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock10 Using cfiCommon0
        CFI NoFunction
        ARM
??OSTaskNameGet??rA:
        ADD      R12,PC,#+1
        BX       R12
        CFI EndBlock cfiBlock10
        REQUIRE OSTaskNameGet
//  524 #endif
//  525 
//  526 /*
//  527 *********************************************************************************************************
//  528 *                                        GET THE NAME OF A TASK
//  529 *
//  530 * Description: This function is called to obtain the name of a task.
//  531 *
//  532 * Arguments  : prio      is the priority of the task that you want to obtain the name from.
//  533 *
//  534 *              pname     is a pointer to an ASCII string that will receive the name of the task.  The 
//  535 *                        string must be able to hold at least OS_TASK_NAME_SIZE characters.
//  536 *
//  537 *              err       is a pointer to an error code that can contain one of the following values:
//  538 *
//  539 *                        OS_NO_ERR                  if the requested task is resumed
//  540 *                        OS_TASK_NOT_EXIST          if the task has not been created
//  541 *                        OS_PRIO_INVALID            if you specified an invalid priority:
//  542 *                                                   A higher value than the idle task or not OS_PRIO_SELF.
//  543 *                        OS_ERR_PNAME_NULL          You passed a NULL pointer for 'pname'
//  544 *
//  545 * Returns    : The length of the string or 0 if the task does not exist.
//  546 *********************************************************************************************************
//  547 */
//  548 
//  549 #if OS_TASK_NAME_SIZE > 1

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock11 Using cfiCommon1
        CFI Function OSTaskNameGet
        THUMB
//  550 INT8U  OSTaskNameGet (INT8U prio, char *pname, INT8U *err)
//  551 {
OSTaskNameGet:
        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     R7,R0
        MOVS     R6,R1
        MOVS     R4,R2
//  552 #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
//  553     OS_CPU_SR  cpu_sr;
//  554 #endif
//  555     OS_TCB    *ptcb;
//  556     INT8U      len;
//  557 
//  558 
//  559     OS_ENTER_CRITICAL();
        _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
        MOVS     R5,R0
//  560 #if OS_ARG_CHK_EN > 0
//  561     if (prio > OS_LOWEST_PRIO && prio != OS_PRIO_SELF) {        /* Task priority valid ?               */
        CMP      R7,#+64
        BCC      ??OSTaskNameGet_0
        CMP      R7,#+255
        BEQ      ??OSTaskNameGet_0
//  562         *err = OS_PRIO_INVALID;                                 /* No                                  */
        MOVS     R0,#+42
??OSTaskNameGet_1:
        STRB     R0,[R4, #+0]
//  563         return (0);
        MOVS     R0,#+0
        B        ??OSTaskNameGet_2
//  564     }
//  565     if (pname == (char *)0) {                    /* Is 'pname' a NULL pointer?                         */
??OSTaskNameGet_0:
        CMP      R6,#+0
        BNE      ??OSTaskNameGet_3
//  566         OS_EXIT_CRITICAL();                      /* Yes                                                */
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  567         *err = OS_ERR_PNAME_NULL;
        MOVS     R0,#+15
        B.N      ??OSTaskNameGet_1
//  568         return (0);
//  569     }
//  570 #endif
//  571     if (prio == OS_PRIO_SELF) {                  /* See if caller desires it's own name                */
??OSTaskNameGet_3:
        CMP      R7,#+255
        BNE      ??OSTaskNameGet_4
//  572         prio = OSTCBCur->OSTCBPrio;
        LDR      R0,??DataTable38  ;; OSTCBCur
        LDR      R0,[R0, #+0]
        ADDS     R0,R0,#+45
        LDRB     R7,[R0, #+0]
//  573     }
//  574     ptcb = OSTCBPrioTbl[prio];
??OSTaskNameGet_4:
        LSLS     R0,R7,#+2
        LDR      R1,??DataTable40  ;; OSTCBPrioTbl
        LDR      R1,[R1, R0]
//  575     if (ptcb == (OS_TCB *)0) {                        /* Does task exist?                              */
        CMP      R1,#+0
        BNE      ??OSTaskNameGet_5
//  576         OS_EXIT_CRITICAL();                           /* No              

⌨️ 快捷键说明

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