comparison nucleus/pif.c @ 0:75a11d740a02

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