comparison gsm-fw/nucleus/pice.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/pice.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 /* pice.c Nucleus PLUS 1.14 */
17 /* */
18 /* COMPONENT */
19 /* */
20 /* PI - Pipe Management */
21 /* */
22 /* DESCRIPTION */
23 /* */
24 /* This file contains error checking routines for core functions */
25 /* of the Pipe 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 /* PICE_Create_Pipe Create a pipe */
35 /* PICE_Delete_Pipe Delete a pipe */
36 /* PICE_Send_To_Pipe Send a pipe message */
37 /* PICE_Receive_From_Pipe Receive a pipe message */
38 /* */
39 /* DEPENDENCIES */
40 /* */
41 /* cs_extr.h Common Service functions */
42 /* tc_extr.h Thread Control functions */
43 /* pi_extr.h Pipe 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 /* 12-19-1995 Modified PICE_Receive_From_Pipe, */
58 /* resulting in version 1.1+ */
59 /* (spr065) */
60 /* 04-17-1996 updated to version 1.2 */
61 /* 03-24-1998 Released version 1.3 */
62 /* 06-04-1998 Modified PICE_Send_To_Pipe 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 "pi_extr.h" /* Pipe functions */
74
75
76 /*************************************************************************/
77 /* */
78 /* FUNCTION */
79 /* */
80 /* PICE_Create_Pipe */
81 /* */
82 /* DESCRIPTION */
83 /* */
84 /* This function performs error checking on the parameters supplied */
85 /* to the pipe create function. */
86 /* */
87 /* CALLED BY */
88 /* */
89 /* Application */
90 /* */
91 /* CALLS */
92 /* */
93 /* PIC_Create_Pipe Actual create pipe function */
94 /* */
95 /* INPUTS */
96 /* */
97 /* pipe_ptr Pipe control block pointer */
98 /* name Pipe name */
99 /* start_address Starting address of actual */
100 /* pipe area */
101 /* pipe_size Total size of pipe */
102 /* message_type Type of message supported by */
103 /* the pipe (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_PIPE Invalid pipe pointer */
112 /* NU_INVALID_MEMORY Invalid pipe starting addr */
113 /* NU_INVALID_SIZE Invalid pipe 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 PICE_Create_Pipe(NU_PIPE *pipe_ptr, CHAR *name,
131 VOID *start_address, UNSIGNED pipe_size,
132 OPTION message_type, UNSIGNED message_size,
133 OPTION suspend_type)
134 {
135
136 PI_PCB *pipe;
137 STATUS status;
138 UNSIGNED overhead;
139
140
141 /* Move input pipe pointer into internal pointer. */
142 pipe = (PI_PCB *) pipe_ptr;
143
144
145 /* Determine if pipe supports variable length messages. If so,
146 additional bytes of overhead are required. */
147 if (message_type == NU_VARIABLE_SIZE)
148
149 /* Calculate the number of overhead bytes necessary for the additional
150 word of overhead and the pad-bytes required to keep the pipe
151 write pointer on an UNSIGNED data element alignment. */
152 overhead = sizeof(UNSIGNED) +
153 (((message_size + sizeof(UNSIGNED) - 1)/sizeof(UNSIGNED)) *
154 sizeof(UNSIGNED)) - message_size;
155
156 else
157
158 /* Fixed-size message queues require no additional overhead. */
159 overhead = 0;
160
161
162 /* Determine if there is an error with the pipe pointer. */
163 if ((pipe == NU_NULL) || (pipe -> pi_id == PI_PIPE_ID))
164
165 /* Indicate that the pipe pointer is invalid. */
166 status = NU_INVALID_PIPE;
167
168 else if (start_address == NU_NULL)
169
170 /* Indicate that the starting address of the pipe is invalid. */
171 status = NU_INVALID_MEMORY;
172
173 else if ((pipe_size == 0) || (message_size == 0) ||
174 ((message_size + overhead) > pipe_size))
175
176 /* Indicate that one or both of the size parameters are invalid. */
177 status = NU_INVALID_SIZE;
178
179 else if ((message_type != NU_FIXED_SIZE) &&
180 (message_type != NU_VARIABLE_SIZE))
181
182 /* Indicate that the message type is invalid. */
183 status = NU_INVALID_MESSAGE;
184
185 else if ((suspend_type != NU_FIFO) && (suspend_type != NU_PRIORITY))
186
187 /* Indicate that the suspend type is invalid. */
188 status = NU_INVALID_SUSPEND;
189
190 else
191
192 /* All the parameters are okay, call the actual function to create
193 a pipe. */
194 status = PIC_Create_Pipe(pipe_ptr, name, start_address, pipe_size,
195 message_type, message_size, suspend_type);
196
197 /* Return completion status. */
198 return(status);
199 }
200
201
202 /*************************************************************************/
203 /* */
204 /* FUNCTION */
205 /* */
206 /* PICE_Delete_Pipe */
207 /* */
208 /* DESCRIPTION */
209 /* */
210 /* This function performs error checking on the parameter supplied */
211 /* to the pipe delete function. */
212 /* */
213 /* CALLED BY */
214 /* */
215 /* Application */
216 /* */
217 /* CALLS */
218 /* */
219 /* PIC_Delete_Pipe Actual delete pipe function */
220 /* */
221 /* INPUTS */
222 /* */
223 /* pipe_ptr Pipe control block pointer */
224 /* */
225 /* OUTPUTS */
226 /* */
227 /* NU_INVALID_PIPE Invalid pipe pointer */
228 /* */
229 /* HISTORY */
230 /* */
231 /* DATE REMARKS */
232 /* */
233 /* 03-01-1993 Created initial version 1.0 */
234 /* 04-19-1993 Verified version 1.0 */
235 /* 03-01-1994 Modified function interface, */
236 /* resulting in version 1.1 */
237 /* */
238 /* 03-18-1994 Verified version 1.1 */
239 /* */
240 /*************************************************************************/
241 STATUS PICE_Delete_Pipe(NU_PIPE *pipe_ptr)
242 {
243
244 PI_PCB *pipe;
245 STATUS status;
246
247
248 /* Move input pipe pointer into internal pointer. */
249 pipe = (PI_PCB *) pipe_ptr;
250
251
252 /* Determine if there is an error with the pipe pointer. */
253 if (pipe == NU_NULL)
254
255 /* Indicate that the pipe pointer is invalid. */
256 status = NU_INVALID_PIPE;
257
258 else if (pipe -> pi_id != PI_PIPE_ID)
259
260 /* Indicate that the pipe pointer is invalid. */
261 status = NU_INVALID_PIPE;
262
263 else
264
265 /* All the parameters are okay, call the actual function to delete
266 a pipe. */
267 status = PIC_Delete_Pipe(pipe_ptr);
268
269 /* Return completion status. */
270 return(status);
271 }
272
273
274 /*************************************************************************/
275 /* */
276 /* FUNCTION */
277 /* */
278 /* PICE_Send_To_Pipe */
279 /* */
280 /* DESCRIPTION */
281 /* */
282 /* This function performs error checking on the parameters supplied */
283 /* to the send message to pipe function. */
284 /* */
285 /* CALLED BY */
286 /* */
287 /* Application */
288 /* */
289 /* CALLS */
290 /* */
291 /* PIC_Send_To_Pipe Actual send pipe message */
292 /* function */
293 /* TCCE_Suspend_Error Check suspend validity */
294 /* */
295 /* INPUTS */
296 /* */
297 /* pipe_ptr Pipe control block pointer */
298 /* message Pointer to message to send */
299 /* size Size of message to send */
300 /* suspend Suspension option if full */
301 /* */
302 /* OUTPUTS */
303 /* */
304 /* NU_INVALID_PIPE Invalid pipe pointer */
305 /* NU_INVALID_POINTER Invalid message pointer */
306 /* NU_INVALID_SIZE Invalid message size */
307 /* NU_INVALID_SUSPEND Invalid suspend request */
308 /* */
309 /* HISTORY */
310 /* */
311 /* DATE REMARKS */
312 /* */
313 /* 03-01-1993 Created initial version 1.0 */
314 /* 04-19-1993 Verified version 1.0 */
315 /* 03-01-1994 Modified function interface, */
316 /* resulting in version 1.1 */
317 /* */
318 /* 03-18-1994 Verified version 1.1 */
319 /* 06-04-1998 Corrected SPR493 */
320 /* */
321 /*************************************************************************/
322 STATUS PICE_Send_To_Pipe(NU_PIPE *pipe_ptr, VOID *message, UNSIGNED size,
323 UNSIGNED suspend)
324 {
325
326 PI_PCB *pipe;
327 STATUS status;
328
329
330 /* Move input pipe pointer into internal pointer. */
331 pipe = (PI_PCB *) pipe_ptr;
332
333 /* Determine if there is an error with the pipe pointer. */
334 if (pipe == NU_NULL)
335
336 /* Indicate that the pipe pointer is invalid. */
337 status = NU_INVALID_PIPE;
338
339 else if (pipe -> pi_id != PI_PIPE_ID)
340
341 /* Indicate that the pipe pointer is invalid. */
342 status = NU_INVALID_PIPE;
343
344 else if (message == NU_NULL)
345
346 /* Indicate that the pointer to the message is invalid. */
347 status = NU_INVALID_POINTER;
348
349 else if (size == 0)
350
351 /* Indicate that the message size is invalid. */
352 status = NU_INVALID_SIZE;
353
354 else if ((pipe -> pi_fixed_size) && (size != pipe -> pi_message_size))
355
356 /* Indicate that the message size is invalid. */
357 status = NU_INVALID_SIZE;
358
359 else if ((!pipe -> pi_fixed_size) && (size > pipe -> pi_message_size))
360
361 /* Indicate that the message size is invalid. */
362 status = NU_INVALID_SIZE;
363
364 else if ((suspend) && (TCCE_Suspend_Error()))
365
366 /* Indicate that suspension is only valid from a non-task thread. */
367 status = NU_INVALID_SUSPEND;
368
369 else
370
371 /* All the parameters are okay, call the actual function to send
372 a message to a pipe. */
373 status = PIC_Send_To_Pipe(pipe_ptr, message, size, suspend);
374
375 /* Return completion status. */
376 return(status);
377 }
378
379
380 /*************************************************************************/
381 /* */
382 /* FUNCTION */
383 /* */
384 /* PICE_Receive_From_Pipe */
385 /* */
386 /* DESCRIPTION */
387 /* */
388 /* This function performs error checking on the parameters supplied */
389 /* to the receive message from pipe function. */
390 /* */
391 /* CALLED BY */
392 /* */
393 /* Application */
394 /* */
395 /* CALLS */
396 /* */
397 /* PIC_Receive_From_Pipe Actual receive message from */
398 /* pipe */
399 /* TCCE_Suspend_Error Check suspend validity */
400 /* */
401 /* INPUTS */
402 /* */
403 /* pipe_ptr Pipe control block pointer */
404 /* message Pointer to message to send */
405 /* size Size of the message */
406 /* actual_size Size of message received */
407 /* suspend Suspension option if empty */
408 /* */
409 /* OUTPUTS */
410 /* */
411 /* NU_INVALID_PIPE Invalid pipe pointer */
412 /* NU_INVALID_POINTER Invalid message pointer */
413 /* NU_INVALID_SIZE Invalid message size */
414 /* NU_INVALID_SUSPEND Invalid suspend request */
415 /* */
416 /* HISTORY */
417 /* */
418 /* DATE REMARKS */
419 /* */
420 /* 03-01-1993 Created initial version 1.0 */
421 /* 04-19-1993 Verified version 1.0 */
422 /* 03-01-1994 Modified function interface, */
423 /* resulting in version 1.1 */
424 /* */
425 /* 03-18-1994 Verified version 1.1 */
426 /* 12-19-1995 Changed the variable pipe check */
427 /* from "message size not equal */
428 /* to pipe message size" to */
429 /* "message size greater than */
430 /* pipe message size",resulting */
431 /* in version 1.1+ (spr065) */
432 /* */
433 /*************************************************************************/
434 STATUS PICE_Receive_From_Pipe(NU_PIPE *pipe_ptr, VOID *message,
435 UNSIGNED size, UNSIGNED *actual_size, UNSIGNED suspend)
436 {
437
438 PI_PCB *pipe;
439 STATUS status;
440
441
442 /* Move input pipe pointer into internal pointer. */
443 pipe = (PI_PCB *) pipe_ptr;
444
445 /* Determine if there is an error with the pipe pointer. */
446 if (pipe == NU_NULL)
447
448 /* Indicate that the pipe pointer is invalid. */
449 status = NU_INVALID_PIPE;
450
451 else if (pipe -> pi_id != PI_PIPE_ID)
452
453 /* Indicate that the pipe pointer is invalid. */
454 status = NU_INVALID_PIPE;
455
456 else if (message == NU_NULL)
457
458 /* Indicate that the pointer to the message is invalid. */
459 status = NU_INVALID_POINTER;
460
461 else if (size == 0)
462
463 /* Indicate that the message size is invalid. */
464 status = NU_INVALID_SIZE;
465
466 else if ((pipe -> pi_fixed_size) && (size != pipe -> pi_message_size))
467
468 /* Indicate that the message size is invalid. */
469 status = NU_INVALID_SIZE;
470
471 else if ((!pipe -> pi_fixed_size) && (size > pipe -> pi_message_size))
472
473 /* Indicate that the message size is invalid. */
474 status = NU_INVALID_SIZE;
475
476 else if ((suspend) && (TCCE_Suspend_Error()))
477
478 /* Indicate that suspension is only valid from a non-task thread. */
479 status = NU_INVALID_SUSPEND;
480
481 else
482
483 /* All the parameters are okay, call the actual function to receive
484 a message from a pipe. */
485 status = PIC_Receive_From_Pipe(pipe_ptr, message, size, actual_size,
486 suspend);
487
488 /* Return completion status. */
489 return(status);
490 }
491
492
493
494
495
496
497