📄 os_core.lst
字号:
C51 COMPILER V7.50 OS_CORE 12/14/2007 08:25:29 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE OS_CORE
OBJECT MODULE PLACED IN OS_CORE.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE OS_CORE.C LARGE BROWSE DEBUG OBJECTEXTEND
line level source
1 /*
2 *********************************************************************************************************
3 * uC/OS-II
4 * The Real-Time Kernel
5 * CORE FUNCTIONS
6 *
7 * (c) Copyright 1992-2007, Jean J. Labrosse, Weston, FL
8 * All Rights Reserved
9 *
10 * File : OS_CORE.C
11 * By : Jean J. Labrosse
12 * Version : V2.85
13 *
14 * LICENSING TERMS:
15 * ---------------
16 * uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research.
-
17 * If you plan on using uC/OS-II in a commercial product you need to contact Micri祄 to properly license
18 * its use in your product. We provide ALL the source code for your convenience and to help you experience
19 * uC/OS-II. The fact that the source is provided does NOT mean that you can use it without paying a
20 * licensing fee.
21 *********************************************************************************************************
22 */
23
24 #ifndef OS_MASTER_FILE
25 #define OS_GLOBALS
26 #include <ucos_ii.h>
27 #endif
28
29 /*
30 *********************************************************************************************************
31 * PRIORITY RESOLUTION TABLE
32 *
33 * Note: Index into table is bit pattern to resolve highest priority
34 * Indexed value corresponds to highest priority bit position (i.e. 0..7)
35 *********************************************************************************************************
36 */
37
38 INT8U const OSUnMapTbl[256] = {
39 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x00 to 0x0F */
40 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x10 to 0x1F */
41 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x20 to 0x2F */
42 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x30 to 0x3F */
43 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x40 to 0x4F */
44 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x50 to 0x5F */
45 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x60 to 0x6F */
46 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x70 to 0x7F */
47 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x80 to 0x8F */
48 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x90 to 0x9F */
49 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0xA0 to 0xAF */
50 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0xB0 to 0xBF */
51 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0xC0 to 0xCF */
52 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0xD0 to 0xDF */
53 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0xE0 to 0xEF */
54 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 /* 0xF0 to 0xFF */
C51 COMPILER V7.50 OS_CORE 12/14/2007 08:25:29 PAGE 2
55 };
56
57 /*$PAGE*/
58 /*
59 *********************************************************************************************************
60 * FUNCTION PROTOTYPES
61 *********************************************************************************************************
62 */
63
64 static void OS_InitEventList(void) reentrant;
65
66 static void OS_InitMisc(void) reentrant;
67
68 static void OS_InitRdyList(void) reentrant;
69
70 static void OS_InitTaskIdle(void) reentrant;
71
72 #if OS_TASK_STAT_EN > 0
73 static void OS_InitTaskStat(void) reentrant;
74 #endif
75
76 static void OS_InitTCBList(void) reentrant;
77
78 static void OS_SchedNew(void) reentrant;
79
80 /*$PAGE*/
81 /*
82 *********************************************************************************************************
83 * GET THE NAME OF A SEMAPHORE, MUTEX, MAILBOX or QUEUE
84 *
85 * Description: This function is used to obtain the name assigned to a semaphore, mutex, mailbox or queue.
86 *
87 * Arguments : pevent is a pointer to the event group. 'pevent' can point either to a semaphore,
88 * a mutex, a mailbox or a queue. Where this function is concerned, the actual
89 * type is irrelevant.
90 *
91 * pname is a pointer to an ASCII string that will receive the name of the semaphore,
92 * mutex, mailbox or queue. The string must be able to hold at least
93 * OS_EVENT_NAME_SIZE characters.
94 *
95 * perr is a pointer to an error code that can contain one of the following values:
96 *
97 * OS_ERR_NONE if the name was copied to 'pname'
98 * OS_ERR_EVENT_TYPE if 'pevent' is not pointing to the proper event
99 * control block type.
100 * OS_ERR_PNAME_NULL You passed a NULL pointer for 'pname'
101 * OS_ERR_PEVENT_NULL if you passed a NULL pointer for 'pevent'
102 *
103 * Returns : The length of the string or 0 if the 'pevent' is a NULL pointer.
104 *********************************************************************************************************
105 */
106
107 #if OS_EVENT_EN && (OS_EVENT_NAME_SIZE > 1)
108 INT8U OSEventNameGet (OS_EVENT *pevent, INT8U *pname, INT8U *perr) reentrant
109 {
110 1 INT8U len;
111 1 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr = 0;
#endif
114 1
115 1
116 1
C51 COMPILER V7.50 OS_CORE 12/14/2007 08:25:29 PAGE 3
117 1 #if OS_ARG_CHK_EN > 0
if (perr == (INT8U *)0) { /* Validate 'perr' */
return (0);
}
if (pevent == (OS_EVENT *)0) { /* Is 'pevent' a NULL pointer? */
*perr = OS_ERR_PEVENT_NULL;
return (0);
}
if (pname == (INT8U *)0) { /* Is 'pname' a NULL pointer? */
*perr = OS_ERR_PNAME_NULL;
return (0);
}
#endif
130 1 if (OSIntNesting > 0) { /* See if trying to call from an ISR */
131 2 *perr = OS_ERR_NAME_GET_ISR;
132 2 return (0);
133 2 }
134 1 switch (pevent->OSEventType) {
135 2 case OS_EVENT_TYPE_SEM:
136 2 case OS_EVENT_TYPE_MUTEX:
137 2 case OS_EVENT_TYPE_MBOX:
138 2 case OS_EVENT_TYPE_Q:
139 2 break;
140 2
141 2 default:
142 2 *perr = OS_ERR_EVENT_TYPE;
143 2 return (0);
144 2 }
145 1 OS_ENTER_CRITICAL();
146 1 len = OS_StrCopy(pname, pevent->OSEventName); /* Copy name from OS_EVENT */
147 1 OS_EXIT_CRITICAL();
148 1 *perr = OS_ERR_NONE;
149 1 return (len);
150 1 }
151 #endif
152
153 /*$PAGE*/
154 /*
155 *********************************************************************************************************
156 * ASSIGN A NAME TO A SEMAPHORE, MUTEX, MAILBOX or QUEUE
157 *
158 * Description: This function assigns a name to a semaphore, mutex, mailbox or queue.
159 *
160 * Arguments : pevent is a pointer to the event group. 'pevent' can point either to a semaphore,
161 * a mutex, a mailbox or a queue. Where this function is concerned, it doesn't
162 * matter the actual type.
163 *
164 * pname is a pointer to an ASCII string that will be used as the name of the semaphore,
165 * mutex, mailbox or queue. The string must be able to hold at least
166 * OS_EVENT_NAME_SIZE characters.
167 *
168 * perr is a pointer to an error code that can contain one of the following values:
169 *
170 * OS_ERR_NONE if the requested task is resumed
171 * OS_ERR_EVENT_TYPE if 'pevent' is not pointing to the proper event
172 * control block type.
173 * OS_ERR_PNAME_NULL You passed a NULL pointer for 'pname'
174 * OS_ERR_PEVENT_NULL if you passed a NULL pointer for 'pevent'
175 * OS_ERR_NAME_SET_ISR if you called this function from an ISR
176 *
177 * Returns : None
178 *********************************************************************************************************
C51 COMPILER V7.50 OS_CORE 12/14/2007 08:25:29 PAGE 4
179 */
180
181 #if OS_EVENT_EN && (OS_EVENT_NAME_SIZE > 1)
182 void OSEventNameSet (OS_EVENT *pevent, INT8U *pname, INT8U *perr) reentrant
183 {
184 1 INT8U len;
185 1 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr = 0;
#endif
188 1
189 1
190 1
191 1 #if OS_ARG_CHK_EN > 0
if (perr == (INT8U *)0) { /* Validate 'perr' */
return;
}
if (pevent == (OS_EVENT *)0) { /* Is 'pevent' a NULL pointer? */
*perr = OS_ERR_PEVENT_NULL;
return;
}
if (pname == (INT8U *)0) { /* Is 'pname' a NULL pointer? */
*perr = OS_ERR_PNAME_NULL;
return;
}
#endif
204 1 if (OSIntNesting > 0) { /* See if trying to call from an ISR */
205 2 *perr = OS_ERR_NAME_SET_ISR;
206 2 return;
207 2 }
208 1 switch (pevent->OSEventType) {
209 2 case OS_EVENT_TYPE_SEM:
210 2 case OS_EVENT_TYPE_MUTEX:
211 2 case OS_EVENT_TYPE_MBOX:
212 2 case OS_EVENT_TYPE_Q:
213 2 break;
214 2
215 2 default:
216 2 *perr = OS_ERR_EVENT_TYPE;
217 2 return;
218 2 }
219 1 OS_ENTER_CRITICAL();
220 1 len = OS_StrLen(pname); /* Can we fit the string in the storage area? */
221 1 if (len > (OS_EVENT_NAME_SIZE - 1)) { /* No */
222 2 OS_EXIT_CRITICAL();
223 2 *perr = OS_ERR_EVENT_NAME_TOO_LONG;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -