comparison nuc-fw/nucleus/evce.c @ 79:947b1f473960

beginning of nuc-fw
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 11 Aug 2013 07:17:25 +0000
parents
children
comparison
equal deleted inserted replaced
78:2c266d4339ff 79:947b1f473960
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 /* evce.c Nucleus PLUS 1.14 */
17 /* */
18 /* COMPONENT */
19 /* */
20 /* EV - Event Group Management */
21 /* */
22 /* DESCRIPTION */
23 /* */
24 /* This file contains the error checking routines for the functions */
25 /* in the Event Group component. This permits easy removal of */
26 /* error checking logic when it is not needed. */
27 /* */
28 /* DATA STRUCTURES */
29 /* */
30 /* None */
31 /* */
32 /* FUNCTIONS */
33 /* */
34 /* EVCE_Create_Event_Group Create an event group */
35 /* EVCE_Delete_Event_Group Delete an event group */
36 /* EVCE_Set_Events Set events in a group */
37 /* EVCE_Retrieve_Events Retrieve events from a group */
38 /* */
39 /* DEPENDENCIES */
40 /* */
41 /* cs_extr.h Common Service functions */
42 /* tc_extr.h Thread Control functions */
43 /* ev_extr.h Event Group functions */
44 /* */
45 /* HISTORY */
46 /* */
47 /* NAME 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 name original error */
52 /* checking file and changed */
53 /* function interfaces, resulting */
54 /* 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 /* 04-17-2002 Released version 1.13m */
60 /* 11-07-2002 Released version 1.14 */
61 /*************************************************************************/
62 #define NU_SOURCE_FILE
63
64
65 #include "cs_extr.h" /* Common service functions */
66 #include "tc_extr.h" /* Thread control functions */
67 #include "ev_extr.h" /* Event Group functions */
68
69
70
71 /*************************************************************************/
72 /* */
73 /* FUNCTION */
74 /* */
75 /* EVCE_Create_Event_Group */
76 /* */
77 /* DESCRIPTION */
78 /* */
79 /* This function performs error checking on the parameters supplied */
80 /* to the create event group function. */
81 /* */
82 /* CALLED BY */
83 /* */
84 /* Application */
85 /* */
86 /* CALLS */
87 /* */
88 /* EVC_Create_Event_Group Actual create event group */
89 /* function */
90 /* */
91 /* INPUTS */
92 /* */
93 /* event_group_ptr Event Group control block ptr*/
94 /* name Event Group name */
95 /* */
96 /* OUTPUTS */
97 /* */
98 /* NU_INVALID_GROUP Event group control block */
99 /* pointer is NULL */
100 /* */
101 /* HISTORY */
102 /* */
103 /* DATE REMARKS */
104 /* */
105 /* 03-01-1993 Created initial version 1.0 */
106 /* 04-19-1993 Verified version 1.0 */
107 /* 03-01-1994 Modified function interface, */
108 /* resulting in version 1.1 */
109 /* */
110 /* 03-18-1994 Verified version 1.1 */
111 /* */
112 /*************************************************************************/
113 STATUS EVCE_Create_Event_Group(NU_EVENT_GROUP *event_group_ptr, CHAR *name)
114 {
115
116 EV_GCB *event_group; /* Event control block ptr */
117 STATUS status; /* Completion status */
118
119
120 /* Move input event group pointer into internal pointer. */
121 event_group = (EV_GCB *) event_group_ptr;
122
123 /* Check for a NULL event group pointer or an already created event
124 group. */
125 if ((event_group == NU_NULL) || (event_group -> ev_id == EV_EVENT_ID))
126
127 /* Invalid event group control block pointer. */
128 status = NU_INVALID_GROUP;
129
130 else
131
132 /* Call the actual service to create the event group. */
133 status = EVC_Create_Event_Group(event_group_ptr, name);
134
135 /* Return completion status. */
136 return(status);
137 }
138
139
140 /*************************************************************************/
141 /* */
142 /* FUNCTION */
143 /* */
144 /* EVCE_Delete_Event_Group */
145 /* */
146 /* DESCRIPTION */
147 /* */
148 /* This function performs error checking on the parameters supplied */
149 /* to the delete event group function. */
150 /* */
151 /* CALLED BY */
152 /* */
153 /* Application */
154 /* */
155 /* CALLS */
156 /* */
157 /* EVC_Delete_Event_Group Actual delete event group */
158 /* function */
159 /* */
160 /* INPUTS */
161 /* */
162 /* event_group_ptr Event Group control block ptr*/
163 /* */
164 /* OUTPUTS */
165 /* */
166 /* NU_INVALID_GROUP Event group control block */
167 /* pointer is invalid */
168 /* */
169 /* HISTORY */
170 /* */
171 /* DATE REMARKS */
172 /* */
173 /* 03-01-1993 Created initial version 1.0 */
174 /* 04-19-1993 Verified version 1.0 */
175 /* 03-01-1994 Modified function interface, */
176 /* resulting in version 1.1 */
177 /* */
178 /* 03-18-1994 Verified version 1.1 */
179 /* */
180 /*************************************************************************/
181 STATUS EVCE_Delete_Event_Group(NU_EVENT_GROUP *event_group_ptr)
182 {
183
184 EV_GCB *event_group; /* Event control block ptr */
185 STATUS status; /* Completion status */
186
187
188 /* Move input event group pointer into internal pointer. */
189 event_group = (EV_GCB *) event_group_ptr;
190
191 /* Determine if the event group pointer is valid. */
192 if ((event_group) && (event_group -> ev_id == EV_EVENT_ID))
193
194 /* Event group pointer is valid, call function to delete it. */
195 status = EVC_Delete_Event_Group(event_group_ptr);
196
197 else
198
199 /* Event group pointer is invalid, indicate in completion status. */
200 status = NU_INVALID_GROUP;
201
202 /* Return completion status. */
203 return(status);
204 }
205
206
207 /*************************************************************************/
208 /* */
209 /* FUNCTION */
210 /* */
211 /* EVCE_Set_Events */
212 /* */
213 /* DESCRIPTION */
214 /* */
215 /* This function performs error checking on the parameters supplied */
216 /* to the set events function. */
217 /* */
218 /* CALLED BY */
219 /* */
220 /* Application */
221 /* */
222 /* CALLS */
223 /* */
224 /* EVC_Set_Events Actual set events function */
225 /* */
226 /* INPUTS */
227 /* */
228 /* event_group_ptr Event Group control block ptr*/
229 /* events Event flag setting */
230 /* operation Operation to perform on the */
231 /* event flag group (AND/OR) */
232 /* */
233 /* OUTPUTS */
234 /* */
235 /* NU_INVALID_GROUP Event group control block */
236 /* pointer is invalid */
237 /* NU_INVALID_OPERATION Event operation is invalid */
238 /* */
239 /* HISTORY */
240 /* */
241 /* DATE REMARKS */
242 /* */
243 /* 03-01-1993 Created initial version 1.0 */
244 /* 04-19-1993 Verified version 1.0 */
245 /* 03-01-1994 Modified function interface, */
246 /* resulting in version 1.1 */
247 /* */
248 /* 03-18-1994 Verified version 1.1 */
249 /* */
250 /*************************************************************************/
251 STATUS EVCE_Set_Events(NU_EVENT_GROUP *event_group_ptr, UNSIGNED events,
252 OPTION operation)
253 {
254
255 EV_GCB *event_group; /* Event control block ptr */
256 STATUS status; /* Completion status */
257
258
259 /* Move input event group pointer into internal pointer. */
260 event_group = (EV_GCB *) event_group_ptr;
261
262 /* Determine if event group pointer is invalid. */
263 if (event_group == NU_NULL)
264
265 /* Event group pointer is invalid, indicate in completion status. */
266 status = NU_INVALID_GROUP;
267
268 else if (event_group -> ev_id != EV_EVENT_ID)
269
270 /* Event group pointer is invalid, indicate in completion status. */
271 status = NU_INVALID_GROUP;
272
273 else if ((operation != NU_AND) && (operation != NU_OR))
274
275 /* Invalid operation on the event flag group. */
276 status = NU_INVALID_OPERATION;
277
278 else
279
280 /* Parameters are valid, call actual function. */
281 status = EVC_Set_Events(event_group_ptr, events, operation);
282
283 /* Return the completion status. */
284 return(status);
285 }
286
287
288 /*************************************************************************/
289 /* */
290 /* FUNCTION */
291 /* */
292 /* EVCE_Retrieve_Events */
293 /* */
294 /* DESCRIPTION */
295 /* */
296 /* This function performs error checking on the parameter supplied */
297 /* to the retrieve events function. */
298 /* */
299 /* CALLED BY */
300 /* */
301 /* Application */
302 /* */
303 /* CALLS */
304 /* */
305 /* EVC_Retrieve_Events Retrieve event flags */
306 /* TCCE_Suspend_Error Check for suspend validity */
307 /* */
308 /* INPUTS */
309 /* */
310 /* event_group_ptr Event Group control block ptr*/
311 /* requested_events Requested event flags */
312 /* operation AND/OR selection of flags */
313 /* retrieved_events Pointer to destination for */
314 /* actual flags retrieved */
315 /* suspend Suspension option */
316 /* */
317 /* OUTPUTS */
318 /* */
319 /* NU_INVALID_GROUP Event group control block */
320 /* pointer is invalid */
321 /* NU_INVALID_POINTER Received event flag pointer */
322 /* is NULL */
323 /* NU_INVALID_OPERATION Event operation is invalid */
324 /* NU_INVALID_SUSPEND Invalid suspension request */
325 /* */
326 /* HISTORY */
327 /* */
328 /* DATE REMARKS */
329 /* */
330 /* 03-01-1993 Created initial version 1.0 */
331 /* 04-19-1993 Verified version 1.0 */
332 /* 03-01-1994 Modified function interface, */
333 /* resulting in version 1.1 */
334 /* */
335 /* 03-18-1994 Verified version 1.1 */
336 /* */
337 /*************************************************************************/
338 STATUS EVCE_Retrieve_Events(NU_EVENT_GROUP *event_group_ptr,
339 UNSIGNED requested_events, OPTION operation,
340 UNSIGNED *retrieved_events, UNSIGNED suspend)
341 {
342
343 EV_GCB *event_group; /* Event control block ptr */
344 STATUS status; /* Completion status */
345
346
347 /* Move input event group pointer into internal pointer. */
348 event_group = (EV_GCB *) event_group_ptr;
349
350 /* Determine if event group pointer is invalid. */
351 if (event_group == NU_NULL)
352
353 /* Event group pointer is invalid, indicate in completion status. */
354 status = NU_INVALID_GROUP;
355
356 else if (event_group -> ev_id != EV_EVENT_ID)
357
358 /* Event group pointer is invalid, indicate in completion status. */
359 status = NU_INVALID_GROUP;
360
361 else if ((operation != NU_AND) &&
362 (operation != NU_AND_CONSUME) &&
363 (operation != NU_OR) &&
364 (operation != NU_OR_CONSUME))
365
366 /* Invalid operation on the event flag group. */
367 status = NU_INVALID_OPERATION;
368
369 else if ((suspend) && (TCCE_Suspend_Error()))
370
371 /* Suspension from an non-task thread. */
372 status = NU_INVALID_SUSPEND;
373
374 else if (retrieved_events == NU_NULL)
375
376 /* Retrieved events pointer is NULL. */
377 status = NU_INVALID_POINTER;
378
379 else
380
381 /* Parameters are valid, call actual function. */
382 status = EVC_Retrieve_Events(event_group_ptr, requested_events,
383 operation, retrieved_events, suspend);
384
385 /* Return the completion status. */
386 return(status);
387 }
388
389
390
391
392
393