comparison src/nucleus/quse.c @ 0:92470e5d0b9e

src: partial import from FC Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 15 May 2020 01:28:16 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:92470e5d0b9e
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 /* quse.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 supplemental */
25 /* functions in the Queue 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 /* QUSE_Reset_Queue Reset a queue */
35 /* QUSE_Send_To_Front_Of_Queue Send message to queue's front*/
36 /* QUSE_Broadcast_To_Queue Broadcast message to queue */
37 /* */
38 /* DEPENDENCIES */
39 /* */
40 /* cs_extr.h Common Service functions */
41 /* tc_extr.h Thread Control functions */
42 /* qu_extr.h Queue 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 "qu_extr.h" /* Queue functions */
64
65
66
67 /*************************************************************************/
68 /* */
69 /* FUNCTION */
70 /* */
71 /* QUSE_Reset_Queue */
72 /* */
73 /* DESCRIPTION */
74 /* */
75 /* This function performs error checking on the parameter supplied */
76 /* to the queue reset function. */
77 /* */
78 /* CALLED BY */
79 /* */
80 /* Application */
81 /* */
82 /* CALLS */
83 /* */
84 /* QUS_Reset_Queue Actual reset queue function */
85 /* */
86 /* INPUTS */
87 /* */
88 /* queue_ptr Queue control block pointer */
89 /* */
90 /* OUTPUTS */
91 /* */
92 /* NU_INVALID_QUEUE Invalid queue pointer */
93 /* */
94 /* HISTORY */
95 /* */
96 /* DATE REMARKS */
97 /* */
98 /* 03-01-1993 Created initial version 1.0 */
99 /* 04-19-1993 Verified version 1.0 */
100 /* 03-01-1994 Modified function interface, */
101 /* resulting in version 1.1 */
102 /* */
103 /* 03-18-1994 Verified version 1.1 */
104 /* */
105 /*************************************************************************/
106 STATUS QUSE_Reset_Queue(NU_QUEUE *queue_ptr)
107 {
108
109 QU_QCB *queue;
110 STATUS status;
111
112
113 /* Move input queue pointer into internal pointer. */
114 queue = (QU_QCB *) queue_ptr;
115
116 /* Determine if there is an error with the queue pointer. */
117 if (queue == NU_NULL)
118
119 /* Indicate that the queue pointer is invalid. */
120 status = NU_INVALID_QUEUE;
121
122 else if (queue -> qu_id != QU_QUEUE_ID)
123
124 /* Indicate that the queue pointer is invalid. */
125 status = NU_INVALID_QUEUE;
126
127 else
128
129 /* All the parameters are okay, call the actual function to reset
130 a queue. */
131 status = QUS_Reset_Queue(queue_ptr);
132
133 /* Return completion status. */
134 return(status);
135 }
136
137
138 /*************************************************************************/
139 /* */
140 /* FUNCTION */
141 /* */
142 /* QUSE_Send_To_Front_Of_Queue */
143 /* */
144 /* DESCRIPTION */
145 /* */
146 /* This function performs error checking on the parameters supplied */
147 /* to the send message to front of queue function. */
148 /* */
149 /* CALLED BY */
150 /* */
151 /* Application */
152 /* */
153 /* CALLS */
154 /* */
155 /* QUS_Send_To_Front_Of_Queue Actual send to front of */
156 /* queue function */
157 /* TCCE_Suspend_Error Check suspend validity */
158 /* */
159 /* INPUTS */
160 /* */
161 /* queue_ptr Queue control block pointer */
162 /* message Pointer to message to send */
163 /* size Size of message to send */
164 /* suspend Suspension option if full */
165 /* */
166 /* OUTPUTS */
167 /* */
168 /* NU_INVALID_QUEUE Invalid queue pointer */
169 /* NU_INVALID_POINTER Invalid message pointer */
170 /* NU_INVALID_SIZE Invalid message size */
171 /* NU_INVALID_SUSPEND Invalid suspension request */
172 /* */
173 /* HISTORY */
174 /* */
175 /* DATE REMARKS */
176 /* */
177 /* 03-01-1993 Created initial version 1.0 */
178 /* 04-19-1993 Verified version 1.0 */
179 /* 03-01-1994 Modified function interface, */
180 /* resulting in version 1.1 */
181 /* */
182 /* 03-18-1994 Verified version 1.1 */
183 /* */
184 /*************************************************************************/
185 STATUS QUSE_Send_To_Front_Of_Queue(NU_QUEUE *queue_ptr, VOID *message,
186 UNSIGNED size, UNSIGNED suspend)
187 {
188
189 QU_QCB *queue;
190 STATUS status;
191
192
193 /* Move input queue pointer into internal pointer. */
194 queue = (QU_QCB *) queue_ptr;
195
196 /* Determine if there is an error with the queue pointer. */
197 if (queue == NU_NULL)
198
199 /* Indicate that the queue pointer is invalid. */
200 status = NU_INVALID_QUEUE;
201
202 else if (queue -> qu_id != QU_QUEUE_ID)
203
204 /* Indicate that the queue pointer is invalid. */
205 status = NU_INVALID_QUEUE;
206
207 else if (message == NU_NULL)
208
209 /* Indicate that the pointer to the message is invalid. */
210 status = NU_INVALID_POINTER;
211
212 else if (size == 0)
213
214 /* Indicate that the message size is invalid. */
215 status = NU_INVALID_SIZE;
216
217 else if ((queue -> qu_fixed_size) && (size != queue -> qu_message_size))
218
219 /* Indicate that the message size is invalid. */
220 status = NU_INVALID_SIZE;
221
222 else if ((!queue -> qu_fixed_size) && (size > queue -> qu_message_size))
223
224 /* Indicate that the message size is invalid. */
225 status = NU_INVALID_SIZE;
226
227 else if ((suspend) && (TCCE_Suspend_Error()))
228
229 /* Indicate that the suspension is only allowed from a task thread. */
230 status = NU_INVALID_SUSPEND;
231
232 else
233
234 /* All the parameters are okay, call the actual function to send
235 a message to a queue. */
236 status = QUS_Send_To_Front_Of_Queue(queue_ptr, message, size,
237 suspend);
238
239 /* Return completion status. */
240 return(status);
241 }
242
243
244 /*************************************************************************/
245 /* */
246 /* FUNCTION */
247 /* */
248 /* QUSE_Broadcast_To_Queue */
249 /* */
250 /* DESCRIPTION */
251 /* */
252 /* This function performs error checking on the parameters supplied */
253 /* to the broadcast message to queue function. */
254 /* */
255 /* CALLED BY */
256 /* */
257 /* Application */
258 /* */
259 /* CALLS */
260 /* */
261 /* QUS_Broadcast_To_Queue Actual broadcast message */
262 /* to queue function */
263 /* TCCE_Suspend_Error Check suspend validity */
264 /* */
265 /* INPUTS */
266 /* */
267 /* queue_ptr Queue control block pointer */
268 /* message Pointer to message to send */
269 /* size Size of message to send */
270 /* suspend Suspension option if full */
271 /* */
272 /* OUTPUTS */
273 /* */
274 /* NU_INVALID_QUEUE Invalid queue pointer */
275 /* NU_INVALID_POINTER Invalid message pointer */
276 /* NU_INVALID_SIZE Invalid message size */
277 /* NU_INVALID_SUSPEND Invalid suspend request */
278 /* */
279 /* HISTORY */
280 /* */
281 /* DATE REMARKS */
282 /* */
283 /* 03-01-1993 Created initial version 1.0 */
284 /* 04-19-1993 Verified version 1.0 */
285 /* 03-1-1994 Modified function interface, */
286 /* resulting in version 1.1 */
287 /* */
288 /* 03-18-1994 Verified version 1.1 */
289 /* */
290 /*************************************************************************/
291 STATUS QUSE_Broadcast_To_Queue(NU_QUEUE *queue_ptr, VOID *message,
292 UNSIGNED size, UNSIGNED suspend)
293 {
294
295 QU_QCB *queue;
296 STATUS status;
297
298
299 /* Move input queue pointer into internal pointer. */
300 queue = (QU_QCB *) queue_ptr;
301
302 /* Determine if there is an error with the queue pointer. */
303 if (queue == NU_NULL)
304
305 /* Indicate that the queue pointer is invalid. */
306 status = NU_INVALID_QUEUE;
307
308 else if (queue -> qu_id != QU_QUEUE_ID)
309
310 /* Indicate that the queue pointer is invalid. */
311 status = NU_INVALID_QUEUE;
312
313 else if (message == NU_NULL)
314
315 /* Indicate that the pointer to the message is invalid. */
316 status = NU_INVALID_POINTER;
317
318 else if (size == 0)
319
320 /* Indicate that the message size is invalid. */
321 status = NU_INVALID_SIZE;
322
323
324 else if ((queue -> qu_fixed_size) && (size != queue -> qu_message_size))
325
326 /* Indicate that the message size is invalid. */
327 status = NU_INVALID_SIZE;
328
329 else if ((!queue -> qu_fixed_size) && (size > queue -> qu_message_size))
330
331 /* Indicate that the message size is invalid. */
332 status = NU_INVALID_SIZE;
333
334 else if ((suspend) && (TCCE_Suspend_Error()))
335
336 /* Indicate that the suspension is only allowed from a task thread. */
337 status = NU_INVALID_SUSPEND;
338
339 else
340
341 /* Broadcast a message to a queue. */
342 status = QUS_Broadcast_To_Queue(queue_ptr, message, size, suspend);
343
344 /* Return completion status. */
345 return(status);
346 }
347
348
349
350