📄 os_task.lst
字号:
161 }
162 return (OS_ERR_NONE);
\ ??OSTaskChangePrio_12:
\ 00000240 0020 MOVS R0,#+0
\ ??OSTaskChangePrio_1:
\ 00000242 BDE8FE8F POP {R1-R11,PC} ;; return
163 }
164 #endif
165 /*$PAGE*/
166 /*
167 *********************************************************************************************************
168 * CREATE A TASK
169 *
170 * Description: This function is used to have uC/OS-II manage the execution of a task. Tasks can either
171 * be created prior to the start of multitasking or by a running task. A task cannot be
172 * created by an ISR.
173 *
174 * Arguments : task is a pointer to the task's code
175 *
176 * p_arg is a pointer to an optional data area which can be used to pass parameters to
177 * the task when the task first executes. Where the task is concerned it thinks
178 * it was invoked and passed the argument 'p_arg' as follows:
179 *
180 * void Task (void *p_arg)
181 * {
182 * for (;;) {
183 * Task code;
184 * }
185 * }
186 *
187 * ptos is a pointer to the task's top of stack. If the configuration constant
188 * OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
189 * memory to low memory). 'pstk' will thus point to the highest (valid) memory
190 * location of the stack. If OS_STK_GROWTH is set to 0, 'pstk' will point to the
191 * lowest memory location of the stack and the stack will grow with increasing
192 * memory locations.
193 *
194 * prio is the task's priority. A unique priority MUST be assigned to each task and the
195 * lower the number, the higher the priority.
196 *
197 * Returns : OS_ERR_NONE if the function was successful.
198 * OS_ERR_PRIO_EXIST if the task priority already exist
199 * (each task MUST have a unique priority).
200 * OS_ERR_PRIO_INVALID if the priority you specify is higher that the maximum
201 * allowed (i.e. >= OS_LOWEST_PRIO)
202 * OS_ERR_TASK_CREATE_ISR if you tried to create a task from an ISR.
203 * OS_ERR_ILLEGAL_CREATE_RUN_TIME if you tried to create a task after safety critical
204 * operation started.
205 *********************************************************************************************************
206 */
207
208 #if OS_TASK_CREATE_EN > 0u
\ In section .text, align 2, keep-with-next
209 INT8U OSTaskCreate (void (*task)(void *p_arg),
210 void *p_arg,
211 OS_STK *ptos,
212 INT8U prio)
213 {
\ OSTaskCreate:
\ 00000000 2DE9F047 PUSH {R4-R10,LR}
\ 00000004 84B0 SUB SP,SP,#+16
\ 00000006 0400 MOVS R4,R0
\ 00000008 0D00 MOVS R5,R1
\ 0000000A 1600 MOVS R6,R2
\ 0000000C 1F00 MOVS R7,R3
214 OS_STK *psp;
215 INT8U err;
216 #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
217 OS_CPU_SR cpu_sr = 0u;
\ 0000000E 5FF0000A MOVS R10,#+0
218 #endif
219
220
221
222 #ifdef OS_SAFETY_CRITICAL_IEC61508
223 if (OSSafetyCriticalStartFlag == OS_TRUE) {
224 OS_SAFETY_CRITICAL_EXCEPTION();
225 return (OS_ERR_ILLEGAL_CREATE_RUN_TIME);
226 }
227 #endif
228
229 #if OS_ARG_CHK_EN > 0u
230 if (prio > OS_LOWEST_PRIO) { /* Make sure priority is within allowable range */
231 return (OS_ERR_PRIO_INVALID);
232 }
233 #endif
234 OS_ENTER_CRITICAL();
\ 00000012 ........ BL OS_CPU_SR_Save
\ 00000016 8246 MOV R10,R0
235 if (OSIntNesting > 0u) { /* Make sure we don't create the task from within an ISR */
\ 00000018 ........ LDR.W R0,??DataTable14_5
\ 0000001C 0078 LDRB R0,[R0, #+0]
\ 0000001E 0028 CMP R0,#+0
\ 00000020 04D0 BEQ.N ??OSTaskCreate_0
236 OS_EXIT_CRITICAL();
\ 00000022 5046 MOV R0,R10
\ 00000024 ........ BL OS_CPU_SR_Restore
237 return (OS_ERR_TASK_CREATE_ISR);
\ 00000028 3C20 MOVS R0,#+60
\ 0000002A 44E0 B.N ??OSTaskCreate_1
238 }
239 if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority */
\ ??OSTaskCreate_0:
\ 0000002C FFB2 UXTB R7,R7 ;; ZeroExt R7,R7,#+24,#+24
\ 0000002E ........ LDR.W R0,??DataTable14
\ 00000032 50F82700 LDR R0,[R0, R7, LSL #+2]
\ 00000036 0028 CMP R0,#+0
\ 00000038 39D1 BNE.N ??OSTaskCreate_2
240 OSTCBPrioTbl[prio] = OS_TCB_RESERVED;/* Reserve the priority to prevent others from doing ... */
\ 0000003A FFB2 UXTB R7,R7 ;; ZeroExt R7,R7,#+24,#+24
\ 0000003C ........ LDR.W R0,??DataTable14
\ 00000040 0121 MOVS R1,#+1
\ 00000042 40F82710 STR R1,[R0, R7, LSL #+2]
241 /* ... the same thing until task is created. */
242 OS_EXIT_CRITICAL();
\ 00000046 5046 MOV R0,R10
\ 00000048 ........ BL OS_CPU_SR_Restore
243 psp = OSTaskStkInit(task, p_arg, ptos, 0u); /* Initialize the task's stack */
\ 0000004C 0023 MOVS R3,#+0
\ 0000004E 3200 MOVS R2,R6
\ 00000050 2900 MOVS R1,R5
\ 00000052 2000 MOVS R0,R4
\ 00000054 ........ BL OSTaskStkInit
\ 00000058 8046 MOV R8,R0
244 err = OS_TCBInit(prio, psp, (OS_STK *)0, 0u, 0u, (void *)0, 0u);
\ 0000005A 0020 MOVS R0,#+0
\ 0000005C 0290 STR R0,[SP, #+8]
\ 0000005E 0020 MOVS R0,#+0
\ 00000060 0190 STR R0,[SP, #+4]
\ 00000062 0020 MOVS R0,#+0
\ 00000064 0090 STR R0,[SP, #+0]
\ 00000066 0023 MOVS R3,#+0
\ 00000068 0022 MOVS R2,#+0
\ 0000006A 4146 MOV R1,R8
\ 0000006C 3800 MOVS R0,R7
\ 0000006E C0B2 UXTB R0,R0 ;; ZeroExt R0,R0,#+24,#+24
\ 00000070 ........ BL OS_TCBInit
\ 00000074 8146 MOV R9,R0
245 if (err == OS_ERR_NONE) {
\ 00000076 5FFA89F9 UXTB R9,R9 ;; ZeroExt R9,R9,#+24,#+24
\ 0000007A B9F1000F CMP R9,#+0
\ 0000007E 07D1 BNE.N ??OSTaskCreate_3
246 if (OSRunning == OS_TRUE) { /* Find highest priority task if multitasking has started */
\ 00000080 ........ LDR.W R0,??DataTable14_4
\ 00000084 0078 LDRB R0,[R0, #+0]
\ 00000086 0128 CMP R0,#+1
\ 00000088 0ED1 BNE.N ??OSTaskCreate_4
247 OS_Sched();
\ 0000008A ........ BL OS_Sched
\ 0000008E 0BE0 B.N ??OSTaskCreate_4
248 }
249 } else {
250 OS_ENTER_CRITICAL();
\ ??OSTaskCreate_3:
\ 00000090 ........ BL OS_CPU_SR_Save
\ 00000094 8246 MOV R10,R0
251 OSTCBPrioTbl[prio] = (OS_TCB *)0;/* Make this priority available to others */
\ 00000096 FFB2 UXTB R7,R7 ;; ZeroExt R7,R7,#+24,#+24
\ 00000098 ........ LDR.W R0,??DataTable14
\ 0000009C 0021 MOVS R1,#+0
\ 0000009E 40F82710 STR R1,[R0, R7, LSL #+2]
252 OS_EXIT_CRITICAL();
\ 000000A2 5046 MOV R0,R10
\ 000000A4 ........ BL OS_CPU_SR_Restore
253 }
254 return (err);
\ ??OSTaskCreate_4:
\ 000000A8 4846 MOV R0,R9
\ 000000AA C0B2 UXTB R0,R0 ;; ZeroExt R0,R0,#+24,#+24
\ 000000AC 03E0 B.N ??OSTaskCreate_1
255 }
256 OS_EXIT_CRITICAL();
\ ??OSTaskCreate_2:
\ 000000AE 5046 MOV R0,R10
\ 000000B0 ........ BL OS_CPU_SR_Restore
257 return (OS_ERR_PRIO_EXIST);
\ 000000B4 2820 MOVS R0,#+40
\ ??OSTaskCreate_1:
\ 000000B6 04B0 ADD SP,SP,#+16
\ 000000B8 BDE8F087 POP {R4-R10,PC} ;; return
258 }
259 #endif
260 /*$PAGE*/
261 /*
262 *********************************************************************************************************
263 * CREATE A TASK (Extended Version)
264 *
265 * Description: This function is used to have uC/OS-II manage the execution of a task. Tasks can either
266 * be created prior to the start of multitasking or by a running task. A task cannot be
267 * created by an ISR. This function is similar to OSTaskCreate() except that it allows
268 * additional information about a task to be specified.
269 *
270 * Arguments : task is a pointer to the task's code
271 *
272 * p_arg is a pointer to an optional data area which can be used to pass parameters to
273 * the task when the task first executes. Where the task is concerned it thinks
274 * it was invoked and passed the argument 'p_arg' as follows:
275 *
276 * void Task (void *p_arg)
277 * {
278 * for (;;) {
279 * Task code;
280 * }
281 * }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -