source: rtems/doc/user/io.t @ 6d00095

4.104.114.84.95
Last change on this file since 6d00095 was 6d00095, checked in by Joel Sherrill <joel.sherrill@…>, on 03/27/02 at 14:39:06

2002-03-22 Chris Johns <ccj@…>

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