📄 os_task.lst
字号:
\ 00000008 0150B0E1 MOVS R5,R1
\ 0000000C 0260B0E1 MOVS R6,R2
\ 00000010 0370B0E1 MOVS R7,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
\ 00000018 00A0B0E1 MOVS R10,R0
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 */
\ 0000001C 200057E3 CMP R7,#+32
\ 00000020 0100003A BCC ??OSTaskCreate_0
200 return (OS_ERR_PRIO_INVALID);
\ 00000024 2A00A0E3 MOV R0,#+42
\ 00000028 420000EA B ??OSTaskCreate_1
201 }
202 #endif
203 OS_ENTER_CRITICAL();
\ ??OSTaskCreate_0:
\ 0000002C ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
\ 00000030 00A0B0E1 MOVS R10,R0
204 if (OSIntNesting > 0) { /* Make sure we don't create the task from within an ISR */
\ 00000034 ........ LDR R0,??DataTable26 ;; OSIntNesting
\ 00000038 0000D0E5 LDRB R0,[R0, #+0]
\ 0000003C 010050E3 CMP R0,#+1
\ 00000040 0300003A BCC ??OSTaskCreate_2
205 OS_EXIT_CRITICAL();
\ 00000044 0A00B0E1 MOVS R0,R10
\ 00000048 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
206 return (OS_ERR_TASK_CREATE_ISR);
\ 0000004C 3C00A0E3 MOV R0,#+60
\ 00000050 380000EA B ??OSTaskCreate_1
207 }
208 if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority */
\ ??OSTaskCreate_2:
\ 00000054 0700B0E1 MOVS R0,R7
\ 00000058 0410A0E3 MOV R1,#+4
\ 0000005C ........ LDR R2,??DataTable52 ;; OSTCBPrioTbl
\ 00000060 912020E0 MLA R0,R1,R0,R2
\ 00000064 000090E5 LDR R0,[R0, #+0]
\ 00000068 000050E3 CMP R0,#+0
\ 0000006C 2E00001A BNE ??OSTaskCreate_3
209 OSTCBPrioTbl[prio] = (OS_TCB *)1; /* Reserve the priority to prevent others from doing ... */
\ 00000070 0700B0E1 MOVS R0,R7
\ 00000074 0410A0E3 MOV R1,#+4
\ 00000078 ........ LDR R2,??DataTable52 ;; OSTCBPrioTbl
\ 0000007C 912020E0 MLA R0,R1,R0,R2
\ 00000080 0110A0E3 MOV R1,#+1
\ 00000084 001080E5 STR R1,[R0, #+0]
210 /* ... the same thing until task is created. */
211 OS_EXIT_CRITICAL();
\ 00000088 0A00B0E1 MOVS R0,R10
\ 0000008C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
212 psp = OSTaskStkInit(task, p_arg, ptos, 0); /* Initialize the task's stack */
\ 00000090 0030A0E3 MOV R3,#+0
\ 00000094 0620B0E1 MOVS R2,R6
\ 00000098 0510B0E1 MOVS R1,R5
\ 0000009C 0400B0E1 MOVS R0,R4
\ 000000A0 ........ _BLF OSTaskStkInit,??OSTaskStkInit??rA
\ 000000A4 0080B0E1 MOVS R8,R0
213 err = OS_TCBInit(prio, psp, (OS_STK *)0, 0, 0, (void *)0, 0);
\ 000000A8 0000A0E3 MOV R0,#+0
\ 000000AC 01002DE9 PUSH {R0}
\ 000000B0 0000A0E3 MOV R0,#+0
\ 000000B4 01002DE9 PUSH {R0}
\ 000000B8 0000A0E3 MOV R0,#+0
\ 000000BC 01002DE9 PUSH {R0}
\ 000000C0 0030A0E3 MOV R3,#+0
\ 000000C4 0020A0E3 MOV R2,#+0
\ 000000C8 0810B0E1 MOVS R1,R8
\ 000000CC 0700B0E1 MOVS R0,R7
\ 000000D0 ........ _BLF OS_TCBInit,??OS_TCBInit??rA
\ 000000D4 0CD08DE2 ADD SP,SP,#+12 ;; stack cleaning
\ 000000D8 0090B0E1 MOVS R9,R0
214 if (err == OS_ERR_NONE) {
\ 000000DC 000059E3 CMP R9,#+0
\ 000000E0 0500001A BNE ??OSTaskCreate_4
215 if (OSRunning == OS_TRUE) { /* Find highest priority task if multitasking has started */
\ 000000E4 ........ LDR R0,??DataTable47 ;; OSRunning
\ 000000E8 0000D0E5 LDRB R0,[R0, #+0]
\ 000000EC 010050E3 CMP R0,#+1
\ 000000F0 0B00001A BNE ??OSTaskCreate_5
216 OS_Sched();
\ 000000F4 ........ _BLF OS_Sched,??OS_Sched??rA
\ 000000F8 090000EA B ??OSTaskCreate_5
217 }
218 } else {
219 OS_ENTER_CRITICAL();
\ ??OSTaskCreate_4:
\ 000000FC ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
\ 00000100 00A0B0E1 MOVS R10,R0
220 OSTCBPrioTbl[prio] = (OS_TCB *)0;/* Make this priority available to others */
\ 00000104 0700B0E1 MOVS R0,R7
\ 00000108 0410A0E3 MOV R1,#+4
\ 0000010C ........ LDR R2,??DataTable52 ;; OSTCBPrioTbl
\ 00000110 912020E0 MLA R0,R1,R0,R2
\ 00000114 0010A0E3 MOV R1,#+0
\ 00000118 001080E5 STR R1,[R0, #+0]
221 OS_EXIT_CRITICAL();
\ 0000011C 0A00B0E1 MOVS R0,R10
\ 00000120 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
222 }
223 return (err);
\ ??OSTaskCreate_5:
\ 00000124 0900B0E1 MOVS R0,R9
\ 00000128 020000EA B ??OSTaskCreate_1
224 }
225 OS_EXIT_CRITICAL();
\ ??OSTaskCreate_3:
\ 0000012C 0A00B0E1 MOVS R0,R10
\ 00000130 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
226 return (OS_ERR_PRIO_EXIST);
\ 00000134 2800A0E3 MOV R0,#+40
\ ??OSTaskCreate_1:
\ 00000138 F087BDE8 POP {R4-R10,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)
310 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -