[b96254f] | 1 | /** |
---|
| 2 | * @file rtems/io.h |
---|
[ac7d5ef0] | 3 | * |
---|
| 4 | * This include file contains all the constants and structures associated |
---|
| 5 | * with the Input/Output Manager. This manager provides a well defined |
---|
| 6 | * mechanism for accessing device drivers and a structured methodology for |
---|
| 7 | * organizing device drivers. |
---|
| 8 | * |
---|
| 9 | * Directives provided are: |
---|
| 10 | * |
---|
| 11 | * + initialize a device driver |
---|
| 12 | * + open a device driver |
---|
| 13 | * + close a device driver |
---|
| 14 | * + read from a device driver |
---|
| 15 | * + write to a device driver |
---|
| 16 | * + special device services |
---|
[b96254f] | 17 | */ |
---|
| 18 | |
---|
| 19 | /* |
---|
[08311cc3] | 20 | * COPYRIGHT (c) 1989-1999. |
---|
[ac7d5ef0] | 21 | * On-Line Applications Research Corporation (OAR). |
---|
| 22 | * |
---|
[98e4ebf5] | 23 | * The license and distribution terms for this file may be |
---|
| 24 | * found in the file LICENSE in this distribution or at |
---|
[2ba508b] | 25 | * http://www.rtems.com/license/LICENSE. |
---|
[ac7d5ef0] | 26 | * |
---|
| 27 | * $Id$ |
---|
| 28 | */ |
---|
| 29 | |
---|
| 30 | #ifndef __RTEMS_IO_h |
---|
| 31 | #define __RTEMS_IO_h |
---|
| 32 | |
---|
| 33 | #ifdef __cplusplus |
---|
| 34 | extern "C" { |
---|
| 35 | #endif |
---|
| 36 | |
---|
[3a4ae6c] | 37 | #include <rtems/rtems/status.h> |
---|
[ac7d5ef0] | 38 | |
---|
| 39 | /* |
---|
[3a4ae6c] | 40 | * |
---|
| 41 | * The following defines the types for: |
---|
| 42 | * |
---|
| 43 | * + major and minor numbers |
---|
| 44 | * + the return type of a device driver entry |
---|
| 45 | * + a pointer to a device driver entry |
---|
| 46 | * + an entry in the the Device Driver Address Table. Each entry in this |
---|
| 47 | * table corresponds to an application provided device driver and |
---|
| 48 | * defines the entry points for that device driver. |
---|
[ac7d5ef0] | 49 | */ |
---|
[8486081] | 50 | |
---|
[8bd41178] | 51 | typedef uint32_t rtems_device_major_number; |
---|
| 52 | typedef uint32_t rtems_device_minor_number; |
---|
[8486081] | 53 | |
---|
[3a4ae6c] | 54 | typedef rtems_status_code rtems_device_driver; |
---|
[8486081] | 55 | |
---|
[3a4ae6c] | 56 | typedef rtems_device_driver ( *rtems_device_driver_entry )( |
---|
| 57 | rtems_device_major_number, |
---|
| 58 | rtems_device_minor_number, |
---|
| 59 | void * |
---|
| 60 | ); |
---|
[ac7d5ef0] | 61 | |
---|
[3a4ae6c] | 62 | typedef struct { |
---|
[2e61938] | 63 | rtems_device_driver_entry initialization_entry; /* initialization procedure */ |
---|
| 64 | rtems_device_driver_entry open_entry; /* open request procedure */ |
---|
| 65 | rtems_device_driver_entry close_entry; /* close request procedure */ |
---|
| 66 | rtems_device_driver_entry read_entry; /* read request procedure */ |
---|
| 67 | rtems_device_driver_entry write_entry; /* write request procedure */ |
---|
| 68 | rtems_device_driver_entry control_entry; /* special functions procedure */ |
---|
[3a4ae6c] | 69 | } rtems_driver_address_table; |
---|
[8486081] | 70 | |
---|
[ac7d5ef0] | 71 | /* |
---|
[b06e68ef] | 72 | * Table for the io device names |
---|
[ac7d5ef0] | 73 | */ |
---|
| 74 | |
---|
[b06e68ef] | 75 | typedef struct { |
---|
| 76 | char *device_name; |
---|
[52399be] | 77 | size_t device_name_length; |
---|
[b06e68ef] | 78 | rtems_device_major_number major; |
---|
| 79 | rtems_device_minor_number minor; |
---|
| 80 | } rtems_driver_name_t; |
---|
| 81 | |
---|
[3a4ae6c] | 82 | /* |
---|
| 83 | * This is the table of device names. |
---|
| 84 | */ |
---|
| 85 | |
---|
| 86 | /* |
---|
| 87 | * The following declare the data required to manage the Driver |
---|
| 88 | * Address Table and Device Name Table. |
---|
| 89 | */ |
---|
[b06e68ef] | 90 | |
---|
[8bd41178] | 91 | SAPI_EXTERN uint32_t _IO_Number_of_drivers; |
---|
[c627b2a3] | 92 | SAPI_EXTERN rtems_driver_address_table *_IO_Driver_address_table; |
---|
[8bd41178] | 93 | SAPI_EXTERN uint32_t _IO_Number_of_devices; |
---|
[c627b2a3] | 94 | SAPI_EXTERN rtems_driver_name_t *_IO_Driver_name_table; |
---|
[ac7d5ef0] | 95 | |
---|
| 96 | /* |
---|
| 97 | * _IO_Manager_initialization |
---|
| 98 | * |
---|
| 99 | * DESCRIPTION: |
---|
| 100 | * |
---|
| 101 | * This routine performs the initialization necessary for this manager. |
---|
| 102 | */ |
---|
| 103 | |
---|
[4ff1920] | 104 | void _IO_Manager_initialization( |
---|
[ac7d5ef0] | 105 | rtems_driver_address_table *driver_table, |
---|
[8bd41178] | 106 | uint32_t drivers_in_table, |
---|
| 107 | uint32_t number_of_drivers, |
---|
| 108 | uint32_t number_of_devices |
---|
[ac7d5ef0] | 109 | ); |
---|
| 110 | |
---|
[059a3714] | 111 | /* |
---|
| 112 | * rtems_io_register_driver |
---|
| 113 | * |
---|
| 114 | * DESCRIPTION: |
---|
| 115 | * |
---|
| 116 | * Register a driver into the device driver table. |
---|
| 117 | * |
---|
| 118 | */ |
---|
| 119 | |
---|
| 120 | rtems_status_code rtems_io_register_driver( |
---|
| 121 | rtems_device_major_number major, |
---|
| 122 | rtems_driver_address_table *driver_table, |
---|
| 123 | rtems_device_major_number *registered_major |
---|
| 124 | ); |
---|
| 125 | |
---|
| 126 | /* |
---|
| 127 | * rtems_io_unregister_driver |
---|
| 128 | * |
---|
| 129 | * DESCRIPTION: |
---|
| 130 | * |
---|
| 131 | * Unregister a driver from the device driver table. |
---|
| 132 | * |
---|
| 133 | */ |
---|
| 134 | |
---|
| 135 | rtems_status_code rtems_io_unregister_driver( |
---|
| 136 | rtems_device_major_number major |
---|
| 137 | ); |
---|
| 138 | |
---|
[b06e68ef] | 139 | /* |
---|
| 140 | * rtems_io_register_name |
---|
| 141 | * |
---|
| 142 | * DESCRIPTION: |
---|
| 143 | * |
---|
| 144 | * Associate a name with a driver. |
---|
| 145 | * |
---|
| 146 | */ |
---|
| 147 | |
---|
| 148 | rtems_status_code rtems_io_register_name( |
---|
[c4808ca] | 149 | char *device_name, |
---|
| 150 | rtems_device_major_number major, |
---|
| 151 | rtems_device_minor_number minor |
---|
[b06e68ef] | 152 | ); |
---|
| 153 | |
---|
| 154 | |
---|
| 155 | /* |
---|
| 156 | * rtems_io_lookup_name |
---|
| 157 | * |
---|
| 158 | * DESCRIPTION: |
---|
| 159 | * |
---|
| 160 | * Find what driver "owns" this name |
---|
| 161 | */ |
---|
| 162 | |
---|
| 163 | rtems_status_code rtems_io_lookup_name( |
---|
[c4808ca] | 164 | const char *name, |
---|
[590cae7] | 165 | rtems_driver_name_t *device_info |
---|
[b06e68ef] | 166 | ); |
---|
| 167 | |
---|
| 168 | |
---|
[ac7d5ef0] | 169 | /* |
---|
| 170 | * rtems_io_initialize |
---|
| 171 | * |
---|
| 172 | * DESCRIPTION: |
---|
| 173 | * |
---|
| 174 | * This routine implements the rtems_io_initialize directive. It is invoked |
---|
| 175 | * to initialize a device driver or an individual device. |
---|
| 176 | */ |
---|
| 177 | |
---|
| 178 | rtems_status_code rtems_io_initialize( |
---|
| 179 | rtems_device_major_number major, |
---|
| 180 | rtems_device_minor_number minor, |
---|
[c4808ca] | 181 | void *argument |
---|
[ac7d5ef0] | 182 | ); |
---|
| 183 | |
---|
| 184 | /* |
---|
| 185 | * rtems_io_open |
---|
| 186 | * |
---|
| 187 | * DESCRIPTION: |
---|
| 188 | * |
---|
| 189 | * This routine implements the rtems_io_open directive. It is invoked |
---|
| 190 | * to open a device. |
---|
| 191 | */ |
---|
| 192 | |
---|
| 193 | rtems_status_code rtems_io_open( |
---|
| 194 | rtems_device_major_number major, |
---|
| 195 | rtems_device_minor_number minor, |
---|
[c4808ca] | 196 | void *argument |
---|
[ac7d5ef0] | 197 | ); |
---|
| 198 | |
---|
| 199 | /* |
---|
| 200 | * rtems_io_close |
---|
| 201 | * |
---|
| 202 | * DESCRIPTION: |
---|
| 203 | * |
---|
| 204 | * This routine implements the rtems_io_close directive. It is invoked |
---|
| 205 | * to close a device. |
---|
| 206 | */ |
---|
| 207 | |
---|
| 208 | rtems_status_code rtems_io_close( |
---|
| 209 | rtems_device_major_number major, |
---|
| 210 | rtems_device_minor_number minor, |
---|
[c4808ca] | 211 | void *argument |
---|
[ac7d5ef0] | 212 | ); |
---|
| 213 | |
---|
| 214 | /* |
---|
| 215 | * rtems_io_read |
---|
| 216 | * |
---|
| 217 | * DESCRIPTION: |
---|
| 218 | * |
---|
| 219 | * This routine implements the rtems_io_read directive. It is invoked |
---|
| 220 | * to read from a device. |
---|
| 221 | */ |
---|
| 222 | |
---|
| 223 | rtems_status_code rtems_io_read( |
---|
| 224 | rtems_device_major_number major, |
---|
| 225 | rtems_device_minor_number minor, |
---|
[c4808ca] | 226 | void *argument |
---|
[ac7d5ef0] | 227 | ); |
---|
| 228 | |
---|
| 229 | /* |
---|
| 230 | * rtems_io_write |
---|
| 231 | * |
---|
| 232 | * DESCRIPTION: |
---|
| 233 | * |
---|
| 234 | * This routine implements the rtems_io_write directive. It is invoked |
---|
| 235 | * to write to a device. |
---|
| 236 | */ |
---|
| 237 | |
---|
| 238 | rtems_status_code rtems_io_write( |
---|
| 239 | rtems_device_major_number major, |
---|
| 240 | rtems_device_minor_number minor, |
---|
[c4808ca] | 241 | void *argument |
---|
[ac7d5ef0] | 242 | ); |
---|
| 243 | |
---|
| 244 | /* |
---|
| 245 | * rtems_io_control |
---|
| 246 | * |
---|
| 247 | * DESCRIPTION: |
---|
| 248 | * |
---|
| 249 | * This routine implements the rtems_io_control directive. It is invoked |
---|
| 250 | * to perform a device specific operation on a device. |
---|
| 251 | */ |
---|
| 252 | |
---|
| 253 | rtems_status_code rtems_io_control( |
---|
| 254 | rtems_device_major_number major, |
---|
| 255 | rtems_device_minor_number minor, |
---|
[c4808ca] | 256 | void *argument |
---|
[ac7d5ef0] | 257 | ); |
---|
| 258 | |
---|
| 259 | /* |
---|
| 260 | * _IO_Initialize_all_drivers |
---|
| 261 | * |
---|
| 262 | * DESCRIPTION: |
---|
| 263 | * |
---|
| 264 | * This routine initializes all of the device drivers configured |
---|
| 265 | * in the Device Driver Address Table. |
---|
| 266 | */ |
---|
| 267 | |
---|
| 268 | void _IO_Initialize_all_drivers( void ); |
---|
| 269 | |
---|
| 270 | #ifdef __cplusplus |
---|
| 271 | } |
---|
| 272 | #endif |
---|
| 273 | |
---|
| 274 | #endif |
---|
| 275 | /* end of include file */ |
---|