comparison src/nucleus/evf.c @ 0:92470e5d0b9e

src: partial import from FC Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 15 May 2020 01:28:16 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:92470e5d0b9e
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 /* evf.c Nucleus PLUS 1.14 */
17 /* */
18 /* COMPONENT */
19 /* */
20 /* EV - Event Group Management */
21 /* */
22 /* DESCRIPTION */
23 /* */
24 /* This file contains routines to obtain facts about the Event */
25 /* Group Management component. */
26 /* */
27 /* DATA STRUCTURES */
28 /* */
29 /* None */
30 /* */
31 /* FUNCTIONS */
32 /* */
33 /* EVF_Established_Event_Groups Number of created groups */
34 /* EVF_Event_Group_Pointers Build event group pointer */
35 /* list */
36 /* EVF_Event_Group_Information Retrieve event group info */
37 /* */
38 /* DEPENDENCIES */
39 /* */
40 /* cs_extr.h Common Service functions */
41 /* tc_extr.h Thread Control functions */
42 /* ev_extr.h Event Group functions */
43 /* hi_extr.h History functions */
44 /* */
45 /* HISTORY */
46 /* */
47 /* DATE REMARKS */
48 /* */
49 /* 03-01-1994 Initial version of event fact */
50 /* service file, version 1.1 */
51 /* */
52 /* 03-18-1994 Verified version 1.1 */
53 /* 04-17-1996 updated to version 1.2 */
54 /* 11-18-1996 Protected Informational service */
55 /* from NULL Control Block pointers */
56 /* creating 1.2a. (SPR220) */
57 /* 03-24-1998 Released version 1.3 */
58 /* 03-26-1999 Released 1.11m (new release */
59 /* numbering scheme) */
60 /* 04-17-2002 Released version 1.13m */
61 /* 11-07-2002 Released version 1.14 */
62 /*************************************************************************/
63 #define NU_SOURCE_FILE
64
65
66 #include "cs_extr.h" /* Common service functions */
67 #include "tc_extr.h" /* Thread control functions */
68 #include "ev_extr.h" /* Event Group functions */
69 #include "hi_extr.h" /* History functions */
70
71
72 /* Define external inner-component global data references. */
73
74 extern CS_NODE *EVD_Created_Event_Groups_List;
75 extern UNSIGNED EVD_Total_Event_Groups;
76 extern TC_PROTECT EVD_List_Protect;
77
78
79
80 /*************************************************************************/
81 /* */
82 /* FUNCTION */
83 /* */
84 /* EVF_Established_Event_Groups */
85 /* */
86 /* DESCRIPTION */
87 /* */
88 /* This function returns the current number of established */
89 /* event groups. Event groups previously deleted are no longer */
90 /* considered established. */
91 /* */
92 /* CALLED BY */
93 /* */
94 /* Application */
95 /* */
96 /* CALLS */
97 /* */
98 /* [TCT_Check_Stack] Stack checking function */
99 /* */
100 /* INPUTS */
101 /* */
102 /* None */
103 /* */
104 /* OUTPUTS */
105 /* */
106 /* EVD_Total_Event_Groups Number of established */
107 /* event groups */
108 /* */
109 /* HISTORY */
110 /* */
111 /* DATE REMARKS */
112 /* */
113 /* 03-01-1993 Created initial version 1.0 */
114 /* 04-19-1993 Verified version 1.0 */
115 /* 03-01-1994 Modified function interface, */
116 /* resulting in version 1.1 */
117 /* */
118 /* 03-18-1994 Verified version 1.1 */
119 /* */
120 /*************************************************************************/
121 UNSIGNED EVF_Established_Event_Groups(VOID)
122 {
123
124
125 #ifdef NU_ENABLE_STACK_CHECK
126
127 /* Call stack checking function to check for an overflow condition. */
128 TCT_Check_Stack();
129
130 #endif
131
132 /* Return the number of established event groups. */
133 return(EVD_Total_Event_Groups);
134 }
135
136
137 /*************************************************************************/
138 /* */
139 /* FUNCTION */
140 /* */
141 /* EVF_Event_Group_Pointers */
142 /* */
143 /* DESCRIPTION */
144 /* */
145 /* This function builds a list of event group pointers, starting at */
146 /* the specified location. The number of event group pointers */
147 /* placed in the list is equivalent to the total number of */
148 /* event groups or the maximum number of pointers specified in the */
149 /* call. */
150 /* */
151 /* CALLED BY */
152 /* */
153 /* Application */
154 /* */
155 /* CALLS */
156 /* */
157 /* [TCT_Check_Stack] Stack checking function */
158 /* TCT_Protect Protect created list */
159 /* TCT_Unprotect Release protection */
160 /* */
161 /* INPUTS */
162 /* */
163 /* pointer_list Pointer to the list area */
164 /* maximum_pointers Maximum number of pointers */
165 /* */
166 /* OUTPUTS */
167 /* */
168 /* pointers Number of event groups placed*/
169 /* in the list */
170 /* HISTORY */
171 /* */
172 /* DATE REMARKS */
173 /* */
174 /* 03-01-1993 Created initial version 1.0 */
175 /* 04-19-1993 Verified version 1.0 */
176 /* 08-09-1993 Corrected pointer retrieval */
177 /* loop, resulting in version 1.0a */
178 /* 08-09-1993 Verified version 1.0a */
179 /* 03-01-1994 Modified function interface, */
180 /* resulting in version 1.1 */
181 /* */
182 /* 03-18-1994 Verified version 1.1 */
183 /* */
184 /*************************************************************************/
185 UNSIGNED EVF_Event_Group_Pointers(NU_EVENT_GROUP **pointer_list,
186 UNSIGNED maximum_pointers)
187 {
188 CS_NODE *node_ptr; /* Pointer to each GCB */
189 UNSIGNED pointers; /* Number of pointers in list*/
190 NU_SUPERV_USER_VARIABLES
191
192 /* Switch to supervisor mode */
193 NU_SUPERVISOR_MODE();
194
195 #ifdef NU_ENABLE_STACK_CHECK
196
197 /* Call stack checking function to check for an overflow condition. */
198 TCT_Check_Stack();
199
200 #endif
201
202 /* Initialize the number of pointers returned. */
203 pointers = 0;
204
205 /* Protect against access to the list of created event groups. */
206 TCT_Protect(&EVD_List_Protect);
207
208 /* Loop until all event group pointers are in the list or until
209 the maximum list size is reached. */
210 node_ptr = EVD_Created_Event_Groups_List;
211 while ((node_ptr) && (pointers < maximum_pointers))
212 {
213
214 /* Place the node into the destination list. */
215 *pointer_list++ = (NU_EVENT_GROUP *) node_ptr;
216
217 /* Increment the pointers variable. */
218 pointers++;
219
220 /* Position the node pointer to the next node. */
221 node_ptr = node_ptr -> cs_next;
222
223 /* Determine if the pointer is at the head of the list. */
224 if (node_ptr == EVD_Created_Event_Groups_List)
225
226 /* The list search is complete. */
227 node_ptr = NU_NULL;
228 }
229
230 /* Release protection against access to the list of created
231 event groups. */
232 TCT_Unprotect();
233
234 /* Return to user mode */
235 NU_USER_MODE();
236
237 /* Return the number of pointers in the list. */
238 return(pointers);
239 }
240
241
242 /*************************************************************************/
243 /* */
244 /* FUNCTION */
245 /* */
246 /* EVF_Event_Group_Information */
247 /* */
248 /* DESCRIPTION */
249 /* */
250 /* This function returns information about the specified event */
251 /* group. However, if the supplied event group pointer is invalid, */
252 /* the function simply returns an error status. */
253 /* */
254 /* CALLED BY */
255 /* */
256 /* Application */
257 /* */
258 /* CALLS */
259 /* */
260 /* [TCT_Check_Stack] Stack checking function */
261 /* TCT_System_Protect Protect event group */
262 /* TCT_Unprotect Release protection */
263 /* */
264 /* INPUTS */
265 /* */
266 /* event_group_ptr Pointer to the event group */
267 /* name Destination for the name */
268 /* event_flags Pointer to a variable to hold*/
269 /* the current event flags */
270 /* tasks_waiting Destination for the tasks */
271 /* waiting count */
272 /* first_task Destination for the pointer */
273 /* to the first task waiting */
274 /* */
275 /* OUTPUTS */
276 /* */
277 /* NU_SUCCESS If a valid event group */
278 /* pointer is supplied */
279 /* NU_INVALID_GROUP If event group pointer is */
280 /* not valid */
281 /* */
282 /* HISTORY */
283 /* */
284 /* DATE REMARKS */
285 /* */
286 /* 03-01-1993 Created initial version 1.0 */
287 /* 04-19-1993 Verified version 1.0 */
288 /* 03-01-1994 Modified function interface, */
289 /* resulting in version 1.1 */
290 /* */
291 /* 03-18-1994 Verified version 1.1 */
292 /* 11-18-1996 Corrected SPR220. */
293 /* */
294 /*************************************************************************/
295 STATUS EVF_Event_Group_Information(NU_EVENT_GROUP *event_group_ptr, CHAR *name,
296 UNSIGNED *event_flags, UNSIGNED *tasks_waiting, NU_TASK **first_task)
297 {
298
299 EV_GCB *event_group; /* Event control block ptr */
300 INT i; /* Working integer variable */
301 STATUS completion; /* Completion status */
302 NU_SUPERV_USER_VARIABLES
303
304 /* Switch to supervisor mode */
305 NU_SUPERVISOR_MODE();
306
307 /* Move input event group pointer into internal pointer. */
308 event_group = (EV_GCB *) event_group_ptr;
309
310
311 #ifdef NU_ENABLE_STACK_CHECK
312
313 /* Call stack checking function to check for an overflow condition. */
314 TCT_Check_Stack();
315
316 #endif
317
318 /* Determine if this event_group id is valid. */
319 if ((event_group != NU_NULL) && (event_group -> ev_id == EV_EVENT_ID))
320 {
321
322 /* Setup protection of the event_group. */
323 TCT_System_Protect();
324
325 /* The event_group pointer is valid. Reflect this in the completion
326 status and fill in the actual information. */
327 completion = NU_SUCCESS;
328
329 /* Copy the event_group's name. */
330 for (i = 0; i < NU_MAX_NAME; i++)
331 *name++ = event_group -> ev_name[i];
332
333 /* Return the current event flags. */
334 *event_flags = event_group -> ev_current_events;
335
336 /* Retrieve the number of tasks waiting and the pointer to the
337 first task waiting. */
338 *tasks_waiting = event_group -> ev_tasks_waiting;
339 if (event_group -> ev_suspension_list)
340
341 /* There is a task waiting. */
342 *first_task = (NU_TASK *)
343 (event_group -> ev_suspension_list) -> ev_suspended_task;
344 else
345
346 /* There are no tasks waiting. */
347 *first_task = NU_NULL;
348
349 /* Release protection of the event group. */
350 TCT_Unprotect();
351 }
352 else
353
354 /* Indicate that the event group pointer is invalid. */
355 completion = NU_INVALID_GROUP;
356
357 /* Return to user mode */
358 NU_USER_MODE();
359
360 /* Return the appropriate completion status. */
361 return(completion);
362 }
363
364
365
366