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

📄 os_task.lst

📁 stm32+ucos-ii
💻 LST
📖 第 1 页 / 共 5 页
字号:
    282          *
    283          *              ptos      is a pointer to the task's top of stack.  If the configuration constant
    284          *                        OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
    285          *                        memory to low memory).  'ptos' will thus point to the highest (valid) memory
    286          *                        location of the stack.  If OS_STK_GROWTH is set to 0, 'ptos' will point to the
    287          *                        lowest memory location of the stack and the stack will grow with increasing
    288          *                        memory locations.  'ptos' MUST point to a valid 'free' data item.
    289          *
    290          *              prio      is the task's priority.  A unique priority MUST be assigned to each task and the
    291          *                        lower the number, the higher the priority.
    292          *
    293          *              id        is the task's ID (0..65535)
    294          *
    295          *              pbos      is a pointer to the task's bottom of stack.  If the configuration constant
    296          *                        OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
    297          *                        memory to low memory).  'pbos' will thus point to the LOWEST (valid) memory
    298          *                        location of the stack.  If OS_STK_GROWTH is set to 0, 'pbos' will point to the
    299          *                        HIGHEST memory location of the stack and the stack will grow with increasing
    300          *                        memory locations.  'pbos' MUST point to a valid 'free' data item.
    301          *
    302          *              stk_size  is the size of the stack in number of elements.  If OS_STK is set to INT8U,
    303          *                        'stk_size' corresponds to the number of bytes available.  If OS_STK is set to
    304          *                        INT16U, 'stk_size' contains the number of 16-bit entries available.  Finally, if
    305          *                        OS_STK is set to INT32U, 'stk_size' contains the number of 32-bit entries
    306          *                        available on the stack.
    307          *
    308          *              pext      is a pointer to a user supplied memory location which is used as a TCB extension.
    309          *                        For example, this user memory can hold the contents of floating-point registers
    310          *                        during a context switch, the time each task takes to execute, the number of times
    311          *                        the task has been switched-in, etc.
    312          *
    313          *              opt       contains additional information (or options) about the behavior of the task.  The
    314          *                        LOWER 8-bits are reserved by uC/OS-II while the upper 8 bits can be application
    315          *                        specific.  See OS_TASK_OPT_??? in uCOS-II.H.  Current choices are:
    316          *
    317          *                        OS_TASK_OPT_STK_CHK      Stack checking to be allowed for the task
    318          *                        OS_TASK_OPT_STK_CLR      Clear the stack when the task is created
    319          *                        OS_TASK_OPT_SAVE_FP      If the CPU has floating-point registers, save them
    320          *                                                 during a context switch.
    321          *
    322          * Returns    : OS_ERR_NONE                      if the function was successful.
    323          *              OS_ERR_PRIO_EXIST                if the task priority already exist
    324          *                                               (each task MUST have a unique priority).
    325          *              OS_ERR_PRIO_INVALID              if the priority you specify is higher that the maximum
    326          *                                               allowed (i.e. > OS_LOWEST_PRIO)
    327          *              OS_ERR_TASK_CREATE_ISR           if you tried to create a task from an ISR.
    328          *              OS_ERR_ILLEGAL_CREATE_RUN_TIME   if you tried to create a task after safety critical
    329          *                                               operation started.
    330          *********************************************************************************************************
    331          */
    332          /*$PAGE*/
    333          #if OS_TASK_CREATE_EXT_EN > 0u

   \                                 In section .text, align 2, keep-with-next
    334          INT8U  OSTaskCreateExt (void   (*task)(void *p_arg),
    335                                  void    *p_arg,
    336                                  OS_STK  *ptos,
    337                                  INT8U    prio,
    338                                  INT16U   id,
    339                                  OS_STK  *pbos,
    340                                  INT32U   stk_size,
    341                                  void    *pext,
    342                                  INT16U   opt)
    343          {
   \                     OSTaskCreateExt:
   \   00000000   2DE9F74F           PUSH     {R0-R2,R4-R11,LR}
   \   00000004   84B0               SUB      SP,SP,#+16
   \   00000006   1E00               MOVS     R6,R3
   \   00000008   109C               LDR      R4,[SP, #+64]
   \   0000000A   119F               LDR      R7,[SP, #+68]
   \   0000000C   DDF84880           LDR      R8,[SP, #+72]
   \   00000010   DDF84C90           LDR      R9,[SP, #+76]
   \   00000014   149D               LDR      R5,[SP, #+80]
    344              OS_STK     *psp;
    345              INT8U       err;
    346          #if OS_CRITICAL_METHOD == 3u                 /* Allocate storage for CPU status register               */
    347              OS_CPU_SR   cpu_sr = 0u;
   \   00000016   5FF0000B           MOVS     R11,#+0
    348          #endif
    349          
    350          
    351          
    352          #ifdef OS_SAFETY_CRITICAL_IEC61508
    353              if (OSSafetyCriticalStartFlag == OS_TRUE) {
    354                  OS_SAFETY_CRITICAL_EXCEPTION();
    355                  return (OS_ERR_ILLEGAL_CREATE_RUN_TIME);
    356              }
    357          #endif
    358          
    359          #if OS_ARG_CHK_EN > 0u
    360              if (prio > OS_LOWEST_PRIO) {             /* Make sure priority is within allowable range           */
    361                  return (OS_ERR_PRIO_INVALID);
    362              }
    363          #endif
    364              OS_ENTER_CRITICAL();
   \   0000001A   ........           BL       OS_CPU_SR_Save
   \   0000001E   8346               MOV      R11,R0
    365              if (OSIntNesting > 0u) {                 /* Make sure we don't create the task from within an ISR  */
   \   00000020   ........           LDR.W    R0,??DataTable14_5
   \   00000024   0078               LDRB     R0,[R0, #+0]
   \   00000026   0028               CMP      R0,#+0
   \   00000028   04D0               BEQ.N    ??OSTaskCreateExt_0
    366                  OS_EXIT_CRITICAL();
   \   0000002A   5846               MOV      R0,R11
   \   0000002C   ........           BL       OS_CPU_SR_Restore
    367                  return (OS_ERR_TASK_CREATE_ISR);
   \   00000030   3C20               MOVS     R0,#+60
   \   00000032   4CE0               B.N      ??OSTaskCreateExt_1
    368              }
    369              if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority  */
   \                     ??OSTaskCreateExt_0:
   \   00000034   F6B2               UXTB     R6,R6            ;; ZeroExt  R6,R6,#+24,#+24
   \   00000036   ........           LDR.W    R0,??DataTable14
   \   0000003A   50F82600           LDR      R0,[R0, R6, LSL #+2]
   \   0000003E   0028               CMP      R0,#+0
   \   00000040   41D1               BNE.N    ??OSTaskCreateExt_2
    370                  OSTCBPrioTbl[prio] = OS_TCB_RESERVED;/* Reserve the priority to prevent others from doing ...  */
   \   00000042   F6B2               UXTB     R6,R6            ;; ZeroExt  R6,R6,#+24,#+24
   \   00000044   ........           LDR.W    R0,??DataTable14
   \   00000048   0121               MOVS     R1,#+1
   \   0000004A   40F82610           STR      R1,[R0, R6, LSL #+2]
    371                                                       /* ... the same thing until task is created.              */
    372                  OS_EXIT_CRITICAL();
   \   0000004E   5846               MOV      R0,R11
   \   00000050   ........           BL       OS_CPU_SR_Restore
    373          
    374          #if (OS_TASK_STAT_STK_CHK_EN > 0u)
    375                  OS_TaskStkClr(pbos, stk_size, opt);                    /* Clear the task stack (if needed)     */
   \   00000054   2A00               MOVS     R2,R5
   \   00000056   92B2               UXTH     R2,R2            ;; ZeroExt  R2,R2,#+16,#+16
   \   00000058   4146               MOV      R1,R8
   \   0000005A   3800               MOVS     R0,R7
   \   0000005C   ........           BL       OS_TaskStkClr
    376          #endif
    377          
    378                  psp = OSTaskStkInit(task, p_arg, ptos, opt);           /* Initialize the task's stack          */
   \   00000060   2B00               MOVS     R3,R5
   \   00000062   9BB2               UXTH     R3,R3            ;; ZeroExt  R3,R3,#+16,#+16
   \   00000064   069A               LDR      R2,[SP, #+24]
   \   00000066   0599               LDR      R1,[SP, #+20]
   \   00000068   0498               LDR      R0,[SP, #+16]
   \   0000006A   ........           BL       OSTaskStkInit
   \   0000006E   0390               STR      R0,[SP, #+12]
    379                  err = OS_TCBInit(prio, psp, pbos, id, stk_size, pext, opt);
   \   00000070   ADB2               UXTH     R5,R5            ;; ZeroExt  R5,R5,#+16,#+16
   \   00000072   0295               STR      R5,[SP, #+8]
   \   00000074   CDF80490           STR      R9,[SP, #+4]
   \   00000078   CDF80080           STR      R8,[SP, #+0]
   \   0000007C   2300               MOVS     R3,R4
   \   0000007E   9BB2               UXTH     R3,R3            ;; ZeroExt  R3,R3,#+16,#+16
   \   00000080   3A00               MOVS     R2,R7
   \   00000082   0399               LDR      R1,[SP, #+12]
   \   00000084   3000               MOVS     R0,R6
   \   00000086   C0B2               UXTB     R0,R0            ;; ZeroExt  R0,R0,#+24,#+24
   \   00000088   ........           BL       OS_TCBInit
   \   0000008C   8246               MOV      R10,R0
    380                  if (err == OS_ERR_NONE) {
   \   0000008E   5FFA8AFA           UXTB     R10,R10          ;; ZeroExt  R10,R10,#+24,#+24
   \   00000092   BAF1000F           CMP      R10,#+0
   \   00000096   07D1               BNE.N    ??OSTaskCreateExt_3
    381                      if (OSRunning == OS_TRUE) {                        /* Find HPT if multitasking has started */
   \   00000098   ........           LDR.W    R0,??DataTable14_4
   \   0000009C   0078               LDRB     R0,[R0, #+0]
   \   0000009E   0128               CMP      R0,#+1
   \   000000A0   0ED1               BNE.N    ??OSTaskCreateExt_4
    382                          OS_Sched();
   \   000000A2   ........           BL       OS_Sched
   \   000000A6   0BE0               B.N      ??OSTaskCreateExt_4
    383                      }
    384                  } else {
    385                      OS_ENTER_CRITICAL();
   \                     ??OSTaskCreateExt_3:
   \   000000A8   ........           BL       OS_CPU_SR_Save
   \   000000AC   8346               MOV      R11,R0
    386                      OSTCBPrioTbl[prio] = (OS_TCB *)0;                  /* Make this priority avail. to others  */
   \   000000AE   F6B2               UXTB     R6,R6            ;; ZeroExt  R6,R6,#+24,#+24
   \   000000B0   ........           LDR.W    R0,??DataTable14
   \   000000B4   0021               MOVS     R1,#+0
   \   000000B6   40F82610           STR      R1,[R0, R6, LSL #+2]
    387                      OS_EXIT_CRITICAL();
   \   000000BA   5846               MOV      R0,R11
   \   000000BC   ........           BL       OS_CPU_SR_Restore
    388                  }
    389                  return (err);
   \                     ??OSTaskCreateExt_4:
   \   000000C0   5046               MOV      R0,R10
   \   000000C2   C0B2               UXTB     R0,R0            ;; ZeroExt  R0,R0,#+24,#+24
   \   000000C4   03E0               B.N      ??OSTaskCreateExt_1
    390              }
    391              OS_EXIT_CRITICAL();
   \                     ??OSTaskCreateExt_2:
   \   000000C6   5846               MOV      R0,R11
   \   000000C8   ........           BL       OS_CPU_SR_Restore
    392              return (OS_ERR_PRIO_EXIST);
   \   000000CC   2820               MOVS     R0,#+40
   \                     ??OSTaskCreateExt_1:
   \   000000CE   07B0               ADD      SP,SP,#+28
   \   000000D0   BDE8F08F           POP      {R4-R11,PC}      ;; return
    393          }
    394          #endif
    395          /*$PAGE*/
    396          /*
    397          *********************************************************************************************************
    398          *                                            DELETE A TASK
    399          *

⌨️ 快捷键说明

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