FreeCalypso > hg > fc-tourmaline
comparison src/nucleus/ioce.c @ 0:4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 16 Oct 2020 06:23:26 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4e78acac3d88 |
---|---|
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 /* ioce.c Nucleus PLUS 1.14 */ | |
17 /* */ | |
18 /* COMPONENT */ | |
19 /* */ | |
20 /* IO - Input/Output Driver Management */ | |
21 /* */ | |
22 /* DESCRIPTION */ | |
23 /* */ | |
24 /* This file contains the error checking routines for the functions */ | |
25 /* in the Input/Output Driver 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 /* IOCE_Create_Driver Create an I/O driver */ | |
35 /* IOCE_Delete_Driver Delete an I/O driver */ | |
36 /* IOCE_Request_Driver Make an I/O driver request */ | |
37 /* IOCE_Resume_Driver Resume a task suspended in */ | |
38 /* an I/O driver */ | |
39 /* IOCE_Suspend_Driver Suspend a task inside an I/O */ | |
40 /* driver */ | |
41 /* */ | |
42 /* DEPENDENCIES */ | |
43 /* */ | |
44 /* cs_extr.h Common Service functions */ | |
45 /* tc_extr.h Thread Control functions */ | |
46 /* io_extr.h I/O driver functions */ | |
47 /* hi_extr.h History functions */ | |
48 /* */ | |
49 /* HISTORY */ | |
50 /* */ | |
51 /* DATE REMARKS */ | |
52 /* */ | |
53 /* 03-01-1993 Created initial version 1.0 */ | |
54 /* 04-19-1993 Verified version 1.0 */ | |
55 /* 03-01-1994 Modified logic that checked task */ | |
56 /* status without protection of */ | |
57 /* scheduling structures, */ | |
58 /* resulting in version 1.0a */ | |
59 /* 03-01-1994 Verified version 1.0a */ | |
60 /* 03-01-1994 Changed name original error */ | |
61 /* checking file and changed */ | |
62 /* function interfaces, resulting */ | |
63 /* in version 1.1 */ | |
64 /* */ | |
65 /* 03-18-1994 Verified version 1.1 */ | |
66 /* 04-17-1996 updated to version 1.2 */ | |
67 /* 03-24-1998 Released version 1.3 */ | |
68 /* 04-17-2002 Released version 1.13m */ | |
69 /* 11-07-2002 Released version 1.14 */ | |
70 /*************************************************************************/ | |
71 #define NU_SOURCE_FILE | |
72 | |
73 | |
74 #include "cs_extr.h" /* Common service functions */ | |
75 #include "tc_extr.h" /* Thread control functions */ | |
76 #include "io_extr.h" /* I/O driver functions */ | |
77 #include "hi_extr.h" /* History functions */ | |
78 | |
79 | |
80 /*************************************************************************/ | |
81 /* */ | |
82 /* FUNCTION */ | |
83 /* */ | |
84 /* IOCE_Create_Driver */ | |
85 /* */ | |
86 /* DESCRIPTION */ | |
87 /* */ | |
88 /* This function performs error checking on the parameters supplied */ | |
89 /* to the I/O driver create function. */ | |
90 /* */ | |
91 /* CALLED BY */ | |
92 /* */ | |
93 /* Application */ | |
94 /* */ | |
95 /* CALLS */ | |
96 /* */ | |
97 /* IOC_Create_Driver Actual create driver routine */ | |
98 /* */ | |
99 /* INPUTS */ | |
100 /* */ | |
101 /* driver Driver control block pointer */ | |
102 /* name Driver's logical name */ | |
103 /* driver_entry Driver's point of entry */ | |
104 /* */ | |
105 /* OUTPUTS */ | |
106 /* */ | |
107 /* NU_INVALID_DRIVER Indicates driver pointer is */ | |
108 /* NULL or is already in use */ | |
109 /* NU_INVALID_POINTER Indicates the driver's entry */ | |
110 /* pointer is NULL */ | |
111 /* */ | |
112 /* HISTORY */ | |
113 /* */ | |
114 /* DATE REMARKS */ | |
115 /* */ | |
116 /* 03-01-1993 Created initial version 1.0 */ | |
117 /* 04-19-1993 Verified version 1.0 */ | |
118 /* 03-01-1994 Changed function interface, */ | |
119 /* resulting in version 1.1 */ | |
120 /* */ | |
121 /* 03-18-1994 Verified version 1.1 */ | |
122 /* */ | |
123 /*************************************************************************/ | |
124 STATUS IOCE_Create_Driver(NU_DRIVER *driver, CHAR *name, | |
125 VOID (*driver_entry)(NU_DRIVER *, NU_DRIVER_REQUEST *)) | |
126 { | |
127 | |
128 STATUS status; /* Completion status */ | |
129 | |
130 | |
131 /* Check for an invalid driver pointer. */ | |
132 if ((driver == NU_NULL) || (driver -> nu_driver_id == IO_DRIVER_ID)) | |
133 | |
134 /* Indicate that the driver pointer is invalid. */ | |
135 status = NU_INVALID_DRIVER; | |
136 | |
137 else if (driver_entry == NU_NULL) | |
138 | |
139 /* Indicate that the driver entry point is invalid. */ | |
140 status = NU_INVALID_POINTER; | |
141 | |
142 else | |
143 | |
144 /* Parameters are okay, call actual function to create an I/O | |
145 driver. */ | |
146 status = IOC_Create_Driver(driver, name, driver_entry); | |
147 | |
148 /* Return completion status. */ | |
149 return(status); | |
150 } | |
151 | |
152 | |
153 /*************************************************************************/ | |
154 /* */ | |
155 /* FUNCTION */ | |
156 /* */ | |
157 /* IOCE_Delete_Driver */ | |
158 /* */ | |
159 /* DESCRIPTION */ | |
160 /* */ | |
161 /* This function performs error checking on the parameters supplied */ | |
162 /* to the I/O driver delete function. */ | |
163 /* */ | |
164 /* CALLED BY */ | |
165 /* */ | |
166 /* Application */ | |
167 /* */ | |
168 /* CALLS */ | |
169 /* */ | |
170 /* IOC_Delete_Driver Actual delete driver routine */ | |
171 /* */ | |
172 /* INPUTS */ | |
173 /* */ | |
174 /* driver Driver control block pointer */ | |
175 /* */ | |
176 /* OUTPUTS */ | |
177 /* */ | |
178 /* NU_INVALID_DRIVER Indicates the driver pointer */ | |
179 /* is invalid */ | |
180 /* */ | |
181 /* HISTORY */ | |
182 /* */ | |
183 /* DATE REMARKS */ | |
184 /* */ | |
185 /* 03-01-1993 Created initial version 1.0 */ | |
186 /* 04-19-1993 Verified version 1.0 */ | |
187 /* 03-01-1994 Changed function interface, */ | |
188 /* resulting in version 1.1 */ | |
189 /* */ | |
190 /* 03-18-1994 Verified version 1.1 */ | |
191 /* */ | |
192 /*************************************************************************/ | |
193 STATUS IOCE_Delete_Driver(NU_DRIVER *driver) | |
194 { | |
195 | |
196 STATUS status; /* Completion status */ | |
197 | |
198 /* Determine if the driver pointer is valid. */ | |
199 if ((driver) && (driver -> nu_driver_id == IO_DRIVER_ID)) | |
200 | |
201 /* Driver pointer is valid, call function to delete it. */ | |
202 status = IOC_Delete_Driver(driver); | |
203 | |
204 else | |
205 | |
206 /* Driver pointer is invalid, indicate in completion status. */ | |
207 status = NU_INVALID_DRIVER; | |
208 | |
209 /* Return completion status. */ | |
210 return(status); | |
211 } | |
212 | |
213 | |
214 /*************************************************************************/ | |
215 /* */ | |
216 /* FUNCTION */ | |
217 /* */ | |
218 /* IOCE_Request_Driver */ | |
219 /* */ | |
220 /* DESCRIPTION */ | |
221 /* */ | |
222 /* This function performs error checking on the parameters supplied */ | |
223 /* to the I/O driver request function. */ | |
224 /* */ | |
225 /* CALLED BY */ | |
226 /* */ | |
227 /* Application */ | |
228 /* */ | |
229 /* CALLS */ | |
230 /* */ | |
231 /* IOC_Request_Driver Actual request driver routine*/ | |
232 /* */ | |
233 /* INPUTS */ | |
234 /* */ | |
235 /* driver Driver control block pointer */ | |
236 /* request User's I/O request */ | |
237 /* */ | |
238 /* OUTPUTS */ | |
239 /* */ | |
240 /* NU_INVALID_DRIVER Indicates the driver pointer */ | |
241 /* is invalid */ | |
242 /* NU_INVALID_POINTER Indicates the request pointer*/ | |
243 /* is invalid */ | |
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 Changed function interface, */ | |
252 /* resulting in version 1.1 */ | |
253 /* */ | |
254 /* 03-18-1994 Verified version 1.1 */ | |
255 /* */ | |
256 /*************************************************************************/ | |
257 STATUS IOCE_Request_Driver(NU_DRIVER *driver , NU_DRIVER_REQUEST *request) | |
258 { | |
259 | |
260 STATUS status; /* Completion status */ | |
261 | |
262 | |
263 /* Determine if driver pointer is invalid. */ | |
264 if (driver == NU_NULL) | |
265 | |
266 /* Driver pointer is invalid, indicate in completion status. */ | |
267 status = NU_INVALID_DRIVER; | |
268 | |
269 else if (driver -> nu_driver_id != IO_DRIVER_ID) | |
270 | |
271 /* Driver pointer is invalid, indicate in completion status. */ | |
272 status = NU_INVALID_DRIVER; | |
273 | |
274 else if (request == NU_NULL) | |
275 | |
276 /* Request pointer is invalid, indicate in completion status. */ | |
277 status = NU_INVALID_POINTER; | |
278 | |
279 else | |
280 | |
281 /* Parameters are valid, call actual function. */ | |
282 status = IOC_Request_Driver(driver, request); | |
283 | |
284 /* Return the completion status. */ | |
285 return(status); | |
286 } | |
287 | |
288 | |
289 /*************************************************************************/ | |
290 /* */ | |
291 /* FUNCTION */ | |
292 /* */ | |
293 /* IOCE_Resume_Driver */ | |
294 /* */ | |
295 /* DESCRIPTION */ | |
296 /* */ | |
297 /* This function performs error checking on the parameters supplied */ | |
298 /* to the I/O driver resume function. */ | |
299 /* */ | |
300 /* CALLED BY */ | |
301 /* */ | |
302 /* Application */ | |
303 /* */ | |
304 /* CALLS */ | |
305 /* */ | |
306 /* TCCE_Validate_Resume Validate resume driver */ | |
307 /* request against actual */ | |
308 /* status */ | |
309 /* IOC_Resume_Driver Actual resume driver routine */ | |
310 /* */ | |
311 /* INPUTS */ | |
312 /* */ | |
313 /* task Pointer of task to resume */ | |
314 /* */ | |
315 /* OUTPUTS */ | |
316 /* */ | |
317 /* NU_INVALID_TASK Indicates the task pointer */ | |
318 /* is invalid */ | |
319 /* NU_INVALID_RESUME Indicates the task is not */ | |
320 /* suspended */ | |
321 /* */ | |
322 /* HISTORY */ | |
323 /* */ | |
324 /* DATE REMARKS */ | |
325 /* */ | |
326 /* 03-01-1993 Created initial version 1.0 */ | |
327 /* 04-19-1993 Verified version 1.0 */ | |
328 /* 03-01-1994 Modified logic that checked task */ | |
329 /* status without protection of */ | |
330 /* scheduling structures, */ | |
331 /* resulting in version 1.0a */ | |
332 /* 03-01-1994 Verified version 1.0a */ | |
333 /* 03-01-1994 Changed function interface, */ | |
334 /* resulting in version 1.1 */ | |
335 /* */ | |
336 /* 03-18-1994 Verified version 1.1 */ | |
337 /* */ | |
338 /*************************************************************************/ | |
339 STATUS IOCE_Resume_Driver(NU_TASK *task) | |
340 { | |
341 | |
342 STATUS status; /* Completion status */ | |
343 | |
344 | |
345 /* Determine if the task pointer is valid. */ | |
346 if ((task == NU_NULL) || (((TC_TCB *) task) -> tc_id != TC_TASK_ID)) | |
347 | |
348 /* Task pointer is invalid. */ | |
349 status = NU_INVALID_TASK; | |
350 | |
351 /* Check actual status of task to see if request is valid. */ | |
352 else if (TCCE_Validate_Resume(NU_DRIVER_SUSPEND, task)) | |
353 | |
354 /* Task is not suspended in a driver, return error status. */ | |
355 status = NU_INVALID_RESUME; | |
356 | |
357 else | |
358 | |
359 /* Call the actual resume service. */ | |
360 status = IOC_Resume_Driver(task); | |
361 | |
362 /* Return the completion status. */ | |
363 return(status); | |
364 } | |
365 | |
366 | |
367 | |
368 /*************************************************************************/ | |
369 /* */ | |
370 /* FUNCTION */ | |
371 /* */ | |
372 /* IOCE_Suspend_Driver */ | |
373 /* */ | |
374 /* DESCRIPTION */ | |
375 /* */ | |
376 /* This function performs error checking on the parameters supplied */ | |
377 /* to the I/O driver suspend function. */ | |
378 /* */ | |
379 /* CALLED BY */ | |
380 /* */ | |
381 /* Application */ | |
382 /* */ | |
383 /* CALLS */ | |
384 /* */ | |
385 /* IOC_Suspend_Driver Actual driver suspend routine*/ | |
386 /* TCCE_Suspend_Error Check for a legal suspension */ | |
387 /* */ | |
388 /* INPUTS */ | |
389 /* */ | |
390 /* terminate_routine Termination/Timeout cleanup */ | |
391 /* routine */ | |
392 /* information Information pointer of the */ | |
393 /* cleanup routine */ | |
394 /* timeout Suspension timeout request */ | |
395 /* */ | |
396 /* OUTPUTS */ | |
397 /* */ | |
398 /* NU_INVALID_SUSPEND Indicates suspension is not */ | |
399 /* legal */ | |
400 /* */ | |
401 /* HISTORY */ | |
402 /* */ | |
403 /* DATE REMARKS */ | |
404 /* */ | |
405 /* 03-01-1993 Created initial version 1.0 */ | |
406 /* 04-19-1993 Verified version 1.0 */ | |
407 /* 03-01-1994 Changed function interface, */ | |
408 /* resulting in version 1.1 */ | |
409 /* */ | |
410 /* 03-18-1994 Verified version 1.1 */ | |
411 /* */ | |
412 /*************************************************************************/ | |
413 STATUS IOCE_Suspend_Driver(VOID (*terminate_routine)(VOID *), | |
414 VOID *information, UNSIGNED timeout) | |
415 { | |
416 | |
417 STATUS status; /* Completion status */ | |
418 | |
419 | |
420 /* Determine if there is a suspension error. */ | |
421 if (TCCE_Suspend_Error()) | |
422 | |
423 /* Suspension error, not called from a legal thread. */ | |
424 status = NU_INVALID_SUSPEND; | |
425 | |
426 else | |
427 | |
428 /* Call the actual suspend service. */ | |
429 status = IOC_Suspend_Driver(terminate_routine, information, timeout); | |
430 | |
431 /* Return the completion status. */ | |
432 return(status); | |
433 } | |
434 | |
435 | |
436 | |
437 | |
438 | |
439 | |
440 |