source: rtems/c/src/exec/sapi/src/io.c @ 3a4ae6c

4.104.114.84.95
Last change on this file since 3a4ae6c was 3a4ae6c, checked in by Joel Sherrill <joel.sherrill@…>, on 09/11/95 at 19:35:39

The word "RTEMS" almost completely removed from the core.

Configuration Table Template file added and all tests
modified to use this. All gvar.h and conftbl.h files
removed from test directories.

Configuration parameter maximum_devices added.

Core semaphore and mutex handlers added and RTEMS API Semaphore
Manager updated to reflect this.

Initialization sequence changed to invoke API specific initialization
routines. Initialization tasks table now owned by RTEMS Tasks Manager.

Added user extension for post-switch.

Utilized user extensions to implement API specific functionality
like signal dispatching.

Added extensions to the System Initialization Thread so that an
API can register a function to be invoked while the system
is being initialized. These are largely equivalent to the
pre-driver and post-driver hooks.

Added the Modules file oar-go32_p5, modified oar-go32, and modified
the file make/custom/go32.cfg to look at an environment varable which
determines what CPU model is being used.

All BSPs updated to reflect named devices and clock driver's IOCTL
used by the Shared Memory Driver. Also merged clock isr into
main file and removed ckisr.c where possible.

Updated spsize to reflect new and moved variables.

Makefiles for the executive source and include files updated to show
break down of files into Core, RTEMS API, and Neither.

Header and inline files installed into subdirectory based on whether
logically in the Core or a part of the RTEMS API.

  • Property mode set to 100644
