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

📄 os_task.lst

📁 IARSOURCECODE是基于LPC2478嵌入式软件IAR EWARM V4.42的应用实例代码
💻 LST
📖 第 1 页 / 共 5 页
字号:

   \                                 In segment CODE, align 4, keep-with-next
    188          INT8U  OSTaskCreate (void (*task)(void *p_arg), void *p_arg, OS_STK *ptos, INT8U prio)
    189          {
   \                     OSTaskCreate:
   \   00000000   F0402DE9           PUSH     {R4-R7,LR}
   \   00000004   0050B0E1           MOVS     R5,R0
   \   00000008   0160B0E1           MOVS     R6,R1
   \   0000000C   0270B0E1           MOVS     R7,R2
   \   00000010   0340B0E1           MOVS     R4,R3
    190              OS_STK    *psp;
    191              INT8U      err;
    192          #if OS_CRITICAL_METHOD == 3                  /* Allocate storage for CPU status register               */
    193              OS_CPU_SR  cpu_sr = 0;
   \   00000014   0000A0E3           MOV      R0,#+0
    194          #endif
    195          
    196          
    197          
    198          #if OS_ARG_CHK_EN > 0
    199              if (prio > OS_LOWEST_PRIO) {             /* Make sure priority is within allowable range           */
   \   00000018   200054E3           CMP      R4,#+32
   \   0000001C   0100003A           BCC      ??OSTaskCreate_0
    200                  return (OS_ERR_PRIO_INVALID);
   \   00000020   2A00A0E3           MOV      R0,#+42
   \   00000024   3A0000EA           B        ??OSTaskCreate_1
    201              }
    202          #endif
    203              OS_ENTER_CRITICAL();
   \                     ??OSTaskCreate_0:
   \   00000028   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
    204              if (OSIntNesting > 0) {                  /* Make sure we don't create the task from within an ISR  */
   \   0000002C   ........           LDR      R1,??DataTable26  ;; OSIntNesting
   \   00000030   0010D1E5           LDRB     R1,[R1, #+0]
   \   00000034   010051E3           CMP      R1,#+1
   \   00000038   0200003A           BCC      ??OSTaskCreate_2
    205                  OS_EXIT_CRITICAL();
   \   0000003C   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
    206                  return (OS_ERR_TASK_CREATE_ISR);
   \   00000040   3C00A0E3           MOV      R0,#+60
   \   00000044   320000EA           B        ??OSTaskCreate_1
    207              }
    208              if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority  */
   \                     ??OSTaskCreate_2:
   \   00000048   0410B0E1           MOVS     R1,R4
   \   0000004C   0420A0E3           MOV      R2,#+4
   \   00000050   ........           LDR      R3,??DataTable59  ;; OSTCBPrioTbl
   \   00000054   923121E0           MLA      R1,R2,R1,R3
   \   00000058   001091E5           LDR      R1,[R1, #+0]
   \   0000005C   000051E3           CMP      R1,#+0
   \   00000060   2900001A           BNE      ??OSTaskCreate_3
    209                  OSTCBPrioTbl[prio] = (OS_TCB *)1;    /* Reserve the priority to prevent others from doing ...  */
   \   00000064   0410B0E1           MOVS     R1,R4
   \   00000068   0420A0E3           MOV      R2,#+4
   \   0000006C   ........           LDR      R3,??DataTable59  ;; OSTCBPrioTbl
   \   00000070   923121E0           MLA      R1,R2,R1,R3
   \   00000074   0120A0E3           MOV      R2,#+1
   \   00000078   002081E5           STR      R2,[R1, #+0]
    210                                                       /* ... the same thing until task is created.              */
    211                  OS_EXIT_CRITICAL();
   \   0000007C   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
    212                  psp = OSTaskStkInit(task, p_arg, ptos, 0);              /* Initialize the task's stack         */
   \   00000080   0030A0E3           MOV      R3,#+0
   \   00000084   0720B0E1           MOVS     R2,R7
   \   00000088   0610B0E1           MOVS     R1,R6
   \   0000008C   0500B0E1           MOVS     R0,R5
   \   00000090   ........           _BLF     OSTaskStkInit,??OSTaskStkInit??rA
   \   00000094   0010B0E1           MOVS     R1,R0
    213                  err = OS_TCBInit(prio, psp, (OS_STK *)0, 0, 0, (void *)0, 0);
   \   00000098   0000A0E3           MOV      R0,#+0
   \   0000009C   01002DE9           PUSH     {R0}
   \   000000A0   0000A0E3           MOV      R0,#+0
   \   000000A4   01002DE9           PUSH     {R0}
   \   000000A8   0000A0E3           MOV      R0,#+0
   \   000000AC   01002DE9           PUSH     {R0}
   \   000000B0   0030A0E3           MOV      R3,#+0
   \   000000B4   0020A0E3           MOV      R2,#+0
   \   000000B8   0400B0E1           MOVS     R0,R4
   \   000000BC   ........           _BLF     OS_TCBInit,??OS_TCBInit??rA
   \   000000C0   0CD08DE2           ADD      SP,SP,#+12       ;; stack cleaning
   \   000000C4   0050B0E1           MOVS     R5,R0
    214                  if (err == OS_ERR_NONE) {
   \   000000C8   000055E3           CMP      R5,#+0
   \   000000CC   0500001A           BNE      ??OSTaskCreate_4
    215                      if (OSRunning == OS_TRUE) {      /* Find highest priority task if multitasking has started */
   \   000000D0   ........           LDR      R0,??DataTable47  ;; OSRunning
   \   000000D4   0000D0E5           LDRB     R0,[R0, #+0]
   \   000000D8   010050E3           CMP      R0,#+1
   \   000000DC   0800001A           BNE      ??OSTaskCreate_5
    216                          OS_Sched();
   \   000000E0   ........           _BLF     OS_Sched,??OS_Sched??rA
   \   000000E4   060000EA           B        ??OSTaskCreate_5
    217                      }
    218                  } else {
    219                      OS_ENTER_CRITICAL();
   \                     ??OSTaskCreate_4:
   \   000000E8   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
    220                      OSTCBPrioTbl[prio] = (OS_TCB *)0;/* Make this priority available to others                 */
   \   000000EC   0410A0E3           MOV      R1,#+4
   \   000000F0   ........           LDR      R2,??DataTable59  ;; OSTCBPrioTbl
   \   000000F4   912422E0           MLA      R2,R1,R4,R2
   \   000000F8   0010A0E3           MOV      R1,#+0
   \   000000FC   001082E5           STR      R1,[R2, #+0]
    221                      OS_EXIT_CRITICAL();
   \   00000100   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
    222                  }
    223                  return (err);
   \                     ??OSTaskCreate_5:
   \   00000104   0500B0E1           MOVS     R0,R5
   \   00000108   010000EA           B        ??OSTaskCreate_1
    224              }
    225              OS_EXIT_CRITICAL();
   \                     ??OSTaskCreate_3:
   \   0000010C   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
    226              return (OS_ERR_PRIO_EXIST);
   \   00000110   2800A0E3           MOV      R0,#+40
   \                     ??OSTaskCreate_1:
   \   00000114   F080BDE8           POP      {R4-R7,PC}       ;; return
    227          }
    228          #endif
    229          /*$PAGE*/
    230          /*
    231          *********************************************************************************************************
    232          *                                     CREATE A TASK (Extended Version)
    233          *
    234          * Description: This function is used to have uC/OS-II manage the execution of a task.  Tasks can either
    235          *              be created prior to the start of multitasking or by a running task.  A task cannot be
    236          *              created by an ISR.  This function is similar to OSTaskCreate() except that it allows
    237          *              additional information about a task to be specified.
    238          *
    239          * Arguments  : task      is a pointer to the task's code
    240          *
    241          *              p_arg     is a pointer to an optional data area which can be used to pass parameters to
    242          *                        the task when the task first executes.  Where the task is concerned it thinks
    243          *                        it was invoked and passed the argument 'p_arg' as follows:
    244          *
    245          *                            void Task (void *p_arg)
    246          *                            {
    247          *                                for (;;) {
    248          *                                    Task code;
    249          *                                }
    250          *                            }
    251          *
    252          *              ptos      is a pointer to the task's top of stack.  If the configuration constant
    253          *                        OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
    254          *                        memory to low memory).  'ptos' will thus point to the highest (valid) memory
    255          *                        location of the stack.  If OS_STK_GROWTH is set to 0, 'ptos' will point to the
    256          *                        lowest memory location of the stack and the stack will grow with increasing
    257          *                        memory locations.  'ptos' MUST point to a valid 'free' data item.
    258          *
    259          *              prio      is the task's priority.  A unique priority MUST be assigned to each task and the
    260          *                        lower the number, the higher the priority.
    261          *
    262          *              id        is the task's ID (0..65535)
    263          *
    264          *              pbos      is a pointer to the task's bottom of stack.  If the configuration constant
    265          *                        OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
    266          *                        memory to low memory).  'pbos' will thus point to the LOWEST (valid) memory
    267          *                        location of the stack.  If OS_STK_GROWTH is set to 0, 'pbos' will point to the
    268          *                        HIGHEST memory location of the stack and the stack will grow with increasing
    269          *                        memory locations.  'pbos' MUST point to a valid 'free' data item.
    270          *
    271          *              stk_size  is the size of the stack in number of elements.  If OS_STK is set to INT8U,
    272          *                        'stk_size' corresponds to the number of bytes available.  If OS_STK is set to
    273          *                        INT16U, 'stk_size' contains the number of 16-bit entries available.  Finally, if
    274          *                        OS_STK is set to INT32U, 'stk_size' contains the number of 32-bit entries
    275          *                        available on the stack.
    276          *
    277          *              pext      is a pointer to a user supplied memory location which is used as a TCB extension.
    278          *                        For example, this user memory can hold the contents of floating-point registers
    279          *                        during a context switch, the time each task takes to execute, the number of times
    280          *                        the task has been switched-in, etc.
    281          *
    282          *              opt       contains additional information (or options) about the behavior of the task.  The
    283          *                        LOWER 8-bits are reserved by uC/OS-II while the upper 8 bits can be application
    284          *                        specific.  See OS_TASK_OPT_??? in uCOS-II.H.  Current choices are:
    285          *
    286          *                        OS_TASK_OPT_STK_CHK      Stack checking to be allowed for the task
    287          *                        OS_TASK_OPT_STK_CLR      Clear the stack when the task is created
    288          *                        OS_TASK_OPT_SAVE_FP      If the CPU has floating-point registers, save them
    289          *                                                 during a context switch.
    290          *
    291          * Returns    : OS_ERR_NONE             if the function was successful.
    292          *              OS_PRIO_EXIT            if the task priority already exist
    293          *                                      (each task MUST have a unique priority).
    294          *              OS_ERR_PRIO_INVALID     if the priority you specify is higher that the maximum allowed
    295          *                                      (i.e. > OS_LOWEST_PRIO)
    296          *              OS_ERR_TASK_CREATE_ISR  if you tried to create a task from an ISR.
    297          *********************************************************************************************************
    298          */
    299          /*$PAGE*/
    300          #if OS_TASK_CREATE_EXT_EN > 0

   \                                 In segment CODE, align 4, keep-with-next
    301          INT8U  OSTaskCreateExt (void   (*task)(void *p_arg),
    302                                  void    *p_arg,
    303                                  OS_STK  *ptos,
    304                                  INT8U    prio,
    305                                  INT16U   id,
    306                                  OS_STK  *pbos,
    307                                  INT32U   stk_size,
    308                                  void    *pext,
    309                                  INT16U   opt)

⌨️ 快捷键说明

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