comparison src/nucleus/mbce.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 /* mbce.c Nucleus PLUS 1.14 */
17 /* */
18 /* COMPONENT */
19 /* */
20 /* MB - Mailbox Management */
21 /* */
22 /* DESCRIPTION */
23 /* */
24 /* This file contains the error checking routines for the core */
25 /* functions in the Mailbox component. This permits easy removal */
26 /* of error checking logic when it is not needed. */
27 /* */
28 /* DATA STRUCTURES */
29 /* */
30 /* None */
31 /* */
32 /* FUNCTIONS */
33 /* */
34 /* MBCE_Create_Mailbox Create a mailbox */
35 /* MBCE_Delete_Mailbox Delete a mailbox */
36 /* MBCE_Send_To_Mailbox Send a mailbox message */
37 /* MBCE_Receive_From_Mailbox Receive a mailbox message */
38 /* */
39 /* DEPENDENCIES */
40 /* */
41 /* cs_extr.h Common Service functions */
42 /* tc_extr.h Thread Control functions */
43 /* mb_extr.h Mailbox 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 Created new file that contains */
52 /* error checking shells for core */
53 /* mailbox functions, also */
54 /* changed interface to exactly */
55 /* match prototype, resulting in */
56 /* version 1.1 */
57 /* */
58 /* 03-18-1994 Verified version 1.1 */
59 /* 04-17-1996 updated to version 1.2 */
60 /* 03-24-1998 Released version 1.3 */
61 /* 04-17-2002 Released version 1.13m */
62 /* 11-07-2002 Released version 1.14 */
63 /*************************************************************************/
64 #define NU_SOURCE_FILE
65
66
67 #include "cs_extr.h" /* Common service functions */
68 #include "tc_extr.h" /* Thread control functions */
69 #include "mb_extr.h" /* Mailbox functions */
70
71
72 /*************************************************************************/
73 /* */
74 /* FUNCTION */
75 /* */
76 /* MBCE_Create_Mailbox */
77 /* */
78 /* DESCRIPTION */
79 /* */
80 /* This function performs error checking on the parameters supplied */
81 /* to the mailbox create function. */
82 /* */
83 /* CALLED BY */
84 /* */
85 /* Application */
86 /* */
87 /* CALLS */
88 /* */
89 /* MBC_Create_Mailbox Actual create mailbox funct. */
90 /* */
91 /* INPUTS */
92 /* */
93 /* mailbox_ptr Mailbox control block pointer*/
94 /* name Mailbox name */
95 /* suspend_type Suspension type */
96 /* */
97 /* OUTPUTS */
98 /* */
99 /* NU_INVALID_MAILBOX Mailbox pointer is NULL */
100 /* NU_INVALID_SUSPEND Suspension type is invalid */
101 /* */
102 /* HISTORY */
103 /* */
104 /* DATE REMARKS */
105 /* */
106 /* 03-01-1993 Created initial version 1.0 */
107 /* 04-19-1993 Verified version 1.0 */
108 /* 03-01-1994 Modified interface to exactly */
109 /* match prototype, resulting in */
110 /* version 1.1 */
111 /* */
112 /* 03-18-1994 Verified version 1.1 */
113 /* */
114 /*************************************************************************/
115 STATUS MBCE_Create_Mailbox(NU_MAILBOX *mailbox_ptr, CHAR *name,
116 OPTION suspend_type)
117 {
118
119 MB_MCB *mailbox; /* Mailbox control block ptr */
120 STATUS status; /* Completion status */
121
122
123 /* Move input mailbox pointer into internal pointer. */
124 mailbox = (MB_MCB *) mailbox_ptr;
125
126 /* Check for a NULL mailbox pointer or an already created mailbox. */
127 if ((mailbox == NU_NULL) || (mailbox -> mb_id == MB_MAILBOX_ID))
128
129 /* Invalid mailbox control block pointer. */
130 status = NU_INVALID_MAILBOX;
131
132 else if ((suspend_type != NU_FIFO) && (suspend_type != NU_PRIORITY))
133
134 /* Invalid suspension type. */
135 status = NU_INVALID_SUSPEND;
136
137 else
138
139 /* Call the actual service to create the mailbox. */
140 status = MBC_Create_Mailbox(mailbox_ptr, name, suspend_type);
141
142 /* Return completion status. */
143 return(status);
144 }
145
146
147 /*************************************************************************/
148 /* */
149 /* FUNCTION */
150 /* */
151 /* MBCE_Delete_Mailbox */
152 /* */
153 /* DESCRIPTION */
154 /* */
155 /* This function performs error checking on the parameters supplied */
156 /* to the actual delete mailbox function. */
157 /* */
158 /* CALLED BY */
159 /* */
160 /* Application */
161 /* */
162 /* CALLS */
163 /* */
164 /* MBC_Delete_Mailbox Actual delete mailbox funct. */
165 /* */
166 /* INPUTS */
167 /* */
168 /* mailbox_ptr Mailbox control block pointer*/
169 /* */
170 /* OUTPUTS */
171 /* */
172 /* NU_INVALID_MAILBOX Invalid mailbox supplied */
173 /* */
174 /* HISTORY */
175 /* */
176 /* DATE REMARKS */
177 /* */
178 /* 03-01-1993 Created initial version 1.0 */
179 /* 04-19-1993 Verified version 1.0 */
180 /* 03-01-1994 Modified interface to exactly */
181 /* match prototype, resulting in */
182 /* version 1.1 */
183 /* */
184 /* 03-18-1994 Verified version 1.1 */
185 /* */
186 /*************************************************************************/
187 STATUS MBCE_Delete_Mailbox(NU_MAILBOX *mailbox_ptr)
188 {
189
190 MB_MCB *mailbox; /* Mailbox control block ptr */
191 STATUS status; /* Completion status */
192
193
194 /* Move input mailbox pointer into internal pointer. */
195 mailbox = (MB_MCB *) mailbox_ptr;
196
197 /* Determine if the mailbox pointer is valid. */
198 if ((mailbox) && (mailbox -> mb_id == MB_MAILBOX_ID))
199
200 /* Mailbox pointer is valid, call function to delete it. */
201 status = MBC_Delete_Mailbox(mailbox_ptr);
202
203 else
204
205 /* Mailbox pointer is invalid, indicate in completion status. */
206 status = NU_INVALID_MAILBOX;
207
208 /* Return completion status. */
209 return(status);
210 }
211
212
213 /*************************************************************************/
214 /* */
215 /* FUNCTION */
216 /* */
217 /* MBCE_Send_To_Mailbox */
218 /* */
219 /* DESCRIPTION */
220 /* */
221 /* This function performs error checking on the parameters supplied */
222 /* to the send-to-mailbox function. */
223 /* */
224 /* CALLED BY */
225 /* */
226 /* Application */
227 /* */
228 /* CALLS */
229 /* */
230 /* MBC_Sent_To_Mailbox Actual mailbox send function */
231 /* TCCE_Suspend_Error Check suspend validity */
232 /* */
233 /* INPUTS */
234 /* */
235 /* mailbox_ptr Mailbox control block pointer*/
236 /* message Pointer to message to send */
237 /* suspend Suspension option if full */
238 /* */
239 /* OUTPUTS */
240 /* */
241 /* NU_INVALID_MAILBOX Mailbox pointer is invalid */
242 /* NU_INVALID_POINTER Message pointer is invalid */
243 /* NU_INVALID_SUSPEND Invalid suspend request */
244 /* */
245 /* HISTORY */
246 /* */
247 /* DATE REMARKS */
248 /* */
249 /* 03-01-1993 Created initial version 1.0 */
250 /* 04-19-1993 Verified version 1.0 */
251 /* 03-01-1994 Modified interface to exactly */
252 /* match prototype, resulting in */
253 /* version 1.1 */
254 /* */
255 /* 03-18-1994 Verified version 1.1 */
256 /* */
257 /*************************************************************************/
258 STATUS MBCE_Send_To_Mailbox(NU_MAILBOX *mailbox_ptr, VOID *message,
259 UNSIGNED suspend)
260 {
261
262 MB_MCB *mailbox; /* Mailbox control block ptr */
263 STATUS status; /* Completion status */
264
265
266 /* Move input mailbox pointer into internal pointer. */
267 mailbox = (MB_MCB *) mailbox_ptr;
268
269 /* Determine if mailbox pointer is invalid. */
270 if (mailbox == NU_NULL)
271
272 /* Mailbox pointer is invalid, indicate in completion status. */
273 status = NU_INVALID_MAILBOX;
274
275 else if (mailbox -> mb_id != MB_MAILBOX_ID)
276
277 /* Mailbox pointer is invalid, indicate in completion status. */
278 status = NU_INVALID_MAILBOX;
279
280 else if (message == NU_NULL)
281
282 /* Message pointer is invalid, indicate in completion status. */
283 status = NU_INVALID_POINTER;
284
285 else if ((suspend) && (TCCE_Suspend_Error()))
286
287 /* Indicate that suspension is only valid from a task thread. */
288 status = NU_INVALID_SUSPEND;
289
290 else
291
292 /* Parameters are valid, call actual function. */
293 status = MBC_Send_To_Mailbox(mailbox_ptr, message, suspend);
294
295 /* Return the completion status. */
296 return(status);
297 }
298
299
300 /*************************************************************************/
301 /* */
302 /* FUNCTION */
303 /* */
304 /* MBCE_Receive_From_Mailbox */
305 /* */
306 /* DESCRIPTION */
307 /* */
308 /* This function performs error checking on the parameters supplied */
309 /* to the receive message from mailbox function. */
310 /* */
311 /* CALLED BY */
312 /* */
313 /* Application */
314 /* */
315 /* CALLS */
316 /* */
317 /* MBC_Receive_From_Mailbox Actual receive function */
318 /* TCCE_Suspend_Error Check suspend validity */
319 /* */
320 /* INPUTS */
321 /* */
322 /* mailbox_ptr Mailbox control block pointer*/
323 /* message Pointer to message to send */
324 /* suspend Suspension option if empty */
325 /* */
326 /* OUTPUTS */
327 /* */
328 /* NU_INVALID_MAILBOX Mailbox pointer is invalid */
329 /* NU_INVALID_POINTER Message pointer is invalid */
330 /* NU_INVALID_SUSPEND Invalid suspend request */
331 /* */
332 /* HISTORY */
333 /* */
334 /* DATE REMARKS */
335 /* */
336 /* 03-01-1993 Created initial version 1.0 */
337 /* 04-19-1993 Verified version 1.0 */
338 /* 03-01-1994 Modified interface to exactly */
339 /* match prototype, resulting in */
340 /* version 1.1 */
341 /* */
342 /* 03-18-1994 Verified version 1.1 */
343 /* */
344 /*************************************************************************/
345 STATUS MBCE_Receive_From_Mailbox(NU_MAILBOX *mailbox_ptr, VOID *message,
346 UNSIGNED suspend)
347 {
348
349 MB_MCB *mailbox; /* Mailbox control block ptr */
350 STATUS status; /* Completion status */
351
352
353 /* Move input mailbox pointer into internal pointer. */
354 mailbox = (MB_MCB *) mailbox_ptr;
355
356 /* Determine if mailbox pointer is invalid. */
357 if (mailbox == NU_NULL)
358
359 /* Mailbox pointer is invalid, indicate in completion status. */
360 status = NU_INVALID_MAILBOX;
361
362 else if (mailbox -> mb_id != MB_MAILBOX_ID)
363
364 /* Mailbox pointer is invalid, indicate in completion status. */
365 status = NU_INVALID_MAILBOX;
366
367 else if (message == NU_NULL)
368
369 /* Message pointer is invalid, indicate in completion status. */
370 status = NU_INVALID_POINTER;
371
372 else if ((suspend) && (TCCE_Suspend_Error()))
373
374 /* Indicate that suspension is only valid from a task thread. */
375 status = NU_INVALID_SUSPEND;
376
377 else
378
379 /* Parameters are valid, call actual function. */
380 status = MBC_Receive_From_Mailbox(mailbox_ptr, message, suspend);
381
382 /* Return the completion status. */
383 return(status);
384 }
385
386
387
388
389
390