📄 os_task.lst
字号:
162 OS_CPU_SR cpu_sr;
163 #endif
164 OS_STK *psp;
165 INT8U err;
166
167
168 #if OS_ARG_CHK_EN > 0
169 if (prio > OS_LOWEST_PRIO) { /* Make sure priority is within allowable range */
\ 0000000A 402F CMP R7,#+64
\ 0000000C 01D3 BCC ??OSTaskCreate_0
170 return (OS_PRIO_INVALID);
\ 0000000E 2A20 MOVS R0,#+42
\ 00000010 45E0 B ??OSTaskCreate_1
171 }
172 #endif
173 OS_ENTER_CRITICAL();
\ ??OSTaskCreate_0:
\ 00000012 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
174 if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority */
\ 00000016 3F06 LSLS R7,R7,#+24 ;; ZeroExtS R7,R7,#+24,#+24
\ 00000018 3F0E LSRS R7,R7,#+24
\ 0000001A 0421 MOVS R1,#+4
\ 0000001C 7943 MULS R1,R7,R1
\ 0000001E .... LDR R2,??DataTable26 ;; OSTCBPrioTbl
\ 00000020 5158 LDR R1,[R2, R1]
\ 00000022 0029 CMP R1,#+0
\ 00000024 38D1 BNE ??OSTaskCreate_2
175 OSTCBPrioTbl[prio] = (OS_TCB *)1; /* Reserve the priority to prevent others from doing ... */
\ 00000026 3F06 LSLS R7,R7,#+24 ;; ZeroExtS R7,R7,#+24,#+24
\ 00000028 3F0E LSRS R7,R7,#+24
\ 0000002A 0423 MOVS R3,#+4
\ 0000002C 7B43 MULS R3,R7,R3
\ 0000002E .... LDR R1,??DataTable26 ;; OSTCBPrioTbl
\ 00000030 0122 MOVS R2,#+1
\ 00000032 CA50 STR R2,[R1, R3]
176 /* ... the same thing until task is created. */
177 OS_EXIT_CRITICAL();
\ 00000034 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
178 psp = (OS_STK *)OSTaskStkInit(task, p_arg, ptos, 0); /* Initialize the task's stack */
\ 00000038 0023 MOVS R3,#+0
\ 0000003A 3200 MOVS R2,R6
\ 0000003C 2900 MOVS R1,R5
\ 0000003E 2000 MOVS R0,R4
\ 00000040 ........ _BLF OSTaskStkInit,??OSTaskStkInit??rT
\ 00000044 0400 MOVS R4,R0
179 err = OS_TCBInit(prio, psp, (OS_STK *)0, 0, 0, (void *)0, 0);
\ 00000046 0022 MOVS R2,#+0
\ 00000048 0021 MOVS R1,#+0
\ 0000004A 0020 MOVS R0,#+0
\ 0000004C 07B4 PUSH {R0-R2}
\ 0000004E 0023 MOVS R3,#+0
\ 00000050 0022 MOVS R2,#+0
\ 00000052 2100 MOVS R1,R4
\ 00000054 3800 MOVS R0,R7
\ 00000056 ........ _BLF OS_TCBInit,??OS_TCBInit??rT
\ 0000005A 03B0 ADD SP,SP,#+12
\ 0000005C 0400 MOVS R4,R0
180 if (err == OS_NO_ERR) {
\ 0000005E 002C CMP R4,#+0
\ 00000060 0FD1 BNE ??OSTaskCreate_3
181 OS_ENTER_CRITICAL();
\ 00000062 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
182 OSTaskCtr++; /* Increment the #tasks counter */
\ 00000066 .... LDR R1,??DataTable35 ;; OSTaskCtr
\ 00000068 .... LDR R2,??DataTable35 ;; OSTaskCtr
\ 0000006A 1278 LDRB R2,[R2, #+0]
\ 0000006C 521C ADDS R2,R2,#+1
\ 0000006E 0A70 STRB R2,[R1, #+0]
183 OS_EXIT_CRITICAL();
\ 00000070 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
184 if (OSRunning == TRUE) { /* Find highest priority task if multitasking has started */
\ 00000074 .... LDR R0,??DataTable25 ;; OSRunning
\ 00000076 0078 LDRB R0,[R0, #+0]
\ 00000078 0128 CMP R0,#+1
\ 0000007A 0BD1 BNE ??OSTaskCreate_4
185 OS_Sched();
\ 0000007C ........ _BLF OS_Sched,??OS_Sched??rT
\ 00000080 08E0 B ??OSTaskCreate_4
186 }
187 } else {
188 OS_ENTER_CRITICAL();
\ ??OSTaskCreate_3:
\ 00000082 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
189 OSTCBPrioTbl[prio] = (OS_TCB *)0;/* Make this priority available to others */
\ 00000086 0421 MOVS R1,#+4
\ 00000088 4F43 MULS R7,R1,R7
\ 0000008A .... LDR R1,??DataTable26 ;; OSTCBPrioTbl
\ 0000008C 0022 MOVS R2,#+0
\ 0000008E CA51 STR R2,[R1, R7]
190 OS_EXIT_CRITICAL();
\ 00000090 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
191 }
192 return (err);
\ ??OSTaskCreate_4:
\ 00000094 2000 MOVS R0,R4
\ 00000096 02E0 B ??OSTaskCreate_1
193 }
194 OS_EXIT_CRITICAL();
\ ??OSTaskCreate_2:
\ 00000098 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
195 return (OS_PRIO_EXIST);
\ 0000009C 2820 MOVS R0,#+40
\ ??OSTaskCreate_1:
\ 0000009E F0BC POP {R4-R7}
\ 000000A0 02BC POP {R1}
\ 000000A2 0847 BX R1 ;; return
196 }
197 #endif
198
199 /*
200 *********************************************************************************************************
201 * CREATE A TASK (Extended Version)
202 *
203 * Description: This function is used to have uC/OS-II manage the execution of a task. Tasks can either
204 * be created prior to the start of multitasking or by a running task. A task cannot be
205 * created by an ISR. This function is similar to OSTaskCreate() except that it allows
206 * additional information about a task to be specified.
207 *
208 * Arguments : task is a pointer to the task's code
209 *
210 * p_arg is a pointer to an optional data area which can be used to pass parameters to
211 * the task when the task first executes. Where the task is concerned it thinks
212 * it was invoked and passed the argument 'p_arg' as follows:
213 *
214 * void Task (void *p_arg)
215 * {
216 * for (;;) {
217 * Task code;
218 * }
219 * }
220 *
221 * ptos is a pointer to the task's top of stack. If the configuration constant
222 * OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
223 * memory to low memory). 'ptos' will thus point to the highest (valid) memory
224 * location of the stack. If OS_STK_GROWTH is set to 0, 'ptos' will point to the
225 * lowest memory location of the stack and the stack will grow with increasing
226 * memory locations. 'ptos' MUST point to a valid 'free' data item.
227 *
228 * prio is the task's priority. A unique priority MUST be assigned to each task and the
229 * lower the number, the higher the priority.
230 *
231 * id is the task's ID (0..65535)
232 *
233 * pbos is a pointer to the task's bottom of stack. If the configuration constant
234 * OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
235 * memory to low memory). 'pbos' will thus point to the LOWEST (valid) memory
236 * location of the stack. If OS_STK_GROWTH is set to 0, 'pbos' will point to the
237 * HIGHEST memory location of the stack and the stack will grow with increasing
238 * memory locations. 'pbos' MUST point to a valid 'free' data item.
239 *
240 * stk_size is the size of the stack in number of elements. If OS_STK is set to INT8U,
241 * 'stk_size' corresponds to the number of bytes available. If OS_STK is set to
242 * INT16U, 'stk_size' contains the number of 16-bit entries available. Finally, if
243 * OS_STK is set to INT32U, 'stk_size' contains the number of 32-bit entries
244 * available on the stack.
245 *
246 * pext is a pointer to a user supplied memory location which is used as a TCB extension.
247 * For example, this user memory can hold the contents of floating-point registers
248 * during a context switch, the time each task takes to execute, the number of times
249 * the task has been switched-in, etc.
250 *
251 * opt contains additional information (or options) about the behavior of the task. The
252 * LOWER 8-bits are reserved by uC/OS-II while the upper 8 bits can be application
253 * specific. See OS_TASK_OPT_??? in uCOS-II.H.
254 *
255 * Returns : OS_NO_ERR if the function was successful.
256 * OS_PRIO_EXIT if the task priority already exist
257 * (each task MUST have a unique priority).
258 * OS_PRIO_INVALID if the priority you specify is higher that the maximum allowed
259 * (i.e. > OS_LOWEST_PRIO)
260 *********************************************************************************************************
261 */
262
263 #if OS_TASK_CREATE_EXT_EN > 0
\ In segment CODE, align 4, keep-with-next
264 INT8U OSTaskCreateExt (void (*task)(void *pd),
265 void *p_arg,
266 OS_STK *ptos,
267 INT8U prio,
268 INT16U id,
269 OS_STK *pbos,
270 INT32U stk_size,
271 void *pext,
272 INT16U opt)
273 {
\ OSTaskCreateExt:
\ 00000000 F3B5 PUSH {R0,R1,R4-R7,LR}
\ 00000002 1400 MOVS R4,R2
\ 00000004 1D00 MOVS R5,R3
\ 00000006 099E LDR R6,[SP, #+36]
\ 00000008 6846 MOV R0,SP
\ 0000000A 878D LDRH R7,[R0, #+44]
274 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
275 OS_CPU_SR cpu_sr;
276 #endif
277 OS_STK *psp;
278 INT8U err;
279
280
281 #if OS_ARG_CHK_EN > 0
282 if (prio > OS_LOWEST_PRIO) { /* Make sure priority is within allowable range */
\ 0000000C 402D CMP R5,#+64
\ 0000000E 01D3 BCC ??OSTaskCreateExt_0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -