📄 os_core.lst
字号:
Function: OS_Sched
Source : F:\Workspace\MyProj\ucos-mc64\OS_CORE.C
Options : -Cni -La=%f.inc -Lasm=%n.lst -N -Os -Ou -Obfv -Oc -OiLib -Ol1 -Or
737: #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
738: OS_CPU_SR cpu_sr;
739: #endif
740: INT8U y;
741:
742:
743: OS_ENTER_CRITICAL();
0000 9a CLI
744: if ((OSIntNesting == 0) && (OSLockNesting == 0)) { /* Sched. only if all ISRs done & not locked */
0001 c60000 LDA OSIntNesting
0004 ca0000 ORA OSLockNesting
0007 2632 BNE L3B ;abs = 003b
745: y = OSUnMapTbl[OSRdyGrp]; /* Get pointer to HPT ready to run */
0009 ce0000 LDX OSRdyGrp
000c 8c CLRH
000d d60000 LDA @OSUnMapTbl,X
746: OSPrioHighRdy = (INT8U)((y << 3) + OSUnMapTbl[OSRdyTbl[y]]);
0010 97 TAX
0011 48 LSLA
0012 48 LSLA
0013 48 LSLA
0014 de0000 LDX @OSRdyTbl,X
0017 db0000 ADD @OSUnMapTbl,X
001a c70000 STA OSPrioHighRdy
747: if (OSPrioHighRdy != OSPrioCur) { /* No Ctx Sw if current task is highest rdy */
001d c10000 CMP OSPrioCur
0020 2719 BEQ L3B ;abs = 003b
748: OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
0022 48 LSLA
0023 97 TAX
0024 de0001 LDX @OSTCBPrioTbl:1,X
0027 cf0001 STX OSTCBHighRdy:1
002a 97 TAX
002b de0000 LDX @OSTCBPrioTbl,X
002e cf0000 STX OSTCBHighRdy
749: OSCtxSwCtr++; /* Increment context switch counter */
0031 450000 LDHX @OSCtxSwCtr
0034 cd0000 JSR _LINC
0037 cd0000 JSR _POP32
750: OS_TASK_SW(); /* Perform a context switch */
003a 83 SWI
003b L3B:
751: }
752: }
753: OS_EXIT_CRITICAL();
003b 9b SEI
754: }
003c 81 RTS
755: /*$PAGE*/
756: /*
757: *********************************************************************************************************
758: * IDLE TASK
759: *
760: * Description: This task is internal to uC/OS-II and executes whenever no other higher priority tasks
761: * executes because they are ALL waiting for event(s) to occur.
762: *
763: * Arguments : none
764: *
765: * Returns : none
766: *
767: * Note(s) : 1) OSTaskIdleHook() is called after the critical section to ensure that interrupts will be
768: * enabled for at least a few instructions. On some processors (ex. Philips XA), enabling
769: * and then disabling interrupts didn't allow the processor enough time to have interrupts
770: * enabled before they were disabled again. uC/OS-II would thus never recognize
771: * interrupts.
772: * 2) This hook has been added to allow you to do such things as STOP the CPU to conserve
773: * power.
774: *********************************************************************************************************
775: */
776:
777: void OS_TaskIdle (void *ppdata)
778: {
Function: OS_TaskIdle
Source : F:\Workspace\MyProj\ucos-mc64\OS_CORE.C
Options : -Cni -La=%f.inc -Lasm=%n.lst -N -Os -Ou -Obfv -Oc -OiLib -Ol1 -Or
0000 L0:
779: #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
780: OS_CPU_SR cpu_sr;
781: #endif
782:
783:
784: ppdata = ppdata; /* Prevent compiler warning for not using 'ppdata' */
785: for (;;) {
786: OS_ENTER_CRITICAL();
0000 9a CLI
787: OSIdleCtr++;
0001 450000 LDHX @OSIdleCtr
0004 cd0000 JSR _LINC
0007 cd0000 JSR _POP32
788: OS_EXIT_CRITICAL();
000a 9b SEI
789: OSTaskIdleHook(); /* Call user definable HOOK */
000b cd0000 JSR OSTaskIdleHook
000e 20f0 BRA L0 ;abs = 0000
790: }
791: }
792: /*$PAGE*/
793: /*
794: *********************************************************************************************************
795: * STATISTICS TASK
796: *
797: * Description: This task is internal to uC/OS-II and is used to compute some statistics about the
798: * multitasking environment. Specifically, OS_TaskStat() computes the CPU usage.
799: * CPU usage is determined by:
800: *
801: * OSIdleCtr
802: * OSCPUUsage = 100 * (1 - ------------) (units are in %)
803: * OSIdleCtrMax
804: *
805: * Arguments : ppdata this pointer is not used at this time.
806: *
807: * Returns : none
808: *
809: * Notes : 1) This task runs at a priority level higher than the idle task. In fact, it runs at the
810: * next higher priority, OS_IDLE_PRIO-1.
811: * 2) You can disable this task by setting the configuration #define OS_TASK_STAT_EN to 0.
812: * 3) We delay for 5 seconds in the beginning to allow the system to reach steady state and
813: * have all other tasks created before we do statistics. You MUST have at least a delay
814: * of 2 seconds to allow for the system to establish the maximum value for the idle
815: * counter.
816: *********************************************************************************************************
817: */
818:
819: #if OS_TASK_STAT_EN > 0
820: void OS_TaskStat (void *ppdata)
821: {
822: #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
823: OS_CPU_SR cpu_sr;
824: #endif
825: INT32U run;
826: INT8S usage;
827:
828:
829: ppdata = ppdata; /* Prevent compiler warning for not using 'ppdata' */
830: while (OSStatRdy == FALSE) {
831: OSTimeDly(2 * OS_TICKS_PER_SEC); /* Wait until statistic task is ready */
832: }
833: for (;;) {
834: OS_ENTER_CRITICAL();
835: OSIdleCtrRun = OSIdleCtr; /* Obtain the of the idle counter for the past second */
836: run = OSIdleCtr;
837: OSIdleCtr = 0L; /* Reset the idle counter for the next second */
838: OS_EXIT_CRITICAL();
839: if (OSIdleCtrMax > 0L) {
840: usage = (INT8S)(100L - 100L * run / OSIdleCtrMax);
841: if (usage >= 0) { /* Make sure we don't have a negative percentage */
842: OSCPUUsage = usage;
843: } else {
844: OSCPUUsage = 0;
845: }
846: } else {
847: OSCPUUsage = 0;
848: }
849: OSTaskStatHook(); /* Invoke user definable hook */
850: OSTimeDly(OS_TICKS_PER_SEC); /* Accumulate OSIdleCtr for the next second */
851: }
852: }
853: #endif
854: /*$PAGE*/
855: /*
856: *********************************************************************************************************
857: * INITIALIZE TCB
858: *
859: * Description: This function is internal to uC/OS-II and is used to initialize a Task Control Block when
860: * a task is created (see OSTaskCreate() and OSTaskCreateExt()).
861: *
862: * Arguments : prio is the priority of the task being created
863: *
864: * ptos is a pointer to the task's top-of-stack assuming that the CPU registers
865: * have been placed on the stack. Note that the top-of-stack corresponds to a
866: * 'high' memory location is OS_STK_GROWTH is set to 1 and a 'low' memory
867: * location if OS_STK_GROWTH is set to 0. Note that stack growth is CPU
868: * specific.
869: *
870: * pbos is a pointer to the bottom of stack. A NULL pointer is passed if called by
871: * 'OSTaskCreate()'.
872: *
873: * id is the task's ID (0..65535)
874: *
875: * stk_size is the size of the stack (in 'stack units'). If the stack units are INT8Us
876: * then, 'stk_size' contains the number of bytes for the stack. If the stack
877: * units are INT32Us then, the stack contains '4 * stk_size' bytes. The stack
878: * units are established by the #define constant OS_STK which is CPU
879: * specific. 'stk_size' is 0 if called by 'OSTaskCreate()'.
880: *
881: * pext is a pointer to a user supplied memory area that is used to extend the task
882: * control block. This allows you to store the contents of floating-point
883: * registers, MMU registers or anything else you could find useful during a
884: * context switch. You can even assign a name to each task and store this name
885: * in this TCB extension. A NULL pointer is passed if called by OSTaskCreate().
886: *
887: * opt options as passed to 'OSTaskCreateExt()' or,
888: * 0 if called from 'OSTaskCreate()'.
889: *
890: * Returns : OS_NO_ERR if the call was successful
891: * OS_NO_MORE_TCB if there are no more free TCBs to be allocated and thus, the task cannot
892: * be created.
893: *
894: * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
895: *********************************************************************************************************
896: */
897:
898: INT8U OS_TCBInit (INT8U prio, OS_STK *ptos, OS_STK *pbos, INT16U id, INT32U stk_size, void *pext, INT16U opt)
899: {
Function: OS_TCBInit
Source : F:\Workspace\MyProj\ucos-mc64\OS_CORE.C
Options : -Cni -La=%f.inc -Lasm=%n.lst -N -Os -Ou -Obfv -Oc -OiLib -Ol1 -Or
0000 a7fe AIS #-2
900: #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
901: OS_CPU_SR cpu_sr;
902: #endif
903: OS_TCB *ptcb;
904:
905:
906: OS_ENTER_CRITICAL();
0002 9a CLI
907: ptcb = OSTCBFreeList; /* Get a free TCB from the free TCB list */
0003 c60001 LDA OSTCBFreeList:1
0006 95 TSX
0007 e701 STA 1,X
0009 c60000 LDA OSTCBFreeList
000c f7 STA ,X
908: if (ptcb != (OS_TCB *)0) {
000d 2607 BNE L16 ;abs = 0016
000f 6d01 TST 1,X
0011 2603 BNE L16 ;abs = 0016
0013 cc00f8 JMP LF8 ;abs = 00f8
0016 L16:
909: OSTCBFreeList = ptcb->OSTCBNext; /* Update pointer to free TCB list */
0016 ee01 LDX 1,X
0018 87 PSHA
0019 8a PULH
001a e603 LDA 3,X
001c c70001 STA OSTCBFreeList:1
001f e602 LDA 2,X
0021 c70000 STA OSTCBFreeList
910: OS_EXIT_CRITICAL();
0024 9b SEI
911: ptcb->OSTCBStkPtr = ptos; /* Load Stack pointer in TCB */
0025 9eee02 LDX 2,SP
0028 89 PSHX
0029 9eee02 LDX 2,SP
002c 9ee611 LDA 17,SP
002f 89 PSHX
0030 9eee02 LDX 2,SP
0033 8a PULH
0034 e701 STA 1,X
0036 9ee610 LDA 16,SP
0039 f7 STA ,X
912: ptcb->OSTCBPrio = (INT8U)prio; /* Load task priority into TCB */
003a 9ee612 LDA 18,SP
003d e709 STA 9,X
913: ptcb->OSTCBStat = OS_STAT_RDY; /* Task is ready to run */
003f 6f08 CLR 8,X
914: ptcb->OSTCBDly = 0; /* Task is not delayed */
0041 6f07 CLR 7,X
0043 6f06 CLR 6,X
915:
916: #if OS_TASK_CREATE_EXT_EN > 0
917: ptcb->OSTCBExtPtr = pext; /* Store pointer to TCB extension */
918: ptcb->OSTCBStkSize = stk_size; /* Store stack size */
919: ptcb->OSTCBStkBottom = pb
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -