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

📄 os_task.lst

📁 编译环境是 iar EWARM ,STM32 下的UCOSII
💻 LST
📖 第 1 页 / 共 5 页
字号:
    312          *
    313          *                        OS_TASK_OPT_STK_CHK      Stack checking to be allowed for the task
    314          *                        OS_TASK_OPT_STK_CLR      Clear the stack when the task is created
    315          *                        OS_TASK_OPT_SAVE_FP      If the CPU has floating-point registers, save them
    316          *                                                 during a context switch.
    317          *
    318          * Returns    : OS_ERR_NONE             if the function was successful.
    319          *              OS_PRIO_EXIT            if the task priority already exist
    320          *                                      (each task MUST have a unique priority).
    321          *              OS_ERR_PRIO_INVALID     if the priority you specify is higher that the maximum allowed
    322          *                                      (i.e. > OS_LOWEST_PRIO)
    323          *              OS_ERR_TASK_CREATE_ISR  if you tried to create a task from an ISR.
    324          *********************************************************************************************************
    325          */
    326          /*$PAGE*/
    327          #if OS_TASK_CREATE_EXT_EN > 0

   \                                 In segment CODE, align 4, keep-with-next
    328          INT8U  OSTaskCreateExt (void   (*task)(void *p_arg),
    329                                  void    *p_arg,
    330                                  OS_STK  *ptos,
    331                                  INT8U    prio,
    332                                  INT16U   id,
    333                                  OS_STK  *pbos,
    334                                  INT32U   stk_size,
    335                                  void    *pext,
    336                                  INT16U   opt)
    337          {
   \                     OSTaskCreateExt:
   \   00000000   2DE9F047           PUSH     {R4-R10,LR}
   \   00000004   8046               MOV      R8,R0
   \   00000006   8946               MOV      R9,R1
   \   00000008   9A46               MOV      R10,R3
   \   0000000A   1700               MOVS     R7,R2
   \   0000000C   0A9D               LDR      R5,[SP, #+40]
   \   0000000E   BDF83060           LDRH     R6,[SP, #+48]
    338              OS_STK    *psp;
    339              INT8U      err;
    340          #if OS_CRITICAL_METHOD == 3                  /* Allocate storage for CPU status register               */
    341              OS_CPU_SR  cpu_sr = 0;
    342          #endif
    343          
    344          
    345          
    346          #if OS_ARG_CHK_EN > 0
    347              if (prio > OS_LOWEST_PRIO) {             /* Make sure priority is within allowable range           */
    348                  return (OS_ERR_PRIO_INVALID);
    349              }
    350          #endif
    351              OS_ENTER_CRITICAL();
   \   00000012   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
    352              if (OSIntNesting > 0) {                  /* Make sure we don't create the task from within an ISR  */
   \   00000016   ....               LDR.N    R1,??DataTable20  ;; OSIntNesting
   \   00000018   0978               LDRB     R1,[R1, #+0]
   \   0000001A   0029               CMP      R1,#+0
   \   0000001C   03D0               BEQ.N    ??OSTaskCreateExt_0
    353                  OS_EXIT_CRITICAL();
   \   0000001E   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    354                  return (OS_ERR_TASK_CREATE_ISR);
   \   00000022   3C20               MOVS     R0,#+60
   \   00000024   36E0               B.N      ??OSTaskCreateExt_1
    355              }
   \                     ??OSTaskCreateExt_0:
   \   00000026   5146               MOV      R1,R10
   \   00000028   ....               LDR.N    R2,??DataTable10  ;; OSTCBPrioTbl
   \   0000002A   12EB8104           ADDS     R4,R2,R1, LSL #+2
   \   0000002E   2168               LDR      R1,[R4, #+0]
   \   00000030   0029               CMP      R1,#+0
   \   00000032   2CD1               BNE.N    ??OSTaskCreateExt_2
    356              if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority  */
    357                  OSTCBPrioTbl[prio] = OS_TCB_RESERVED;/* Reserve the priority to prevent others from doing ...  */
   \   00000034   0121               MOVS     R1,#+1
   \   00000036   2160               STR      R1,[R4, #+0]
    358                                                       /* ... the same thing until task is created.              */
    359                  OS_EXIT_CRITICAL();
   \   00000038   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    360          
    361          #if (OS_TASK_STAT_STK_CHK_EN > 0)
    362                  OS_TaskStkClr(pbos, stk_size, opt);                    /* Clear the task stack (if needed)     */
   \   0000003C   3200               MOVS     R2,R6
   \   0000003E   2900               MOVS     R1,R5
   \   00000040   0998               LDR      R0,[SP, #+36]
   \   00000042   ........           BL       OS_TaskStkClr
    363          #endif
    364          
    365                  psp = OSTaskStkInit(task, p_arg, ptos, opt);           /* Initialize the task's stack          */
   \   00000046   3300               MOVS     R3,R6
   \   00000048   3A00               MOVS     R2,R7
   \   0000004A   4946               MOV      R1,R9
   \   0000004C   4046               MOV      R0,R8
   \   0000004E   ........           _BLF     OSTaskStkInit,??OSTaskStkInit??rT
   \   00000052   0700               MOVS     R7,R0
    366                  err = OS_TCBInit(prio, psp, pbos, id, stk_size, pext, opt);
   \   00000054   3200               MOVS     R2,R6
   \   00000056   0B99               LDR      R1,[SP, #+44]
   \   00000058   2800               MOVS     R0,R5
   \   0000005A   07B4               PUSH     {R0-R2}
   \   0000005C   BDF82C30           LDRH     R3,[SP, #+44]
   \   00000060   0C9A               LDR      R2,[SP, #+48]
   \   00000062   3900               MOVS     R1,R7
   \   00000064   5046               MOV      R0,R10
   \   00000066   ........           _BLF     OS_TCBInit,??OS_TCBInit??rT
   \   0000006A   0500               MOVS     R5,R0
    367                  if (err == OS_ERR_NONE) {
   \   0000006C   03B0               ADD      SP,SP,#+12
   \   0000006E   06D1               BNE.N    ??OSTaskCreateExt_3
    368                      if (OSRunning == OS_TRUE) {                        /* Find HPT if multitasking has started */
   \   00000070   ....               LDR.N    R0,??DataTable17  ;; OSRunning
   \   00000072   0078               LDRB     R0,[R0, #+0]
   \   00000074   0128               CMP      R0,#+1
   \   00000076   08D1               BNE.N    ??OSTaskCreateExt_4
    369                          OS_Sched();
   \   00000078   ........           _BLF     OS_Sched,??OS_Sched??rT
   \   0000007C   05E0               B.N      ??OSTaskCreateExt_4
    370                      }
    371                  } else {
    372                      OS_ENTER_CRITICAL();
   \                     ??OSTaskCreateExt_3:
   \   0000007E   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
    373                      OSTCBPrioTbl[prio] = (OS_TCB *)0;                  /* Make this priority avail. to others  */
   \   00000082   0021               MOVS     R1,#+0
   \   00000084   2160               STR      R1,[R4, #+0]
    374                      OS_EXIT_CRITICAL();
   \   00000086   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    375                  }
    376                  return (err);
   \                     ??OSTaskCreateExt_4:
   \   0000008A   2800               MOVS     R0,R5
   \   0000008C   02E0               B.N      ??OSTaskCreateExt_1
    377              }
    378              OS_EXIT_CRITICAL();
   \                     ??OSTaskCreateExt_2:
   \   0000008E   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    379              return (OS_ERR_PRIO_EXIST);
   \   00000092   2820               MOVS     R0,#+40
   \                     ??OSTaskCreateExt_1:
   \   00000094   BDE8F087           POP      {R4-R10,PC}      ;; return
    380          }
    381          #endif
    382          /*$PAGE*/
    383          /*
    384          *********************************************************************************************************
    385          *                                            DELETE A TASK
    386          *
    387          * Description: This function allows you to delete a task.  The calling task can delete itself by
    388          *              its own priority number.  The deleted task is returned to the dormant state and can be
    389          *              re-activated by creating the deleted task again.
    390          *
    391          * Arguments  : prio    is the priority of the task to delete.  Note that you can explicitely delete
    392          *                      the current task without knowing its priority level by setting 'prio' to
    393          *                      OS_PRIO_SELF.
    394          *
    395          * Returns    : OS_ERR_NONE             if the call is successful
    396          *              OS_ERR_TASK_DEL_IDLE    if you attempted to delete uC/OS-II's idle task
    397          *              OS_ERR_PRIO_INVALID     if the priority you specify is higher that the maximum allowed
    398          *                                      (i.e. >= OS_LOWEST_PRIO) or, you have not specified OS_PRIO_SELF.
    399          *              OS_ERR_TASK_DEL         if the task is assigned to a Mutex PIP.   
    400          *              OS_ERR_TASK_NOT_EXIST   if the task you want to delete does not exist.
    401          *              OS_ERR_TASK_DEL_ISR     if you tried to delete a task from an ISR
    402          *
    403          * Notes      : 1) To reduce interrupt latency, OSTaskDel() 'disables' the task:
    404          *                    a) by making it not ready
    405          *                    b) by removing it from any wait lists
    406          *                    c) by preventing OSTimeTick() from making the task ready to run.
    407          *                 The task can then be 'unlinked' from the miscellaneous structures in uC/OS-II.
    408          *              2) The function OS_Dummy() is called after OS_EXIT_CRITICAL() because, on most processors,
    409          *                 the next instruction following the enable interrupt instruction is ignored.
    410          *              3) An ISR cannot delete a task.
    411          *              4) The lock nesting counter is incremented because, for a brief instant, if the current
    412          *                 task is being deleted, the current task would not be able to be rescheduled because it
    413          *                 is removed from the ready list.  Incrementing the nesting counter prevents another task
    414          *                 from being schedule.  This means that an ISR would return to the current task which is
    415          *                 being deleted.  The rest of the deletion would thus be able to be completed.
    416          *********************************************************************************************************
    417          */
    418          
    419          #if OS_TASK_DEL_EN > 0

   \                                 In segment CODE, align 4, keep-with-next
    420          INT8U  OSTaskDel (INT8U prio)
    421          {
   \                     OSTaskDel:
   \   00000000   2DE9F043           PUSH     {R4-R9,LR}
   \   00000004   0500               MOVS     R5,R0
    422          #if (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
    423              OS_FLAG_NODE *pnode;
    424          #endif
    425              OS_TCB       *ptcb;
    426          #if OS_CRITICAL_METHOD == 3                             /* Allocate storage for CPU status register    */
    427              OS_CPU_SR     cpu_sr = 0;
    428          #endif
    429          
    430          
    431          
    432              if (OSIntNesting > 0) {                             /* See if trying to delete from ISR            */
   \   00000006   ....               LDR.N    R0,??DataTable20  ;; OSIntNesting
   \   00000008   0078               LDRB     R0,[R0, #+0]
   \   0000000A   0028               CMP      R0,#+0
   \   0000000C   01D0               BEQ.N    ??OSTaskDel_0
    433                  return (OS_ERR_TASK_DEL_ISR);
   \   0000000E   4020               MOVS     R0,#+64
   \   00000010   86E0               B.N      ??OSTaskDel_1
    434              }
    435              if (prio == OS_TASK_IDLE_PRIO) {                    /* Not allowed to delete idle task             */
   \                     ??OSTaskDel_0:
   \   00000012   1F2D               CMP      R5,#+31

⌨️ 快捷键说明

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