📄 os_core.lst
字号:
ANSI-C/cC++ Compiler for HC08 V-5.0.12 ICG, Oct 6 2000
1: /*
2: *********************************************************************************************************
3: * uC/OS-II
4: * The Real-Time Kernel
5: * CORE FUNCTIONS
6: *
7: * (c) Copyright 1992-2001, Jean J. Labrosse, Weston, FL
8: * All Rights Reserved
9: *
10: * File : OS_CORE.C
11: * By : Jean J. Labrosse
12: *********************************************************************************************************
13: */
14:
15: #ifndef OS_MASTER_FILE
16: #define OS_GLOBALS
17: #include "includes.h"
18: #endif
19:
20: /*
21: *********************************************************************************************************
22: * MAPPING TABLE TO MAP BIT POSITION TO BIT MASK
23: *
24: * Note: Index into table is desired bit position, 0..7
25: * Indexed value corresponds to bit mask
26: *********************************************************************************************************
27: */
28:
29: INT8U const OSMapTbl[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
30:
31: /*
32: *********************************************************************************************************
33: * PRIORITY RESOLUTION TABLE
34: *
35: * Note: Index into table is bit pattern to resolve highest priority
36: * Indexed value corresponds to highest priority bit position (i.e. 0..7)
37: *********************************************************************************************************
38: */
39:
40: INT8U const OSUnMapTbl[] = {
41: 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
42: 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
43: 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
44: 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
45: 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
46: 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
47: 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
48: 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
49: 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
50: 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
51: 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
52: 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
53: 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
54: 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
55: 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
56: 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
57: };
58: /*$PAGE*/
59: /*
60: *********************************************************************************************************
61: * INITIALIZATION
62: *
63: * Description: This function is used to initialize the internals of uC/OS-II and MUST be called prior to
64: * creating any uC/OS-II object and, prior to calling OSStart().
65: *
66: * Arguments : none
67: *
68: * Returns : none
69: *********************************************************************************************************
70: */
71:
72: void OSInit (void)
73: {
Function: OSInit
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 a7f8 AIS #-8
74: INT16U i;
75: INT8U *prdytbl;
76: OS_TCB *ptcb1;
77: OS_TCB *ptcb2;
78: #if (OS_EVENT_EN > 0) && (OS_MAX_EVENTS > 1)
79: OS_EVENT *pevent1;
80: OS_EVENT *pevent2;
81: #endif
82:
83:
84: #if OS_VERSION >= 204
85: OSInitHookBegin(); /* Call port specific initialization code */
0002 cd0000 JSR OSInitHookBegin
86: #endif
87:
88: #if OS_TIME_GET_SET_EN > 0
89: OSTime = 0L; /* Clear the 32-bit system clock */
0005 4f CLRA
0006 450000 LDHX @OSTime
0009 e703 STA 3,X
000b e702 STA 2,X
000d e701 STA 1,X
000f f7 STA ,X
90: #endif
91: OSIntNesting = 0; /* Clear the interrupt nesting counter */
0010 c70000 STA OSIntNesting
92: OSLockNesting = 0; /* Clear the scheduling lock counter */
0013 c70000 STA OSLockNesting
93: OSTaskCtr = 0; /* Clear the number of tasks */
0016 c70000 STA OSTaskCtr
94: OSRunning = FALSE; /* Indicate that multitasking not started */
0019 c70000 STA OSRunning
95: OSIdleCtr = 0L; /* Clear the 32-bit idle counter */
001c 450000 LDHX @OSIdleCtr
001f e703 STA 3,X
0021 e702 STA 2,X
0023 e701 STA 1,X
0025 f7 STA ,X
96: #if (OS_TASK_STAT_EN > 0) && (OS_TASK_CREATE_EXT_EN > 0)
97: OSIdleCtrRun = 0L;
98: OSIdleCtrMax = 0L;
99: OSStatRdy = FALSE; /* Statistic task is not ready */
100: #endif
101: OSCtxSwCtr = 0; /* Clear the context switch counter */
0026 450000 LDHX @OSCtxSwCtr
0029 e703 STA 3,X
002b e702 STA 2,X
002d e701 STA 1,X
002f f7 STA ,X
102: OSRdyGrp = 0x00; /* Clear the ready list */
0030 c70000 STA OSRdyGrp
103: prdytbl = &OSRdyTbl[0];
0033 a600 LDA @OSRdyTbl
0035 95 TSX
0036 e707 STA 7,X
0038 a600 LDA @OSRdyTbl:MSB
003a e706 STA 6,X
104: for (i = 0; i < OS_RDY_TBL_SIZE; i++) {
003c 6f01 CLR 1,X
003e 7f CLR ,X
003f L3F:
105: *prdytbl++ = 0x00;
003f 95 TSX
0040 e606 LDA 6,X
0042 87 PSHA
0043 ee07 LDX 7,X
0045 8a PULH
0046 7f CLR ,X
0047 af01 AIX #1
0049 9eef08 STX 8,SP
004c 8b PSHH
004d 86 PULA
004e 95 TSX
004f e706 STA 6,X
0051 6c01 INC 1,X
0053 2601 BNE L56 ;abs = 0056
0055 7c INC ,X
0056 L56:
0056 f6 LDA ,X
0057 87 PSHA
0058 ee01 LDX 1,X
005a 8a PULH
005b 650002 CPHX #2
005e 25df BCS L3F ;abs = 003f
106: }
107:
108: OSPrioCur = 0;
0060 4f CLRA
0061 c70000 STA OSPrioCur
109: OSPrioHighRdy = 0;
0064 c70000 STA OSPrioHighRdy
110: OSTCBHighRdy = (OS_TCB *)0; /* TCB Initialization */
0067 4f CLRA
0068 c70001 STA OSTCBHighRdy:1
006b c70000 STA OSTCBHighRdy
111: OSTCBCur = (OS_TCB *)0;
006e c70001 STA OSTCBCur:1
0071 c70000 STA OSTCBCur
112: OSTCBList = (OS_TCB *)0;
0074 c70001 STA OSTCBList:1
0077 c70000 STA OSTCBList
113: for (i = 0; i < (OS_LOWEST_PRIO + 1); i++) { /* Clear the priority table */
007a 95 TSX
007b 6f01 CLR 1,X
007d 7f CLR ,X
007e L7E:
114: OSTCBPrioTbl[i] = (OS_TCB *)0;
007e 9eee02 LDX 2,SP
0081 58 LSLX
0082 8c CLRH
0083 4f CLRA
0084 d70001 STA @OSTCBPrioTbl:1,X
0087 d70000 STA @OSTCBPrioTbl,X
008a 95 TSX
008b 6c01 INC 1,X
008d 2601 BNE L90 ;abs = 0090
008f 7c INC ,X
0090 L90:
0090 f6 LDA ,X
0091 87 PSHA
0092 ee01 LDX 1,X
0094 8a PULH
0095 65000d CPHX #13
0098 25e4 BCS L7E ;abs = 007e
115: }
116: ptcb1 = &OSTCBTbl[0];
009a a600 LDA @OSTCBTbl
009c 95 TSX
009d e703 STA 3,X
009f a600 LDA @OSTCBTbl:MSB
00a1 e702 STA 2,X
117: ptcb2 = &OSTCBTbl[1];
00a3 a60e LDA @OSTCBTbl:14
00a5 e705 STA 5,X
00a7 a60e LDA @OSTCBTbl:14:MSB
00a9 e704 STA 4,X
118: for (i = 0; i < (OS_MAX_TASKS + OS_N_SYS_TASKS - 1); i++) { /* Init. list of free TCBs */
00ab 6f01 CLR 1,X
00ad 7f CLR ,X
00ae LAE:
119: ptcb1->OSTCBNext = ptcb2;
00ae 95 TSX
00af e602 LDA 2,X
00b1 87 PSHA
00b2 ee03 LDX 3,X
00b4 9ee607 LDA 7,SP
00b7 8a PULH
00b8 e703 STA 3,X
00ba 9ee605 LDA 5,SP
00bd e702 STA 2,X
120: ptcb1++;
00bf 9f TXA
00c0 ab0e ADD #14
00c2 9ee704 STA 4,SP
00c5 8b PSHH
00c6 86 PULA
00c7 a900 ADC #0
00c9 95 TSX
00ca e702 STA 2,X
121: ptcb2++;
00cc e605 LDA 5,X
00ce ab0e ADD #14
00d0 e705 STA 5,X
00d2 e604 LDA 4,X
00d4 a900 ADC #0
00d6 e704 STA 4,X
00d8 6c01 INC 1,X
00da 2601 BNE LDD ;abs = 00dd
00dc 7c INC ,X
00dd LDD:
00dd f6 LDA ,X
00de 87 PSHA
00df ee01 LDX 1,X
00e1 8a PULH
00e2 65000b CPHX #11
00e5 25c7 BCS LAE ;abs = 00ae
122: }
123: ptcb1->OSTCBNext = (OS_TCB *)0; /* Last OS_TCB */
00e7 95 TSX
00e8 e602 LDA 2,X
00ea 87 PSHA
00eb ee03 LDX 3,X
00ed 8a PULH
00ee 6f03 CLR 3,X
00f0 6f02 CLR 2,X
124: OSTCBFreeList = &OSTCBTbl[0];
00f2 a600 LDA @OSTCBTbl
00f4 c70001 STA OSTCBFreeList:1
00f7 a600 LDA @OSTCBTbl:MSB
00f9 c70000 STA OSTCBFreeList
125:
126: #if (OS_EVENT_EN > 0) && (OS_MAX_EVENTS > 0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -