Changeset fed66f99 in rtems


Ignore:
Timestamp:
May 14, 2012, 1:19:20 PM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
53da07e
Parents:
df01da67
git-author:
Sebastian Huber <sebastian.huber@…> (05/14/12 13:19:20)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/15/12 08:01:42)
Message:

Filesystem: Add shared device IO support

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

Location:
cpukit
Files:
2 added
11 edited
1 moved

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/Makefile.am

    rdf01da67 rfed66f99  
    2525## rtems
    2626include_rtems_HEADERS += include/rtems/assoc.h
     27include_rtems_HEADERS += include/rtems/deviceio.h
    2728include_rtems_HEADERS += include/rtems/error.h
    2829include_rtems_HEADERS += include/rtems/libcsupport.h
     
    128129    src/sup_fs_mount_iterate.c \
    129130    src/sup_fs_node_type.c \
     131    src/sup_fs_deviceio.c \
     132    src/sup_fs_deviceerrno.c \
    130133    src/clonenode.c \
    131134    src/freenode.c \
  • cpukit/libcsupport/preinstall.am

    rdf01da67 rfed66f99  
    7272PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/assoc.h
    7373
     74$(PROJECT_INCLUDE)/rtems/deviceio.h: include/rtems/deviceio.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
     75        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/deviceio.h
     76PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/deviceio.h
     77
    7478$(PROJECT_INCLUDE)/rtems/error.h: include/rtems/error.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
    7579        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/error.h
  • cpukit/libcsupport/src/sup_fs_deviceerrno.c

    rdf01da67 rfed66f99  
    1414
    1515#if HAVE_CONFIG_H
    16 #include "config.h"
     16  #include "config.h"
    1717#endif
    1818
     19#include <rtems/deviceio.h>
     20
    1921#include <errno.h>
    20 
    21 #include <rtems.h>
    22 #include <rtems/libio.h>
    23 #include <rtems/devfs.h>
    2422
    2523static const int status_code_to_errno [RTEMS_STATUS_CODES_LAST + 1] = {
  • cpukit/libfs/Makefile.am

    rdf01da67 rfed66f99  
    3838libimfs_a_SOURCES =
    3939
    40 libimfs_a_SOURCES += src/imfs/deviceerrno.c src/imfs/deviceio.c \
     40libimfs_a_SOURCES += src/imfs/deviceio.c \
    4141    src/imfs/fifoimfs_init.c src/imfs/imfs_chown.c src/imfs/imfs_config.c \
    4242    src/imfs/imfs_creat.c src/imfs/imfs_debug.c src/imfs/imfs_directory.c \
  • cpukit/libfs/src/devfs/devclose.c

    rdf01da67 rfed66f99  
    66
    77#if HAVE_CONFIG_H
    8 #include "config.h"
     8  #include "config.h"
    99#endif
    1010
    11 #include <rtems.h>
    12 #include <rtems/io.h>
     11#include "devfs.h"
    1312
    14 #include "devfs.h"
     13#include <rtems/deviceio.h>
    1514
    1615int devFS_close(
     
    1817)
    1918{
    20   rtems_libio_open_close_args_t  args;
    21   rtems_status_code              status;
    2219  const devFS_node *np = iop->pathinfo.node_access;
    2320
    24   args.iop   = iop;
    25   args.flags = 0;
    26   args.mode  = 0;
    27 
    28   status = rtems_io_close(
    29     np->major,
    30     np->minor,
    31     (void *) &args
    32   );
    33 
    34   return rtems_deviceio_errno(status);
     21  return rtems_deviceio_close( iop, np->major, np->minor );
    3522}
    36 
    37 
  • cpukit/libfs/src/devfs/devfs.h

    rdf01da67 rfed66f99  
    5050extern const rtems_filesystem_file_handlers_r  devFS_file_handlers;
    5151
    52 /**
    53  *  This routine associates RTEMS status code with errno
    54  */
    55 
    56 extern int rtems_deviceio_errno(rtems_status_code code);
    57 
    5852static inline const devFS_data *devFS_get_data(
    5953  const rtems_filesystem_location_info_t *loc
  • cpukit/libfs/src/devfs/devioctl.c

    rdf01da67 rfed66f99  
    1 #if HAVE_CONFIG_H
    21/*
    32 *  The license and distribution terms for this file may be
     
    65 */
    76
    8 #include "config.h"
     7#if HAVE_CONFIG_H
     8  #include "config.h"
    99#endif
    1010
    11 #include <rtems.h>
    12 #include <rtems/io.h>
     11#include "devfs.h"
    1312
    14 #include "devfs.h"
     13#include <rtems/deviceio.h>
    1514
    1615int devFS_ioctl(
     
    2019)
    2120{
    22   rtems_libio_ioctl_args_t  args;
    23   rtems_status_code         status;
    2421  const devFS_node *np = iop->pathinfo.node_access;
    2522
    26   args.iop     = iop;
    27   args.command = command;
    28   args.buffer  = buffer;
    29 
    30   status = rtems_io_control(
    31     np->major,
    32     np->minor,
    33     (void *) &args
    34   );
    35 
    36   if ( status )
    37     return rtems_deviceio_errno(status);
    38 
    39   return args.ioctl_return;
     23  return rtems_deviceio_control( iop, command, buffer, np->major, np->minor );
    4024}
    41 
  • cpukit/libfs/src/devfs/devopen.c

    rdf01da67 rfed66f99  
    66
    77#if HAVE_CONFIG_H
    8 #include "config.h"
     8  #include "config.h"
    99#endif
    1010
    11 #include <rtems.h>
    12 #include <rtems/io.h>
     11#include "devfs.h"
    1312
    14 #include "devfs.h"
     13#include <rtems/deviceio.h>
    1514
    1615int devFS_open(
     
    2120)
    2221{
    23   rtems_libio_open_close_args_t  args;
    24   rtems_status_code              status;
    2522  const devFS_node *np = iop->pathinfo.node_access;
    2623
    27   args.iop   = iop;
    28   args.flags = iop->flags;
    29   args.mode  = mode;
    30 
    31   status = rtems_io_open(
     24  return rtems_deviceio_open(
     25    iop,
     26    pathname,
     27    oflag,
     28    mode,
    3229    np->major,
    33     np->minor,
    34     (void *) &args
     30    np->minor
    3531  );
    36 
    37   return rtems_deviceio_errno(status);
    3832}
  • cpukit/libfs/src/devfs/devread.c

    rdf01da67 rfed66f99  
    66
    77#if HAVE_CONFIG_H
    8 #include "config.h"
     8  #include "config.h"
    99#endif
    1010
    11 #include <rtems.h>
    12 #include <rtems/io.h>
     11#include "devfs.h"
    1312
    14 #include "devfs.h"
     13#include <rtems/deviceio.h>
    1514
    1615ssize_t devFS_read(
     
    2019)
    2120{
    22   rtems_libio_rw_args_t   args;
    23   rtems_status_code       status;
    2421  const devFS_node *np = iop->pathinfo.node_access;
    2522
    26   args.iop         = iop;
    27   args.offset      = iop->offset;
    28   args.buffer      = buffer;
    29   args.count       = count;
    30   args.flags       = iop->flags;
    31   args.bytes_moved = 0;
    32 
    33   status = rtems_io_read(
    34     np->major,
    35     np->minor,
    36     (void *) &args
    37   );
    38 
    39   if ( status )
    40     return rtems_deviceio_errno(status);
    41 
    42   return (ssize_t) args.bytes_moved;
     23  return rtems_deviceio_read( iop, buffer, count, np->major, np->minor );
    4324}
    44 
  • cpukit/libfs/src/devfs/devwrite.c

    rdf01da67 rfed66f99  
    66
    77#if HAVE_CONFIG_H
    8 #include "config.h"
     8  #include "config.h"
    99#endif
    1010
    11 #include <rtems.h>
    12 #include <rtems/io.h>
     11#include "devfs.h"
    1312
    14 #include "devfs.h"
     13#include <rtems/deviceio.h>
    1514
    1615ssize_t devFS_write(
     
    2019)
    2120{
    22   rtems_libio_rw_args_t   args;
    23   rtems_status_code       status;
    2421  const devFS_node *np = iop->pathinfo.node_access;
    2522
    26   args.iop         = iop;
    27   args.offset      = iop->offset;
    28   args.buffer      = (void *) buffer;
    29   args.count       = count;
    30   args.flags       = iop->flags;
    31   args.bytes_moved = 0;
    32 
    33   status = rtems_io_write(
    34     np->major,
    35     np->minor,
    36     (void *) &args
    37   );
    38 
    39   if ( status )
    40     return rtems_deviceio_errno(status);
    41 
    42   return (ssize_t) args.bytes_moved;
     23  return rtems_deviceio_write( iop, buffer, count, np->major, np->minor );
    4324}
    44 
  • cpukit/libfs/src/imfs/deviceio.c

    rdf01da67 rfed66f99  
    55 *  IMFS device nodes onto calls to the RTEMS Classic API IO Manager.
    66 *
    7  *  COPYRIGHT (c) 1989-2008.
     7 *  COPYRIGHT (c) 1989-2012.
    88 *  On-Line Applications Research Corporation (OAR).
    99 *
     
    1919#include "imfs.h"
    2020
    21 #include <rtems/devfs.h>
    22 
    23 /*
    24  *  device_open
    25  *
    26  *  This handler maps an open() operation onto rtems_io_open().
    27  */
     21#include <rtems/deviceio.h>
    2822
    2923int device_open(
     
    3428)
    3529{
    36   rtems_libio_open_close_args_t  args;
    37   rtems_status_code              status;
    3830  IMFS_jnode_t                  *the_jnode;
    3931
    4032  the_jnode  = iop->pathinfo.node_access;
    4133
    42   args.iop   = iop;
    43   args.flags = iop->flags;
    44   args.mode  = mode;
    45 
    46   status = rtems_io_open(
     34  return rtems_deviceio_open(
     35    iop,
     36    pathname,
     37    oflag,
     38    mode,
    4739    the_jnode->info.device.major,
    48     the_jnode->info.device.minor,
    49     (void *) &args
     40    the_jnode->info.device.minor
    5041  );
    51 
    52   return rtems_deviceio_errno( status );
    5342}
    54 
    55 /*
    56  *  device_close
    57  *
    58  *  This handler maps a close() operation onto rtems_io_close().
    59  */
    6043
    6144int device_close(
     
    6346)
    6447{
    65   rtems_libio_open_close_args_t  args;
    66   rtems_status_code              status;
    6748  IMFS_jnode_t                  *the_jnode;
    6849
    6950  the_jnode = iop->pathinfo.node_access;
    7051
    71   args.iop   = iop;
    72   args.flags = 0;
    73   args.mode  = 0;
    74 
    75   status = rtems_io_close(
     52  return rtems_deviceio_close(
     53    iop,
    7654    the_jnode->info.device.major,
    77     the_jnode->info.device.minor,
    78     (void *) &args
     55    the_jnode->info.device.minor
    7956  );
    80 
    81   return rtems_deviceio_errno( status );
    8257}
    83 
    84 /*
    85  *  device_read
    86  *
    87  *  This handler maps a read() operation onto rtems_io_read().
    88  */
    8958
    9059ssize_t device_read(
     
    9463)
    9564{
    96   rtems_libio_rw_args_t   args;
    97   rtems_status_code       status;
    9865  IMFS_jnode_t           *the_jnode;
    9966
    10067  the_jnode = iop->pathinfo.node_access;
    10168
    102   args.iop         = iop;
    103   args.offset      = iop->offset;
    104   args.buffer      = buffer;
    105   args.count       = count;
    106   args.flags       = iop->flags;
    107   args.bytes_moved = 0;
    108 
    109   status = rtems_io_read(
     69  return rtems_deviceio_read(
     70    iop,
     71    buffer,
     72    count,
    11073    the_jnode->info.device.major,
    111     the_jnode->info.device.minor,
    112     (void *) &args
     74    the_jnode->info.device.minor
    11375  );
    114 
    115   if ( status )
    116     return rtems_deviceio_errno(status);
    117 
    118   return (ssize_t) args.bytes_moved;
    11976}
    120 
    121 /*
    122  *  device_write
    123  *
    124  *  This handler maps a write() operation onto rtems_io_write().
    125  */
    12677
    12778ssize_t device_write(
     
    13182)
    13283{
    133   rtems_libio_rw_args_t   args;
    134   rtems_status_code       status;
    13584  IMFS_jnode_t           *the_jnode;
    13685
    13786  the_jnode = iop->pathinfo.node_access;
    13887
    139   args.iop         = iop;
    140   args.offset      = iop->offset;
    141   args.buffer      = (void *) buffer;
    142   args.count       = count;
    143   args.flags       = iop->flags;
    144   args.bytes_moved = 0;
    145 
    146   status = rtems_io_write(
     88  return rtems_deviceio_write(
     89    iop,
     90    buffer,
     91    count,
    14792    the_jnode->info.device.major,
    148     the_jnode->info.device.minor,
    149     (void *) &args
     93    the_jnode->info.device.minor
    15094  );
    151 
    152   if ( status )
    153     return rtems_deviceio_errno(status);
    154 
    155   return (ssize_t) args.bytes_moved;
    15695}
    157 
    158 /*
    159  *  device_ioctl
    160  *
    161  *  This handler maps an ioctl() operation onto rtems_io_ioctl().
    162  */
    16396
    16497int device_ioctl(
     
    168101)
    169102{
    170   rtems_libio_ioctl_args_t  args;
    171   rtems_status_code         status;
    172103  IMFS_jnode_t             *the_jnode;
    173 
    174   args.iop     = iop;
    175   args.command = command;
    176   args.buffer  = buffer;
    177104
    178105  the_jnode = iop->pathinfo.node_access;
    179106
    180   status = rtems_io_control(
     107  return rtems_deviceio_control(
     108    iop,
     109    command,
     110    buffer,
    181111    the_jnode->info.device.major,
    182     the_jnode->info.device.minor,
    183     (void *) &args
     112    the_jnode->info.device.minor
    184113  );
    185 
    186   if ( status )
    187     return rtems_deviceio_errno(status);
    188 
    189   return args.ioctl_return;
    190114}
    191 
    192 /*
    193  *  device_stat
    194  *
    195  *  The IMFS_stat() is used.
    196  */
    197 
    198 /*
    199  *  device_rmnod
    200  *
    201  *  The IMFS_rmnod() is used.
    202  */
    203115
    204116int device_ftruncate(
  • cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c

    rdf01da67 rfed66f99  
    1919
    2020#if HAVE_CONFIG_H
    21 #include "config.h"
     21  #include "config.h"
    2222#endif
    2323
    24 #include <rtems/devfs.h>
    2524#include "rtems-rfs-rtems.h"
     25
     26#include <rtems/deviceio.h>
    2627
    2728static void
     
    4950                              mode_t         mode)
    5051{
    51   rtems_libio_open_close_args_t args;
    5252  rtems_rfs_file_system*        fs = rtems_rfs_rtems_pathloc_dev (&iop->pathinfo);
    5353  rtems_rfs_ino                 ino = rtems_rfs_rtems_get_iop_ino (iop);
     
    5555  rtems_device_major_number     major;
    5656  rtems_device_minor_number     minor;
    57   rtems_status_code             status;
    5857  int                           rc;
    5958
     
    8281  iop->data1 = (void *) minor;
    8382
    84   args.iop   = iop;
    85   args.flags = iop->flags;
    86   args.mode  = mode;
    87 
    88   status = rtems_io_open (major, minor, (void *) &args);
    89 
    90   return rtems_deviceio_errno (status);
     83  return rtems_deviceio_open (iop, pathname, oflag, mode, minor, major);
    9184}
    9285
     
    10194rtems_rfs_rtems_device_close (rtems_libio_t* iop)
    10295{
    103   rtems_libio_open_close_args_t args;
    104   rtems_status_code             status;
    10596  rtems_device_major_number     major;
    10697  rtems_device_minor_number     minor;
     
    10899  rtems_rfs_rtems_device_get_major_and_minor (iop, &major, &minor);
    109100
    110   args.iop   = iop;
    111   args.flags = 0;
    112   args.mode  = 0;
    113 
    114   status = rtems_io_close (major, minor, (void *) &args);
    115 
    116   return rtems_deviceio_errno (status);
     101  return rtems_deviceio_close (iop, major, minor);
    117102}
    118103
     
    129114rtems_rfs_rtems_device_read (rtems_libio_t* iop, void* buffer, size_t count)
    130115{
    131   rtems_libio_rw_args_t     args;
    132   rtems_status_code         status;
    133116  rtems_device_major_number major;
    134117  rtems_device_minor_number minor;
     
    136119  rtems_rfs_rtems_device_get_major_and_minor (iop, &major, &minor);
    137120
    138   args.iop         = iop;
    139   args.offset      = iop->offset;
    140   args.buffer      = buffer;
    141   args.count       = count;
    142   args.flags       = iop->flags;
    143   args.bytes_moved = 0;
    144 
    145   status = rtems_io_read (major, minor, (void *) &args);
    146   if (status)
    147     return rtems_deviceio_errno (status);
    148 
    149   return (ssize_t) args.bytes_moved;
     121  return rtems_deviceio_read (iop, buffer, count, major, minor);
    150122}
    151123
     
    164136                              size_t         count)
    165137{
    166   rtems_libio_rw_args_t     args;
    167   rtems_status_code         status;
    168138  rtems_device_major_number major;
    169139  rtems_device_minor_number minor;
     
    171141  rtems_rfs_rtems_device_get_major_and_minor (iop, &major, &minor);
    172142
    173   args.iop         = iop;
    174   args.offset      = iop->offset;
    175   args.buffer      = (void *) buffer;
    176   args.count       = count;
    177   args.flags       = iop->flags;
    178   args.bytes_moved = 0;
    179 
    180   status = rtems_io_write (major, minor, (void *) &args);
    181   if (status)
    182     return rtems_deviceio_errno (status);
    183 
    184   return (ssize_t) args.bytes_moved;
     143  return rtems_deviceio_write (iop, buffer, count, major, minor);
    185144}
    186145
     
    199158                              void*           buffer)
    200159{
    201   rtems_libio_ioctl_args_t  args;
    202   rtems_status_code         status;
    203160  rtems_device_major_number major;
    204161  rtems_device_minor_number minor;
     
    206163  rtems_rfs_rtems_device_get_major_and_minor (iop, &major, &minor);
    207164
    208   args.iop     = iop;
    209   args.command = command;
    210   args.buffer  = buffer;
    211 
    212   status = rtems_io_control (major, minor, (void *) &args);
    213   if (status)
    214     return rtems_deviceio_errno (status);
    215 
    216   return args.ioctl_return;
     165  return rtems_deviceio_control (iop, command, buffer, major, minor);
    217166}
    218167
Note: See TracChangeset for help on using the changeset viewer.