source: rtems/cpukit/include/rtems/devfs.h @ 2afb22b

Last change on this file since 2afb22b was 2afb22b, checked in by Chris Johns <chrisj@…>, on Dec 23, 2017 at 7:18:56 AM

Remove make preinstall

A speciality of the RTEMS build system was the make preinstall step. It
copied header files from arbitrary locations into the build tree. The
header files were included via the -Bsome/build/tree/path GCC command
line option.

This has at least seven problems:

  • The make preinstall step itself needs time and disk space.
  • Errors in header files show up in the build tree copy. This makes it hard for editors to open the right file to fix the error.
  • There is no clear relationship between source and build tree header files. This makes an audit of the build process difficult.
  • The visibility of all header files in the build tree makes it difficult to enforce API barriers. For example it is discouraged to use BSP-specifics in the cpukit.
  • An introduction of a new build system is difficult.
  • Include paths specified by the -B option are system headers. This may suppress warnings.
  • The parallel build had sporadic failures on some hosts.

This patch removes the make preinstall step. All installed header
files are moved to dedicated include directories in the source tree.
Let @RTEMS_CPU@ be the target architecture, e.g. arm, powerpc, sparc,
etc. Let @RTEMS_BSP_FAMILIY@ be a BSP family base directory, e.g.
erc32, imx, qoriq, etc.

The new cpukit include directories are:

  • cpukit/include
  • cpukit/score/cpu/@RTEMS_CPU@/include
  • cpukit/libnetworking

The new BSP include directories are:

  • bsps/include
  • bsps/@RTEMS_CPU@/include
  • bsps/@RTEMS_CPU@/@RTEMS_BSP_FAMILIY@/include

There are build tree include directories for generated files.

The include directory order favours the most general header file, e.g.
it is not possible to override general header files via the include path
order.

The "bootstrap -p" option was removed. The new "bootstrap -H" option
should be used to regenerate the "headers.am" files.

Update #3254.

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