comparison gsm-fw/nucleus/quce.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/quce.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 /* quce.c Nucleus PLUS 1.14 */
17 /* */
18 /* COMPONENT */
19 /* */
20 /* QU - Queue Management */
21 /* */
22 /* DESCRIPTION */
23 /* */
24 /* This file contains error checking routines for core functions */
25 /* of the Queue component. This permits easy removal of error */
26 /* checking logic when it is not needed. */
27 /* */
28 /* DATA STRUCTURES */
29 /* */
30 /* None */
31 /* */
32 /* FUNCTIONS */
33 /* */
34 /* QUCE_Create_Queue Create a queue */
35 /* QUCE_Delete_Queue Delete a queue */
36 /* QUCE_Send_To_Queue Send a queue message */
37 /* QUCE_Receive_From_Queue Receive a queue message */
38 /* */
39 /* DEPENDENCIES */
40 /* */
41 /* cs_extr.h Common Service functions */
42 /* tc_extr.h Thread Control functions */
43 /* qu_extr.h Queue functions */
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 Split original error checking */
52 /* file and changed function */
53 /* interfaces, resulting in */
54 /* version 1.1 */
55 /* */
56 /* 03-18-1994 Verified version 1.1 */
57 /* 04-17-1996 updated to version 1.2 */
58 /* 10-28-1997 Modified QUCE_Receive_From_Queue */
59 /* to correct SPR142. This */
60 /* created version 1.2a. */
61 /* 03-24-1998 Released version 1.3. */
62 /* 06-04-1998 Modified QUCE_Send_To_Queue to */
63 /* check for a size of 0, created */
64 /* version 1.3a. (SPR493) */
65 /* 04-17-2002 Released version 1.13m */
66 /* 11-07-2002 Released version 1.14 */
67 /*************************************************************************/
68 #define NU_SOURCE_FILE
69
70
71 #include "cs_extr.h" /* Common service functions */
72 #include "tc_extr.h" /* Thread control functions */
73 #include "qu_extr.h" /* Queue functions */
74
75
76 /*************************************************************************/
77 /* */
78 /* FUNCTION */
79 /* */
80 /* QUCE_Create_Queue */
81 /* */
82 /* DESCRIPTION */
83 /* */
84 /* This function performs error checking on the parameters supplied */
85 /* to the queue create function. */
86 /* */
87 /* CALLED BY */
88 /* */
89 /* Application */
90 /* */
91 /* CALLS */
92 /* */
93 /* QUC_Create_Queue Actual create queue function */
94 /* */
95 /* INPUTS */
96 /* */
97 /* queue_ptr Queue control block pointer */
98 /* name Queue name */
99 /* start_address Starting address of actual */
100 /* queue area */
101 /* queue_size Total size of queue */
102 /* message_type Type of message supported by */
103 /* the queue (fixed/variable) */
104 /* message_size Size of message. Variable */
105 /* message-length queues, this*/
106 /* represents the maximum size*/
107 /* suspend_type Suspension type */
108 /* */
109 /* OUTPUTS */
110 /* */
111 /* NU_INVALID_QUEUE Invalid queue pointer */
112 /* NU_INVALID_MEMORY Invalid queue starting addr */
113 /* NU_INVALID_SIZE Invalid queue size and/or */
114 /* size of message */
115 /* NU_INVALID_MESSAGE Invalid message type */
116 /* NU_INVALID_SUSPEND Invalid suspend type */
117 /* */
118 /* HISTORY */
119 /* */
120 /* DATE REMARKS */
121 /* */
122 /* 03-01-1993 Created initial version 1.0 */
123 /* 04-19-1993 Verified version 1.0 */
124 /* 03-01-1994 Modified function interface, */
125 /* resulting in version 1.1 */
126 /* */
127 /* 03-18-1994 Verified version 1.1 */
128 /* */
129 /*************************************************************************/
130 STATUS QUCE_Create_Queue(NU_QUEUE *queue_ptr, CHAR *name,
131 VOID *start_address, UNSIGNED queue_size,
132 OPTION message_type, UNSIGNED message_size,
133 OPTION suspend_type)
134 {
135
136 QU_QCB *queue;
137 STATUS status;
138 INT overhead;
139
140
141 /* Move input queue pointer into internal pointer. */
142 queue = (QU_QCB *) queue_ptr;
143
144 /* Determine if queue supports variable length messages. If so, an
145 additional word of overhead is required. */
146 if (message_type == NU_VARIABLE_SIZE)
147
148 /* Variable-size queues require an additional word of overhead. */
149 overhead = 1;
150 else
151
152 /* Fixed-size message queues require no additional overhead. */
153 overhead = 0;
154
155 /* Determine if there is an error with the queue pointer. */
156 if ((queue == NU_NULL) || (queue -> qu_id == QU_QUEUE_ID))
157
158 /* Indicate that the queue pointer is invalid. */
159 status = NU_INVALID_QUEUE;
160
161 else if (start_address == NU_NULL)
162
163 /* Indicate that the starting address of the queue is invalid. */
164 status = NU_INVALID_MEMORY;
165
166 else if ((queue_size == 0) || (message_size == 0) ||
167 ((message_size+overhead) > queue_size))
168
169 /* Indicate that one or both of the size parameters are invalid. */
170 status = NU_INVALID_SIZE;
171
172 else if ((message_type != NU_FIXED_SIZE) &&
173 (message_type != NU_VARIABLE_SIZE))
174
175 /* Indicate that the message type is invalid. */
176 status = NU_INVALID_MESSAGE;
177
178 else if ((suspend_type != NU_FIFO) && (suspend_type != NU_PRIORITY))
179
180 /* Indicate that the suspend type is invalid. */
181 status = NU_INVALID_SUSPEND;
182
183 else
184
185 /* All the parameters are okay, call the actual function to create
186 a queue. */
187 status = QUC_Create_Queue(queue_ptr, name, start_address, queue_size,
188 message_type, message_size, suspend_type);
189
190 /* Return completion status. */
191 return(status);
192 }
193
194
195 /*************************************************************************/
196 /* */
197 /* FUNCTION */
198 /* */
199 /* QUCE_Delete_Queue */
200 /* */
201 /* DESCRIPTION */
202 /* */
203 /* This function performs error checking on the parameter supplied */
204 /* to the queue delete function. */
205 /* */
206 /* CALLED BY */
207 /* */
208 /* Application */
209 /* */
210 /* CALLS */
211 /* */
212 /* QUC_Delete_Queue Actual delete queue function */
213 /* */
214 /* INPUTS */
215 /* */
216 /* queue_ptr Queue control block pointer */
217 /* */
218 /* OUTPUTS */
219 /* */
220 /* NU_INVALID_QUEUE Invalid queue pointer */
221 /* */
222 /* HISTORY */
223 /* */
224 /* DATE REMARKS */
225 /* */
226 /* 03-01-1993 Created initial version 1.0 */
227 /* 04-19-1993 Verified version 1.0 */
228 /* 03-01-1994 Modified function interface, */
229 /* resulting in version 1.1 */
230 /* */
231 /* 03-18-1994 Verified version 1.1 */
232 /* */
233 /*************************************************************************/
234 STATUS QUCE_Delete_Queue(NU_QUEUE *queue_ptr)
235 {
236
237 QU_QCB *queue;
238 STATUS status;
239
240
241 /* Move input queue pointer into internal pointer. */
242 queue = (QU_QCB *) queue_ptr;
243
244 /* Determine if there is an error with the queue pointer. */
245 if (queue == NU_NULL)
246
247 /* Indicate that the queue pointer is invalid. */
248 status = NU_INVALID_QUEUE;
249
250 else if (queue -> qu_id != QU_QUEUE_ID)
251
252 /* Indicate that the queue pointer is invalid. */
253 status = NU_INVALID_QUEUE;
254
255 else
256
257 /* All the parameters are okay, call the actual function to delete
258 a queue. */
259 status = QUC_Delete_Queue(queue_ptr);
260
261 /* Return completion status. */
262 return(status);
263 }
264
265
266 /*************************************************************************/
267 /* */
268 /* FUNCTION */
269 /* */
270 /* QUCE_Send_To_Queue */
271 /* */
272 /* DESCRIPTION */
273 /* */
274 /* This function performs error checking on the parameters supplied */
275 /* to the send message to queue function. */
276 /* */
277 /* CALLED BY */
278 /* */
279 /* Application */
280 /* */
281 /* CALLS */
282 /* */
283 /* QUC_Send_To_Queue Actual send queue message */
284 /* function */
285 /* TCCE_Suspend_Error Check suspend validity */
286 /* */
287 /* INPUTS */
288 /* */
289 /* queue_ptr Queue control block pointer */
290 /* message Pointer to message to send */
291 /* size Size of message to send */
292 /* suspend Suspension option if full */
293 /* */
294 /* OUTPUTS */
295 /* */
296 /* NU_INVALID_QUEUE Invalid queue pointer */
297 /* NU_INVALID_POINTER Invalid message pointer */
298 /* NU_INVALID_SIZE Invalid message size */
299 /* NU_INVALID_SUSPEND Invalid suspend request */
300 /* */
301 /* HISTORY */
302 /* */
303 /* DATE REMARKS */
304 /* */
305 /* 03-01-1993 Created initial version 1.0 */
306 /* 04-19-1993 Verified version 1.0 */
307 /* 03-01-1994 Modified function interface, */
308 /* resulting in version 1.1 */
309 /* */
310 /* 03-18-1994 Verified version 1.1 */
311 /* 06-04-1998 Corrected SPR493 */
312 /* */
313 /*************************************************************************/
314 STATUS QUCE_Send_To_Queue(NU_QUEUE *queue_ptr, VOID *message, UNSIGNED size,
315 UNSIGNED suspend)
316 {
317
318 QU_QCB *queue;
319 STATUS status;
320
321
322 /* Move input queue pointer into internal pointer. */
323 queue = (QU_QCB *) queue_ptr;
324
325 /* Determine if there is an error with the queue pointer. */
326 if (queue == NU_NULL)
327
328 /* Indicate that the queue pointer is invalid. */
329 status = NU_INVALID_QUEUE;
330
331 else if (queue -> qu_id != QU_QUEUE_ID)
332
333 /* Indicate that the queue pointer is invalid. */
334 status = NU_INVALID_QUEUE;
335
336 else if (message == NU_NULL)
337
338 /* Indicate that the pointer to the message is invalid. */
339 status = NU_INVALID_POINTER;
340
341 else if (size == 0)
342
343 /* Indicate that the message size is invalid. */
344 status = NU_INVALID_SIZE;
345
346 else if ((queue -> qu_fixed_size) && (size != queue -> qu_message_size))
347
348 /* Indicate that the message size is invalid. */
349 status = NU_INVALID_SIZE;
350
351 else if ((!queue -> qu_fixed_size) && (size > queue -> qu_message_size))
352
353 /* Indicate that the message size is invalid. */
354 status = NU_INVALID_SIZE;
355
356 else if ((suspend) && (TCCE_Suspend_Error()))
357
358 /* Indicate that the suspension is only allowed from a task thread. */
359 status = NU_INVALID_SUSPEND;
360
361 else
362
363 /* All the parameters are okay, call the actual function to send
364 a message to a queue. */
365 status = QUC_Send_To_Queue(queue_ptr, message, size, suspend);
366
367 /* Return completion status. */
368 return(status);
369 }
370
371
372 /*************************************************************************/
373 /* */
374 /* FUNCTION */
375 /* */
376 /* QUCE_Receive_From_Queue */
377 /* */
378 /* DESCRIPTION */
379 /* */
380 /* This function performs error checking on the parameters supplied */
381 /* to the receive message from queue function. */
382 /* */
383 /* CALLED BY */
384 /* */
385 /* Application */
386 /* */
387 /* CALLS */
388 /* */
389 /* QUC_Receive_From_Queue Actual receive message from */
390 /* queue */
391 /* TCCE_Suspend_Error Check suspend validity */
392 /* */
393 /* INPUTS */
394 /* */
395 /* queue_ptr Queue control block pointer */
396 /* message Pointer to message to send */
397 /* size Size of the message */
398 /* actual_size Size of message received */
399 /* suspend Suspension option if empty */
400 /* */
401 /* OUTPUTS */
402 /* */
403 /* NU_INVALID_QUEUE Invalid queue pointer */
404 /* NU_INVALID_POINTER Invalid message pointer */
405 /* NU_INVALID_SIZE Invalid message size */
406 /* NU_INVALID_SUSPEND Invalid suspend request */
407 /* */
408 /* HISTORY */
409 /* */
410 /* DATE REMARKS */
411 /* */
412 /* 03-01-1993 Created initial version 1.0 */
413 /* 04-19-1993 Verified version 1.0 */
414 /* 03-01-1994 Modified function interface, */
415 /* resulting in version 1.1 */
416 /* */
417 /* 03-18-1994 Verified version 1.1 */
418 /* 05-24-1996 Changed the variable queue check */
419 /* from "message size not equal */
420 /* to pipe message size" to */
421 /* "message size greater than */
422 /* pipe message size" (SPR142). */
423 /* */
424 /*************************************************************************/
425 STATUS QUCE_Receive_From_Queue(NU_QUEUE *queue_ptr, VOID *message,
426 UNSIGNED size, UNSIGNED *actual_size, UNSIGNED suspend)
427 {
428
429 QU_QCB *queue;
430 STATUS status;
431
432
433 /* Move input queue pointer into internal pointer. */
434 queue = (QU_QCB *) queue_ptr;
435
436 /* Determine if there is an error with the queue pointer. */
437 if (queue == NU_NULL)
438
439 /* Indicate that the queue pointer is invalid. */
440 status = NU_INVALID_QUEUE;
441
442 else if (queue -> qu_id != QU_QUEUE_ID)
443
444 /* Indicate that the queue pointer is invalid. */
445 status = NU_INVALID_QUEUE;
446
447 else if (message == NU_NULL)
448
449 /* Indicate that the pointer to the message is invalid. */
450 status = NU_INVALID_POINTER;
451
452 else if (size == 0)
453
454 /* Indicate that the message size is invalid. */
455 status = NU_INVALID_SIZE;
456
457 else if ((queue -> qu_fixed_size) && (size != queue -> qu_message_size))
458
459 /* Indicate that the message size is invalid. */
460 status = NU_INVALID_SIZE;
461
462 else if ((!queue -> qu_fixed_size) && (size > queue -> qu_message_size))
463
464 /* Indicate that the message size is invalid. */
465 status = NU_INVALID_SIZE;
466
467 else if ((suspend) && (TCCE_Suspend_Error()))
468
469 /* Indicate that the suspension is only allowed from a task thread. */
470 status = NU_INVALID_SUSPEND;
471
472 else
473
474 /* All the parameters are okay, call the actual function to receive
475 a message from a queue. */
476 status = QUC_Receive_From_Queue(queue_ptr, message, size,
477 actual_size, suspend);
478
479 /* Return completion status. */
480 return(status);
481 }
482
483
484
485
486
487
488