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

📄 os_task.lst

📁 称植到lpc2124上的UCOS2.85版 是本人初学移植和ARM的成果 可能已有人上传类似的了
💻 LST
📖 第 1 页 / 共 5 页
字号:
   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:
 111               	.global	OSTaskCreate
 113               	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-2007, 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.85
  13:../OSsrc/os_task.c **** *
  14:../OSsrc/os_task.c **** * LICENSING TERMS:
  15:../OSsrc/os_task.c **** * ---------------
  16:../OSsrc/os_task.c **** *   uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful re
  17:../OSsrc/os_task.c **** * If you plan on using  uC/OS-II  in a commercial product you need to contact Micri祄 to properly l
  18:../OSsrc/os_task.c **** * its use in your product. We provide ALL the source code for your convenience and to help you expe
  19:../OSsrc/os_task.c **** * uC/OS-II.   The fact that the  source is provided does  NOT  mean that you can use it without  pa
  20:../OSsrc/os_task.c **** * licensing fee.
  21:../OSsrc/os_task.c **** ***************************************************************************************************
  22:../OSsrc/os_task.c **** */
  23:../OSsrc/os_task.c **** 
  24:../OSsrc/os_task.c **** #ifndef  OS_MASTER_FILE
  25:../OSsrc/os_task.c **** #include <ucos_ii.h>
  26:../OSsrc/os_task.c **** #endif
  27:../OSsrc/os_task.c **** 
  28:../OSsrc/os_task.c **** /*$PAGE*/
  29:../OSsrc/os_task.c **** /*
  30:../OSsrc/os_task.c **** ***************************************************************************************************
  31:../OSsrc/os_task.c **** *                                        CHANGE PRIORITY OF A TASK
  32:../OSsrc/os_task.c **** *
  33:../OSsrc/os_task.c **** * Description: This function allows you to change the priority of a task dynamically.  Note that th
  34:../OSsrc/os_task.c **** *              priority MUST be available.
  35:../OSsrc/os_task.c **** *
  36:../OSsrc/os_task.c **** * Arguments  : oldp     is the old priority
  37:../OSsrc/os_task.c **** *
  38:../OSsrc/os_task.c **** *              newp     is the new priority
  39:../OSsrc/os_task.c **** *
  40:../OSsrc/os_task.c **** * Returns    : OS_ERR_NONE            is the call was successful
  41:../OSsrc/os_task.c **** *              OS_ERR_PRIO_INVALID    if the priority you specify is higher that the maximum allowe
  42:../OSsrc/os_task.c **** *                                     (i.e. >= OS_LOWEST_PRIO)
  43:../OSsrc/os_task.c **** *              OS_ERR_PRIO_EXIST      if the new priority already exist.
  44:../OSsrc/os_task.c **** *              OS_ERR_PRIO            there is no task with the specified OLD priority (i.e. the OL
  45:../OSsrc/os_task.c **** *                                     not exist.
  46:../OSsrc/os_task.c **** *              OS_ERR_TASK_NOT_EXIST  if the task is assigned to a Mutex PIP.
  47:../OSsrc/os_task.c **** ***************************************************************************************************
  48:../OSsrc/os_task.c **** */
  49:../OSsrc/os_task.c **** 
  50:../OSsrc/os_task.c **** #if OS_TASK_CHANGE_PRIO_EN > 0
  51:../OSsrc/os_task.c **** INT8U  OSTaskChangePrio (INT8U oldprio, INT8U newprio)
  52:../OSsrc/os_task.c **** {
  53:../OSsrc/os_task.c **** #if OS_EVENT_EN
  54:../OSsrc/os_task.c ****     OS_EVENT    *pevent;
  55:../OSsrc/os_task.c **** #endif
  56:../OSsrc/os_task.c ****     OS_TCB      *ptcb;
  57:../OSsrc/os_task.c ****     INT8U        x;
  58:../OSsrc/os_task.c ****     INT8U        y;
  59:../OSsrc/os_task.c **** #if OS_LOWEST_PRIO <= 63
  60:../OSsrc/os_task.c ****     INT8U        bitx;
  61:../OSsrc/os_task.c ****     INT8U        bity;
  62:../OSsrc/os_task.c **** #else
  63:../OSsrc/os_task.c ****     INT16U       bitx;
  64:../OSsrc/os_task.c ****     INT16U       bity;
  65:../OSsrc/os_task.c **** #endif
  66:../OSsrc/os_task.c ****     INT8U        y_old;
  67:../OSsrc/os_task.c **** #if OS_CRITICAL_METHOD == 3
  68:../OSsrc/os_task.c ****     OS_CPU_SR    cpu_sr = 0;                                    /* Storage for CPU status register 
  69:../OSsrc/os_task.c **** #endif
  70:../OSsrc/os_task.c **** 
  71:../OSsrc/os_task.c **** 
  72:../OSsrc/os_task.c **** 
  73:../OSsrc/os_task.c **** #if OS_ARG_CHK_EN > 0
  74:../OSsrc/os_task.c ****     if (oldprio >= OS_LOWEST_PRIO) {
  75:../OSsrc/os_task.c ****         if (oldprio != OS_PRIO_SELF) {
  76:../OSsrc/os_task.c ****             return (OS_ERR_PRIO_INVALID);
  77:../OSsrc/os_task.c ****         }
  78:../OSsrc/os_task.c ****     }
  79:../OSsrc/os_task.c ****     if (newprio >= OS_LOWEST_PRIO) {
  80:../OSsrc/os_task.c ****         return (OS_ERR_PRIO_INVALID);
  81:../OSsrc/os_task.c ****     }
  82:../OSsrc/os_task.c **** #endif
  83:../OSsrc/os_task.c ****     OS_ENTER_CRITICAL();
  84:../OSsrc/os_task.c ****     if (OSTCBPrioTbl[newprio] != (OS_TCB *)0) {                 /* New priority must not already ex
  85:../OSsrc/os_task.c ****         OS_EXIT_CRITICAL();
  86:../OSsrc/os_task.c ****         return (OS_ERR_PRIO_EXIST);
  87:../OSsrc/os_task.c ****     }
  88:../OSsrc/os_task.c ****     if (oldprio == OS_PRIO_SELF) {                              /* See if changing self            
  89:../OSsrc/os_task.c ****         oldprio = OSTCBCur->OSTCBPrio;                          /* Yes, get priority               
  90:../OSsrc/os_task.c ****     }
  91:../OSsrc/os_task.c ****     ptcb = OSTCBPrioTbl[oldprio];
  92:../OSsrc/os_task.c ****     if (ptcb == (OS_TCB *)0) {                                  /* Does task to change exist?      
  93:../OSsrc/os_task.c ****         OS_EXIT_CRITICAL();                                     /* No, can't change its priority!  
  94:../OSsrc/os_task.c ****         return (OS_ERR_PRIO);
  95:../OSsrc/os_task.c ****     }
  96:../OSsrc/os_task.c ****     if (ptcb == OS_TCB_RESERVED) {                              /* Is task assigned to Mutex       
  97:../OSsrc/os_task.c ****         OS_EXIT_CRITICAL();                                     /* No, can't change its priority!  
  98:../OSsrc/os_task.c ****         return (OS_ERR_TASK_NOT_EXIST);
  99:../OSsrc/os_task.c ****     }
 100:../OSsrc/os_task.c **** #if OS_LOWEST_PRIO <= 63
 101:../OSsrc/os_task.c ****     y                     = (INT8U)(newprio >> 3);              /* Yes, compute new TCB fields     
 102:../OSsrc/os_task.c ****     x                     = (INT8U)(newprio & 0x07);
 103:../OSsrc/os_task.c ****     bity                  = (INT8U)(1 << y);
 104:../OSsrc/os_task.c ****     bitx                  = (INT8U)(1 << x);
 105:../OSsrc/os_task.c **** #else
 106:../OSsrc/os_task.c ****     y                     = (INT8U)((newprio >> 4) & 0x0F);
 107:../OSsrc/os_task.c ****     x                     = (INT8U)( newprio & 0x0F);
 108:../OSsrc/os_task.c ****     bity                  = (INT16U)(1 << y);
 109:../OSsrc/os_task.c ****     bitx                  = (INT16U)(1 << x);
 110:../OSsrc/os_task.c **** #endif
 111:../OSsrc/os_task.c **** 
 112:../OSsrc/os_task.c ****     OSTCBPrioTbl[oldprio] = (OS_TCB *)0;                        /* Remove TCB from old priority    
 113:../OSsrc/os_task.c ****     OSTCBPrioTbl[newprio] = ptcb;                               /* Place pointer to TCB @ new prior
 114:../OSsrc/os_task.c ****     y_old                 = ptcb->OSTCBY;
 115:../OSsrc/os_task.c ****     if ((OSRdyTbl[y_old] & ptcb->OSTCBBitX) != 0) {             /* If task is ready make it not    
 116:../OSsrc/os_task.c ****         OSRdyTbl[y_old] &= ~ptcb->OSTCBBitX;
 117:../OSsrc/os_task.c ****         if (OSRdyTbl[y_old] == 0) {
 118:../OSsrc/os_task.c ****             OSRdyGrp &= ~ptcb->OSTCBBitY;
 119:../OSsrc/os_task.c ****         }
 120:../OSsrc/os_task.c ****         OSRdyGrp    |= bity;                                    /* Make new priority ready to run  
 121:../OSsrc/os_task.c ****         OSRdyTbl[y] |= bitx;
 122:../OSsrc/os_task.c ****     }
 123:../OSsrc/os_task.c **** #if OS_EVENT_EN
 124:../OSsrc/os_task.c ****     pevent = ptcb->OSTCBEventPtr;
 125:../OSsrc/os_task.c ****     if (pevent != (OS_EVENT *)0) {                              /* ... remove from event wait list 
 126:../OSsrc/os_task.c ****         pevent->OSEventTbl[y_old] &= ~ptcb->OSTCBBitX;
 127:../OSsrc/os_task.c ****         if (pevent->OSEventTbl[y_old] == 0) {
 128:../OSsrc/os_task.c ****             pevent->OSEventGrp &= ~ptcb->OSTCBBitY;
 129:../OSsrc/os_task.c ****         }
 130:../OSsrc/os_task.c ****         pevent->OSEventGrp    |= bity;                          /* Add new priority to wait list   
 131:../OSsrc/os_task.c ****         pevent->OSEventTbl[y] |= bitx;
 132:../OSsrc/os_task.c ****     }
 133:../OSsrc/os_task.c **** #endif
 134:../OSsrc/os_task.c ****     ptcb->OSTCBPrio = newprio;                                  /* Set new task priority           
 135:../OSsrc/os_task.c ****     ptcb->OSTCBY    = y;
 136:../OSsrc/os_task.c ****     ptcb->OSTCBX    = x;
 137:../OSsrc/os_task.c ****     ptcb->OSTCBBitY = bity;
 138:../OSsrc/os_task.c ****     ptcb->OSTCBBitX = bitx;
 139:../OSsrc/os_task.c ****     OS_EXIT_CRITICAL();
 140:../OSsrc/os_task.c ****     if (OSRunning == OS_TRUE) {
 141:../OSsrc/os_task.c ****         OS_Sched();                                             /* Find new highest priority task  
 142:../OSsrc/os_task.c ****     }
 143:../OSsrc/os_task.c ****     return (OS_ERR_NONE);
 144:../OSsrc/os_task.c **** }
 145:../OSsrc/os_task.c **** #endif
 146:../OSsrc/os_task.c **** /*$PAGE*/
 147:../OSsrc/os_task.c **** /*
 148:../OSsrc/os_task.c **** ***************************************************************************************************
 149:../OSsrc/os_task.c **** *                                            CREATE A TASK
 150:../OSsrc/os_task.c **** *
 151:../OSsrc/os_task.c **** * Description: This function is used to have uC/OS-II manage the execution of a task.  Tasks can ei
 152:../OSsrc/os_task.c **** *              be created prior to the start of multitasking or by a running task.  A task cannot b
 153:../OSsrc/os_task.c **** *              created by an ISR.
 154:../OSsrc/os_task.c **** *
 155:../OSsrc/os_task.c **** * Arguments  : task     is a pointer to the task's code
 156:../OSsrc/os_task.c **** *
 157:../OSsrc/os_task.c **** *              p_arg    is a pointer to an optional data area which can be used to pass parameters 
 158:../OSsrc/os_task.c **** *                       the task when the task first executes.  Where the task is concerned it thin
 159:../OSsrc/os_task.c **** *                       it was invoked and passed the argument 'p_arg' as follows:
 160:../OSsrc/os_task.c **** *
 161:../OSsrc/os_task.c **** *                           void Task (void *p_arg)
 162:../OSsrc/os_task.c **** *                           {
 163:../OSsrc/os_task.c **** *                               for (;;) {
 164:../OSsrc/os_task.c **** *                                   Task code;
 165:../OSsrc/os_task.c **** *                               }
 166:../OSsrc/os_task.c **** *                           }
 167:../OSsrc/os_task.c **** *
 168:../OSsrc/os_task.c **** *              ptos     is a pointer to the task's top of stack.  If the configuration constant
 169:../OSsrc/os_task.c **** *                       OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from
 170:../OSsrc/os_task.c **** *                       memory to low memory).  'pstk' will thus point to the highest (valid) memor
 171:../OSsrc/os_task.c **** *                       location of the stack.  If OS_STK_GROWTH is set to 0, 'pstk' will point to 
 172:../OSsrc/os_task.c **** *                       lowest memory location of the stack and the stack will grow with increasing
 173:../OSsrc/os_task.c **** *                       memory locations.
 174:../OSsrc/os_task.c **** *
 175:../OSsrc/os_task.c **** *              prio     is the task's priority.  A unique priority MUST be assigned to each task an
 176:../OSsrc/os_task.c **** *                       lower the number, the higher the priority.

⌨️ 快捷键说明

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