📄 os_task.lst
字号:
\ 00000176 0020 MOVS R0,#+0
\ ??OSTaskChangePrio_1:
\ 00000178 05B0 ADD SP,SP,#+20
\ 0000017A BDE8F08F POP {R4-R11,PC} ;; return
171 }
172 #endif
173 /*$PAGE*/
174 /*
175 *********************************************************************************************************
176 * CREATE A TASK
177 *
178 * Description: This function is used to have uC/OS-II manage the execution of a task. Tasks can either
179 * be created prior to the start of multitasking or by a running task. A task cannot be
180 * created by an ISR.
181 *
182 * Arguments : task is a pointer to the task's code
183 *
184 * p_arg is a pointer to an optional data area which can be used to pass parameters to
185 * the task when the task first executes. Where the task is concerned it thinks
186 * it was invoked and passed the argument 'p_arg' as follows:
187 *
188 * void Task (void *p_arg)
189 * {
190 * for (;;) {
191 * Task code;
192 * }
193 * }
194 *
195 * ptos is a pointer to the task's top of stack. If the configuration constant
196 * OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
197 * memory to low memory). 'pstk' will thus point to the highest (valid) memory
198 * location of the stack. If OS_STK_GROWTH is set to 0, 'pstk' will point to the
199 * lowest memory location of the stack and the stack will grow with increasing
200 * memory locations.
201 *
202 * prio is the task's priority. A unique priority MUST be assigned to each task and the
203 * lower the number, the higher the priority.
204 *
205 * Returns : OS_ERR_NONE if the function was successful.
206 * OS_PRIO_EXIT if the task priority already exist
207 * (each task MUST have a unique priority).
208 * OS_ERR_PRIO_INVALID if the priority you specify is higher that the maximum allowed
209 * (i.e. >= OS_LOWEST_PRIO)
210 * OS_ERR_TASK_CREATE_ISR if you tried to create a task from an ISR.
211 *********************************************************************************************************
212 */
213
214 #if OS_TASK_CREATE_EN > 0
\ In segment CODE, align 4, keep-with-next
215 INT8U OSTaskCreate (void (*task)(void *p_arg), void *p_arg, OS_STK *ptos, INT8U prio)
216 {
\ OSTaskCreate:
\ 00000000 2DE9F041 PUSH {R4-R8,LR}
\ 00000004 8046 MOV R8,R0
\ 00000006 0E00 MOVS R6,R1
\ 00000008 1700 MOVS R7,R2
\ 0000000A 1D00 MOVS R5,R3
217 OS_STK *psp;
218 INT8U err;
219 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
220 OS_CPU_SR cpu_sr = 0;
221 #endif
222
223
224
225 #if OS_ARG_CHK_EN > 0
226 if (prio > OS_LOWEST_PRIO) { /* Make sure priority is within allowable range */
227 return (OS_ERR_PRIO_INVALID);
228 }
229 #endif
230 OS_ENTER_CRITICAL();
\ 0000000C ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
231 if (OSIntNesting > 0) { /* Make sure we don't create the task from within an ISR */
\ 00000010 .... LDR.N R1,??DataTable20 ;; OSIntNesting
\ 00000012 0978 LDRB R1,[R1, #+0]
\ 00000014 0029 CMP R1,#+0
\ 00000016 03D0 BEQ.N ??OSTaskCreate_0
232 OS_EXIT_CRITICAL();
\ 00000018 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
233 return (OS_ERR_TASK_CREATE_ISR);
\ 0000001C 3C20 MOVS R0,#+60
\ 0000001E 2EE0 B.N ??OSTaskCreate_1
234 }
\ ??OSTaskCreate_0:
\ 00000020 .... LDR.N R1,??DataTable10 ;; OSTCBPrioTbl
\ 00000022 11EB8504 ADDS R4,R1,R5, LSL #+2
\ 00000026 2168 LDR R1,[R4, #+0]
\ 00000028 0029 CMP R1,#+0
\ 0000002A 25D1 BNE.N ??OSTaskCreate_2
235 if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority */
236 OSTCBPrioTbl[prio] = OS_TCB_RESERVED;/* Reserve the priority to prevent others from doing ... */
\ 0000002C 0121 MOVS R1,#+1
\ 0000002E 2160 STR R1,[R4, #+0]
237 /* ... the same thing until task is created. */
238 OS_EXIT_CRITICAL();
\ 00000030 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
239 psp = OSTaskStkInit(task, p_arg, ptos, 0); /* Initialize the task's stack */
\ 00000034 0023 MOVS R3,#+0
\ 00000036 3A00 MOVS R2,R7
\ 00000038 3100 MOVS R1,R6
\ 0000003A 4046 MOV R0,R8
\ 0000003C ........ _BLF OSTaskStkInit,??OSTaskStkInit??rT
\ 00000040 0600 MOVS R6,R0
240 err = OS_TCBInit(prio, psp, (OS_STK *)0, 0, 0, (void *)0, 0);
\ 00000042 0022 MOVS R2,#+0
\ 00000044 1146 MOV R1,R2
\ 00000046 0846 MOV R0,R1
\ 00000048 07B4 PUSH {R0-R2}
\ 0000004A 0346 MOV R3,R0
\ 0000004C 3100 MOVS R1,R6
\ 0000004E 2800 MOVS R0,R5
\ 00000050 ........ _BLF OS_TCBInit,??OS_TCBInit??rT
\ 00000054 0500 MOVS R5,R0
241 if (err == OS_ERR_NONE) {
\ 00000056 03B0 ADD SP,SP,#+12
\ 00000058 06D1 BNE.N ??OSTaskCreate_3
242 if (OSRunning == OS_TRUE) { /* Find highest priority task if multitasking has started */
\ 0000005A .... LDR.N R0,??DataTable17 ;; OSRunning
\ 0000005C 0078 LDRB R0,[R0, #+0]
\ 0000005E 0128 CMP R0,#+1
\ 00000060 08D1 BNE.N ??OSTaskCreate_4
243 OS_Sched();
\ 00000062 ........ _BLF OS_Sched,??OS_Sched??rT
\ 00000066 05E0 B.N ??OSTaskCreate_4
244 }
245 } else {
246 OS_ENTER_CRITICAL();
\ ??OSTaskCreate_3:
\ 00000068 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
247 OSTCBPrioTbl[prio] = (OS_TCB *)0;/* Make this priority available to others */
\ 0000006C 0021 MOVS R1,#+0
\ 0000006E 2160 STR R1,[R4, #+0]
248 OS_EXIT_CRITICAL();
\ 00000070 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
249 }
250 return (err);
\ ??OSTaskCreate_4:
\ 00000074 2800 MOVS R0,R5
\ 00000076 02E0 B.N ??OSTaskCreate_1
251 }
252 OS_EXIT_CRITICAL();
\ ??OSTaskCreate_2:
\ 00000078 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
253 return (OS_ERR_PRIO_EXIST);
\ 0000007C 2820 MOVS R0,#+40
\ ??OSTaskCreate_1:
\ 0000007E BDE8F081 POP {R4-R8,PC} ;; return
254 }
255 #endif
256 /*$PAGE*/
257 /*
258 *********************************************************************************************************
259 * CREATE A TASK (Extended Version)
260 *
261 * Description: This function is used to have uC/OS-II manage the execution of a task. Tasks can either
262 * be created prior to the start of multitasking or by a running task. A task cannot be
263 * created by an ISR. This function is similar to OSTaskCreate() except that it allows
264 * additional information about a task to be specified.
265 *
266 * Arguments : task is a pointer to the task's code
267 *
268 * p_arg is a pointer to an optional data area which can be used to pass parameters to
269 * the task when the task first executes. Where the task is concerned it thinks
270 * it was invoked and passed the argument 'p_arg' as follows:
271 *
272 * void Task (void *p_arg)
273 * {
274 * for (;;) {
275 * Task code;
276 * }
277 * }
278 *
279 * ptos is a pointer to the task's top of stack. If the configuration constant
280 * OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
281 * memory to low memory). 'ptos' will thus point to the highest (valid) memory
282 * location of the stack. If OS_STK_GROWTH is set to 0, 'ptos' will point to the
283 * lowest memory location of the stack and the stack will grow with increasing
284 * memory locations. 'ptos' MUST point to a valid 'free' data item.
285 *
286 * prio is the task's priority. A unique priority MUST be assigned to each task and the
287 * lower the number, the higher the priority.
288 *
289 * id is the task's ID (0..65535)
290 *
291 * pbos is a pointer to the task's bottom of stack. If the configuration constant
292 * OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
293 * memory to low memory). 'pbos' will thus point to the LOWEST (valid) memory
294 * location of the stack. If OS_STK_GROWTH is set to 0, 'pbos' will point to the
295 * HIGHEST memory location of the stack and the stack will grow with increasing
296 * memory locations. 'pbos' MUST point to a valid 'free' data item.
297 *
298 * stk_size is the size of the stack in number of elements. If OS_STK is set to INT8U,
299 * 'stk_size' corresponds to the number of bytes available. If OS_STK is set to
300 * INT16U, 'stk_size' contains the number of 16-bit entries available. Finally, if
301 * OS_STK is set to INT32U, 'stk_size' contains the number of 32-bit entries
302 * available on the stack.
303 *
304 * pext is a pointer to a user supplied memory location which is used as a TCB extension.
305 * For example, this user memory can hold the contents of floating-point registers
306 * during a context switch, the time each task takes to execute, the number of times
307 * the task has been switched-in, etc.
308 *
309 * opt contains additional information (or options) about the behavior of the task. The
310 * LOWER 8-bits are reserved by uC/OS-II while the upper 8 bits can be application
311 * specific. See OS_TASK_OPT_??? in uCOS-II.H. Current choices are:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -