os_task.lis

来自「将本站的UCOSFORAVR128V276版本升级到了280版」· LIS 代码 · 共 1,140 行 · 第 1/4 页

LIS
1,140
字号
 0078 0E940000          xcall _OSTaskStkInit
 007C 6801              movw R12,R16
 007E                   .dbline 201
 007E           ;         err = OS_TCBInit(prio, psp, (OS_STK *)0, 0, 0, (void *)0, 0);
 007E 2224              clr R2
 0080 3324              clr R3
 0082 3B86              std y+11,R3
 0084 2A86              std y+10,R2
 0086 3986              std y+9,R3
 0088 2886              std y+8,R2
 008A 40E0              ldi R20,0
 008C 50E0              ldi R21,0
 008E 60E0              ldi R22,0
 0090 70E0              ldi R23,0
 0092 4C83              std y+4,R20
 0094 5D83              std y+5,R21
 0096 6E83              std y+6,R22
 0098 7F83              std y+7,R23
 009A 3B82              std y+3,R3
 009C 2A82              std y+2,R2
 009E 3982              std y+1,R3
 00A0 2882              std y+0,R2
 00A2 9601              movw R18,R12
 00A4 0E2D              mov R16,R14
 00A6 0E940000          xcall _OS_TCBInit
 00AA C02E              mov R12,R16
 00AC                   .dbline 202
 00AC           ;         if (err == OS_NO_ERR) {
 00AC 0023              tst R16
 00AE 39F4              brne L6
 00B0                   .dbline 202
 00B0                   .dbline 203
 00B0           ;             if (OSRunning == TRUE) {         /* Find highest priority task if multitasking has started */
 00B0 80910000          lds R24,_OSRunning
 00B4 8130              cpi R24,1
 00B6 99F4              brne L7
 00B8                   .dbline 203
 00B8                   .dbline 204
 00B8           ;                 OS_Sched();
 00B8 0E940000          xcall _OS_Sched
 00BC                   .dbline 205
 00BC           ;             }
 00BC                   .dbline 206
 00BC 10C0              xjmp L7
 00BE           L6:
 00BE                   .dbline 206
 00BE           ;         } else {
 00BE                   .dbline 207
 00BE           ;             OS_ENTER_CRITICAL();
 00BE 0E940000          xcall _OS_CPU_SR_Save
 00C2 A02E              mov R10,R16
 00C4                   .dbline 208
 00C4           ;             OSTCBPrioTbl[prio] = (OS_TCB *)0;/* Make this priority available to others                 */
 00C4 82E0              ldi R24,2
 00C6 8E9D              mul R24,R14
 00C8 F001              movw R30,R0
 00CA 80E0              ldi R24,<_OSTCBPrioTbl
 00CC 90E0              ldi R25,>_OSTCBPrioTbl
 00CE E80F              add R30,R24
 00D0 F91F              adc R31,R25
 00D2 2224              clr R2
 00D4 3324              clr R3
 00D6 3182              std z+1,R3
 00D8 2082              std z+0,R2
 00DA                   .dbline 209
 00DA           ;             OS_EXIT_CRITICAL();
 00DA 0E940000          xcall _OS_CPU_SR_Restore
 00DE                   .dbline 210
 00DE           ;         }
 00DE           L7:
 00DE                   .dbline 211
 00DE           ;         return (err);
 00DE 0C2D              mov R16,R12
 00E0 04C0              xjmp L1
 00E2           L4:
 00E2                   .dbline 213
 00E2           ;     }
 00E2           ;     OS_EXIT_CRITICAL();
 00E2 0A2D              mov R16,R10
 00E4 0E940000          xcall _OS_CPU_SR_Restore
 00E8                   .dbline 214
 00E8           ;     return (OS_PRIO_EXIST);
 00E8 08E2              ldi R16,40
 00EA                   .dbline -2
 00EA           L1:
 00EA 2C96              adiw R28,12
 00EC 0E940000          xcall pop_gset5
 00F0 2296              adiw R28,2
 00F2                   .dbline 0 ; func end
 00F2 0895              ret
 00F4                   .dbsym r psp 12 pc
 00F4                   .dbsym r err 12 c
 00F4                   .dbsym r cpu_sr 10 c
 00F4                   .dbsym r prio 14 c
 00F4                   .dbsym l ptos 24 pc
 00F4                   .dbsym l p_arg 22 pV
 00F4                   .dbsym r task 12 pfV
 00F4                   .dbend
 00F4                   .dbfunc e OSTaskDel _OSTaskDel fc
 00F4                   .dbstruct 0 8 os_event
 00F4                   .dbfield 0 OSEventType c
 00F4                   .dbfield 1 OSEventPtr pV
 00F4                   .dbfield 3 OSEventCnt i
 00F4                   .dbfield 5 OSEventGrp c
 00F4                   .dbfield 6 OSEventTbl A[2:2]c
 00F4                   .dbend
 00F4                   .dbstruct 0 18 os_tcb
 00F4                   .dbfield 0 OSTCBStkPtr pc
 00F4                   .dbfield 2 OSTCBNext pS[os_tcb]
 00F4                   .dbfield 4 OSTCBPrev pS[os_tcb]
 00F4                   .dbfield 6 OSTCBEventPtr pS[os_event]
 00F4                   .dbfield 8 OSTCBDly i
 00F4                   .dbfield 10 OSTCBStat c
 00F4                   .dbfield 11 OSTCBPendTO c
 00F4                   .dbfield 12 OSTCBPrio c
 00F4                   .dbfield 13 OSTCBX c
 00F4                   .dbfield 14 OSTCBY c
 00F4                   .dbfield 15 OSTCBBitX c
 00F4                   .dbfield 16 OSTCBBitY c
 00F4                   .dbfield 17 OSTCBDelReq c
 00F4                   .dbend
 00F4           ;         pevent -> R12,R13
 00F4           ;              y -> R14
 00F4           ;         cpu_sr -> R20
 00F4           ;           ptcb -> R22,R23
 00F4           ;           prio -> R10
                        .even
 00F4           _OSTaskDel::
 00F4 0E940000          xcall push_gset5
 00F8 A02E              mov R10,R16
 00FA                   .dbline -1
 00FA                   .dbline 380
 00FA           ; }
 00FA           ; #endif
 00FA           ; /*$PAGE*/
 00FA           ; /*
 00FA           ; *********************************************************************************************************
 00FA           ; *                                     CREATE A TASK (Extended Version)
 00FA           ; *
 00FA           ; * Description: This function is used to have uC/OS-II manage the execution of a task.  Tasks can either
 00FA           ; *              be created prior to the start of multitasking or by a running task.  A task cannot be
 00FA           ; *              created by an ISR.  This function is similar to OSTaskCreate() except that it allows
 00FA           ; *              additional information about a task to be specified.
 00FA           ; *
 00FA           ; * Arguments  : task      is a pointer to the task's code
 00FA           ; *
 00FA           ; *              p_arg     is a pointer to an optional data area which can be used to pass parameters to
 00FA           ; *                        the task when the task first executes.  Where the task is concerned it thinks
 00FA           ; *                        it was invoked and passed the argument 'p_arg' as follows:
 00FA           ; *
 00FA           ; *                            void Task (void *p_arg)
 00FA           ; *                            {
 00FA           ; *                                for (;;) {
 00FA           ; *                                    Task code;
 00FA           ; *                                }
 00FA           ; *                            }
 00FA           ; *
 00FA           ; *              ptos      is a pointer to the task's top of stack.  If the configuration constant
 00FA           ; *                        OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
 00FA           ; *                        memory to low memory).  'ptos' will thus point to the highest (valid) memory
 00FA           ; *                        location of the stack.  If OS_STK_GROWTH is set to 0, 'ptos' will point to the
 00FA           ; *                        lowest memory location of the stack and the stack will grow with increasing
 00FA           ; *                        memory locations.  'ptos' MUST point to a valid 'free' data item.
 00FA           ; *
 00FA           ; *              prio      is the task's priority.  A unique priority MUST be assigned to each task and the
 00FA           ; *                        lower the number, the higher the priority.
 00FA           ; *
 00FA           ; *              id        is the task's ID (0..65535)
 00FA           ; *
 00FA           ; *              pbos      is a pointer to the task's bottom of stack.  If the configuration constant
 00FA           ; *                        OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
 00FA           ; *                        memory to low memory).  'pbos' will thus point to the LOWEST (valid) memory
 00FA           ; *                        location of the stack.  If OS_STK_GROWTH is set to 0, 'pbos' will point to the
 00FA           ; *                        HIGHEST memory location of the stack and the stack will grow with increasing
 00FA           ; *                        memory locations.  'pbos' MUST point to a valid 'free' data item.
 00FA           ; *
 00FA           ; *              stk_size  is the size of the stack in number of elements.  If OS_STK is set to INT8U,
 00FA           ; *                        'stk_size' corresponds to the number of bytes available.  If OS_STK is set to
 00FA           ; *                        INT16U, 'stk_size' contains the number of 16-bit entries available.  Finally, if
 00FA           ; *                        OS_STK is set to INT32U, 'stk_size' contains the number of 32-bit entries
 00FA           ; *                        available on the stack.
 00FA           ; *
 00FA           ; *              pext      is a pointer to a user supplied memory location which is used as a TCB extension.
 00FA           ; *                        For example, this user memory can hold the contents of floating-point registers
 00FA           ; *                        during a context switch, the time each task takes to execute, the number of times
 00FA           ; *                        the task has been switched-in, etc.
 00FA           ; *
 00FA           ; *              opt       contains additional information (or options) about the behavior of the task.  The
 00FA           ; *                        LOWER 8-bits are reserved by uC/OS-II while the upper 8 bits can be application
 00FA           ; *                        specific.  See OS_TASK_OPT_??? in uCOS-II.H.  Current choices are:
 00FA           ; *
 00FA           ; *                        OS_TASK_OPT_STK_CHK      Stack checking to be allowed for the task
 00FA           ; *                        OS_TASK_OPT_STK_CLR      Clear the stack when the task is created
 00FA           ; *                        OS_TASK_OPT_SAVE_FP      If the CPU has floating-point registers, save them
 00FA           ; *                                                 during a context switch.
 00FA           ; *
 00FA           ; * Returns    : OS_NO_ERR               if the function was successful.
 00FA           ; *              OS_PRIO_EXIT            if the task priority already exist
 00FA           ; *                                      (each task MUST have a unique priority).
 00FA           ; *              OS_PRIO_INVALID         if the priority you specify is higher that the maximum allowed
 00FA           ; *                                      (i.e. > OS_LOWEST_PRIO)
 00FA           ; *              OS_ERR_TASK_CREATE_ISR  if you tried to create a task from an ISR.
 00FA           ; *********************************************************************************************************
 00FA           ; */
 00FA           ; /*$PAGE*/
 00FA           ; #if OS_TASK_CREATE_EXT_EN > 0
 00FA           ; INT8U  OSTaskCreateExt (void   (*task)(void *p_arg),
 00FA           ;                         void    *p_arg,
 00FA           ;                         OS_STK  *ptos,
 00FA           ;                         INT8U    prio,
 00FA           ;                         INT16U   id,
 00FA           ;                         OS_STK  *pbos,
 00FA           ;                         INT32U   stk_size,
 00FA           ;                         void    *pext,
 00FA           ;                         INT16U   opt)
 00FA           ; {
 00FA           ;     OS_STK    *psp;
 00FA           ;     INT8U      err;
 00FA           ; #if OS_CRITICAL_METHOD == 3                  /* Allocate storage for CPU status register               */
 00FA           ;     OS_CPU_SR  cpu_sr = 0;
 00FA           ; #endif
 00FA           ; 
 00FA           ; 
 00FA           ; 
 00FA           ; #if OS_ARG_CHK_EN > 0
 00FA           ;     if (prio > OS_LOWEST_PRIO) {             /* Make sure priority is within allowable range           */
 00FA           ;         return (OS_PRIO_INVALID);
 00FA           ;     }
 00FA           ; #endif
 00FA           ;     OS_ENTER_CRITICAL();
 00FA           ;     if (OSIntNesting > 0) {                  /* Make sure we don't create the task from within an ISR  */
 00FA           ;         OS_EXIT_CRITICAL();
 00FA           ;         return (OS_ERR_TASK_CREATE_ISR);
 00FA           ;     }
 00FA           ;     if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority  */
 00FA           ;         OSTCBPrioTbl[prio] = (OS_TCB *)1;    /* Reserve the priority to prevent others from doing ...  */
 00FA           ;                                              /* ... the same thing until task is created.              */
 00FA           ;         OS_EXIT_CRITICAL();
 00FA           ; 
 00FA           ;         OS_TaskStkClr(pbos, stk_size, opt);                    /* Clear the task stack (if needed)     */
 00FA           ; 
 00FA           ;         psp = OSTaskStkInit(task, p_arg, ptos, opt);           /* Initialize the task's stack          */
 00FA           ;         err = OS_TCBInit(prio, psp, pbos, id, stk_size, pext, opt);
 00FA           ;         if (err == OS_NO_ERR) {
 00FA           ;             if (OSRunning == TRUE) {                           /* Find HPT if multitasking has started */
 00FA           ;                 OS_Sched();
 00FA           ;             }
 00FA           ;         } else {
 00FA           ;             OS_ENTER_CRITICAL();
 00FA           ;             OSTCBPrioTbl[prio] = (OS_TCB *)0;                  /* Make this priority avail. to others  */
 00FA           ;             OS_EXIT_CRITICAL();
 00FA           ;         }
 00FA           ;         return (err);
 00FA           ;     }
 00FA           ;     OS_EXIT_CRITICAL();
 00FA           ;     return (OS_PRIO_EXIST);
 00FA           ; }
 00FA           ; #endif
 00FA           ; /*$PAGE*/
 00FA           ; /*
 00FA           ; *********************************************************************************************************
 00FA           ; *                                            DELETE A TASK
 00FA           ; *
 00FA           ; * Description: This function allows you to delete a task.  The calling task can delete itself by
 00FA           ; *              its own priority number.  The deleted task is returned to the dormant state and can be
 00FA           ; *              re-activated by creating the deleted task again.
 00FA           ; *
 00FA           ; * Arguments  : prio    is the priority of the task to delete.  Note that you can explicitely delete
 00FA           ; *                      the current task without knowing its priority level by setting 'prio' to
 00FA           ; *                      OS_PRIO_SELF.
 00FA           ; *
 00FA           ; * Returns    : OS_NO_ERR           if the call is successful
 00FA           ; *              OS_TASK_DEL_IDLE    if you attempted to delete uC/OS-II's idle task
 00FA           ; *              OS_PRIO_INVALID     if the priority you specify is higher that the maximum allowed
 00FA           ; *                                  (i.e. >= OS_LOWEST_PRIO) or, you have not specified OS_PRIO_SELF.
 00FA           ; *              OS_TASK_DEL_ERR     if the task you want to delete does not exist.
 00FA           ; *              OS_TASK_NOT_EXIST   if the task is assigned to a Mutex PIP.
 00FA           ; *              OS_TASK_DEL_ISR     if you tried to delete a task from an ISR
 00FA           ; *
 00FA           ; * Notes      : 1) To reduce interrupt latency, OSTaskDel() 'disables' the task:
 00FA           ; *                    a) by making it not ready
 00FA           ; *                    b) by removing it from any wait lists
 00FA           ; *                    c) by preventing OSTimeTick() from making the task ready to run.
 00FA           ; *                 The task can then be 'unlinked' from the miscellaneous structures in uC/OS-II.
 00FA           ; *              2) The function OS_Dummy() is called after OS_EXIT_CRITICAL() because, on most processors,

⌨️ 快捷键说明

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