source: rtems/doc/user/io.t @ 68f54e1

4.104.114.84.95
Last change on this file since 68f54e1 was 68f54e1, checked in by Joel Sherrill <joel.sherrill@…>, on 07/01/99 at 23:05:34

Fixed reference to initialize_executive to use the current name.

  • Property mode set to 100644
File size: 15.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@chapter I/O Manager
10
11@section Introduction
12
13The input/output interface manager provides a
14well-defined mechanism for accessing device drivers and a
15structured methodology for organizing device drivers.  The
16directives 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
33Each application utilizing the RTEMS I/O manager must
34specify the address of a Device Driver Table in its
35Configuration Table.  This table contains each device driver's
36entry points.  Each device driver may contain the following
37entry 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
48If the device driver does not support a particular
49entry point, then that entry in the Configuration Table should
50be NULL.  RTEMS will return
51@code{@value{RPREFIX}SUCCESSFUL} as the executive's and
52zero (0) as the device driver's return code for these device
53driver entry points.
54
55@subsection Major and Minor Device Numbers
56
57Each call to the I/O manager must provide a device's
58major and minor numbers as arguments.  The major number is the
59index of the requested driver's entry points in the Device
60Driver Table, and is used to select a specific device driver.
61The exact usage of the minor number is driver specific, but is
62commonly used to distinguish between a number of devices
63controlled by the same driver.
64
65@subsection Device Names
66
67The I/O Manager provides facilities to associate a
68name with a particular device.  Directives are provided to
69register the name of a device and to look up the major/minor
70number pair associated with a device name.
71
72@subsection Device Driver Environment
73
74Application developers, as well as device driver
75developers, must be aware of the following regarding the RTEMS
76I/O Manager:
77
78@itemize @bullet
79@item A device driver routine executes in the context of the
80invoking task.  Thus if the driver blocks, the invoking task
81blocks.
82
83@item The device driver is free to change the modes of the
84invoking task, although the driver should restore them to their
85original values.
86
87@item Device drivers may be invoked from ISRs.
88
89@item Only local device drivers are accessible through the I/O
90manager.
91
92@item A device driver routine may invoke all other RTEMS
93directives, including I/O directives, on both local and global
94objects.
95
96@end itemize
97
98Although the RTEMS I/O manager provides a framework
99for device drivers, it makes no assumptions regarding the
100construction or operation of a device driver.
101
102@subsection Device Driver Interface
103
104When an application invokes an I/O manager directive,
105RTEMS determines which device driver entry point must be
106invoked.  The information passed by the application to RTEMS is
107then passed to the correct device driver entry point.  RTEMS
108will invoke each device driver entry point assuming it is
109compatible with the following prototype:
110
111@ifset is-C
112@example
113rtems_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
123function 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
131The format and contents of the parameter block are
132device driver and entry point dependent.
133
134It is recommended that a device driver avoid
135generating error codes which conflict with those used by
136application components.  A common technique used to generate
137driver specific error codes is to make the most significant part
138of the status indicate a driver specific code.
139
140@subsection Device Driver Initialization
141
142RTEMS automatically initializes all device drivers
143when multitasking is initiated via the
144@code{@value{DIRPREFIX}initialize_executive}
145directive.  RTEMS initializes the device drivers by invoking
146each device driver initialization entry point with the following
147parameters:
148
149@table @asis
150@item major
151the major device number for this device driver.
152
153@item minor
154zero.
155
156@item argument_block
157will point to  the Configuration Table.
158
159@end table
160
161The returned status will be ignored by RTEMS.  If the driver
162cannot successfully initialize the device, then it should invoke
163the fatal_error_occurred directive.
164
165@section Operations
166
167@subsection Register and Lookup Name
168
169The @code{@value{DIRPREFIX}io_register} directive associates a name with the
170specified device (i.e. major/minor number pair).  Device names
171are typically registered as part of the device driver
172initialization sequence.  The @code{@value{DIRPREFIX}io_lookup}
173directive is used to
174determine the major/minor number pair associated with the
175specified device name.  The use of these directives frees the
176application from being dependent on the arbitrary assignment of
177major numbers in a particular application.  No device naming
178conventions are dictated by RTEMS.
179
180@subsection Accessing an Device Driver
181
182The I/O manager provides directives which enable the
183application program to utilize device drivers in a standard
184manner.  There is a direct correlation between the RTEMS I/O
185manager 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}
192and the underlying device driver entry points.
193
194@section Directives
195
196This section details the I/O manager's directives.  A
197subsection is dedicated to each of this manager's directives and
198describes the calling sequence, related constants, usage, and
199status 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
209rtems_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
219procedure 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
235This directive calls the device driver initialization
236routine specified in the Device Driver Table for this major
237number. This directive is automatically invoked for each device
238driver when multitasking is initiated via the
239initialize_executive directive.
240
241A device driver initialization module is responsible
242for initializing all hardware and data structures associated
243with a device. If necessary, it can allocate memory to be used
244during other operations.
245
246@subheading NOTES:
247
248This directive may or may not cause the calling task
249to be preempted.  This is dependent on the device driver being
250initialized.
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
260rtems_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
270procedure 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
285This directive associates name with the specified
286major/minor number pair.
287
288@subheading NOTES:
289
290This directive will not cause the calling task to be
291preempted.
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
301rtems_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
310procedure 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
324This directive returns the major/minor number pair
325associated with the given device name in device_info.
326
327@subheading NOTES:
328
329This directive will not cause the calling task to be
330preempted.
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
340rtems_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
350procedure 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
366This directive calls the device driver open routine
367specified in the Device Driver Table for this major number.  The
368open entry point is commonly used by device drivers to provide
369exclusive access to a device.
370
371@subheading NOTES:
372
373This directive may or may not cause the calling task
374to be preempted.  This is dependent on the device driver being
375invoked.
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
385rtems_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
395procedure 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
411This directive calls the device driver close routine
412specified in the Device Driver Table for this major number.  The
413close entry point is commonly used by device drivers to
414relinquish exclusive access to a device.
415
416@subheading NOTES:
417
418This directive may or may not cause the calling task
419to be preempted.  This is dependent on the device driver being
420invoked.
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
430rtems_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
440procedure 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
456This directive calls the device driver read routine
457specified in the Device Driver Table for this major number.
458Read operations typically require a buffer address as part of
459the argument parameter block.  The contents of this buffer will
460be replaced with data from the device.
461
462@subheading NOTES:
463
464This directive may or may not cause the calling task
465to be preempted.  This is dependent on the device driver being
466invoked.
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
476rtems_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
486procedure 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
502This directive calls the device driver write routine
503specified in the Device Driver Table for this major number.
504Write operations typically require a buffer address as part of
505the argument parameter block.  The contents of this buffer will
506be sent to the device.
507
508@subheading NOTES:
509
510This directive may or may not cause the calling task
511to be preempted.  This is dependent on the device driver being
512invoked.
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
522rtems_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
532procedure 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
548This directive calls the device driver I/O control
549routine specified in the Device Driver Table for this major
550number.  The exact functionality of the driver entry called by
551this directive is driver dependent.  It should not be assumed
552that the control entries of two device drivers are compatible.
553For example, an RS-232 driver I/O control operation may change
554the baud rate of a serial line, while an I/O control operation
555for a floppy disk driver may cause a seek operation.
556
557@subheading NOTES:
558
559This directive may or may not cause the calling task
560to be preempted.  This is dependent on the device driver being
561invoked.
562
563
564
Note: See TracBrowser for help on using the repository browser.