File size: 6.5 KB
Line 
1/*
2 *  Input/Output Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
6 *  On-Line Applications Research Corporation (OAR).
7 *  All rights assigned to U.S. Government, 1994.
8 *
9 *  This material may be reproduced by or for the U.S. Government pursuant
10 *  to the copyright license under the clause at DFARS 252.227-7013.  This
11 *  notice must appear in all copies of this file and its derivatives.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/io.h>
18#include <rtems/core/isr.h>
19#include <rtems/core/thread.h>
20
21#include <string.h>
22
23/*PAGE
24 *
25 *  _IO_Initialize_all_drivers
26 *
27 *  This routine initializes all device drivers
28 *
29 *  Input Paramters:   NONE
30 *
31 *  Output Parameters: NONE
32 */
33
34void _IO_Initialize_all_drivers( void )
35{
36   rtems_device_major_number major;
37
38   for ( major=0 ; major < _IO_Number_of_drivers ; major ++ )
39     (void) rtems_io_initialize( major, 0, NULL);
40}
41
42/*PAGE
43 *
44 *  rtems_io_register_name
45 *
46 *  Associate a name with a driver
47 *
48 *  Input Paramters:
49 *
50 *  Output Parameters:
51 */
52
53rtems_status_code rtems_io_register_name(
54    char *device_name,
55    rtems_device_major_number major,
56    rtems_device_minor_number minor
57  )
58{
59    rtems_driver_name_t *np;
60    unsigned32 level;
61    unsigned32 index;
62
63    /* find an empty slot */
64    for( index=0, np = _IO_Driver_name_table ;
65         index < _IO_Number_of_devices ;
66         index++, np++ )
67    {
68
69        _ISR_Disable(level);
70        if (np->device_name == 0)
71        {
72            np->device_name = device_name;
73            np->device_name_length = strlen(device_name);
74            np->major = major;
75            np->minor = minor;
76            _ISR_Enable(level);
77
78            return RTEMS_SUCCESSFUL;
79        }
80        _ISR_Enable(level);
81    }
82
83    return RTEMS_TOO_MANY;
84}
85
86/*PAGE
87 *
88 *  rtems_io_lookup_name
89 *
90 *  Find what driver "owns" this name
91 *
92 *  Input Paramters:
93 *
94 *  Output Parameters:
95 */
96
97rtems_status_code rtems_io_lookup_name(
98    const char           *pathname,
99    rtems_driver_name_t **rnp
100)
101{
102    rtems_driver_name_t *np;
103    unsigned32 index;
104
105    for( index=0, np = _IO_Driver_name_table ;
106         index < _IO_Number_of_devices ;
107         index++, np++ )
108        if (np->device_name)
109            if (strncmp(np->device_name, pathname, np->device_name_length) == 0)
110            {               
111                *rnp = np;
112                return RTEMS_SUCCESSFUL;
113            }
114   
115    *rnp = 0;
116    return RTEMS_UNSATISFIED;
117}
118
119
120/*PAGE
121 *
122 *  rtems_io_initialize
123 *
124 *  This routine is the initialization directive of the IO manager.
125 *
126 *  Input Paramters:
127 *    major        - device driver number
128 *    minor        - device number
129 *    argument     - pointer to argument(s)
130 *
131 *  Output Parameters:
132 *    returns       - return code
133 */
134
135rtems_status_code rtems_io_initialize(
136  rtems_device_major_number  major,
137  rtems_device_minor_number  minor,
138  void             *argument
139)
140{
141    rtems_device_driver_entry callout;
142   
143    if ( major >= _IO_Number_of_drivers )
144        return RTEMS_INVALID_NUMBER;
145
146    callout = _IO_Driver_address_table[major].initialization;
147    return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
148}
149
150/*PAGE
151 *
152 *  rtems_io_open
153 *
154 *  This routine is the open directive of the IO manager.
155 *
156 *  Input Paramters:
157 *    major        - device driver number
158 *    minor        - device number
159 *    argument     - pointer to argument(s)
160 *
161 *  Output Parameters:
162 *    returns       - return code
163 */
164
165rtems_status_code rtems_io_open(
166  rtems_device_major_number  major,
167  rtems_device_minor_number  minor,
168  void             *argument
169)
170{
171    rtems_device_driver_entry callout;
172   
173    if ( major >= _IO_Number_of_drivers )
174        return RTEMS_INVALID_NUMBER;
175
176    callout = _IO_Driver_address_table[major].open;
177    return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
178}
179
180/*PAGE
181 *
182 *  rtems_io_close
183 *
184 *  This routine is the close directive of the IO manager.
185 *
186 *  Input Paramters:
187 *    major        - device driver number
188 *    minor        - device number
189 *    argument     - pointer to argument(s)
190 *
191 *  Output Parameters:
192 *    returns       - return code
193 */
194
195rtems_status_code rtems_io_close(
196  rtems_device_major_number  major,
197  rtems_device_minor_number  minor,
198  void             *argument
199)
200{
201    rtems_device_driver_entry callout;
202   
203    if ( major >= _IO_Number_of_drivers )
204        return RTEMS_INVALID_NUMBER;
205
206    callout = _IO_Driver_address_table[major].close;
207    return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
208}
209
210/*PAGE
211 *
212 *  rtems_io_read
213 *
214 *  This routine is the read directive of the IO manager.
215 *
216 *  Input Paramters:
217 *    major        - device driver number
218 *    minor        - device number
219 *    argument     - pointer to argument(s)
220 *
221 *  Output Parameters:
222 *    returns       - return code
223 */
224
225rtems_status_code rtems_io_read(
226  rtems_device_major_number  major,
227  rtems_device_minor_number  minor,
228  void             *argument
229)
230{
231    rtems_device_driver_entry callout;
232   
233    if ( major >= _IO_Number_of_drivers )
234        return RTEMS_INVALID_NUMBER;
235
236    callout = _IO_Driver_address_table[major].read;
237    return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
238}
239
240/*PAGE
241 *
242 *  rtems_io_write
243 *
244 *  This routine is the write directive of the IO manager.
245 *
246 *  Input Paramters:
247 *    major        - device driver number
248 *    minor        - device number
249 *    argument     - pointer to argument(s)
250 *
251 *  Output Parameters:
252 *    returns       - return code
253 */
254
255rtems_status_code rtems_io_write(
256  rtems_device_major_number  major,
257  rtems_device_minor_number  minor,
258  void             *argument
259)
260{
261    rtems_device_driver_entry callout;
262   
263    if ( major >= _IO_Number_of_drivers )
264        return RTEMS_INVALID_NUMBER;
265
266    callout = _IO_Driver_address_table[major].write;
267    return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
268}
269
270/*PAGE
271 *
272 *  rtems_io_control
273 *
274 *  This routine is the control directive of the IO manager.
275 *
276 *  Input Paramters:
277 *    major        - device driver number
278 *    minor        - device number
279 *    argument     - pointer to argument(s)
280 *
281 *  Output Parameters:
282 *    returns       - return code
283 */
284
285rtems_status_code rtems_io_control(
286  rtems_device_major_number  major,
287  rtems_device_minor_number  minor,
288  void             *argument
289)
290{
291    rtems_device_driver_entry callout;
292   
293    if ( major >= _IO_Number_of_drivers )
294        return RTEMS_INVALID_NUMBER;
295
296    callout = _IO_Driver_address_table[major].control;
297    return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
298}
299
Note: See TracBrowser for help on using the repository browser.