OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libc/] [deviceio.c] - Blame information for rev 773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  IMFS Device Node Handlers
3
 *
4
 *  This file contains the set of handlers used to map operations on
5
 *  IMFS device nodes onto calls to the RTEMS Classic API IO Manager.
6
 *
7
 *  COPYRIGHT (c) 1989-1999.
8
 *  On-Line Applications Research Corporation (OAR).
9
 *
10
 *  The license and distribution terms for this file may be
11
 *  found in the file LICENSE in this distribution or at
12
 *  http://www.OARcorp.com/rtems/license.html.
13
 *
14
 *  $Id: deviceio.c,v 1.2 2001-09-27 12:01:15 chris Exp $
15
 */
16
 
17
#include <rtems.h>
18
#include <rtems/libio.h>
19
#include "libio_.h"
20
 
21
#include "imfs.h"
22
 
23
/*
24
 *  device_open
25
 *
26
 *  This handler maps an open() operation onto rtems_io_open().
27
 */
28
 
29
int device_open(
30
  rtems_libio_t *iop,
31
  const char    *pathname,
32
  unsigned32     flag,
33
  unsigned32     mode
34
)
35
{
36
  rtems_libio_open_close_args_t  args;
37
  rtems_status_code              status;
38
  IMFS_jnode_t                  *the_jnode;
39
 
40
  the_jnode  = iop->file_info;
41
 
42
  args.iop   = iop;
43
  args.flags = iop->flags;
44
  args.mode  = mode;
45
 
46
  status = rtems_io_open(
47
    the_jnode->info.device.major,
48
    the_jnode->info.device.minor,
49
    (void *) &args
50
  );
51
  if ( status )
52
    return RTEMS_UNSATISFIED;
53
 
54
  return 0;
55
}
56
 
57
/*
58
 *  device_close
59
 *
60
 *  This handler maps a close() operation onto rtems_io_close().
61
 */
62
 
63
int device_close(
64
  rtems_libio_t *iop
65
)
66
{
67
  rtems_libio_open_close_args_t  args;
68
  rtems_status_code              status;
69
  IMFS_jnode_t                  *the_jnode;
70
 
71
  the_jnode = iop->file_info;
72
 
73
  args.iop   = iop;
74
  args.flags = 0;
75
  args.mode  = 0;
76
 
77
  status = rtems_io_close(
78
    the_jnode->info.device.major,
79
    the_jnode->info.device.minor,
80
    (void *) &args
81
  );
82
  if ( status )
83
    return RTEMS_UNSATISFIED;
84
 
85
  return 0;
86
}
87
 
88
/*
89
 *  device_read
90
 *
91
 *  This handler maps a read() operation onto rtems_io_read().
92
 */
93
 
94
int device_read(
95
  rtems_libio_t *iop,
96
  void          *buffer,
97
  unsigned32     count
98
)
99
{
100
  rtems_libio_rw_args_t   args;
101
  rtems_status_code       status;
102
  IMFS_jnode_t           *the_jnode;
103
 
104
  the_jnode = iop->file_info;
105
 
106
  args.iop         = iop;
107
  args.offset      = iop->offset;
108
  args.buffer      = buffer;
109
  args.count       = count;
110
  args.flags       = iop->flags;
111
  args.bytes_moved = 0;
112
 
113
  status = rtems_io_read(
114
    the_jnode->info.device.major,
115
    the_jnode->info.device.minor,
116
    (void *) &args
117
  );
118
 
119
  if ( status )
120
    return -1;
121
 
122
  return args.bytes_moved;
123
}
124
 
125
/*
126
 *  device_write
127
 *
128
 *  This handler maps a write() operation onto rtems_io_write().
129
 */
130
 
131
int device_write(
132
  rtems_libio_t *iop,
133
  const void    *buffer,
134
  unsigned32     count
135
)
136
{
137
  rtems_libio_rw_args_t   args;
138
  rtems_status_code       status;
139
  IMFS_jnode_t           *the_jnode;
140
 
141
  the_jnode = iop->file_info;
142
 
143
  args.iop         = iop;
144
  args.offset      = iop->offset;
145
  args.buffer      = (void *) buffer;
146
  args.count       = count;
147
  args.flags       = iop->flags;
148
  args.bytes_moved = 0;
149
 
150
  status = rtems_io_write(
151
    the_jnode->info.device.major,
152
    the_jnode->info.device.minor,
153
    (void *) &args
154
  );
155
 
156
  if ( status )
157
    return -1;
158
 
159
  return args.bytes_moved;
160
}
161
 
162
/*
163
 *  device_ioctl
164
 *
165
 *  This handler maps an ioctl() operation onto rtems_io_ioctl().
166
 */
167
 
168
int device_ioctl(
169
  rtems_libio_t *iop,
170
  unsigned32     command,
171
  void          *buffer
172
)
173
{
174
  rtems_libio_ioctl_args_t  args;
175
  rtems_status_code         status;
176
  IMFS_jnode_t             *the_jnode;
177
 
178
  args.iop     = iop;
179
  args.command = command;
180
  args.buffer  = buffer;
181
 
182
  the_jnode = iop->file_info;
183
 
184
  status = rtems_io_control(
185
    the_jnode->info.device.major,
186
    the_jnode->info.device.minor,
187
    (void *) &args
188
  );
189
 
190
  if ( status )
191
    return -1;
192
 
193
  return args.ioctl_return;
194
}
195
 
196
/*
197
 *  device_lseek
198
 *
199
 *  This handler eats all lseek() operations.
200
 */
201
 
202
int device_lseek(
203
  rtems_libio_t *iop,
204
  off_t          offset,
205
  int            whence
206
)
207
{
208
  return 0;
209
}
210
 
211
/*
212
 *  device_stat
213
 *
214
 *  The IMFS_stat() is used.
215
 */
216
 
217
/*
218
 *  device_rmnod
219
 *
220
 *  The IMFS_rmnod() is used.
221
 */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.