📄 os_task.lst
字号:
0028 a601 LDA #1
002a 9eee01 LDX 1,SP
002d e701 STA @OSTCBPrioTbl:1,X
002f 6f00 CLR @OSTCBPrioTbl,X
185: /* ... the same thing until task is created. */
186: OS_EXIT_CRITICAL();
0031 9a CLI
187: psp = (void *)OSTaskStkInit(task, pdata, ptos, 0); /* Initialize the task's stack */
0032 95 TSX
0033 e60c LDA 12,X
0035 87 PSHA
0036 e60b LDA 11,X
0038 87 PSHA
0039 e60a LDA 10,X
003b 87 PSHA
003c e609 LDA 9,X
003e 87 PSHA
003f e608 LDA 8,X
0041 87 PSHA
0042 e607 LDA 7,X
0044 87 PSHA
0045 4f CLRA
0046 5f CLRX
0047 cd0000 JSR OSTaskStkInit
004a a706 AIS #6
004c 9ee704 STA 4,SP
004f 9eef03 STX 3,SP
188: err = OSTCBInit(prio, psp, (void *)0, 0, 0, (void *)0, 0);
0052 9ee605 LDA 5,SP
0055 87 PSHA
0056 9ee605 LDA 5,SP
0059 87 PSHA
005a 89 PSHX
005b 4f CLRA
005c 87 PSHA
005d 87 PSHA
005e 87 PSHA
005f 87 PSHA
0060 87 PSHA
0061 87 PSHA
0062 5f CLRX
0063 89 PSHX
0064 89 PSHX
0065 cd0000 JSR OSTCBInit
0068 a70b AIS #11
006a 9ee702 STA 2,SP
189: if (err == OS_NO_ERR) {
006d 2619 BNE L88 ;abs = 0088
190: OS_ENTER_CRITICAL();
006f 9b SEI
191: OSTaskCtr++; /* Increment the #tasks counter */
0070 3c00 INC OSTaskCtr
192: OSTaskCreateHook(OSTCBPrioTbl[prio]); /* Call user defined hook */
0072 9eee05 LDX 5,SP
0075 58 LSLX
0076 8c CLRH
0077 e601 LDA @OSTCBPrioTbl:1,X
0079 ee00 LDX @OSTCBPrioTbl,X
007b cd0000 JSR OSTaskCreateHook
193: OS_EXIT_CRITICAL();
007e 9a CLI
194: if (OSRunning) { /* Find highest priority task if multitasking has started */
007f 3d00 TST OSRunning
0081 2710 BEQ L93 ;abs = 0093
195: OSSched();
0083 cd0000 JSR OSSched
0086 200b BRA L93 ;abs = 0093
0088 L88:
196: }
197: } else {
198: OS_ENTER_CRITICAL();
0088 9b SEI
199: OSTCBPrioTbl[prio] = (OS_TCB *)0;/* Make this priority available to others */
0089 9eee05 LDX 5,SP
008c 58 LSLX
008d 8c CLRH
008e 6f01 CLR @OSTCBPrioTbl:1,X
0090 6f00 CLR @OSTCBPrioTbl,X
200: OS_EXIT_CRITICAL();
0092 9a CLI
0093 L93:
201: }
202: return (err);
0093 9ee602 LDA 2,SP
0096 L96:
0096 2003 BRA L9B ;abs = 009b
0098 L98:
203: } else {
204: OS_EXIT_CRITICAL();
0098 9a CLI
205: return (OS_PRIO_EXIST);
0099 a628 LDA #40
009b L9B:
206: }
207: }
009b a705 AIS #5
009d 81 RTS
208: #endif
209: /*$PAGE*/
210: /*
211: *********************************************************************************************************
212: * CREATE A TASK (Extended Version)
213: *
214: * Description: This function is used to have uC/OS-II manage the execution of a task. Tasks can either
215: * be created prior to the start of multitasking or by a running task. A task cannot be
216: * created by an ISR. This function is similar to OSTaskCreate() except that it allows
217: * additional information about a task to be specified.
218: *
219: * Arguments : task is a pointer to the task's code
220: *
221: * pdata is a pointer to an optional data area which can be used to pass parameters to
222: * the task when the task first executes. Where the task is concerned it thinks
223: * it was invoked and passed the argument 'pdata' as follows:
224: *
225: * void Task (void *pdata)
226: * {
227: * for (;;) {
228: * Task code;
229: * }
230: * }
231: *
232: * ptos is a pointer to the task's top of stack. If the configuration constant
233: * OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
234: * memory to low memory). 'pstk' will thus point to the highest (valid) memory
235: * location of the stack. If OS_STK_GROWTH is set to 0, 'pstk' will point to the
236: * lowest memory location of the stack and the stack will grow with increasing
237: * memory locations. 'pstk' MUST point to a valid 'free' data item.
238: *
239: * prio is the task's priority. A unique priority MUST be assigned to each task and the
240: * lower the number, the higher the priority.
241: *
242: * id is the task's ID (0..65535)
243: *
244: * pbos is a pointer to the task's bottom of stack. If the configuration constant
245: * OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
246: * memory to low memory). 'pbos' will thus point to the LOWEST (valid) memory
247: * location of the stack. If OS_STK_GROWTH is set to 0, 'pbos' will point to the
248: * HIGHEST memory location of the stack and the stack will grow with increasing
249: * memory locations. 'pbos' MUST point to a valid 'free' data item.
250: *
251: * stk_size is the size of the stack in number of elements. If OS_STK is set to INT8U,
252: * 'stk_size' corresponds to the number of bytes available. If OS_STK is set to
253: * INT16U, 'stk_size' contains the number of 16-bit entries available. Finally, if
254: * OS_STK is set to INT32U, 'stk_size' contains the number of 32-bit entries
255: * available on the stack.
256: *
257: * pext is a pointer to a user supplied memory location which is used as a TCB extension.
258: * For example, this user memory can hold the contents of floating-point registers
259: * during a context switch, the time each task takes to execute, the number of times
260: * the task has been switched-in, etc.
261: *
262: * opt contains additional information (or options) about the behavior of the task. The
263: * LOWER 8-bits are reserved by uC/OS-II while the upper 8 bits can be application
264: * specific. See OS_TASK_OPT_??? in uCOS-II.H.
265: *
266: * Returns : OS_NO_ERR if the function was successful.
267: * OS_PRIO_EXIT if the task priority already exist
268: * (each task MUST have a unique priority).
269: * OS_PRIO_INVALID if the priority you specify is higher that the maximum allowed
270: * (i.e. > OS_LOWEST_PRIO)
271: *********************************************************************************************************
272: */
273: /*$PAGE*/
274: #if OS_TASK_CREATE_EXT_EN
275: INT8U OSTaskCreateExt (void (*task)(void *pd),
276: void *pdata,
277: OS_STK *ptos,
278: INT8U prio,
279: INT16U id,
280: OS_STK *pbos,
281: INT32U stk_size,
282: void *pext,
283: INT16U opt)
284: {
285: void *psp;
286: INT8U err;
287: INT16U i;
288: OS_STK *pfill;
289:
290:
291: if (prio > OS_LOWEST_PRIO) { /* Make sure priority is within allowable range */
292: return (OS_PRIO_INVALID);
293: }
294: OS_ENTER_CRITICAL();
295: if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority */
296: OSTCBPrioTbl[prio] = (OS_TCB *)1; /* Reserve the priority to prevent others from doing ... */
297: /* ... the same thing until task is created. */
298: OS_EXIT_CRITICAL();
299:
300: if (opt & OS_TASK_OPT_STK_CHK) { /* See if stack checking has been enabled */
301: if (opt & OS_TASK_OPT_STK_CLR) { /* See if stack needs to be cleared */
302: pfill = pbos; /* Yes, fill the stack with zeros */
303: for (i = 0; i < stk_size; i++) {
304: #if OS_STK_GROWTH == 1
305: *pfill++ = (OS_STK)0;
306: #else
307: *pfill-- = (OS_STK)0;
308: #endif
309: }
310: }
311: }
312:
313: psp = (void *)OSTaskStkInit(task, pdata, ptos, opt); /* Initialize the task's stack */
314: err = OSTCBInit(prio, psp, pbos, id, stk_size, pext, opt);
315: if (err == OS_NO_ERR) {
316: OS_ENTER_CRITICAL();
317: OSTaskCtr++; /* Increment the #tasks counter */
318: OSTaskCreateHook(OSTCBPrioTbl[prio]); /* Call user defined hook */
319: OS_EXIT_CRITICAL();
320: if (OSRunning) { /* Find highest priority task if multitasking has started */
321: OSSched();
322: }
323: } else {
324: OS_ENTER_CRITICAL();
325: OSTCBPrioTbl[prio] = (OS_TCB *)0;/* Make this priority available to others */
326: OS_EXIT_CRITICAL();
327: }
328: return (err);
329: } else {
330: OS_EXIT_CRITICAL();
331: return (OS_PRIO_EXIST);
332: }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -