source: rtems/cpukit/sapi/include/rtems/io.h @ 031b57c

4.104.11
Last change on this file since 031b57c was 031b57c, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 9, 2009 at 1:46:39 PM

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

  • cpukit/sapi/include/rtems/io.h: Documentation.
  • cpukit/sapi/src/ioregisterdriver.c: Call from interrupt context is an error.
  • cpukit/sapi/src/iounregisterdriver.c: Disable preemption during critical section.
  • Property mode set to 100644
File size: 4.8 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 RTEMS_CALLED_FROM_ISR Called from interrupt context.
96 * @retval * Status code depends on rtems_io_initialize().
97 */
98rtems_status_code rtems_io_register_driver(
99  rtems_device_major_number major,
100  const rtems_driver_address_table *driver_table,
101  rtems_device_major_number *registered_major
102);
103
104/**
105 * @brief Unregisters the device driver with number @a major.
106 *
107 * @retval RTEMS_SUCCESSFUL Device driver successfully unregistered.
108 * @retval RTEMS_UNSATISFIED Invalid major number.
109 * @retval RTEMS_CALLED_FROM_ISR Called from interrupt context.
110 */
111rtems_status_code rtems_io_unregister_driver(
112  rtems_device_major_number major
113);
114
115/**
116 * @brief Registers the name @a device_name in the file system for the device
117 * with number tuple @a major and @a minor.
118 *
119 * @retval RTEMS_SUCCESSFUL Name successfully registered.
120 * @retval RTEMS_TOO_MANY Name already in use or other errors.
121 */
122rtems_status_code rtems_io_register_name(
123  const char *device_name,
124  rtems_device_major_number major,
125  rtems_device_minor_number minor
126);
127
128/** @} */
129
130/**
131 * @name Device Driver Invocation
132 *
133 * @{
134 */
135
136rtems_status_code rtems_io_initialize(
137  rtems_device_major_number  major,
138  rtems_device_minor_number  minor,
139  void                      *argument
140);
141
142rtems_status_code rtems_io_open(
143  rtems_device_major_number  major,
144  rtems_device_minor_number  minor,
145  void                      *argument
146);
147
148rtems_status_code rtems_io_close(
149  rtems_device_major_number  major,
150  rtems_device_minor_number  minor,
151  void                      *argument
152);
153
154rtems_status_code rtems_io_read(
155  rtems_device_major_number  major,
156  rtems_device_minor_number  minor,
157  void                      *argument
158);
159
160rtems_status_code rtems_io_write(
161  rtems_device_major_number  major,
162  rtems_device_minor_number  minor,
163  void                      *argument
164);
165
166rtems_status_code rtems_io_control(
167  rtems_device_major_number  major,
168  rtems_device_minor_number  minor,
169  void                      *argument
170);
171
172/** @} */
173
174/** @} */
175
176typedef struct {
177    char                     *device_name;
178    size_t                    device_name_length;
179    rtems_device_major_number major;
180    rtems_device_minor_number minor;
181} rtems_driver_name_t;
182
183/**
184 * @deprecated Use stat() instead.
185 */
186rtems_status_code rtems_io_lookup_name(
187    const char           *name,
188    rtems_driver_name_t  *device_info
189) RTEMS_COMPILER_DEPRECATED_ATTRIBUTE;
190
191SAPI_IO_EXTERN uint32_t _IO_Number_of_drivers;
192
193SAPI_IO_EXTERN rtems_driver_address_table *_IO_Driver_address_table;
194
195void _IO_Manager_initialization( void );
196
197void _IO_Initialize_all_drivers( void );
198
199#ifdef __cplusplus
200}
201#endif
202
203#endif
204/* end of include file */
Note: See TracBrowser for help on using the repository browser.