FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/nucleus/csc.c @ 143:afceeeb2cba1
Our nuc-fw is destined to become gsm-fw, so I went ahead and did the big hg mv
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 12 Nov 2013 05:35:48 +0000 |
parents | nuc-fw/nucleus/csc.c@947b1f473960 |
children |
comparison
equal
deleted
inserted
replaced
142:15d5977390c2 | 143:afceeeb2cba1 |
---|---|
1 /*************************************************************************/ | |
2 /* */ | |
3 /* Copyright Mentor Graphics Corporation 2002 */ | |
4 /* All Rights Reserved. */ | |
5 /* */ | |
6 /* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS */ | |
7 /* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS */ | |
8 /* SUBJECT TO LICENSE TERMS. */ | |
9 /* */ | |
10 /*************************************************************************/ | |
11 | |
12 /*************************************************************************/ | |
13 /* */ | |
14 /* FILE NAME VERSION */ | |
15 /* */ | |
16 /* csc.c Nucleus PLUS 1.14 */ | |
17 /* */ | |
18 /* COMPONENT */ | |
19 /* */ | |
20 /* CS - Common Services */ | |
21 /* */ | |
22 /* DESCRIPTION */ | |
23 /* */ | |
24 /* This file contains linked list manipulation facilities used */ | |
25 /* throughout the Nucleus PLUS system. These facilities operate */ | |
26 /* on doubly-linked circular lists. */ | |
27 /* */ | |
28 /* DATA STRUCTURES */ | |
29 /* */ | |
30 /* None */ | |
31 /* */ | |
32 /* FUNCTIONS */ | |
33 /* */ | |
34 /* CSC_Place_On_List Place node at the end of a */ | |
35 /* list */ | |
36 /* CSC_Priority_Place_On_List Place node in priority order */ | |
37 /* on a list */ | |
38 /* CSC_Remove_From_List Remove a node from a list */ | |
39 /* */ | |
40 /* DEPENDENCIES */ | |
41 /* */ | |
42 /* nucleus.h Nucleus PLUS constants */ | |
43 /* cs_defs.h Common service definitions */ | |
44 /* */ | |
45 /* HISTORY */ | |
46 /* */ | |
47 /* DATE REMARKS */ | |
48 /* */ | |
49 /* 03-01-1993 Created initial version 1.0 */ | |
50 /* 04-19-1993 Verified version 1.0 */ | |
51 /* 03-01-1994 Changed void to VOID, removed */ | |
52 /* clearing link pointers during */ | |
53 /* removal of a node from a list, */ | |
54 /* resulting in version 1.1 */ | |
55 /* */ | |
56 /* 03-18-1994 Verified version 1.1 */ | |
57 /* 04-17-1996 updated to version 1.2 */ | |
58 /* 03-24-1998 Released version 1.3. */ | |
59 /* 03-26-1999 Released 1.11m (new release */ | |
60 /* numbering scheme) */ | |
61 /* 04-17-2002 Released version 1.13m */ | |
62 /* 11-07-2002 Released version 1.14 */ | |
63 /*************************************************************************/ | |
64 #define NU_SOURCE_FILE | |
65 | |
66 | |
67 #include "cs_defs.h" /* Include CS definitions */ | |
68 #include "cs_extr.h" /* Common service functions */ | |
69 | |
70 | |
71 /*************************************************************************/ | |
72 /* */ | |
73 /* FUNCTION */ | |
74 /* */ | |
75 /* CSC_Place_On_List */ | |
76 /* */ | |
77 /* DESCRIPTION */ | |
78 /* */ | |
79 /* This function places the specified node at the end of specified */ | |
80 /* linked list. */ | |
81 /* */ | |
82 /* CALLED BY */ | |
83 /* */ | |
84 /* various components */ | |
85 /* */ | |
86 /* CALLS */ | |
87 /* */ | |
88 /* None */ | |
89 /* */ | |
90 /* INPUTS */ | |
91 /* */ | |
92 /* head Pointer to head pointer */ | |
93 /* node Pointer to node to add */ | |
94 /* */ | |
95 /* OUTPUTS */ | |
96 /* */ | |
97 /* modified list */ | |
98 /* */ | |
99 /* HISTORY */ | |
100 /* */ | |
101 /* NAME DATE REMARKS */ | |
102 /* */ | |
103 /* W. Lamie 03-01-1993 Created initial version 1.0 */ | |
104 /* D. Lamie 04-19-1993 Verified version 1.0 */ | |
105 /* */ | |
106 /*************************************************************************/ | |
107 | |
108 #ifndef NU_INLINE | |
109 | |
110 VOID CSC_Place_On_List(CS_NODE **head, CS_NODE *new_node) | |
111 { | |
112 NU_SUPERV_USER_VARIABLES | |
113 | |
114 /* Switch to supervisor mode */ | |
115 NU_SUPERVISOR_MODE(); | |
116 | |
117 /* Determine if the list in non-empty. */ | |
118 if (*head) | |
119 { | |
120 | |
121 /* The list is not empty. Add the new node to the end of | |
122 the list. */ | |
123 new_node -> cs_previous = (*head) -> cs_previous; | |
124 (new_node -> cs_previous) -> cs_next = new_node; | |
125 new_node -> cs_next = (*head); | |
126 (new_node -> cs_next) -> cs_previous = new_node; | |
127 } | |
128 else | |
129 { | |
130 | |
131 /* The list is empty, setup the head and the new node. */ | |
132 (*head) = new_node; | |
133 new_node -> cs_previous = new_node; | |
134 new_node -> cs_next = new_node; | |
135 } | |
136 | |
137 /* Return to user mode */ | |
138 NU_USER_MODE(); | |
139 } | |
140 | |
141 #endif | |
142 | |
143 /*************************************************************************/ | |
144 /* */ | |
145 /* FUNCTION */ | |
146 /* */ | |
147 /* CSC_Priority_Place_On_List */ | |
148 /* */ | |
149 /* DESCRIPTION */ | |
150 /* */ | |
151 /* This function places the specified node after all other nodes on */ | |
152 /* the list of equal or greater priority. Note that lower */ | |
153 /* numerical values indicate greater priority. */ | |
154 /* */ | |
155 /* CALLED BY */ | |
156 /* */ | |
157 /* various components */ | |
158 /* */ | |
159 /* CALLS */ | |
160 /* */ | |
161 /* None */ | |
162 /* */ | |
163 /* INPUTS */ | |
164 /* */ | |
165 /* head Pointer to head pointer */ | |
166 /* node Pointer to node to add */ | |
167 /* */ | |
168 /* OUTPUTS */ | |
169 /* */ | |
170 /* modified list */ | |
171 /* */ | |
172 /* HISTORY */ | |
173 /* */ | |
174 /* NAME DATE REMARKS */ | |
175 /* */ | |
176 /* W. Lamie 03-01-1993 Created initial version 1.0 */ | |
177 /* D. Lamie 04-19-1993 Verified version 1.0 */ | |
178 /* */ | |
179 /*************************************************************************/ | |
180 | |
181 VOID CSC_Priority_Place_On_List(CS_NODE **head, CS_NODE *new_node) | |
182 { | |
183 | |
184 CS_NODE *search_ptr; /* List search pointer */ | |
185 NU_SUPERV_USER_VARIABLES | |
186 | |
187 /* Switch to supervisor mode */ | |
188 NU_SUPERVISOR_MODE(); | |
189 | |
190 /* Determine if the list in non-empty. */ | |
191 if (*head) | |
192 { | |
193 | |
194 /* Search the list to find the proper place for the new node. */ | |
195 search_ptr = (*head); | |
196 | |
197 /* Check for insertion before the first node on the list. */ | |
198 if (search_ptr -> cs_priority > new_node -> cs_priority) | |
199 { | |
200 | |
201 /* Update the head pointer to point at the new node. */ | |
202 (*head) = new_node; | |
203 } | |
204 else | |
205 { | |
206 | |
207 /* We know that the new node is not the highest priority and | |
208 must be placed somewhere after the head pointer. */ | |
209 | |
210 /* Move search pointer up to the next node since we are trying | |
211 to find the proper node to insert in front of. */ | |
212 search_ptr = search_ptr -> cs_next; | |
213 while ((search_ptr -> cs_priority <= new_node -> cs_priority) && | |
214 (search_ptr != (*head))) | |
215 { | |
216 | |
217 /* Move along to the next node. */ | |
218 search_ptr = search_ptr -> cs_next; | |
219 } | |
220 } | |
221 | |
222 /* Insert before search pointer. */ | |
223 new_node -> cs_previous = search_ptr -> cs_previous; | |
224 (new_node -> cs_previous) -> cs_next = new_node; | |
225 new_node -> cs_next = search_ptr; | |
226 (new_node -> cs_next) -> cs_previous = new_node; | |
227 } | |
228 else | |
229 { | |
230 | |
231 /* The list is empty, setup the head and the new node. */ | |
232 (*head) = new_node; | |
233 new_node -> cs_previous = new_node; | |
234 new_node -> cs_next = new_node; | |
235 } | |
236 | |
237 /* Return to user mode */ | |
238 NU_USER_MODE(); | |
239 } | |
240 | |
241 /*************************************************************************/ | |
242 /* */ | |
243 /* FUNCTION */ | |
244 /* */ | |
245 /* CSC_Remove_From_List */ | |
246 /* */ | |
247 /* DESCRIPTION */ | |
248 /* */ | |
249 /* This function removes the specified node from the specified */ | |
250 /* linked list. */ | |
251 /* */ | |
252 /* CALLED BY */ | |
253 /* */ | |
254 /* various components */ | |
255 /* */ | |
256 /* CALLS */ | |
257 /* */ | |
258 /* None */ | |
259 /* */ | |
260 /* INPUTS */ | |
261 /* */ | |
262 /* head Pointer to head pointer */ | |
263 /* node Pointer to node to add */ | |
264 /* */ | |
265 /* OUTPUTS */ | |
266 /* */ | |
267 /* modified list */ | |
268 /* */ | |
269 /* HISTORY */ | |
270 /* */ | |
271 /* NAME DATE REMARKS */ | |
272 /* */ | |
273 /* W. Lamie 03-01-1993 Created initial version 1.0 */ | |
274 /* D. Lamie 04-19-1993 Verified version 1.0 */ | |
275 /* W. Lamie 03-01-1994 Removed clearing link pointers */ | |
276 /* during removal of a node from */ | |
277 /* list, resulting in version 1.1 */ | |
278 /* R. Pfaff - */ | |
279 /* D. Lamie 03-18-1994 Verified version 1.1 */ | |
280 /* */ | |
281 /*************************************************************************/ | |
282 | |
283 #ifndef NU_INLINE | |
284 | |
285 VOID CSC_Remove_From_List(CS_NODE **head, CS_NODE *node) | |
286 { | |
287 NU_SUPERV_USER_VARIABLES | |
288 | |
289 /* Switch to supervisor mode */ | |
290 NU_SUPERVISOR_MODE(); | |
291 | |
292 /* Determine if this is the only node in the system. */ | |
293 if (node -> cs_previous == node) | |
294 { | |
295 | |
296 /* Yes, this is the only node in the system. Clear the node's | |
297 pointers and the head pointer. */ | |
298 (*head) = NU_NULL; | |
299 } | |
300 else | |
301 { | |
302 | |
303 /* Unlink the node from a multiple node list. */ | |
304 (node -> cs_previous) -> cs_next = node -> cs_next; | |
305 (node -> cs_next) -> cs_previous = node -> cs_previous; | |
306 | |
307 /* Check to see if the node to delete is at the head of the | |
308 list. */ | |
309 if (node == *head) | |
310 | |
311 /* Move the head pointer to the node after. */ | |
312 *head = node -> cs_next; | |
313 } | |
314 | |
315 /* Return to user mode */ | |
316 NU_USER_MODE(); | |
317 } | |
318 | |
319 #endif | |
320 | |
321 | |
322 | |
323 | |
324 |