source: rtems/doc/user/io.t @ f331481c

4.104.114.84.95
Last change on this file since f331481c was f331481c, checked in by Joel Sherrill <joel.sherrill@…>, on 03/27/98 at 13:24:52

Conditionally adding RTEMS_ and rtems_ prefixes.

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