Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:18

0001 /**
0002  * @file
0003  *
0004  * @ingroup libmisc_devnull Device Driver
0005  *
0006  * @brief Null Device Driver Init Routine
0007  *
0008  * Derived from rtems' stub driver.
0009  */
0010 
0011 /*
0012  *  Author: Ralf Corsepius (corsepiu@faw.uni-ulm.de)
0013  *
0014  *  COPYRIGHT (c) 1989-2000.
0015  *  On-Line Applications Research Corporation (OAR).
0016  *
0017  *  The license and distribution terms for this file may be
0018  *  found in the file LICENSE in this distribution or at
0019  *  http://www.rtems.org/license/LICENSE.
0020  */
0021 
0022 #ifdef HAVE_CONFIG_H
0023 #include "config.h"
0024 #endif
0025 
0026 #include <rtems.h>
0027 #include <rtems/devnull.h>
0028 #include <rtems/libio.h>
0029 
0030 /*  null_initialize
0031  *
0032  *  This routine is the null device driver init routine.
0033  *
0034  *  Input parameters:
0035  *    major - device major number
0036  *    minor - device minor number
0037  *    pargp - pointer to parameter block
0038  *
0039  *  Output parameters:
0040  *    rval       - NULL_SUCCESSFUL
0041  */
0042 
0043 uint32_t   NULL_major;
0044 static char initialized;
0045 
0046 rtems_device_driver null_initialize(
0047   rtems_device_major_number major,
0048   rtems_device_minor_number minor RTEMS_UNUSED,
0049   void *pargp RTEMS_UNUSED
0050 )
0051 {
0052   rtems_device_driver status;
0053 
0054   if ( !initialized ) {
0055     initialized = 1;
0056 
0057     status = rtems_io_register_name(
0058       "/dev/null",
0059       major,
0060       (rtems_device_minor_number) 0
0061     );
0062 
0063     if (status != RTEMS_SUCCESSFUL)
0064       rtems_fatal_error_occurred(status);
0065 
0066     NULL_major = major;
0067   }
0068 
0069   return RTEMS_SUCCESSFUL;
0070 }
0071 
0072 /*  null_open
0073  *
0074  *  This routine is the null device driver open routine.
0075  *
0076  *  Input parameters:
0077  *    major - device major number
0078  *    minor - device minor number
0079  *    pargb - pointer to open parameter block
0080  *
0081  *  Output parameters:
0082  *    rval       - NULL_SUCCESSFUL
0083  */
0084 
0085 rtems_device_driver null_open(
0086   rtems_device_major_number major RTEMS_UNUSED,
0087   rtems_device_minor_number minor RTEMS_UNUSED,
0088   void *pargp RTEMS_UNUSED
0089 )
0090 {
0091   return NULL_SUCCESSFUL;
0092 }
0093 
0094 
0095 /*  null_close
0096  *
0097  *  This routine is the null device driver close routine.
0098  *
0099  *  Input parameters:
0100  *    major - device major number
0101  *    minor - device minor number
0102  *    pargb - pointer to close parameter block
0103  *
0104  *  Output parameters:
0105  *    rval       - NULL_SUCCESSFUL
0106  */
0107 
0108 rtems_device_driver null_close(
0109   rtems_device_major_number major RTEMS_UNUSED,
0110   rtems_device_minor_number minor RTEMS_UNUSED,
0111   void *pargp RTEMS_UNUSED
0112 )
0113 {
0114   return NULL_SUCCESSFUL;
0115 }
0116 
0117 
0118 /*  null_read
0119  *
0120  *  This routine is the null device driver read routine.
0121  *
0122  *  Input parameters:
0123  *    major - device major number
0124  *    minor - device minor number
0125  *    pargp - pointer to read parameter block
0126  *
0127  *  Output parameters:
0128  *    rval       - NULL_SUCCESSFUL
0129  */
0130 
0131 rtems_device_driver null_read(
0132   rtems_device_major_number major RTEMS_UNUSED,
0133   rtems_device_minor_number minor RTEMS_UNUSED,
0134   void *pargp RTEMS_UNUSED
0135 )
0136 {
0137   return NULL_SUCCESSFUL;
0138 }
0139 
0140 
0141 /*  null_write
0142  *
0143  *  This routine is the null device driver write routine.
0144  *
0145  *  Input parameters:
0146  *    major - device major number
0147  *    minor - device minor number
0148  *    pargp - pointer to write parameter block
0149  *
0150  *  Output parameters:
0151  *    rval       - NULL_SUCCESSFUL
0152  */
0153 
0154 rtems_device_driver null_write(
0155   rtems_device_major_number major RTEMS_UNUSED,
0156   rtems_device_minor_number minor RTEMS_UNUSED,
0157   void *pargp
0158 )
0159 {
0160   rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *) pargp;
0161 
0162   if ( rw_args )
0163     rw_args->bytes_moved = rw_args->count;
0164 
0165   return NULL_SUCCESSFUL;
0166 }
0167 
0168 
0169 /*  null_control
0170  *
0171  *  This routine is the null device driver control routine.
0172  *
0173  *  Input parameters:
0174  *    major - device major number
0175  *    minor - device minor number
0176  *    pargp - pointer to cntrl parameter block
0177  *
0178  *  Output parameters:
0179  *    rval       - NULL_SUCCESSFUL
0180  */
0181 
0182 rtems_device_driver null_control(
0183   rtems_device_major_number major RTEMS_UNUSED,
0184   rtems_device_minor_number minor RTEMS_UNUSED,
0185   void *pargp RTEMS_UNUSED
0186 )
0187 {
0188   return NULL_SUCCESSFUL;
0189 }