📄 ucos_ii.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-1998, Jean J. Labrosse, Plantation, FL
8: * All Rights Reserved
9: *
10: * V2.00
11: *
12: * File : OS_CORE.C
13: * By : Jean J. Labrosse
14: *********************************************************************************************************
15: */
16:
17: #ifndef OS_MASTER_FILE
18: #define OS_GLOBALS
19: #include "includes.h"
20: #endif
21:
22: /*
23: *********************************************************************************************************
24: * LOCAL GLOBAL VARIABLES
25: *********************************************************************************************************
26: */
27:
28: static INT8U OSIntExitY; /* Variable used by 'OSIntExit' to prevent using locals */
29:
30: static OS_STK OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE]; /* Idle task stack */
31:
32: #if OS_TASK_STAT_EN
33: static OS_STK OSTaskStatStk[OS_TASK_STAT_STK_SIZE]; /* Statistics task stack */
34: #endif
35:
36: static OS_TCB OSTCBTbl[OS_MAX_TASKS + OS_N_SYS_TASKS]; /* Table of TCBs */
37:
38: /*$PAGE*/
39: /*
40: *********************************************************************************************************
41: * MAPPING TABLE TO MAP BIT POSITION TO BIT MASK
42: *
43: * Note: Index into table is desired bit position, 0..7
44: * Indexed value corresponds to bit mask
45: *********************************************************************************************************
46: */
47:
48: INT8U const OSMapTbl[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
49:
50: /*
51: *********************************************************************************************************
52: * PRIORITY RESOLUTION TABLE
53: *
54: * Note: Index into table is bit pattern to resolve highest priority
55: * Indexed value corresponds to highest priority bit position (i.e. 0..7)
56: *********************************************************************************************************
57: */
58:
59: INT8U const OSUnMapTbl[] = {
60: 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
61: 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
62: 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
63: 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
64: 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
65: 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
66: 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
67: 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
68: 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
69: 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
70: 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
71: 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
72: 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
73: 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
74: 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
75: 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
76: };
77:
78: /*$PAGE*/
79: /*
80: *********************************************************************************************************
81: * MAKE TASK READY TO RUN BASED ON EVENT OCCURING
82: *
83: * Description: This function is called by other uC/OS-II services and is used to ready a task that was
84: * waiting for an event to occur.
85: *
86: * Arguments : pevent is a pointer to the event control block corresponding to the event.
87: *
88: * msg is a pointer to a message. This pointer is used by message oriented services
89: * such as MAILBOXEs and QUEUEs. The pointer is not used when called by other
90: * service functions.
91: *
92: * msk is a mask that is used to clear the status byte of the TCB. For example,
93: * OSSemPost() will pass OS_STAT_SEM, OSMboxPost() will pass OS_STAT_MBOX etc.
94: *
95: * Returns : none
96: *
97: * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
98: *********************************************************************************************************
99: */
100: #if (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN || OS_SEM_EN
101: void OSEventTaskRdy (OS_EVENT *pevent, void *msg, INT8U msk)
102: {
103: OS_TCB *ptcb;
104: INT8U x;
105: INT8U y;
106: INT8U bitx;
107: INT8U bity;
108: INT8U prio;
109:
110:
111: y = OSUnMapTbl[pevent->OSEventGrp]; /* Find highest prio. task waiting for message */
112: bity = OSMapTbl[y];
113: x = OSUnMapTbl[pevent->OSEventTbl[y]];
114: bitx = OSMapTbl[x];
115: prio = (INT8U)((y << 3) + x); /* Find priority of task getting the msg */
116: if ((pevent->OSEventTbl[y] &= ~bitx) == 0) { /* Remove this task from the waiting list */
117: pevent->OSEventGrp &= ~bity;
118: }
119: ptcb = OSTCBPrioTbl[prio]; /* Point to this task's OS_TCB */
120: ptcb->OSTCBDly = 0; /* Prevent OSTimeTick() from readying task */
121: ptcb->OSTCBEventPtr = (OS_EVENT *)0; /* Unlink ECB from this task */
122: #if (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN
123: ptcb->OSTCBMsg = msg; /* Send message directly to waiting task */
124: #else
125: msg = msg; /* Prevent compiler warning if not used */
126: #endif
127: ptcb->OSTCBStat &= ~msk; /* Clear bit associated with event type */
128: if (ptcb->OSTCBStat == OS_STAT_RDY) { /* See if task is ready (could be susp'd) */
129: OSRdyGrp |= bity; /* Put task in the ready to run list */
130: OSRdyTbl[y] |= bitx;
131: }
132: }
133: #endif
134: /*$PAGE*/
135: /*
136: *********************************************************************************************************
137: * MAKE TASK WAIT FOR EVENT TO OCCUR
138: *
139: * Description: This function is called by other uC/OS-II services to suspend a task because an event has
140: * not occurred.
141: *
142: * Arguments : pevent is a pointer to the event control block for which the task will be waiting for.
143: *
144: * Returns : none
145: *
146: * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
147: *********************************************************************************************************
148: */
149: #if (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN || OS_SEM_EN
150: void OSEventTaskWait (OS_EVENT *pevent)
151: {
152: OSTCBCur->OSTCBEventPtr = pevent; /* Store pointer to event control block in TCB */
153: if ((OSRdyTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0) { /* Task no longer ready */
154: OSRdyGrp &= ~OSTCBCur->OSTCBBitY;
155: }
156: pevent->OSEventTbl[OSTCBCur->OSTCBY] |= OSTCBCur->OSTCBBitX; /* Put task in waiting list */
157: pevent->OSEventGrp |= OSTCBCur->OSTCBBitY;
158: }
159: #endif
160: /*$PAGE*/
161: /*
162: *********************************************************************************************************
163: * MAKE TASK READY TO RUN BASED ON EVENT TIMEOUT
164: *
165: * Description: This function is called by other uC/OS-II services to make a task ready to run because a
166: * timeout occurred.
167: *
168: * Arguments : pevent is a pointer to the event control block which is readying a task.
169: *
170: * Returns : none
171: *
172: * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
173: *********************************************************************************************************
174: */
175: #if (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN || OS_SEM_EN
176: void OSEventTO (OS_EVENT *pevent)
177: {
178: if ((pevent->OSEventTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0) {
179: pevent->OSEventGrp &= ~OSTCBCur->OSTCBBitY;
180: }
181: OSTCBCur->OSTCBStat = OS_STAT_RDY; /* Set status to ready */
182: OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0; /* No longer waiting for event */
183: }
184: #endif
185: /*$PAGE*/
186: /*
187: *********************************************************************************************************
188: * INITIALIZE EVENT CONTROL BLOCK'S WAIT LIST
189: *
190: * Description: This function is called by other uC/OS-II services to initialize the event wait list.
191: *
192: * Arguments : pevent is a pointer to the event control block allocated to the event.
193: *
194: * Returns : none
195: *
196: * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
197: *********************************************************************************************************
198: */
199: #if (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN || OS_SEM_EN
200: void OSEventWaitListInit (OS_EVENT *pevent)
201: {
202: INT8U i;
203:
204:
205: pevent->OSEventGrp = 0x00; /* No task waiting on event */
206: for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
207: pevent->OSEventTbl[i] = 0x00;
208: }
209: }
210: #endif
211: /*$PAGE*/
212: /*
213: *********************************************************************************************************
214: * INITIALIZATION
215: *
216: * Description: This function is used to initialize the internals of uC/OS-II and MUST be called prior to
217: * creating any uC/OS-II object and, prior to calling OSStart().
218: *
219: * Arguments : none
220: *
221: * Returns : none
222: *********************************************************************************************************
223: */
224:
225: void OSInit (void)
226: {
Function: OSInit
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 a7fd AIS #-3
227: INT16U i;
228:
229:
230: OSTime = 0L; /* Clear the 32-bit system clock */
0002 5f CLRX
0003 8c CLRH
0004 3502 STHX OSTime:2
0006 5f CLRX
0007 8c CLRH
0008 3500 STHX OSTime
231: OSIntNesting = 0; /* Clear the interrupt nesting counter */
000a 3f00 CLR OSIntNesting
232: OSLockNesting = 0; /* Clear the scheduling lock counter */
000c 3f00 CLR OSLockNesting
233: OSRunning = FALSE; /* Indicate that multitasking not started */
000e 3f00 CLR OSRunning
234: OSIdleCtr = 0L; /* Clear the 32-bit idle counter */
0010 5f CLRX
0011 8c CLRH
0012 3502 STHX OSIdleCtr:2
0014 5f CLRX
0015 8c CLRH
0016 3500 STHX OSIdleCtr
235: OSCtxSwCtr = 0; /* Clear the context switch counter */
0018 5f CLRX
0019 8c CLRH
001a 3502 STHX OSCtxSwCtr:2
001c 5f CLRX
001d 8c CLRH
001e 3500 STHX OSCtxSwCtr
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -