source: rtems/cpukit/sapi/include/rtems/io.h @ 3cf4031

4.115
Last change on this file since 3cf4031 was 3cf4031, checked in by Alex Ivanov <alexivanov97@…>, on 12/28/12 at 23:48:12

Header File Doxygen Enhancement Task #1

  • Property mode set to 100644
File size: 7.0 KB
Line 
1/**
2 * @file
3 *
4 * @brief Classic Input/Output Manager API
5 *
6 * This file emulates the old Classic RTEMS IO manager directives
7 * which register and lookup names using the in-memory filesystem.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2008.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 */
18
19#ifndef _RTEMS_IO_H
20#define _RTEMS_IO_H
21
22#ifndef SAPI_IO_EXTERN
23#define SAPI_IO_EXTERN extern
24#endif
25
26#include <rtems/rtems/status.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/**
33 * @defgroup ClassicIO Input/Output
34 *
35 * @ingroup ClassicRTEMS
36 *
37 * @{
38 */
39
40typedef uint32_t rtems_device_major_number;
41
42typedef uint32_t rtems_device_minor_number;
43
44typedef rtems_status_code rtems_device_driver;
45
46typedef rtems_device_driver (*rtems_device_driver_entry)(
47  rtems_device_major_number,
48  rtems_device_minor_number,
49  void *
50);
51
52typedef struct {
53  rtems_device_driver_entry initialization_entry;
54  rtems_device_driver_entry open_entry;
55  rtems_device_driver_entry close_entry;
56  rtems_device_driver_entry read_entry;
57  rtems_device_driver_entry write_entry;
58  rtems_device_driver_entry control_entry;
59} rtems_driver_address_table;
60
61/**
62 * @name Device Driver Maintainance
63 *
64 * @{
65 */
66
67/**
68 * @brief Returns @c RTEMS_IO_ERROR.
69 *
70 * @retval RTEMS_IO_ERROR Only this one.
71 */
72rtems_status_code rtems_io_driver_io_error(
73  rtems_device_major_number major,
74  rtems_device_minor_number minor,
75  void *arg
76);
77
78/**
79 * @brief Registers and initializes the device with the device driver table
80 * @a driver_table and major number @a major.
81 *
82 * If the major number equals zero a major number will be obtained.  The major
83 * number of the registered driver will be returned in @a registered_major.
84 *
85 * After a successful registration rtems_io_initialize() will be called to
86 * initialize the device.
87 *
88 * @retval RTEMS_SUCCESSFUL Device successfully registered and initialized.
89 * @retval RTEMS_INVALID_ADDRESS Pointer to driver table or to registered
90 * major number are invalid.  Device driver table is empty.
91 * @retval RTEMS_INVALID_NUMBER Invalid major number.
92 * @retval RTEMS_TOO_MANY No major number available.
93 * @retval RTEMS_RESOURCE_IN_USE Major number in use.
94 * @retval RTEMS_CALLED_FROM_ISR Called from interrupt context.
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 Unregister a Driver from the Device Driver Table.
105 *
106 *  @param[in] major is the device major number.
107 *
108 *  @retval RTEMS_SUCCESSFUL Device driver successfully unregistered.
109 *  @retval RTEMS_UNSATISFIED Invalid major number.
110 *  @retval RTEMS_CALLED_FROM_ISR Called from interrupt context.
111 */
112rtems_status_code rtems_io_unregister_driver(
113  rtems_device_major_number major
114);
115
116/**
117 * @brief Registers the name @a device_name in the file system for the device
118 * with number tuple @a major and @a minor.
119 *
120 * This assumes that all registered devices are character devices.
121 *
122 * @retval RTEMS_SUCCESSFUL Name successfully registered.
123 * @retval RTEMS_TOO_MANY Name already in use or other errors.
124 */
125rtems_status_code rtems_io_register_name(
126  const char *device_name,
127  rtems_device_major_number major,
128  rtems_device_minor_number minor
129);
130
131/** @} */
132
133/**
134 *  @brief IO Driver Initialization
135 *
136 *  This routine is the initialization directive of the IO manager.
137 *
138 *  @param[in] major is the device drive number
139 *  @param[in] minor is the device number
140 *  @param[in] argument is the pointer to the argument(s)
141 *
142 *  @return status code
143 */
144rtems_status_code rtems_io_initialize(
145  rtems_device_major_number  major,
146  rtems_device_minor_number  minor,
147  void                      *argument
148);
149
150/**
151 *  @brief Opening for The IO Manager
152 * 
153 *  Opens a device driver with the number @a major.
154 *
155 *  @param[in] major is the device driver number.
156 *  @param[in] minor is the device number.
157 *  @param[in] argument is the pointer to the argument(s).
158 *
159 *  @return Status code.
160 */
161rtems_status_code rtems_io_open(
162  rtems_device_major_number  major,
163  rtems_device_minor_number  minor,
164  void                      *argument
165);
166
167/**
168 *  @brief Closing for The IO Manager
169 * 
170 *  This routine is the close directive of the IO manager.
171 *
172 *  @param[in] major is the device driver number.
173 *  @param[in] minor is the device number.
174 *  @param[in] argument is the pointer to the argument(s).
175 *
176 *  @return Status code.
177 */
178rtems_status_code rtems_io_close(
179  rtems_device_major_number  major,
180  rtems_device_minor_number  minor,
181  void                      *argument
182);
183
184/**
185 *  @brief Reading for The IO Manager
186 * 
187 *  This routine is the read directive of the IO manager.
188 *
189 *  @param[in] major is the device driver number.
190 *  @param[in] minor is the device number.
191 *  @param[in] argument is the pointer to the argument(s).
192 *
193 *  @return Status code.
194 */
195rtems_status_code rtems_io_read(
196  rtems_device_major_number  major,
197  rtems_device_minor_number  minor,
198  void                      *argument
199);
200
201/**
202 *  @brief Writing for The IO Manager
203 * 
204 *  This routine is the write directive of the IO manager.
205 *
206 *  @param[in] major is the device driver number.
207 *  @param[in] minor is the device number.
208 *  @param[in] argument is the pointer to the argument(s).
209 *
210 *  @return Status code.
211 */
212rtems_status_code rtems_io_write(
213  rtems_device_major_number  major,
214  rtems_device_minor_number  minor,
215  void                      *argument
216);
217
218/**
219 *  @brief Control for The IO Manager
220 * 
221 *  This routine is the control directive of the IO manager.
222 *
223 *  @param[in] major is the device driver number.
224 *  @param[in] minor is the device number.
225 *  @param[in] argument is the pointer to the argument(s).
226 *
227 *  @return Status code.
228 */
229rtems_status_code rtems_io_control(
230  rtems_device_major_number  major,
231  rtems_device_minor_number  minor,
232  void                      *argument
233);
234
235/** @} */
236
237/** @} */
238
239typedef struct {
240    const char               *device_name;
241    size_t                    device_name_length;
242    rtems_device_major_number major;
243    rtems_device_minor_number minor;
244} rtems_driver_name_t;
245
246/**
247 * @deprecated Use stat() instead.
248 */
249rtems_status_code rtems_io_lookup_name(
250    const char           *name,
251    rtems_driver_name_t  *device_info
252) RTEMS_COMPILER_DEPRECATED_ATTRIBUTE;
253
254SAPI_IO_EXTERN uint32_t _IO_Number_of_drivers;
255
256SAPI_IO_EXTERN rtems_driver_address_table *_IO_Driver_address_table;
257
258/**
259 *  @brief Initialization of Device Drivers
260 *
261 *  @note The IO manager has been extended to support runtime driver
262 *  registration. The driver table is now allocated in the
263 *  workspace.
264 */
265void _IO_Manager_initialization( void );
266
267/**
268 *  @brief Initialization of All Device Drivers
269 *
270 *  Initializes all device drivers.
271 */
272void _IO_Initialize_all_drivers( void );
273
274#ifdef __cplusplus
275}
276#endif
277
278#endif
279/* end of include file */
Note: See TracBrowser for help on using the repository browser.