📄 tasks.lst
字号:
380 * creation of the first user task.
381 *
382 * The portTASK_FUNCTION_PROTO() macro is used to allow port/compiler specific
383 * language extensions. The equivalent prototype for this function is:
384 *
385 * void prvIdleTask( void *pvParameters );
386 *
387 */
388 static portTASK_FUNCTION_PROTO( prvIdleTask, pvParameters );
389
390 /*
391 * Utility to free all memory allocated by the scheduler to hold a TCB,
392 * including the stack pointed to by the TCB.
393 *
394 * This does not free memory allocated by the task itself (i.e. memory
395 * allocated by calls to pvPortMalloc from within the tasks application code).
396 */
397 #if ( ( INCLUDE_vTaskDelete == 1 ) || ( INCLUDE_vTaskCleanUpResources == 1 ) )
398 static void prvDeleteTCB( tskTCB *pxTCB );
399 #endif
400
401 /*
402 * Used only by the idle task. This checks to see if anything has been placed
403 * in the list of tasks waiting to be deleted. If so the task is cleaned up
404 * and its TCB deleted.
405 */
406 static void prvCheckTasksWaitingTermination( void );
407
408 /*
409 * Allocates memory from the heap for a TCB and associated stack. Checks the
410 * allocation was successful.
411 */
412 static tskTCB *prvAllocateTCBAndStack( unsigned portSHORT usStackDepth );
413
414 /*
415 * Called from vTaskList. vListTasks details all the tasks currently under
416 * control of the scheduler. The tasks may be in one of a number of lists.
417 * prvListTaskWithinSingleList accepts a list and details the tasks from
418 * within just that list.
419 *
420 * THIS FUNCTION IS INTENDED FOR DEBUGGING ONLY, AND SHOULD NOT BE CALLED FROM
421 * NORMAL APPLICATION CODE.
422 */
423 #if ( configUSE_TRACE_FACILITY == 1 )
424
425 static void prvListTaskWithinSingleList( signed portCHAR *pcWriteBuffer, xList *pxList, signed portCHAR cStatus );
426
427 #endif
428
429 /*
430 * When a task is created, the stack of the task is filled with a known value.
431 * This function determines the 'high water mark' of the task stack by
432 * determining how much of the stack remains at the original preset value.
433 */
434 #if ( configUSE_TRACE_FACILITY == 1 )
435
436 unsigned portSHORT usTaskCheckFreeStackSpace( const unsigned portCHAR *pucStackByte );
437
438 #endif
439
440 /*lint +e956 */
441
442
443
444
445
446 /*-----------------------------------------------------------
447 * TASK CREATION API documented in task.h
448 *----------------------------------------------------------*/
449
\ In segment CODE, align 2
450 signed portBASE_TYPE xTaskCreate( pdTASK_CODE pvTaskCode, const signed portCHAR * const pcName, unsigned portSHORT usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask )
\ xTaskCreate:
451 {
\ 000000 0A12 PUSH.W R10
\ 000002 0B12 PUSH.W R11
\ 000004 0812 PUSH.W R8
\ 000006 0912 PUSH.W R9
\ 000008 0612 PUSH.W R6
\ 00000A 0712 PUSH.W R7
\ 00000C 0412 PUSH.W R4
\ 00000E 0512 PUSH.W R5
\ 000010 0C12 PUSH.W R12
\ 000012 0A4E MOV.W R14, R10
\ 000014 1B411400 MOV.W 0x14(SP), R11
\ 000018 18411600 MOV.W 0x16(SP), R8
\ 00001C 19411800 MOV.W 0x18(SP), R9
\ 000020 16411A00 MOV.W 0x1a(SP), R6
452 signed portBASE_TYPE xReturn;
453 tskTCB * pxNewTCB;
454 static unsigned portBASE_TYPE uxTaskNumber = 0; /*lint !e956 Static is deliberate - this is guarded before use. */
455
456 /* Allocate the memory required by the TCB and stack for the new task.
457 checking that the allocation was successful. */
458 pxNewTCB = prvAllocateTCBAndStack( usStackDepth );
\ 000024 0C4B MOV.W R11, R12
\ 000026 B012.... CALL #prvAllocateTCBAndStack
\ 00002A 044C MOV.W R12, R4
459
460 if( pxNewTCB != NULL )
\ 00002C 0493 CMP.W #0x0, R4
\ 00002E 5D24 JEQ ??xTaskCreate_0
461 {
462 portSTACK_TYPE *pxTopOfStack;
463
464 /* Setup the newly allocated TCB with the initial state of the task. */
465 prvInitialiseTCBVariables( pxNewTCB, usStackDepth, pcName, uxPriority );
\ 000030 0912 PUSH.W R9
\ 000032 0A12 PUSH.W R10
\ 000034 0E4B MOV.W R11, R14
\ 000036 0C44 MOV.W R4, R12
\ 000038 B012.... CALL #prvInitialiseTCBVariables
466
467 /* Calculate the top of stack address. This depends on whether the
468 stack grows from high memory to low (as per the 80x86) or visa versa.
469 portSTACK_GROWTH is used to make the result positive or negative as
470 required by the port. */
471 #if portSTACK_GROWTH < 0
472 {
473 pxTopOfStack = pxNewTCB->pxStack + ( pxNewTCB->usStackDepth - 1 );
\ 00003C 1F441800 MOV.W 0x18(R4), R15
\ 000040 1E442400 MOV.W 0x24(R4), R14
\ 000044 0E5E RLA.W R14
\ 000046 0F5E ADD.W R14, R15
\ 000048 3F50FEFF ADD.W #0xfffe, R15
\ 00004C 054F MOV.W R15, R5
474 }
475 #else
476 {
477 pxTopOfStack = pxNewTCB->pxStack;
478 }
479 #endif
480
481 /* Initialize the TCB stack to look as if the task was already running,
482 but had been interrupted by the scheduler. The return address is set
483 to the start of the task function. Once the stack has been initialised
484 the top of stack variable is updated. */
485 pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pvTaskCode, pvParameters );
\ 00004E 0812 PUSH.W R8
\ 000050 1E410600 MOV.W 0x6(SP), R14
\ 000054 0C45 MOV.W R5, R12
\ 000056 B012.... CALL #pxPortInitialiseStack
\ 00005A 844C0000 MOV.W R12, 0(R4)
486
487 /* We are going to manipulate the task queues to add this task to a
488 ready list, so must make sure no interrupts occur. */
489 portENTER_CRITICAL();
\ 00005E 32C2 DINT
\ 000060 0343 NOP
\ 000062 9253.... ADD.W #0x1, &usCriticalNesting
490 {
491 uxCurrentNumberOfTasks++;
\ 000066 9253.... ADD.W #0x1, &uxCurrentNumberOfTasks
492 if( uxCurrentNumberOfTasks == ( unsigned portBASE_TYPE ) 1 )
\ 00006A 31500600 ADD.W #0x6, SP
\ 00006E 9293.... CMP.W #0x1, &uxCurrentNumberOfTasks
\ 000072 0520 JNE ??xTaskCreate_1
493 {
494 /* As this is the first task it must also be the current task. */
495 pxCurrentTCB = pxNewTCB;
\ 000074 8244.... MOV.W R4, &pxCurrentTCB
496
497 /* This is the first task to be created so do the preliminary
498 initialisation required. We will not recover if this call
499 fails, but we will report the failure. */
500 prvInitialiseTaskLists();
\ 000078 B012.... CALL #prvInitialiseTaskLists
\ 00007C 0A3C JMP ??xTaskCreate_2
501 }
502 else
503 {
504 /* If the scheduler is not already running, make this task the
505 current task if it is the highest priority task to be created
506 so far. */
507 if( xSchedulerRunning == pdFALSE )
\ ??xTaskCreate_1:
\ 00007E 8293.... CMP.W #0x0, &xSchedulerRunning
\ 000082 0720 JNE ??xTaskCreate_2
508 {
509 if( pxCurrentTCB->uxPriority <= uxPriority )
\ 000084 1F42.... MOV.W &pxCurrentTCB, R15
\ 000088 199F1600 CMP.W 0x16(R15), R9
\ 00008C 0228 JNC ??xTaskCreate_2
510 {
511 pxCurrentTCB = pxNewTCB;
\ 00008E 8244.... MOV.W R4, &pxCurrentTCB
512 }
513 }
514 }
515
516 /* Remember the top priority to make context switching faster. Use
517 the priority in pxNewTCB as this has been capped to a valid value. */
518 if( pxNewTCB->uxPriority > uxTopUsedPriority )
\ ??xTaskCreate_2:
\ 000092 92941600.... CMP.W 0x16(R4), &uxTopUsedPriority
\ 000098 032C JC ??xTaskCreate_3
519 {
520 uxTopUsedPriority = pxNewTCB->uxPriority;
\ 00009A 92441600.... MOV.W 0x16(R4), &uxTopUsedPriority
521 }
522
523 /* Add a counter into the TCB for tracing only. */
524 pxNewTCB->uxTCBNumber = uxTaskNumber;
\ ??xTaskCreate_3:
\ 0000A0 9442....1A00 MOV.W &??uxTaskNumber, 0x1a(R4)
525 uxTaskNumber++;
\ 0000A6 9253.... ADD.W #0x1, &??uxTaskNumber
526
527 prvAddTaskToReadyQueue( pxNewTCB );
\ 0000AA 92941600.... CMP.W 0x16(R4), &uxTopReadyPriority
\ 0000B0 032C JC ??xTaskCreate_4
\ 0000B2 92441600.... MOV.W 0x16(R4), &uxTopReadyPriority
\ ??xTaskCreate_4:
\ 0000B8 0E44 MOV.W R4, R14
\ 0000BA 2E53 ADD.W #0x2, R14
\ 0000BC 3C40.... MOV.W #pxReadyTasksLists, R12
\ 0000C0 1F441600 MOV.W 0x16(R4), R15
\ 0000C4 0F5F RLA.W R15
\ 0000C6 0D4F MOV.W R15, R13
\ 0000C8 0F5F RLA.W R15
\ 0000CA 0F5F RLA.W R15
\ 0000CC 0F5D ADD.W R13, R15
\ 0000CE 0C5F ADD.W R15, R12
\ 0000D0 B012.... CALL #vListInsertEnd
528
529 xReturn = pdPASS;
\ 0000D4 1743 MOV.W #0x1, R7
530 }
531 portEXIT_CRITICAL();
\ 0000D6 8293.... CMP.W #0x0, &usCriticalNesting
\ 0000DA 0824 JEQ ??xTaskCreate_5
\ 0000DC B253.... ADD.W #0xffff, &usCriticalNesting
\ 0000E0 8293.... CMP.W #0x0, &usCriticalNesting
\ 0000E4 0320 JNE ??xTaskCreate_5
\ 0000E6 32D2 EINT
\ 0000E8 013C JMP ??xTaskCreate_5
532 }
533 else
534 {
535 xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY;
\ ??xTaskCreate_0:
\ 0000EA 3743 MOV.W #0xffff, R7
536 }
537
538 if( xReturn == pdPASS )
\ ??xTaskCreate_5:
\ 0000EC 1793 CMP.W #0x1, R7
\ 0000EE 0E20 JNE ??xTaskCreate_6
539 {
540 if( ( void * ) pxCreatedTask != NULL )
\ 0000F0 0693 CMP.W #0x0, R6
\ 0000F2 0224 JEQ ??xTaskCreate_7
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -