comparison gsm-fw/nucleus/quf.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/quf.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 /* quf.c Nucleus PLUS 1.14 */
17 /* */
18 /* COMPONENT */
19 /* */
20 /* QU - Queue Management */
21 /* */
22 /* DESCRIPTION */
23 /* */
24 /* This file contains routines to obtain facts about the Queue */
25 /* management component. */
26 /* */
27 /* DATA STRUCTURES */
28 /* */
29 /* None */
30 /* */
31 /* FUNCTIONS */
32 /* */
33 /* QUF_Established_Queues Number of created queues */
34 /* QUF_Queue_Information Retrieve queue information */
35 /* QUF_Queue_Pointers Build queue pointer list */
36 /* */
37 /* DEPENDENCIES */
38 /* */
39 /* cs_extr.h Common Service functions */
40 /* tc_extr.h Thread Control functions */
41 /* qu_extr.h Queue functions */
42 /* hi_extr.h History functions */
43 /* */
44 /* HISTORY */
45 /* */
46 /* DATE REMARKS */
47 /* */
48 /* 03-01-1994 Initial version of queue 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 "qu_extr.h" /* Queue functions */
68 #include "hi_extr.h" /* History functions */
69
70
71 /* Define external inner-component global data references. */
72
73 extern CS_NODE *QUD_Created_Queues_List;
74 extern UNSIGNED QUD_Total_Queues;
75 extern TC_PROTECT QUD_List_Protect;
76
77
78
79 /*************************************************************************/
80 /* */
81 /* FUNCTION */
82 /* */
83 /* QUF_Established_Queues */
84 /* */
85 /* DESCRIPTION */
86 /* */
87 /* This function returns the current number of established */
88 /* queues. Queues 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 /* QUD_Total_Queues Number of established */
106 /* queues */
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 QUF_Established_Queues(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 queues. */
132 return(QUD_Total_Queues);
133 }
134
135
136 /*************************************************************************/
137 /* */
138 /* FUNCTION */
139 /* */
140 /* QUF_Queue_Pointers */
141 /* */
142 /* DESCRIPTION */
143 /* */
144 /* This function builds a list of queue pointers, starting at the */
145 /* specified location. The number of queue pointers placed in the */
146 /* list is equivalent to the total number of queues 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 queue 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 QUF_Queue_Pointers(NU_QUEUE **pointer_list,UNSIGNED maximum_pointers)
184 {
185 CS_NODE *node_ptr; /* Pointer to each QCB */
186 UNSIGNED pointers; /* Number of pointers in list*/
187 NU_SUPERV_USER_VARIABLES
188
189 /* Switch to supervisor mode */
190 NU_SUPERVISOR_MODE();
191
192 #ifdef NU_ENABLE_STACK_CHECK
193
194 /* Call stack checking function to check for an overflow condition. */
195 TCT_Check_Stack();
196
197 #endif
198
199 /* Initialize the number of pointers returned. */
200 pointers = 0;
201
202 /* Protect against access to the list of created queues. */
203 TCT_Protect(&QUD_List_Protect);
204
205 /* Loop until all queue pointers are in the list or until the maximum
206 list size is reached. */
207 node_ptr = QUD_Created_Queues_List;
208 while ((node_ptr) && (pointers < maximum_pointers))
209 {
210
211 /* Place the node into the destination list. */
212 *pointer_list++ = (NU_QUEUE *) node_ptr;
213
214 /* Increment the pointers variable. */
215 pointers++;
216
217 /* Position the node pointer to the next node. */
218 node_ptr = node_ptr -> cs_next;
219
220 /* Determine if the pointer is at the head of the list. */
221 if (node_ptr == QUD_Created_Queues_List)
222
223 /* The list search is complete. */
224 node_ptr = NU_NULL;
225 }
226
227 /* Release protection against access to the list of created queues. */
228 TCT_Unprotect();
229
230 /* Return to user mode */
231 NU_USER_MODE();
232
233 /* Return the number of pointers in the list. */
234 return(pointers);
235 }
236
237
238 /*************************************************************************/
239 /* */
240 /* FUNCTION */
241 /* */
242 /* QUF_Queue_Information */
243 /* */
244 /* DESCRIPTION */
245 /* */
246 /* This function returns information about the specified queue. */
247 /* However, if the supplied queue pointer is invalid, the */
248 /* function simply returns an error status. */
249 /* */
250 /* CALLED BY */
251 /* */
252 /* Application */
253 /* */
254 /* CALLS */
255 /* */
256 /* [TCT_Check_Stack] Stack checking function */
257 /* TCT_System_Protect Protect queue */
258 /* TCT_Unprotect Release protection */
259 /* */
260 /* INPUTS */
261 /* */
262 /* queue_ptr Pointer to the queue */
263 /* name Destination for the name */
264 /* start_address Destination for the start */
265 /* address of the queue */
266 /* queue_size Destination for queue size */
267 /* available Destination for available */
268 /* room in queue */
269 /* messages Destination for number of */
270 /* messages queued */
271 /* message_type Destination for message type */
272 /* message_size Destination for message size */
273 /* suspend_type Destination for suspension */
274 /* type */
275 /* tasks_waiting Destination for the tasks */
276 /* waiting count */
277 /* first_task Destination for the pointer */
278 /* to the first task waiting */
279 /* */
280 /* OUTPUTS */
281 /* */
282 /* NU_SUCCESS If a valid queue pointer */
283 /* is supplied */
284 /* NU_INVALID_QUEUE If queue pointer invalid */
285 /* */
286 /* HISTORY */
287 /* */
288 /* DATE REMARKS */
289 /* */
290 /* 03-01-1993 Created initial version 1.0 */
291 /* 04-19-1993 Verified version 1.0 */
292 /* 03-01-1994 Modified function interface, */
293 /* changed protection logic, */
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 QUF_Queue_Information(NU_QUEUE *queue_ptr, CHAR *name,
301 VOID **start_address, UNSIGNED *queue_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 QU_QCB *queue; /* Queue 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 queue pointer into internal pointer. */
317 queue = (QU_QCB *) queue_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 queue id is valid. */
328 if ((queue != NU_NULL) && (queue -> qu_id == QU_QUEUE_ID))
329 {
330
331 /* Setup protection of the queue. */
332 TCT_System_Protect();
333
334 /* The queue pointer is valid. Reflect this in the completion
335 status and fill in the actual information. */
336 completion = NU_SUCCESS;
337
338 /* Copy the queue's name. */
339 for (i = 0; i < NU_MAX_NAME; i++)
340 *name++ = queue -> qu_name[i];
341
342 /* Determine the suspension type. */
343 if (queue -> qu_fifo_suspend)
344 *suspend_type = NU_FIFO;
345 else
346 *suspend_type = NU_PRIORITY;
347
348 /* Determine the message type. */
349 if (queue -> qu_fixed_size)
350 *message_type = NU_FIXED_SIZE;
351 else
352 *message_type = NU_VARIABLE_SIZE;
353
354 /* Get various information about the queue. */
355 *start_address = (UNSIGNED *) queue -> qu_start;
356 *queue_size = queue -> qu_queue_size;
357 *available = queue -> qu_available;
358 *messages = queue -> qu_messages;
359 *message_size = queue -> qu_message_size;
360
361 /* Retrieve the number of tasks waiting and the pointer to the
362 first task waiting. */
363 *tasks_waiting = queue -> qu_tasks_waiting;
364 if (queue -> qu_suspension_list)
365
366 /* There is a task waiting. */
367 *first_task = (NU_TASK *)
368 (queue -> qu_suspension_list) -> qu_suspended_task;
369 else
370
371 /* There are no tasks waiting. */
372 *first_task = NU_NULL;
373
374 /* Release protection of the queue. */
375 TCT_Unprotect();
376 }
377 else
378
379 /* Indicate that the queue pointer is invalid. */
380 completion = NU_INVALID_QUEUE;
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