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

4.104.115
Last change on this file since 031b57c was 031b57c, checked in by Joel Sherrill <joel.sherrill@…>, on 10/09/09 at 13:46:39

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
RevLine 
[b96254f]1/**
[456a776]2 * @file
[ac7d5ef0]3 *
[456a776]4 * @ingroup ClassicIO
[ac7d5ef0]5 *
[456a776]6 * @brief Classic Input/Output Manager API.
[b96254f]7 */
8 
9/*
[790b50b]10 *  COPYRIGHT (c) 1989-2008.
[ac7d5ef0]11 *  On-Line Applications Research Corporation (OAR).
12 *
[98e4ebf5]13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
[2ba508b]15 *  http://www.rtems.com/license/LICENSE.
[ac7d5ef0]16 *
17 *  $Id$
18 */
19
[092f142a]20#ifndef _RTEMS_IO_H
21#define _RTEMS_IO_H
[ac7d5ef0]22
[9c556023]23#ifndef SAPI_IO_EXTERN
24#define SAPI_IO_EXTERN extern
25#endif
26
[cd8b8c3]27#include <rtems/rtems/status.h>
28
[ac7d5ef0]29#ifdef __cplusplus
30extern "C" {
31#endif
32
[456a776]33/**
34 * @defgroup ClassicIO Input/Output
[3a4ae6c]35 *
[456a776]36 * @ingroup ClassicRTEMS
[3a4ae6c]37 *
[456a776]38 * @{
[ac7d5ef0]39 */
[8486081]40
[456a776]41typedef uint32_t rtems_device_major_number;
42
43typedef uint32_t rtems_device_minor_number;
[8486081]44
[3a4ae6c]45typedef rtems_status_code rtems_device_driver;
[8486081]46
[456a776]47typedef rtems_device_driver (*rtems_device_driver_entry)(
48  rtems_device_major_number,
49  rtems_device_minor_number,
50  void *
51);
[ac7d5ef0]52
[3a4ae6c]53typedef struct {
[456a776]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;
[8486081]61
[456a776]62/**
63 * @name Device Driver Maintainance
64 *
65 * @{
[3a4ae6c]66 */
[b06e68ef]67
[456a776]68/**
69 * @brief Returns @c RTEMS_IO_ERROR.
[ac7d5ef0]70 *
[456a776]71 * @retval RTEMS_IO_ERROR Only this one.
[ac7d5ef0]72 */
[456a776]73rtems_status_code rtems_io_driver_io_error(
74  rtems_device_major_number major,
75  rtems_device_minor_number minor,
76  void *arg
77);
[ac7d5ef0]78
[456a776]79/**
80 * @brief Registers and initializes the device with the device driver table
81 * @a driver_table and major number @a major.
[059a3714]82 *
[456a776]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.
[059a3714]85 *
[456a776]86 * After a successful registration rtems_io_initialize() will be called to
87 * initialize the device.
[059a3714]88 *
[456a776]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.
[031b57c]95 * @retval RTEMS_CALLED_FROM_ISR Called from interrupt context.
[456a776]96 * @retval * Status code depends on rtems_io_initialize().
[059a3714]97 */
98rtems_status_code rtems_io_register_driver(
[456a776]99  rtems_device_major_number major,
100  const rtems_driver_address_table *driver_table,
101  rtems_device_major_number *registered_major
[059a3714]102);
103
[456a776]104/**
105 * @brief Unregisters the device driver with number @a major.
[059a3714]106 *
[456a776]107 * @retval RTEMS_SUCCESSFUL Device driver successfully unregistered.
108 * @retval RTEMS_UNSATISFIED Invalid major number.
[031b57c]109 * @retval RTEMS_CALLED_FROM_ISR Called from interrupt context.
[059a3714]110 */
111rtems_status_code rtems_io_unregister_driver(
[456a776]112  rtems_device_major_number major
[059a3714]113);
114
[456a776]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.
[b06e68ef]118 *
[456a776]119 * @retval RTEMS_SUCCESSFUL Name successfully registered.
120 * @retval RTEMS_TOO_MANY Name already in use or other errors.
[b06e68ef]121 */
122rtems_status_code rtems_io_register_name(
[456a776]123  const char *device_name,
124  rtems_device_major_number major,
125  rtems_device_minor_number minor
[b06e68ef]126);
127
[456a776]128/** @} */
[b06e68ef]129
[456a776]130/**
131 * @name Device Driver Invocation
[ac7d5ef0]132 *
[456a776]133 * @{
[ac7d5ef0]134 */
135
136rtems_status_code rtems_io_initialize(
137  rtems_device_major_number  major,
138  rtems_device_minor_number  minor,
[c4808ca]139  void                      *argument
[ac7d5ef0]140);
141
142rtems_status_code rtems_io_open(
143  rtems_device_major_number  major,
144  rtems_device_minor_number  minor,
[c4808ca]145  void                      *argument
[ac7d5ef0]146);
147
148rtems_status_code rtems_io_close(
149  rtems_device_major_number  major,
150  rtems_device_minor_number  minor,
[c4808ca]151  void                      *argument
[ac7d5ef0]152);
153
154rtems_status_code rtems_io_read(
155  rtems_device_major_number  major,
156  rtems_device_minor_number  minor,
[c4808ca]157  void                      *argument
[ac7d5ef0]158);
159
160rtems_status_code rtems_io_write(
161  rtems_device_major_number  major,
162  rtems_device_minor_number  minor,
[c4808ca]163  void                      *argument
[ac7d5ef0]164);
165
166rtems_status_code rtems_io_control(
167  rtems_device_major_number  major,
168  rtems_device_minor_number  minor,
[c4808ca]169  void                      *argument
[ac7d5ef0]170);
171
[456a776]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.
[ac7d5ef0]185 */
[456a776]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 );
[ac7d5ef0]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.