1 | @c |
---|
2 | @c COPYRIGHT (c) 1988-1998. |
---|
3 | @c On-Line Applications Research Corporation (OAR). |
---|
4 | @c All rights reserved. |
---|
5 | @c |
---|
6 | @c $Id$ |
---|
7 | @c |
---|
8 | |
---|
9 | @chapter I/O Manager |
---|
10 | |
---|
11 | @section Introduction |
---|
12 | |
---|
13 | The input/output interface manager provides a |
---|
14 | well-defined mechanism for accessing device drivers and a |
---|
15 | structured methodology for organizing device drivers. The |
---|
16 | directives provided by the I/O manager are: |
---|
17 | |
---|
18 | @itemize @bullet |
---|
19 | @item @code{@value{DIRPREFIX}io_initialize} - Initialize a device driver |
---|
20 | @item @code{@value{DIRPREFIX}io_register_name} - Register a device name |
---|
21 | @item @code{@value{DIRPREFIX}io_lookup_name} - Look up a device name |
---|
22 | @item @code{@value{DIRPREFIX}io_open} - Open a device |
---|
23 | @item @code{@value{DIRPREFIX}io_close} - Close a device |
---|
24 | @item @code{@value{DIRPREFIX}io_read} - Read from a device |
---|
25 | @item @code{@value{DIRPREFIX}io_write} - Write to a device |
---|
26 | @item @code{@value{DIRPREFIX}io_control} - Special device services |
---|
27 | @end itemize |
---|
28 | |
---|
29 | @section Background |
---|
30 | |
---|
31 | @subsection Device Driver Table |
---|
32 | |
---|
33 | Each application utilizing the RTEMS I/O manager must |
---|
34 | specify the address of a Device Driver Table in its |
---|
35 | Configuration Table. This table contains each device driver's |
---|
36 | entry points. Each device driver may contain the following |
---|
37 | entry points: |
---|
38 | |
---|
39 | @itemize @bullet |
---|
40 | @item Initialization |
---|
41 | @item Open |
---|
42 | @item Close |
---|
43 | @item Read |
---|
44 | @item Write |
---|
45 | @item Control |
---|
46 | @end itemize |
---|
47 | |
---|
48 | If the device driver does not support a particular |
---|
49 | entry point, then that entry in the Configuration Table should |
---|
50 | be NULL. RTEMS will return |
---|
51 | @code{@value{RPREFIX}SUCCESSFUL} as the executive's and |
---|
52 | zero (0) as the device driver's return code for these device |
---|
53 | driver entry points. |
---|
54 | |
---|
55 | @subsection Major and Minor Device Numbers |
---|
56 | |
---|
57 | Each call to the I/O manager must provide a device's |
---|
58 | major and minor numbers as arguments. The major number is the |
---|
59 | index of the requested driver's entry points in the Device |
---|
60 | Driver Table, and is used to select a specific device driver. |
---|
61 | The exact usage of the minor number is driver specific, but is |
---|
62 | commonly used to distinguish between a number of devices |
---|
63 | controlled by the same driver. |
---|
64 | |
---|
65 | @subsection Device Names |
---|
66 | |
---|
67 | The I/O Manager provides facilities to associate a |
---|
68 | name with a particular device. Directives are provided to |
---|
69 | register the name of a device and to look up the major/minor |
---|
70 | number pair associated with a device name. |
---|
71 | |
---|
72 | @subsection Device Driver Environment |
---|
73 | |
---|
74 | Application developers, as well as device driver |
---|
75 | developers, must be aware of the following regarding the RTEMS |
---|
76 | I/O Manager: |
---|
77 | |
---|
78 | @itemize @bullet |
---|
79 | @item A device driver routine executes in the context of the |
---|
80 | invoking task. Thus if the driver blocks, the invoking task |
---|
81 | blocks. |
---|
82 | |
---|
83 | @item The device driver is free to change the modes of the |
---|
84 | invoking task, although the driver should restore them to their |
---|
85 | original values. |
---|
86 | |
---|
87 | @item Device drivers may be invoked from ISRs. |
---|
88 | |
---|
89 | @item Only local device drivers are accessible through the I/O |
---|
90 | manager. |
---|
91 | |
---|
92 | @item A device driver routine may invoke all other RTEMS |
---|
93 | directives, including I/O directives, on both local and global |
---|
94 | objects. |
---|
95 | |
---|
96 | @end itemize |
---|
97 | |
---|
98 | Although the RTEMS I/O manager provides a framework |
---|
99 | for device drivers, it makes no assumptions regarding the |
---|
100 | construction or operation of a device driver. |
---|
101 | |
---|
102 | @subsection Device Driver Interface |
---|
103 | |
---|
104 | When an application invokes an I/O manager directive, |
---|
105 | RTEMS determines which device driver entry point must be |
---|
106 | invoked. The information passed by the application to RTEMS is |
---|
107 | then passed to the correct device driver entry point. RTEMS |
---|
108 | will invoke each device driver entry point assuming it is |
---|
109 | compatible with the following prototype: |
---|
110 | |
---|
111 | @ifset is-C |
---|
112 | @example |
---|
113 | rtems_device_driver io_entry( |
---|
114 | rtems_device_major_number major, |
---|
115 | rtems_device_minor_number minor, |
---|
116 | void *argument_block |
---|
117 | ); |
---|
118 | @end example |
---|
119 | @end ifset |
---|
120 | |
---|
121 | @ifset is-Ada |
---|
122 | @example |
---|
123 | function IO_Entry ( |
---|
124 | Major : in RTEMS.Device_Major_Number; |
---|
125 | Minor : in RTEMS.Device_Major_Number; |
---|
126 | Argument_Block : in RTEMS.Address |
---|
127 | ) return RTEMS.Status_Code; |
---|
128 | @end example |
---|
129 | @end ifset |
---|
130 | |
---|
131 | The format and contents of the parameter block are |
---|
132 | device driver and entry point dependent. |
---|
133 | |
---|
134 | It is recommended that a device driver avoid |
---|
135 | generating error codes which conflict with those used by |
---|
136 | application components. A common technique used to generate |
---|
137 | driver specific error codes is to make the most significant part |
---|
138 | of the status indicate a driver specific code. |
---|
139 | |
---|
140 | @subsection Device Driver Initialization |
---|
141 | |
---|
142 | RTEMS automatically initializes all device drivers |
---|
143 | when multitasking is initiated via the |
---|
144 | @code{@value{DIRPREFIX}initialize_executive} |
---|
145 | directive. RTEMS initializes the device drivers by invoking |
---|
146 | each device driver initialization entry point with the following |
---|
147 | parameters: |
---|
148 | |
---|
149 | @table @asis |
---|
150 | @item major |
---|
151 | the major device number for this device driver. |
---|
152 | |
---|
153 | @item minor |
---|
154 | zero. |
---|
155 | |
---|
156 | @item argument_block |
---|
157 | will point to the Configuration Table. |
---|
158 | |
---|
159 | @end table |
---|
160 | |
---|
161 | The returned status will be ignored by RTEMS. If the driver |
---|
162 | cannot successfully initialize the device, then it should invoke |
---|
163 | the fatal_error_occurred directive. |
---|
164 | |
---|
165 | @section Operations |
---|
166 | |
---|
167 | @subsection Register and Lookup Name |
---|
168 | |
---|
169 | The @code{@value{DIRPREFIX}io_register} directive associates a name with the |
---|
170 | specified device (i.e. major/minor number pair). Device names |
---|
171 | are typically registered as part of the device driver |
---|
172 | initialization sequence. The @code{@value{DIRPREFIX}io_lookup} |
---|
173 | directive is used to |
---|
174 | determine the major/minor number pair associated with the |
---|
175 | specified device name. The use of these directives frees the |
---|
176 | application from being dependent on the arbitrary assignment of |
---|
177 | major numbers in a particular application. No device naming |
---|
178 | conventions are dictated by RTEMS. |
---|
179 | |
---|
180 | @subsection Accessing an Device Driver |
---|
181 | |
---|
182 | The I/O manager provides directives which enable the |
---|
183 | application program to utilize device drivers in a standard |
---|
184 | manner. There is a direct correlation between the RTEMS I/O |
---|
185 | manager directives |
---|
186 | @code{@value{DIRPREFIX}io_initialize}, |
---|
187 | @code{@value{DIRPREFIX}io_open}, |
---|
188 | @code{@value{DIRPREFIX}io_close}, |
---|
189 | @code{@value{DIRPREFIX}io_read}, |
---|
190 | @code{@value{DIRPREFIX}io_write}, and |
---|
191 | @code{@value{DIRPREFIX}io_control} |
---|
192 | and the underlying device driver entry points. |
---|
193 | |
---|
194 | @section Directives |
---|
195 | |
---|
196 | This section details the I/O manager's directives. A |
---|
197 | subsection is dedicated to each of this manager's directives and |
---|
198 | describes the calling sequence, related constants, usage, and |
---|
199 | status codes. |
---|
200 | |
---|
201 | @page |
---|
202 | @subsection IO_INITIALIZE - Initialize a device driver |
---|
203 | |
---|
204 | @subheading CALLING SEQUENCE: |
---|
205 | |
---|
206 | @ifset is-C |
---|
207 | @c @findex rtems_io_initialize |
---|
208 | @example |
---|
209 | rtems_status_code rtems_io_initialize( |
---|
210 | rtems_device_major_number major, |
---|
211 | rtems_device_minor_number minor, |
---|
212 | void *argument |
---|
213 | ); |
---|
214 | @end example |
---|
215 | @end ifset |
---|
216 | |
---|
217 | @ifset is-Ada |
---|
218 | @example |
---|
219 | procedure IO_Initialize ( |
---|
220 | Major : in RTEMS.Device_Major_Number; |
---|
221 | Minor : in RTEMS.Device_Minor_Number; |
---|
222 | Argument : in RTEMS.Address; |
---|
223 | Return_Value : out RTEMS.Unsigned32; |
---|
224 | Result : out RTEMS.Status_Codes |
---|
225 | ); |
---|
226 | @end example |
---|
227 | @end ifset |
---|
228 | |
---|
229 | @subheading DIRECTIVE STATUS CODES: |
---|
230 | @code{@value{RPREFIX}SUCCESSFUL} - successfully initialized@* |
---|
231 | @code{@value{RPREFIX}INVALID_NUMBER} - invalid major device number |
---|
232 | |
---|
233 | @subheading DESCRIPTION: |
---|
234 | |
---|
235 | This directive calls the device driver initialization |
---|
236 | routine specified in the Device Driver Table for this major |
---|
237 | number. This directive is automatically invoked for each device |
---|
238 | driver when multitasking is initiated via the |
---|
239 | initialize_executive directive. |
---|
240 | |
---|
241 | A device driver initialization module is responsible |
---|
242 | for initializing all hardware and data structures associated |
---|
243 | with a device. If necessary, it can allocate memory to be used |
---|
244 | during other operations. |
---|
245 | |
---|
246 | @subheading NOTES: |
---|
247 | |
---|
248 | This directive may or may not cause the calling task |
---|
249 | to be preempted. This is dependent on the device driver being |
---|
250 | initialized. |
---|
251 | |
---|
252 | @page |
---|
253 | @subsection IO_REGISTER_NAME - Register a device |
---|
254 | |
---|
255 | @subheading CALLING SEQUENCE: |
---|
256 | |
---|
257 | @ifset is-C |
---|
258 | @c @findex rtems_io_register_name |
---|
259 | @example |
---|
260 | rtems_status_code rtems_io_register_name( |
---|
261 | char *name, |
---|
262 | rtems_device_major_number major, |
---|
263 | rtems_device_minor_number minor |
---|
264 | ); |
---|
265 | @end example |
---|
266 | @end ifset |
---|
267 | |
---|
268 | @ifset is-Ada |
---|
269 | @example |
---|
270 | procedure IO_Register_Name ( |
---|
271 | Name : in String; |
---|
272 | Major : in RTEMS.Device_Major_Number; |
---|
273 | Minor : in RTEMS.Device_Minor_Number; |
---|
274 | Result : out RTEMS.Status_Codes |
---|
275 | ); |
---|
276 | @end example |
---|
277 | @end ifset |
---|
278 | |
---|
279 | @subheading DIRECTIVE STATUS CODES: |
---|
280 | @code{@value{RPREFIX}SUCCESSFUL} - successfully initialized@* |
---|
281 | @code{@value{RPREFIX}TOO_MANY} - too many devices registered |
---|
282 | |
---|
283 | @subheading DESCRIPTION: |
---|
284 | |
---|
285 | This directive associates name with the specified |
---|
286 | major/minor number pair. |
---|
287 | |
---|
288 | @subheading NOTES: |
---|
289 | |
---|
290 | This directive will not cause the calling task to be |
---|
291 | preempted. |
---|
292 | |
---|
293 | @page |
---|
294 | @subsection IO_LOOKUP_NAME - Lookup a device |
---|
295 | |
---|
296 | @subheading CALLING SEQUENCE: |
---|
297 | |
---|
298 | @ifset is-C |
---|
299 | @c @findex rtems_io_lookup_name |
---|
300 | @example |
---|
301 | rtems_status_code rtems_io_lookup_name( |
---|
302 | const char *name, |
---|
303 | rtems_driver_name_t **device_info |
---|
304 | ); |
---|
305 | @end example |
---|
306 | @end ifset |
---|
307 | |
---|
308 | @ifset is-Ada |
---|
309 | @example |
---|
310 | procedure IO_Lookup_Name ( |
---|
311 | Name : in String; |
---|
312 | Device_Info : out RTEMS.Driver_Name_t; |
---|
313 | Result : out RTEMS.Status_Codes |
---|
314 | ); |
---|
315 | @end example |
---|
316 | @end ifset |
---|
317 | |
---|
318 | @subheading DIRECTIVE STATUS CODES: |
---|
319 | @code{@value{RPREFIX}SUCCESSFUL} - successfully initialized@* |
---|
320 | @code{@value{RPREFIX}UNSATISFIED} - name not registered |
---|
321 | |
---|
322 | @subheading DESCRIPTION: |
---|
323 | |
---|
324 | This directive returns the major/minor number pair |
---|
325 | associated with the given device name in device_info. |
---|
326 | |
---|
327 | @subheading NOTES: |
---|
328 | |
---|
329 | This directive will not cause the calling task to be |
---|
330 | preempted. |
---|
331 | |
---|
332 | @page |
---|
333 | @subsection IO_OPEN - Open a device |
---|
334 | |
---|
335 | @subheading CALLING SEQUENCE: |
---|
336 | |
---|
337 | @ifset is-C |
---|
338 | @c @findex rtems_io_open |
---|
339 | @example |
---|
340 | rtems_status_code rtems_io_open( |
---|
341 | rtems_device_major_number major, |
---|
342 | rtems_device_minor_number minor, |
---|
343 | void *argument |
---|
344 | ); |
---|
345 | @end example |
---|
346 | @end ifset |
---|
347 | |
---|
348 | @ifset is-Ada |
---|
349 | @example |
---|
350 | procedure IO_Open ( |
---|
351 | Major : in RTEMS.Device_Major_Number; |
---|
352 | Minor : in RTEMS.Device_Minor_Number; |
---|
353 | Argument : in RTEMS.Address; |
---|
354 | Return_Value : out RTEMS.Unsigned32; |
---|
355 | Result : out RTEMS.Status_Codes |
---|
356 | ); |
---|
357 | @end example |
---|
358 | @end ifset |
---|
359 | |
---|
360 | @subheading DIRECTIVE STATUS CODES: |
---|
361 | @code{@value{RPREFIX}SUCCESSFUL} - successfully initialized@* |
---|
362 | @code{@value{RPREFIX}INVALID_NUMBER} - invalid major device number |
---|
363 | |
---|
364 | @subheading DESCRIPTION: |
---|
365 | |
---|
366 | This directive calls the device driver open routine |
---|
367 | specified in the Device Driver Table for this major number. The |
---|
368 | open entry point is commonly used by device drivers to provide |
---|
369 | exclusive access to a device. |
---|
370 | |
---|
371 | @subheading NOTES: |
---|
372 | |
---|
373 | This directive may or may not cause the calling task |
---|
374 | to be preempted. This is dependent on the device driver being |
---|
375 | invoked. |
---|
376 | |
---|
377 | @page |
---|
378 | @subsection IO_CLOSE - Close a device |
---|
379 | |
---|
380 | @subheading CALLING SEQUENCE: |
---|
381 | |
---|
382 | @ifset is-C |
---|
383 | @c @findex rtems_io_close |
---|
384 | @example |
---|
385 | rtems_status_code rtems_io_close( |
---|
386 | rtems_device_major_number major, |
---|
387 | rtems_device_minor_number minor, |
---|
388 | void *argument |
---|
389 | ); |
---|
390 | @end example |
---|
391 | @end ifset |
---|
392 | |
---|
393 | @ifset is-Ada |
---|
394 | @example |
---|
395 | procedure IO_Close ( |
---|
396 | Major : in RTEMS.Device_Major_Number; |
---|
397 | Minor : in RTEMS.Device_Minor_Number; |
---|
398 | Argument : in RTEMS.Address; |
---|
399 | Return_Value : out RTEMS.Unsigned32; |
---|
400 | Result : out RTEMS.Status_Codes |
---|
401 | ); |
---|
402 | @end example |
---|
403 | @end ifset |
---|
404 | |
---|
405 | @subheading DIRECTIVE STATUS CODES: |
---|
406 | @code{@value{RPREFIX}SUCCESSFUL} - successfully initialized@* |
---|
407 | @code{@value{RPREFIX}INVALID_NUMBER} - invalid major device number |
---|
408 | |
---|
409 | @subheading DESCRIPTION: |
---|
410 | |
---|
411 | This directive calls the device driver close routine |
---|
412 | specified in the Device Driver Table for this major number. The |
---|
413 | close entry point is commonly used by device drivers to |
---|
414 | relinquish exclusive access to a device. |
---|
415 | |
---|
416 | @subheading NOTES: |
---|
417 | |
---|
418 | This directive may or may not cause the calling task |
---|
419 | to be preempted. This is dependent on the device driver being |
---|
420 | invoked. |
---|
421 | |
---|
422 | @page |
---|
423 | @subsection IO_READ - Read from a device |
---|
424 | |
---|
425 | @subheading CALLING SEQUENCE: |
---|
426 | |
---|
427 | @ifset is-C |
---|
428 | @c @findex rtems_io_read |
---|
429 | @example |
---|
430 | rtems_status_code rtems_io_read( |
---|
431 | rtems_device_major_number major, |
---|
432 | rtems_device_minor_number minor, |
---|
433 | void *argument |
---|
434 | ); |
---|
435 | @end example |
---|
436 | @end ifset |
---|
437 | |
---|
438 | @ifset is-Ada |
---|
439 | @example |
---|
440 | procedure IO_Read ( |
---|
441 | Major : in RTEMS.Device_Major_Number; |
---|
442 | Minor : in RTEMS.Device_Minor_Number; |
---|
443 | Argument : in RTEMS.Address; |
---|
444 | Return_Value : out RTEMS.Unsigned32; |
---|
445 | Result : out RTEMS.Status_Codes |
---|
446 | ); |
---|
447 | @end example |
---|
448 | @end ifset |
---|
449 | |
---|
450 | @subheading DIRECTIVE STATUS CODES: |
---|
451 | @code{@value{RPREFIX}SUCCESSFUL} - successfully initialized@* |
---|
452 | @code{@value{RPREFIX}INVALID_NUMBER} - invalid major device number |
---|
453 | |
---|
454 | @subheading DESCRIPTION: |
---|
455 | |
---|
456 | This directive calls the device driver read routine |
---|
457 | specified in the Device Driver Table for this major number. |
---|
458 | Read operations typically require a buffer address as part of |
---|
459 | the argument parameter block. The contents of this buffer will |
---|
460 | be replaced with data from the device. |
---|
461 | |
---|
462 | @subheading NOTES: |
---|
463 | |
---|
464 | This directive may or may not cause the calling task |
---|
465 | to be preempted. This is dependent on the device driver being |
---|
466 | invoked. |
---|
467 | |
---|
468 | @page |
---|
469 | @subsection IO_WRITE - Write to a device |
---|
470 | |
---|
471 | @subheading CALLING SEQUENCE: |
---|
472 | |
---|
473 | @ifset is-C |
---|
474 | @c @findex rtems_io_write |
---|
475 | @example |
---|
476 | rtems_status_code rtems_io_write( |
---|
477 | rtems_device_major_number major, |
---|
478 | rtems_device_minor_number minor, |
---|
479 | void *argument |
---|
480 | ); |
---|
481 | @end example |
---|
482 | @end ifset |
---|
483 | |
---|
484 | @ifset is-Ada |
---|
485 | @example |
---|
486 | procedure IO_Write ( |
---|
487 | Major : in RTEMS.Device_Major_Number; |
---|
488 | Minor : in RTEMS.Device_Minor_Number; |
---|
489 | Argument : in RTEMS.Address; |
---|
490 | Return_Value : out RTEMS.Unsigned32; |
---|
491 | Result : out RTEMS.Status_Codes |
---|
492 | ); |
---|
493 | @end example |
---|
494 | @end ifset |
---|
495 | |
---|
496 | @subheading DIRECTIVE STATUS CODES: |
---|
497 | @code{@value{RPREFIX}SUCCESSFUL} - successfully initialized@* |
---|
498 | @code{@value{RPREFIX}INVALID_NUMBER} - invalid major device number |
---|
499 | |
---|
500 | @subheading DESCRIPTION: |
---|
501 | |
---|
502 | This directive calls the device driver write routine |
---|
503 | specified in the Device Driver Table for this major number. |
---|
504 | Write operations typically require a buffer address as part of |
---|
505 | the argument parameter block. The contents of this buffer will |
---|
506 | be sent to the device. |
---|
507 | |
---|
508 | @subheading NOTES: |
---|
509 | |
---|
510 | This directive may or may not cause the calling task |
---|
511 | to be preempted. This is dependent on the device driver being |
---|
512 | invoked. |
---|
513 | |
---|
514 | @page |
---|
515 | @subsection IO_CONTROL - Special device services |
---|
516 | |
---|
517 | @subheading CALLING SEQUENCE: |
---|
518 | |
---|
519 | @ifset is-C |
---|
520 | @c @findex rtems_io_control |
---|
521 | @example |
---|
522 | rtems_status_code rtems_io_control( |
---|
523 | rtems_device_major_number major, |
---|
524 | rtems_device_minor_number minor, |
---|
525 | void *argument |
---|
526 | ); |
---|
527 | @end example |
---|
528 | @end ifset |
---|
529 | |
---|
530 | @ifset is-Ada |
---|
531 | @example |
---|
532 | procedure IO_Control ( |
---|
533 | Major : in RTEMS.Device_Major_Number; |
---|
534 | Minor : in RTEMS.Device_Minor_Number; |
---|
535 | Argument : in RTEMS.Address; |
---|
536 | Return_Value : out RTEMS.Unsigned32; |
---|
537 | Result : out RTEMS.Status_Codes |
---|
538 | ); |
---|
539 | @end example |
---|
540 | @end ifset |
---|
541 | |
---|
542 | @subheading DIRECTIVE STATUS CODES: |
---|
543 | @code{@value{RPREFIX}SUCCESSFUL} - successfully initialized@* |
---|
544 | @code{@value{RPREFIX}INVALID_NUMBER} - invalid major device number |
---|
545 | |
---|
546 | @subheading DESCRIPTION: |
---|
547 | |
---|
548 | This directive calls the device driver I/O control |
---|
549 | routine specified in the Device Driver Table for this major |
---|
550 | number. The exact functionality of the driver entry called by |
---|
551 | this directive is driver dependent. It should not be assumed |
---|
552 | that the control entries of two device drivers are compatible. |
---|
553 | For example, an RS-232 driver I/O control operation may change |
---|
554 | the baud rate of a serial line, while an I/O control operation |
---|
555 | for a floppy disk driver may cause a seek operation. |
---|
556 | |
---|
557 | @subheading NOTES: |
---|
558 | |
---|
559 | This directive may or may not cause the calling task |
---|
560 | to be preempted. This is dependent on the device driver being |
---|
561 | invoked. |
---|
562 | |
---|
563 | |
---|
564 | |
---|