FreeCalypso > hg > freecalypso-citrine
comparison nucleus/pise.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 /* pise.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 supplemental */ | |
25 /* functions of the Pipe component. This permits easy removal of */ | |
26 /* error checking logic when it is not needed. */ | |
27 /* */ | |
28 /* DATA STRUCTURES */ | |
29 /* */ | |
30 /* None */ | |
31 /* */ | |
32 /* FUNCTIONS */ | |
33 /* */ | |
34 /* PISE_Reset_Pipe Reset a pipe */ | |
35 /* PISE_Send_To_Front_Of_Pipe Send message to pipe's front */ | |
36 /* PISE_Broadcast_To_Pipe Broadcast message to pipe */ | |
37 /* */ | |
38 /* DEPENDENCIES */ | |
39 /* */ | |
40 /* cs_extr.h Common Service functions */ | |
41 /* tc_extr.h Thread Control functions */ | |
42 /* pi_extr.h Pipe functions */ | |
43 /* */ | |
44 /* HISTORY */ | |
45 /* */ | |
46 /* DATE REMARKS */ | |
47 /* */ | |
48 /* 03-01-1994 Created initial version 1.1 from */ | |
49 /* routines originally in core */ | |
50 /* error checking file */ | |
51 /* */ | |
52 /* 03-18-1994 Verified version 1.1 */ | |
53 /* 04-17-1996 updated to version 1.2 */ | |
54 /* 03-24-1998 Released version 1.3. */ | |
55 /* 04-17-2002 Released version 1.13m */ | |
56 /* 11-07-2002 Released version 1.14 */ | |
57 /*************************************************************************/ | |
58 #define NU_SOURCE_FILE | |
59 | |
60 | |
61 #include "cs_extr.h" /* Common service functions */ | |
62 #include "tc_extr.h" /* Thread control functions */ | |
63 #include "pi_extr.h" /* Pipe functions */ | |
64 | |
65 | |
66 /*************************************************************************/ | |
67 /* */ | |
68 /* FUNCTION */ | |
69 /* */ | |
70 /* PISE_Reset_Pipe */ | |
71 /* */ | |
72 /* DESCRIPTION */ | |
73 /* */ | |
74 /* This function performs error checking on the parameter supplied */ | |
75 /* to the pipe reset function. */ | |
76 /* */ | |
77 /* CALLED BY */ | |
78 /* */ | |
79 /* Application */ | |
80 /* */ | |
81 /* CALLS */ | |
82 /* */ | |
83 /* PIS_Reset_Pipe Actual reset pipe function */ | |
84 /* */ | |
85 /* INPUTS */ | |
86 /* */ | |
87 /* pipe_ptr Pipe control block pointer */ | |
88 /* */ | |
89 /* OUTPUTS */ | |
90 /* */ | |
91 /* NU_INVALID_PIPE Invalid pipe pointer */ | |
92 /* */ | |
93 /* HISTORY */ | |
94 /* */ | |
95 /* DATE REMARKS */ | |
96 /* */ | |
97 /* 03-01-1993 Created initial version 1.0 */ | |
98 /* 04-19-1993 Verified version 1.0 */ | |
99 /* 03-01-1994 Modified function interface, */ | |
100 /* resulting in version 1.1 */ | |
101 /* */ | |
102 /* 03-18-1994 Verified version 1.1 */ | |
103 /* */ | |
104 /*************************************************************************/ | |
105 STATUS PISE_Reset_Pipe(NU_PIPE *pipe_ptr) | |
106 { | |
107 | |
108 PI_PCB *pipe; | |
109 STATUS status; | |
110 | |
111 | |
112 /* Move input pipe pointer into internal pointer. */ | |
113 pipe = (PI_PCB *) pipe_ptr; | |
114 | |
115 /* Determine if there is an error with the pipe pointer. */ | |
116 if (pipe == NU_NULL) | |
117 | |
118 /* Indicate that the pipe pointer is invalid. */ | |
119 status = NU_INVALID_PIPE; | |
120 | |
121 else if (pipe -> pi_id != PI_PIPE_ID) | |
122 | |
123 /* Indicate that the pipe pointer is invalid. */ | |
124 status = NU_INVALID_PIPE; | |
125 | |
126 else | |
127 | |
128 /* All the parameters are okay, call the actual function to reset | |
129 a pipe. */ | |
130 status = PIS_Reset_Pipe(pipe_ptr); | |
131 | |
132 /* Return completion status. */ | |
133 return(status); | |
134 } | |
135 | |
136 | |
137 /*************************************************************************/ | |
138 /* */ | |
139 /* FUNCTION */ | |
140 /* */ | |
141 /* PISE_Send_To_Front_Of_Pipe */ | |
142 /* */ | |
143 /* DESCRIPTION */ | |
144 /* */ | |
145 /* This function performs error checking on the parameters supplied */ | |
146 /* to the send message to front of pipe function. */ | |
147 /* */ | |
148 /* CALLED BY */ | |
149 /* */ | |
150 /* Application */ | |
151 /* */ | |
152 /* CALLS */ | |
153 /* */ | |
154 /* PIS_Send_To_Front_Of_Pipe Actual send to front of pipe */ | |
155 /* function */ | |
156 /* TCCE_Suspend_Error Check suspend validity */ | |
157 /* */ | |
158 /* INPUTS */ | |
159 /* */ | |
160 /* pipe_ptr Pipe control block pointer */ | |
161 /* message Pointer to message to send */ | |
162 /* size Size of message to send */ | |
163 /* suspend Suspension option if full */ | |
164 /* */ | |
165 /* OUTPUTS */ | |
166 /* */ | |
167 /* NU_INVALID_PIPE Invalid pipe pointer */ | |
168 /* NU_INVALID_POINTER Invalid message pointer */ | |
169 /* NU_INVALID_SIZE Invalid message size */ | |
170 /* NU_INVALID_SUSPEND Invalid suspend request */ | |
171 /* */ | |
172 /* HISTORY */ | |
173 /* */ | |
174 /* DATE REMARKS */ | |
175 /* */ | |
176 /* 03-01-1993 Created initial version 1.0 */ | |
177 /* 04-19-1993 Verified version 1.0 */ | |
178 /* 03-01-1994 Modified function interface, */ | |
179 /* resulting in version 1.1 */ | |
180 /* */ | |
181 /* 03-18-1994 Verified version 1.1 */ | |
182 /* */ | |
183 /*************************************************************************/ | |
184 STATUS PISE_Send_To_Front_Of_Pipe(NU_PIPE *pipe_ptr, VOID *message, | |
185 UNSIGNED size, UNSIGNED suspend) | |
186 { | |
187 | |
188 PI_PCB *pipe; | |
189 STATUS status; | |
190 | |
191 | |
192 /* Move input pipe pointer into internal pointer. */ | |
193 pipe = (PI_PCB *) pipe_ptr; | |
194 | |
195 /* Determine if there is an error with the pipe pointer. */ | |
196 if (pipe == NU_NULL) | |
197 | |
198 /* Indicate that the pipe pointer is invalid. */ | |
199 status = NU_INVALID_PIPE; | |
200 | |
201 else if (pipe -> pi_id != PI_PIPE_ID) | |
202 | |
203 /* Indicate that the pipe pointer is invalid. */ | |
204 status = NU_INVALID_PIPE; | |
205 | |
206 else if (message == NU_NULL) | |
207 | |
208 /* Indicate that the pointer to the message is invalid. */ | |
209 status = NU_INVALID_POINTER; | |
210 | |
211 else if (size == 0) | |
212 | |
213 /* Indicate that the message size is invalid */ | |
214 status = NU_INVALID_SIZE; | |
215 | |
216 else if ((pipe -> pi_fixed_size) && (size != pipe -> pi_message_size)) | |
217 | |
218 /* Indicate that the message size is invalid. */ | |
219 status = NU_INVALID_SIZE; | |
220 | |
221 else if ((!pipe -> pi_fixed_size) && (size > pipe -> pi_message_size)) | |
222 | |
223 /* Indicate that the message size is invalid. */ | |
224 status = NU_INVALID_SIZE; | |
225 | |
226 else if ((suspend) && (TCCE_Suspend_Error())) | |
227 | |
228 /* Indicate that suspension is only valid from a non-task thread. */ | |
229 status = NU_INVALID_SUSPEND; | |
230 | |
231 else | |
232 | |
233 /* All the parameters are okay, call the actual function to send | |
234 a message to a pipe. */ | |
235 status = PIS_Send_To_Front_Of_Pipe(pipe_ptr, message, size, suspend); | |
236 | |
237 /* Return completion status. */ | |
238 return(status); | |
239 } | |
240 | |
241 | |
242 /*************************************************************************/ | |
243 /* */ | |
244 /* FUNCTION */ | |
245 /* */ | |
246 /* PISE_Broadcast_To_Pipe */ | |
247 /* */ | |
248 /* DESCRIPTION */ | |
249 /* */ | |
250 /* This function performs error checking on the parameters supplied */ | |
251 /* to the broadcast message to pipe function. */ | |
252 /* */ | |
253 /* CALLED BY */ | |
254 /* */ | |
255 /* Application */ | |
256 /* */ | |
257 /* CALLS */ | |
258 /* */ | |
259 /* PIS_Broadcast_To_Pipe Actual broadcast message to */ | |
260 /* pipe function */ | |
261 /* TCCE_Suspend_Error Check suspend validity */ | |
262 /* */ | |
263 /* INPUTS */ | |
264 /* */ | |
265 /* pipe_ptr Pipe control block pointer */ | |
266 /* message Pointer to message to send */ | |
267 /* size Size of message to send */ | |
268 /* suspend Suspension option if full */ | |
269 /* */ | |
270 /* OUTPUTS */ | |
271 /* */ | |
272 /* NU_INVALID_PIPE Invalid pipe pointer */ | |
273 /* NU_INVALID_POINTER Invalid message pointer */ | |
274 /* NU_INVALID_SIZE Invalid message size */ | |
275 /* NU_INVALID_SUSPEND Invalid suspend request */ | |
276 /* */ | |
277 /* HISTORY */ | |
278 /* */ | |
279 /* DATE REMARKS */ | |
280 /* */ | |
281 /* 03-01-1993 Created initial version 1.0 */ | |
282 /* 04-19-1993 Verified version 1.0 */ | |
283 /* 03-01-1994 Modified function interface, */ | |
284 /* resulting in version 1.1 */ | |
285 /* */ | |
286 /* 03-18-1994 Verified version 1.1 */ | |
287 /* */ | |
288 /*************************************************************************/ | |
289 STATUS PISE_Broadcast_To_Pipe(NU_PIPE *pipe_ptr, VOID *message, | |
290 UNSIGNED size, UNSIGNED suspend) | |
291 { | |
292 | |
293 PI_PCB *pipe; | |
294 STATUS status; | |
295 | |
296 | |
297 /* Move input pipe pointer into internal pointer. */ | |
298 pipe = (PI_PCB *) pipe_ptr; | |
299 | |
300 /* Determine if there is an error with the pipe pointer. */ | |
301 if (pipe == NU_NULL) | |
302 | |
303 /* Indicate that the pipe pointer is invalid. */ | |
304 status = NU_INVALID_PIPE; | |
305 | |
306 else if (pipe -> pi_id != PI_PIPE_ID) | |
307 | |
308 /* Indicate that the pipe pointer is invalid. */ | |
309 status = NU_INVALID_PIPE; | |
310 | |
311 else if (message == NU_NULL) | |
312 | |
313 /* Indicate that the pointer to the message is invalid. */ | |
314 status = NU_INVALID_POINTER; | |
315 | |
316 else if (size == 0) | |
317 | |
318 /* Indicate that the message size is invalid */ | |
319 status = NU_INVALID_SIZE; | |
320 | |
321 else if ((pipe -> pi_fixed_size) && (size != pipe -> pi_message_size)) | |
322 | |
323 /* Indicate that the message size is invalid. */ | |
324 status = NU_INVALID_SIZE; | |
325 | |
326 else if ((!pipe -> pi_fixed_size) && (size > pipe -> pi_message_size)) | |
327 | |
328 /* Indicate that the message size is invalid. */ | |
329 status = NU_INVALID_SIZE; | |
330 | |
331 else if ((suspend) && (TCCE_Suspend_Error())) | |
332 | |
333 /* Indicate that suspension is only valid from a non-task thread. */ | |
334 status = NU_INVALID_SUSPEND; | |
335 | |
336 else | |
337 | |
338 /* All the parameters are okay, call the actual function to broadcast | |
339 a message to a pipe. */ | |
340 status = PIS_Broadcast_To_Pipe(pipe_ptr, message, size, suspend); | |
341 | |
342 /* Return completion status. */ | |
343 return(status); | |
344 } | |
345 | |
346 | |
347 | |
348 | |
349 | |
350 | |
351 |