source: rtems/cpukit/sapi/include/rtems/io.h @ 456a776

4.104.11
Last change on this file since 456a776 was 456a776, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 5, 2009 at 3:00:53 PM

2009-10-04 Sebastian Huber <Sebastian.Huber@…>

  • sapi/include/rtems/io.h, sapi/src/ioregisterdriver.c: Documenation. rtems_io_lookup_name() is now deprecated. Added rtems_io_driver_io_error(). rtems_io_register_driver() is now thread-safe.
  • Property mode set to 100644
File size: 4.7 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ClassicIO
5 *
6 * @brief Classic Input/Output Manager API.
7 */
8 
9/*
10 *  COPYRIGHT (c) 1989-2008.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#ifndef _RTEMS_IO_H
21#define _RTEMS_IO_H
22
23#ifndef SAPI_IO_EXTERN
24#define SAPI_IO_EXTERN extern
25#endif
26
27#include <rtems/rtems/status.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/**
34 * @defgroup ClassicIO Input/Output
35 *
36 * @ingroup ClassicRTEMS
37 *
38 * @{
39 */
40
41typedef uint32_t rtems_device_major_number;
42
43typedef uint32_t rtems_device_minor_number;
44
45typedef rtems_status_code rtems_device_driver;
46
47typedef rtems_device_driver (*rtems_device_driver_entry)(
48  rtems_device_major_number,
49  rtems_device_minor_number,
50  void *
51);
52
53typedef struct {
54  rtems_device_driver_entry initialization_entry;
55  rtems_device_driver_entry open_entry;
56  rtems_device_driver_entry close_entry;
57  rtems_device_driver_entry read_entry;
58  rtems_device_driver_entry write_entry;
59  rtems_device_driver_entry control_entry;
60} rtems_driver_address_table;
61
62/**
63 * @name Device Driver Maintainance
64 *
65 * @{
66 */
67
68/**
69 * @brief Returns @c RTEMS_IO_ERROR.
70 *
71 * @retval RTEMS_IO_ERROR Only this one.
72 */
73rtems_status_code rtems_io_driver_io_error(
74  rtems_device_major_number major,
75  rtems_device_minor_number minor,
76  void *arg
77);
78
79/**
80 * @brief Registers and initializes the device with the device driver table
81 * @a driver_table and major number @a major.
82 *
83 * If the major number equals zero a major number will be obtained.  The major
84 * number of the registered driver will be returned in @a registered_major.
85 *
86 * After a successful registration rtems_io_initialize() will be called to
87 * initialize the device.
88 *
89 * @retval RTEMS_SUCCESSFUL Device successfully registered and initialized.
90 * @retval RTEMS_INVALID_ADDRESS Pointer to driver table or to registered
91 * major number are invalid.  Device driver table is empty.
92 * @retval RTEMS_INVALID_NUMBER Invalid major number.
93 * @retval RTEMS_TOO_MANY No major number available.
94 * @retval RTEMS_RESOURCE_IN_USE Major number in use.
95 * @retval * Status code depends on rtems_io_initialize().
96 */
97rtems_status_code rtems_io_register_driver(
98  rtems_device_major_number major,
99  const rtems_driver_address_table *driver_table,
100  rtems_device_major_number *registered_major
101);
102
103/**
104 * @brief Unregisters the device driver with number @a major.
105 *
106 * @retval RTEMS_SUCCESSFUL Device driver successfully unregistered.
107 * @retval RTEMS_UNSATISFIED Invalid major number.
108 */
109rtems_status_code rtems_io_unregister_driver(
110  rtems_device_major_number major
111);
112
113/**
114 * @brief Registers the name @a device_name in the file system for the device
115 * with number tuple @a major and @a minor.
116 *
117 * @retval RTEMS_SUCCESSFUL Name successfully registered.
118 * @retval RTEMS_TOO_MANY Name already in use or other errors.
119 */
120rtems_status_code rtems_io_register_name(
121  const char *device_name,
122  rtems_device_major_number major,
123  rtems_device_minor_number minor
124);
125
126/** @} */
127
128/**
129 * @name Device Driver Invocation
130 *
131 * @{
132 */
133
134rtems_status_code rtems_io_initialize(
135  rtems_device_major_number  major,
136  rtems_device_minor_number  minor,
137  void                      *argument
138);
139
140rtems_status_code rtems_io_open(
141  rtems_device_major_number  major,
142  rtems_device_minor_number  minor,
143  void                      *argument
144);
145
146rtems_status_code rtems_io_close(
147  rtems_device_major_number  major,
148  rtems_device_minor_number  minor,
149  void                      *argument
150);
151
152rtems_status_code rtems_io_read(
153  rtems_device_major_number  major,
154  rtems_device_minor_number  minor,
155  void                      *argument
156);
157
158rtems_status_code rtems_io_write(
159  rtems_device_major_number  major,
160  rtems_device_minor_number  minor,
161  void                      *argument
162);
163
164rtems_status_code rtems_io_control(
165  rtems_device_major_number  major,
166  rtems_device_minor_number  minor,
167  void                      *argument
168);
169
170/** @} */
171
172/** @} */
173
174typedef struct {
175    char                     *device_name;
176    size_t                    device_name_length;
177    rtems_device_major_number major;
178    rtems_device_minor_number minor;
179} rtems_driver_name_t;
180
181/**
182 * @deprecated Use stat() instead.
183 */
184rtems_status_code rtems_io_lookup_name(
185    const char           *name,
186    rtems_driver_name_t  *device_info
187) RTEMS_COMPILER_DEPRECATED_ATTRIBUTE;
188
189SAPI_IO_EXTERN uint32_t _IO_Number_of_drivers;
190
191SAPI_IO_EXTERN rtems_driver_address_table *_IO_Driver_address_table;
192
193void _IO_Manager_initialization( void );
194
195void _IO_Initialize_all_drivers( void );
196
197#ifdef __cplusplus
198}
199#endif
200
201#endif
202/* end of include file */
Note: See TracBrowser for help on using the repository browser.