source: rtems/cpukit/libfs/src/devfs/devfs.h @ fed66f99

4.11
Last change on this file since fed66f99 was fed66f99, checked in by Sebastian Huber <sebastian.huber@…>, on May 14, 2012 at 1:19:20 PM

Filesystem: Add shared device IO support

The device IO file system support in IMFS, devFS, and RFS uses now a
shared implementation.

  • Property mode set to 100644
File size: 5.9 KB
Line 
1/**
2*  @file  libfs/devfs/devfs.h
3*
4*  This include file contains all constants and structures associated
5*  with the 'device-only' filesystem.
6*/
7
8#ifndef _RTEMS_DEVFS_H
9#define _RTEMS_DEVFS_H
10
11#include <rtems/libio_.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17/**
18 *  This structure define the type of device table
19 */
20typedef struct {
21  /** This member points to device name which is not a null-terminated string */
22  const char               *name;
23  /** This member is the name length of a device */
24  size_t                    namelen;
25  /** major number of a device */
26  rtems_device_major_number major;
27  /** minor number of a device */
28  rtems_device_minor_number minor;
29  /** device creation mode, only device file can be created */
30  mode_t                    mode;
31} devFS_node;
32
33typedef struct {
34  devFS_node *nodes;
35  size_t count;
36} devFS_data;
37
38/**
39 *  The following defines the device-only filesystem operating
40 *  operations.
41 */
42
43extern const rtems_filesystem_operations_table devFS_ops;
44
45/**
46 *  The following defines the device-only filesystem operating
47 *  handlers.
48 */
49
50extern const rtems_filesystem_file_handlers_r  devFS_file_handlers;
51
52static inline const devFS_data *devFS_get_data(
53  const rtems_filesystem_location_info_t *loc
54)
55{
56  return (const devFS_data *) loc->mt_entry->immutable_fs_info;
57}
58
59extern void devFS_eval_path(
60  rtems_filesystem_eval_path_context_t *ctx
61);
62
63/**
64 *  This handler maps open operation to rtems_io_open.
65 *  @param iop This is the RTEMS's internal representation of file.
66 *  @param pathname a null-terminated string that starts with /dev.
67 *  @param flag access flags
68 *  @param mode access mode
69 *  @retval the same as open
70 */
71
72extern int devFS_open(
73  rtems_libio_t *iop,
74  const char    *pathname,
75  int            oflag,
76  mode_t         mode
77);
78
79
80/**
81 *  This handler maps close operation to rtems_io_close.
82 *  @param iop This is the RTEMS's internal representation of file
83 *  @retval the same as close
84 */
85
86
87extern int devFS_close(
88  rtems_libio_t *iop
89);
90
91
92/**
93 *  This handler maps read operation to rtems_io_read.
94 *  @param iop This is the RTEMS's internal representation of file
95 *  @param  buffer memory location to store read data
96 *  @param  count  how many bytes to read
97 *  @retval On successful, this routine returns total bytes read. On error
98 *  it returns -1 and errno is set to proper value.
99 */
100
101extern ssize_t devFS_read(
102  rtems_libio_t *iop,
103  void          *buffer,
104  size_t         count
105);
106
107
108/**
109 *  This handler maps write operation to rtems_io_write.
110 *  @param iop This is the RTEMS's internal representation of file
111 *  @param buffer data to be written
112 *  @param count  how many bytes to write
113 *  @retval On successful, this routine returns total bytes written. On error
114 *  it returns -1 and errno is set to proper value.
115 */
116
117extern ssize_t devFS_write(
118  rtems_libio_t *iop,
119  const void    *buffer,
120  size_t         count
121);
122
123
124/**
125 *  This handler maps ioctl operation to rtems_io_ioctl.
126 *  @param iop This is the RTEMS's internal representation of file
127 *  @param command io control command
128 *  @param buffer  io control parameters
129 *  @retval On successful, this routine returns total bytes written. On error
130 *  it returns -1 and errno is set to proper value.
131 */
132
133extern int devFS_ioctl(
134  rtems_libio_t   *iop,
135  ioctl_command_t  command,
136  void            *buffer
137);
138
139
140
141
142/**
143 *  This handler gets the device file information. This routine only set the following member of struct stat:
144 *  st_dev : device number
145 *  st_mode: device file creation mode, only two mode are accepted:
146 *           S_IFCHR: character device file
147 *           S_IFBLK: block device file
148 *  @param loc contains filesystem access information
149 *  @param buf buffer to hold the device file's information
150 *  @retval On successful, this routine returns 0. On error
151 *  it returns -1 and errno is set to proper value.
152 */
153
154extern int devFS_stat(
155  const rtems_filesystem_location_info_t *loc,
156  struct stat *buf
157);
158
159
160
161/**
162 *  This routine is invoked upon determination of a node type.
163 *  Since this is a device-only filesystem, so there is only
164 *  one node type in the system.
165 *
166 *  @param loc contains filesytem access information, this
167 *         parameter is ignored
168 *  @retval always returns RTEMS_FILESYSTEM_DEVICE
169 */
170
171extern rtems_filesystem_node_types_t devFS_node_type(
172  const rtems_filesystem_location_info_t*loc
173);
174
175/**
176 *  This routine is invoked upon registration of a new device
177 *  file. It is responsible for creating a item in the main
178 *  device table. This routine searches the device table in
179 *  sequential order, when found a empty slot, it fills the slot
180 *  with proper values.
181 *
182 *  @see rtems_filesystem_mknod_t.
183 */
184
185extern int devFS_mknod(
186  const rtems_filesystem_location_info_t *parentloc,
187  const char *name,
188  size_t namelen,
189  mode_t mode,
190  dev_t dev
191);
192
193
194/**
195 *  This routine is invoked upon rtems filesystem initialization.
196 *  It is responsible for creating the main device table,
197 *  initializing it to a known state, and set device file operation
198 *  handlers. After this, the device-only filesytem is ready for use
199 *
200 *  @param  mt_entry The filesystem mount table entry.
201 *  @param  data Filesystem specific data.
202 *  @retval upon success, this routine returns 0; otherwise it returns
203 *  -1 and errno is set to proper value. The only error is when malloc
204 *  failed, and errno is set to NOMEM.
205 */
206
207extern int devFS_initialize(
208  rtems_filesystem_mount_table_entry_t *mt_entry,
209  const void                           *data
210);
211
212
213/**
214 *  This routine retrieves all the device registered in system, and
215 *  prints out their detail information. For example, on one system,
216 *  devFS_show will print out following message:
217 *
218 *  /dev/console     0  0
219 *  /dev/clock       1  0
220 *  /dev/tty0        0  0
221 *  /flash           2  0
222 *
223 *  This routine is intended for debugging, and can be used by shell
224 *  program to provide user with the system information.
225 */
226
227extern void devFS_Show(void);
228
229#ifdef __cplusplus
230}
231#endif
232
233#endif
234
Note: See TracBrowser for help on using the repository browser.