os_task.lst

来自「atmega单片机用的ucos系统 占用内存适中 是atmega单片机合适的操作」· LST 代码 · 共 1,070 行 · 第 1/5 页

LST
1,070
字号
   1               		.file	"os_task.c"
   2               		.arch atmega128
   3               	__SREG__ = 0x3f
   4               	__SP_H__ = 0x3e
   5               	__SP_L__ = 0x3d
   6               	__tmp_reg__ = 0
   7               	__zero_reg__ = 1
   8               		.global __do_copy_data
   9               		.global __do_clear_bss
  11               		.text
  12               	.Ltext0:
  88               	.global	OSTaskCreate
  90               	OSTaskCreate:
   1:OSsrc/os_task.c **** /*
   2:OSsrc/os_task.c **** ***************************************************************************************************
   3:OSsrc/os_task.c **** *                                                uC/OS-II
   4:OSsrc/os_task.c **** *                                          The Real-Time Kernel
   5:OSsrc/os_task.c **** *                                            TASK MANAGEMENT
   6:OSsrc/os_task.c **** *
   7:OSsrc/os_task.c **** *                          (c) Copyright 1992-2003, Jean J. Labrosse, Weston, FL
   8:OSsrc/os_task.c **** *                                           All Rights Reserved
   9:OSsrc/os_task.c **** *
  10:OSsrc/os_task.c **** * File    : OS_TASK.C
  11:OSsrc/os_task.c **** * By      : Jean J. Labrosse
  12:OSsrc/os_task.c **** * Version : V2.76
  13:OSsrc/os_task.c **** ***************************************************************************************************
  14:OSsrc/os_task.c **** */
  15:OSsrc/os_task.c **** 
  16:OSsrc/os_task.c **** #ifndef  OS_MASTER_FILE
  17:OSsrc/os_task.c **** #include "ucos_ii.h"
  18:OSsrc/os_task.c **** #endif
  19:OSsrc/os_task.c **** 
  20:OSsrc/os_task.c **** /*
  21:OSsrc/os_task.c **** ***************************************************************************************************
  22:OSsrc/os_task.c **** *                                        CHANGE PRIORITY OF A TASK
  23:OSsrc/os_task.c **** *
  24:OSsrc/os_task.c **** * Description: This function allows you to change the priority of a task dynamically.  Note that th
  25:OSsrc/os_task.c **** *              priority MUST be available.
  26:OSsrc/os_task.c **** *
  27:OSsrc/os_task.c **** * Arguments  : oldp     is the old priority
  28:OSsrc/os_task.c **** *
  29:OSsrc/os_task.c **** *              newp     is the new priority
  30:OSsrc/os_task.c **** *
  31:OSsrc/os_task.c **** * Returns    : OS_NO_ERR          is the call was successful
  32:OSsrc/os_task.c **** *              OS_PRIO_INVALID    if the priority you specify is higher that the maximum allowed
  33:OSsrc/os_task.c **** *                                 (i.e. >= OS_LOWEST_PRIO)
  34:OSsrc/os_task.c **** *              OS_PRIO_EXIST      if the new priority already exist.
  35:OSsrc/os_task.c **** *              OS_PRIO_ERR        there is no task with the specified OLD priority (i.e. the OLD ta
  36:OSsrc/os_task.c **** *                                 not exist.
  37:OSsrc/os_task.c **** *              OS_TASK_NOT_EXIST  if the task is assigned to a Mutex PIP.
  38:OSsrc/os_task.c **** ***************************************************************************************************
  39:OSsrc/os_task.c **** */
  40:OSsrc/os_task.c **** 
  41:OSsrc/os_task.c **** #if OS_TASK_CHANGE_PRIO_EN > 0
  42:OSsrc/os_task.c **** INT8U  OSTaskChangePrio (INT8U oldprio, INT8U newprio)
  43:OSsrc/os_task.c **** {
  44:OSsrc/os_task.c **** #if OS_EVENT_EN
  45:OSsrc/os_task.c ****     OS_EVENT    *pevent;
  46:OSsrc/os_task.c **** #endif
  47:OSsrc/os_task.c ****     OS_TCB      *ptcb;
  48:OSsrc/os_task.c ****     INT8U        x;
  49:OSsrc/os_task.c ****     INT8U        y;
  50:OSsrc/os_task.c ****     INT8U        bitx;
  51:OSsrc/os_task.c ****     INT8U        bity;
  52:OSsrc/os_task.c ****     INT8U        y_old;
  53:OSsrc/os_task.c **** #if OS_CRITICAL_METHOD == 3                                     
  54:OSsrc/os_task.c ****     OS_CPU_SR    cpu_sr;                                        /* Storage for CPU status register 
  55:OSsrc/os_task.c **** 
  56:OSsrc/os_task.c **** 
  57:OSsrc/os_task.c **** 
  58:OSsrc/os_task.c ****     cpu_sr = 0;                                                 /* Prevent compiler warning        
  59:OSsrc/os_task.c **** #endif    
  60:OSsrc/os_task.c **** #if OS_ARG_CHK_EN > 0
  61:OSsrc/os_task.c ****     if (oldprio >= OS_LOWEST_PRIO) {
  62:OSsrc/os_task.c **** 	    if (oldprio != OS_PRIO_SELF) {
  63:OSsrc/os_task.c ****             return (OS_PRIO_INVALID);
  64:OSsrc/os_task.c **** 		}
  65:OSsrc/os_task.c **** 	}
  66:OSsrc/os_task.c ****     if (newprio >= OS_LOWEST_PRIO) {
  67:OSsrc/os_task.c ****         return (OS_PRIO_INVALID);
  68:OSsrc/os_task.c ****     }
  69:OSsrc/os_task.c **** #endif
  70:OSsrc/os_task.c ****     OS_ENTER_CRITICAL();
  71:OSsrc/os_task.c ****     if (OSTCBPrioTbl[newprio] != (OS_TCB *)0) {                 /* New priority must not already ex
  72:OSsrc/os_task.c ****         OS_EXIT_CRITICAL();
  73:OSsrc/os_task.c ****         return (OS_PRIO_EXIST);
  74:OSsrc/os_task.c ****     } 
  75:OSsrc/os_task.c ****     if (oldprio == OS_PRIO_SELF) {                              /* See if changing self            
  76:OSsrc/os_task.c ****         oldprio = OSTCBCur->OSTCBPrio;                          /* Yes, get priority               
  77:OSsrc/os_task.c ****     }
  78:OSsrc/os_task.c ****     ptcb = OSTCBPrioTbl[oldprio];
  79:OSsrc/os_task.c ****     if (ptcb == (OS_TCB *)0) {                                  /* Does task to change exist?      
  80:OSsrc/os_task.c ****         OS_EXIT_CRITICAL();                                     /* No, can't change its priority!  
  81:OSsrc/os_task.c ****         return (OS_PRIO_ERR);
  82:OSsrc/os_task.c ****     }                                       
  83:OSsrc/os_task.c ****     if (ptcb == (OS_TCB *)1) {                                  /* Is task assigned to Mutex       
  84:OSsrc/os_task.c ****         OS_EXIT_CRITICAL();                                     /* No, can't change its priority!  
  85:OSsrc/os_task.c ****         return (OS_TASK_NOT_EXIST);
  86:OSsrc/os_task.c ****     }                                       
  87:OSsrc/os_task.c ****     y                     = newprio >> 3;                       /* Yes, compute new TCB fields     
  88:OSsrc/os_task.c ****     bity                  = OSMapTbl[y];
  89:OSsrc/os_task.c ****     x                     = newprio & 0x07;
  90:OSsrc/os_task.c ****     bitx                  = OSMapTbl[x];
  91:OSsrc/os_task.c ****     OSTCBPrioTbl[oldprio] = (OS_TCB *)0;                        /* Remove TCB from old priority    
  92:OSsrc/os_task.c ****     OSTCBPrioTbl[newprio] = ptcb;                               /* Place pointer to TCB @ new prior
  93:OSsrc/os_task.c ****     y_old                 = ptcb->OSTCBY;
  94:OSsrc/os_task.c ****     if ((OSRdyTbl[y_old] & ptcb->OSTCBBitX) != 0x00) {          /* If task is ready make it not    
  95:OSsrc/os_task.c ****         OSRdyTbl[y_old] &= ~ptcb->OSTCBBitX;
  96:OSsrc/os_task.c ****         if (OSRdyTbl[y_old] == 0x00) {
  97:OSsrc/os_task.c ****             OSRdyGrp &= ~ptcb->OSTCBBitY;
  98:OSsrc/os_task.c ****         }
  99:OSsrc/os_task.c ****         OSRdyGrp    |= bity;                                    /* Make new priority ready to run  
 100:OSsrc/os_task.c ****         OSRdyTbl[y] |= bitx;
 101:OSsrc/os_task.c **** #if OS_EVENT_EN
 102:OSsrc/os_task.c ****     } else {                                                    /* Task was not ready ...          
 103:OSsrc/os_task.c ****         pevent = ptcb->OSTCBEventPtr;
 104:OSsrc/os_task.c ****         if (pevent != (OS_EVENT *)0) {                          /* ... remove from event wait list 
 105:OSsrc/os_task.c ****             pevent->OSEventTbl[y_old] &= ~ptcb->OSTCBBitX;
 106:OSsrc/os_task.c ****             if (pevent->OSEventTbl[y_old] == 0) {
 107:OSsrc/os_task.c ****                 pevent->OSEventGrp &= ~ptcb->OSTCBBitY;
 108:OSsrc/os_task.c ****             }
 109:OSsrc/os_task.c ****             pevent->OSEventGrp    |= bity;                      /* Add new priority to wait list   
 110:OSsrc/os_task.c ****             pevent->OSEventTbl[y] |= bitx;
 111:OSsrc/os_task.c ****         }
 112:OSsrc/os_task.c **** #endif
 113:OSsrc/os_task.c ****     }
 114:OSsrc/os_task.c ****     ptcb->OSTCBPrio = newprio;                                  /* Set new task priority           
 115:OSsrc/os_task.c ****     ptcb->OSTCBY    = y;
 116:OSsrc/os_task.c ****     ptcb->OSTCBX    = x;
 117:OSsrc/os_task.c ****     ptcb->OSTCBBitY = bity;
 118:OSsrc/os_task.c ****     ptcb->OSTCBBitX = bitx;
 119:OSsrc/os_task.c ****     OS_EXIT_CRITICAL();
 120:OSsrc/os_task.c ****     OS_Sched();                                                 /* Run highest priority task ready 
 121:OSsrc/os_task.c ****     return (OS_NO_ERR);
 122:OSsrc/os_task.c **** }
 123:OSsrc/os_task.c **** #endif
 124:OSsrc/os_task.c **** /*$PAGE*/
 125:OSsrc/os_task.c **** /*
 126:OSsrc/os_task.c **** ***************************************************************************************************
 127:OSsrc/os_task.c **** *                                            CREATE A TASK
 128:OSsrc/os_task.c **** *
 129:OSsrc/os_task.c **** * Description: This function is used to have uC/OS-II manage the execution of a task.  Tasks can ei
 130:OSsrc/os_task.c **** *              be created prior to the start of multitasking or by a running task.  A task cannot b
 131:OSsrc/os_task.c **** *              created by an ISR.
 132:OSsrc/os_task.c **** *
 133:OSsrc/os_task.c **** * Arguments  : task     is a pointer to the task's code
 134:OSsrc/os_task.c **** *
 135:OSsrc/os_task.c **** *              p_arg    is a pointer to an optional data area which can be used to pass parameters 
 136:OSsrc/os_task.c **** *                       the task when the task first executes.  Where the task is concerned it thin
 137:OSsrc/os_task.c **** *                       it was invoked and passed the argument 'p_arg' as follows:
 138:OSsrc/os_task.c **** *
 139:OSsrc/os_task.c **** *                           void Task (void *p_arg)
 140:OSsrc/os_task.c **** *                           {
 141:OSsrc/os_task.c **** *                               for (;;) {
 142:OSsrc/os_task.c **** *                                   Task code;
 143:OSsrc/os_task.c **** *                               }
 144:OSsrc/os_task.c **** *                           }
 145:OSsrc/os_task.c **** *
 146:OSsrc/os_task.c **** *              ptos     is a pointer to the task's top of stack.  If the configuration constant
 147:OSsrc/os_task.c **** *                       OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from
 148:OSsrc/os_task.c **** *                       memory to low memory).  'pstk' will thus point to the highest (valid) memor
 149:OSsrc/os_task.c **** *                       location of the stack.  If OS_STK_GROWTH is set to 0, 'pstk' will point to 
 150:OSsrc/os_task.c **** *                       lowest memory location of the stack and the stack will grow with increasing
 151:OSsrc/os_task.c **** *                       memory locations.
 152:OSsrc/os_task.c **** *
 153:OSsrc/os_task.c **** *              prio     is the task's priority.  A unique priority MUST be assigned to each task an
 154:OSsrc/os_task.c **** *                       lower the number, the higher the priority.
 155:OSsrc/os_task.c **** *
 156:OSsrc/os_task.c **** * Returns    : OS_NO_ERR               if the function was successful.
 157:OSsrc/os_task.c **** *              OS_PRIO_EXIT            if the task priority already exist
 158:OSsrc/os_task.c **** *                                      (each task MUST have a unique priority).
 159:OSsrc/os_task.c **** *              OS_PRIO_INVALID         if the priority you specify is higher that the maximum allow
 160:OSsrc/os_task.c **** *                                      (i.e. >= OS_LOWEST_PRIO)
 161:OSsrc/os_task.c **** *              OS_ERR_TASK_CREATE_ISR  if you tried to create a task from an ISR.
 162:OSsrc/os_task.c **** ***************************************************************************************************
 163:OSsrc/os_task.c **** */
 164:OSsrc/os_task.c **** 
 165:OSsrc/os_task.c **** #if OS_TASK_CREATE_EN > 0
 166:OSsrc/os_task.c **** INT8U  OSTaskCreate (void (*task)(void *pd), void *p_arg, OS_STK *ptos, INT8U prio)
 167:OSsrc/os_task.c **** {
  92               	.LM1:
  93               	/* prologue: frame size=0 */
  94 0000 9F92      		push r9
  95 0002 AF92      		push r10
  96 0004 BF92      		push r11
  97 0006 CF92      		push r12
  98 0008 DF92      		push r13
  99 000a EF92      		push r14
 100 000c FF92      		push r15
 101 000e 0F93      		push r16
 102 0010 1F93      		push r17
 103 0012 CF93      		push r28
 104 0014 DF93      		push r29
 105               	/* prologue end (size=11) */
 106 0016 DC01      		movw r26,r24
 107 0018 922E      		mov r9,r18
 168:OSsrc/os_task.c ****     OS_STK    *psp;
 169:OSsrc/os_task.c ****     INT8U      err;
 170:OSsrc/os_task.c **** #if OS_CRITICAL_METHOD == 3                  /* Allocate storage for CPU status register           
 171:OSsrc/os_task.c ****     OS_CPU_SR  cpu_sr;
 172:OSsrc/os_task.c **** 
 173:OSsrc/os_task.c **** 
 174:OSsrc/os_task.c **** 
 175:OSsrc/os_task.c ****     cpu_sr = 0;                              /* Prevent compiler warning                           
 176:OSsrc/os_task.c **** #endif    
 177:OSsrc/os_task.c **** #if OS_ARG_CHK_EN > 0
 178:OSsrc/os_task.c ****     if (prio > OS_LOWEST_PRIO) {             /* Make sure priority is within allowable range       
 109               	.LM2:
 110 001a 8FE3      		ldi r24,lo8(63)
 111 001c 8217      		cp r24,r18
 112 001e 18F4      		brsh .L2
 179:OSsrc/os_task.c ****         return (OS_PRIO_INVALID);
 114               	.LM3:
 115 0020 8AE2      		ldi r24,lo8(42)

⌨️ 快捷键说明

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