📄 ucos_ii.lst
字号:
499: {
Function: OSTaskIdle
Source : C:\motoctest\ucos1\sources\os_core.c
Options : -Cc -EnvGENPATH=C:\motoctest\ucos1;C:\motoctest\ucos1\bin;C:\motoctest\ucos1\cmd;C:\motoctest\ucos1\prm;C:\motoctest\ucos1\sources;C:\Metrowerks\lib\HC08c\LIB;C:\Metrowerks\lib\HC08c\src;C:\Metrowerks\lib\HC08c\INCLUDE -EnvLIBPATH=C:\Metrowerks\lib\HC08c\INCLUDE -EnvOBJPATH=C:\motoctest\ucos1\bin -EnvTEXTPATH=C:\motoctest\ucos1\bin -La=%f.inc -Lasm=%n.lst -ObjN=C:\motoctest\ucos1\ucos1_Data\MMDS-MMEVS\ObjectCode\Ucos_ii.c.o
0000 L0:
500: pdata = pdata; /* Prevent compiler warning for not using 'pdata' */
501: for (;;) {
502: OS_ENTER_CRITICAL();
0000 9b SEI
503: OSIdleCtr++;
0001 ae00 LDX @OSIdleCtr
0003 8c CLRH
0004 cd0000 JSR _LINC
0007 cd0000 JSR _POP32
504: OS_EXIT_CRITICAL();
000a 9a CLI
000b 20f3 BRA L0 ;abs = 0000
505: }
506: }
507: /*$PAGE*/
508: /*
509: *********************************************************************************************************
510: * STATISTICS TASK
511: *
512: * Description: This task is internal to uC/OS-II and is used to compute some statistics about the
513: * multitasking environment. Specifically, OSTaskStat() computes the CPU usage.
514: * CPU usage is determined by:
515: *
516: * OSIdleCtr
517: * OSCPUUsage = 100 * (1 - ------------) (units are in %)
518: * OSIdleCtrMax
519: *
520: * Arguments : pdata this pointer is not used at this time.
521: *
522: * Returns : none
523: *
524: * Notes : 1) This task runs at a priority level higher than the idle task. In fact, it runs at the
525: * next higher priority, OS_IDLE_PRIO-1.
526: * 2) You can disable this task by setting the configuration #define OS_TASK_STAT_EN to 0.
527: * 3) We delay for 5 seconds in the beginning to allow the system to reach steady state and
528: * have all other tasks created before we do statistics. You MUST have at least a delay
529: * of 2 seconds to allow for the system to establish the maximum value for the idle
530: * counter.
531: *********************************************************************************************************
532: */
533:
534: #if OS_TASK_STAT_EN
535: void OSTaskStat (void *pdata)
536: {
537: INT32U run;
538: INT8S usage;
539:
540:
541: pdata = pdata; /* Prevent compiler warning for not using 'pdata' */
542: while (OSStatRdy == FALSE) {
543: OSTimeDly(2 * OS_TICKS_PER_SEC); /* Wait until statistic task is ready */
544: }
545: for (;;) {
546: OS_ENTER_CRITICAL();
547: OSIdleCtrRun = OSIdleCtr; /* Obtain the of the idle counter for the past second */
548: run = OSIdleCtr;
549: OSIdleCtr = 0L; /* Reset the idle counter for the next second */
550: OS_EXIT_CRITICAL();
551: if (OSIdleCtrMax > 0L) {
552: usage = (INT8S)(100L - 100L * run / OSIdleCtrMax);
553: if (usage > 100) {
554: OSCPUUsage = 100;
555: } else if (usage < 0) {
556: OSCPUUsage = 0;
557: } else {
558: OSCPUUsage = usage;
559: }
560: } else {
561: OSCPUUsage = 0;
562: }
563: OSTaskStatHook(); /* Invoke user definable hook */
564: OSTimeDly(OS_TICKS_PER_SEC); /* Accumulate OSIdleCtr for the next second */
565: }
566: }
567: #endif
568: /*$PAGE*/
569: /*
570: *********************************************************************************************************
571: * INITIALIZE TCB
572: *
573: * Description: This function is internal to uC/OS-II and is used to initialize a Task Control Block when
574: * a task is created (see OSTaskCreate() and OSTaskCreateExt()).
575: *
576: * Arguments : prio is the priority of the task being created
577: *
578: * ptos is a pointer to the task's top-of-stack assuming that the CPU registers
579: * have been placed on the stack. Note that the top-of-stack corresponds to a
580: * 'high' memory location is OS_STK_GROWTH is set to 1 and a 'low' memory
581: * location if OS_STK_GROWTH is set to 0. Note that stack growth is CPU
582: * specific.
583: *
584: * pbos is a pointer to the bottom of stack. A NULL pointer is passed if called by
585: * 'OSTaskCreate()'.
586: *
587: * id is the task's ID (0..65535)
588: *
589: * stk_size is the size of the stack (in 'stack units'). If the stack units are INT8Us
590: * then, 'stk_size' contains the number of bytes for the stack. If the stack
591: * units are INT32Us then, the stack contains '4 * stk_size' bytes. The stack
592: * units are established by the #define constant OS_STK which is CPU
593: * specific. 'stk_size' is 0 if called by 'OSTaskCreate()'.
594: *
595: * pext is a pointer to a user supplied memory area that is used to extend the task
596: * control block. This allows you to store the contents of floating-point
597: * registers, MMU registers or anything else you could find useful during a
598: * context switch. You can even assign a name to each task and store this name
599: * in this TCB extension. A NULL pointer is passed if called by OSTaskCreate().
600: *
601: * opt options as passed to 'OSTaskCreateExt()' or,
602: * 0 if called from 'OSTaskCreate()'.
603: *
604: * Returns : OS_NO_ERR if the call was successful
605: * OS_NO_MORE_TCB if there are no more free TCBs to be allocated and thus, the task cannot
606: * be created.
607: *
608: * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
609: *********************************************************************************************************
610: */
611:
612: INT8U OSTCBInit (INT8U prio, OS_STK *ptos, OS_STK *pbos, INT16U id, INT16U stk_size, void *pext, INT16U opt)
613: {
Function: OSTCBInit
Source : C:\motoctest\ucos1\sources\os_core.c
Options : -Cc -EnvGENPATH=C:\motoctest\ucos1;C:\motoctest\ucos1\bin;C:\motoctest\ucos1\cmd;C:\motoctest\ucos1\prm;C:\motoctest\ucos1\sources;C:\Metrowerks\lib\HC08c\LIB;C:\Metrowerks\lib\HC08c\src;C:\Metrowerks\lib\HC08c\INCLUDE -EnvLIBPATH=C:\Metrowerks\lib\HC08c\INCLUDE -EnvOBJPATH=C:\motoctest\ucos1\bin -EnvTEXTPATH=C:\motoctest\ucos1\bin -La=%f.inc -Lasm=%n.lst -ObjN=C:\motoctest\ucos1\ucos1_Data\MMDS-MMEVS\ObjectCode\Ucos_ii.c.o
0000 a7fc AIS #-4
614: OS_TCB *ptcb;
615:
616:
617: OS_ENTER_CRITICAL();
0002 9b SEI
618: ptcb = OSTCBFreeList; /* Get a free TCB from the free TCB list */
0003 b601 LDA OSTCBFreeList:1
0005 be00 LDX OSTCBFreeList
0007 9ee704 STA 4,SP
000a 9eef03 STX 3,SP
619: if (ptcb != (OS_TCB *)0) {
000d 2608 BNE L17 ;abs = 0017
000f 9e6d04 TST 4,SP
0012 2603 BNE L17 ;abs = 0017
0014 cc00d7 JMP LD7 ;abs = 00d7
0017 L17:
620: OSTCBFreeList = ptcb->OSTCBNext; /* Update pointer to free TCB list */
0017 89 PSHX
0018 8a PULH
0019 97 TAX
001a e603 LDA 3,X
001c b701 STA OSTCBFreeList:1
001e e602 LDA 2,X
0020 b700 STA OSTCBFreeList
621: OS_EXIT_CRITICAL();
0022 9a CLI
622: ptcb->OSTCBStkPtr = ptos; /* Load Stack pointer in TCB */
0023 95 TSX
0024 e602 LDA 2,X
0026 87 PSHA
0027 ee03 LDX 3,X
0029 9ee611 LDA 17,SP
002c 8a PULH
002d e701 STA 1,X
002f 9ee60f LDA 15,SP
0032 f7 STA ,X
623: ptcb->OSTCBPrio = (INT8U)prio; /* Load task priority into TCB */
0033 9ee611 LDA 17,SP
0036 e709 STA 9,X
624: ptcb->OSTCBStat = OS_STAT_RDY; /* Task is ready to run */
0038 6f08 CLR 8,X
625: ptcb->OSTCBDly = 0; /* Task is not delayed */
003a 6f07 CLR 7,X
003c 6f06 CLR 6,X
626:
627: #if OS_TASK_CREATE_EXT_EN
628: ptcb->OSTCBExtPtr = pext; /* Store pointer to TCB extension */
629: ptcb->OSTCBStkSize = stk_size; /* Store stack size */
630: ptcb->OSTCBStkBottom = pbos; /* Store pointer to bottom of stack */
631: ptcb->OSTCBOpt = opt; /* Store task options */
632: ptcb->OSTCBId = id; /* Store task ID */
633: #else
634: pext = pext; /* Prevent compiler warning if not used */
635: stk_size = stk_size;
636: pbos = pbos;
637: opt = opt;
638: id = id;
639: #endif
640:
641: #if OS_TASK_DEL_EN
642: ptcb->OSTCBDelReq = OS_NO_ERR;
643: #endif
644:
645: ptcb->OSTCBY = prio >> 3; /* Pre-compute X, Y, BitX and BitY */
003e 89 PSHX
003f 9eee12 LDX 18,SP
0042 54 LSRX
0043 54 LSRX
0044 54 LSRX
0045 9f TXA
0046 9eee01 LDX 1,SP
0049 e70b STA 11,X
646: ptcb->OSTCBBitY = OSMapTbl[ptcb->OSTCBY];
004b 8c CLRH
004c 97 TAX
004d de0000 LDX @OSMapTbl,X
0050 9ee604 LDA 4,SP
0053 87 PSHA
0054 8a PULH
0055 9f TXA
0056 9eee01 LDX 1,SP
0059 e70d STA 13,X
647: ptcb->OSTCBX = prio & 0x07;
005b 9ee612 LDA 18,SP
005e a407 AND #7
0060 e70a STA 10,X
648: ptcb->OSTCBBitX = OSMapTbl[ptcb->OSTCBX];
0062 8c CLRH
0063 97 TAX
0064 de0000 LDX @OSMapTbl,X
0067 9ee604 LDA 4,SP
006a 87 PSHA
006b 8a PULH
006c 9f TXA
006d 88 PULX
006e e70c STA 12,X
649:
650: #if OS_MBOX_EN || (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_SEM_EN
651: ptcb->OSTCBEventPtr = (OS_EVENT *)0; /* Task is not pending on an event */
652: #endif
653:
654: #if OS_MBOX_EN || (OS_Q_EN && (OS_MAX_QS >= 2))
655: ptcb->OSTCBMsg = (void *)0; /* No message received */
656: #endif
657:
658: OS_ENTER_CRITICAL();
0070 9b SEI
659: OSTCBPrioTbl[prio] = ptcb;
0071 9eee11 LDX 17,SP
0074 58 LSLX
0075 9ee603 LDA 3,SP
0078 87 PSHA
0079 8a PULH
007a 89 PSHX
007b 9eee05 LDX 5,SP
007e 8c CLRH
007f 9eef02 STX 2,SP
0082 88 PULX
0083 9ee702 STA 2,SP
0086 9ee601 LDA 1,SP
0089 e701 STA @OSTCBPrioTbl:1,X
008b 9ee603 LDA 3,SP
008e e700 STA @OSTCBPrioTbl,X
660: ptcb->OSTCBNext = OSTCBList; /* Link into TCB chain */
0090 9ee603 LDA 3,SP
0093 87 PSHA
0094 8a PULH
0095 b600 LDA OSTCBList
0097 9eee01 LDX 1,SP
009a e702 STA 2,X
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -