Changeset 059a3714 in rtems


Ignore:
Timestamp:
Oct 16, 2001, 7:05:29 PM (19 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
8670008c
Parents:
8917506d
Message:

2001-10-16 Chris Johns <ccj@…>

  • include/confdefs.h, include/rtems/config.h, include/rtems/io.h, optman/no-io.c, src/exinit.c, src/io.c: Added a device driver register/unregister interface to allow device drivers to be installed and removed at runtime. This means you do not need devices present in the device table when you build.
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/sapi/ChangeLog

    r8917506d r059a3714  
     12001-10-16      Chris Johns <ccj@acm.org>
     2
     3        * include/confdefs.h, include/rtems/config.h, include/rtems/io.h,
     4        optman/no-io.c, src/exinit.c, src/io.c: Added a device driver
     5        register/unregister interface to allow device drivers to be
     6        installed and removed at runtime. This means you do not need devices
     7        present in the device table when you build.
     8
    192001-10-16      Ralf Corsepius <corsepiu@faw.uni-ulm.de>
    210
  • c/src/exec/sapi/include/confdefs.h

    r8917506d r059a3714  
    301301
    302302/*
     303 *  Default the number of drivers per node.  This value may be
     304 *  overridden by the user.
     305 */
     306
     307#ifndef CONFIGURE_MAXIMUM_DRIVERS
     308#define CONFIGURE_MAXIMUM_DRIVERS   10
     309#endif
     310
     311/*
    303312 *  Default the number of devices per device driver.  This value may be
    304313 *  overridden by the user.
     
    9941003  CONFIGURE_TICKS_PER_TIMESLICE,
    9951004  CONFIGURE_MAXIMUM_DEVICES,
     1005  CONFIGURE_MAXIMUM_DRIVERS,
    9961006  sizeof (Device_drivers)/
    9971007    sizeof(rtems_driver_address_table),      /* number of device drivers */
  • c/src/exec/sapi/include/rtems/config.h

    r8917506d r059a3714  
    105105  unsigned32                        ticks_per_timeslice;
    106106  unsigned32                        maximum_devices;
     107  unsigned32                        maximum_drivers;
    107108  unsigned32                        number_of_device_drivers;
    108109  rtems_driver_address_table       *Device_driver_table;
  • c/src/exec/sapi/include/rtems/io.h

    r8917506d r059a3714  
    101101void _IO_Manager_initialization(
    102102  rtems_driver_address_table *driver_table,
     103  unsigned32                  drivers_in_table,
    103104  unsigned32                  number_of_drivers,
    104105  unsigned32                  number_of_devices
     106);
     107
     108/*
     109 *  rtems_io_register_driver
     110 *
     111 *  DESCRIPTION:
     112 *
     113 *  Register a driver into the device driver table.
     114 *
     115 */
     116
     117rtems_status_code rtems_io_register_driver(
     118    rtems_device_major_number   major,
     119    rtems_driver_address_table *driver_table,
     120    rtems_device_major_number  *registered_major
     121);
     122
     123/*
     124 *  rtems_io_unregister_driver
     125 *
     126 *  DESCRIPTION:
     127 *
     128 *  Unregister a driver from the device driver table.
     129 *
     130 */
     131
     132rtems_status_code rtems_io_unregister_driver(
     133    rtems_device_major_number major
    105134);
    106135
  • c/src/exec/sapi/optman/no-io.c

    r8917506d r059a3714  
    2222void _IO_Manager_initialization(
    2323  rtems_driver_address_table *driver_table,
     24  unsigned32                  drivers_in_table,
    2425  unsigned32                  number_of_drivers,
    2526  unsigned32                  number_of_devices
     
    3233}
    3334
     35rtems_status_code rtems_io_register_driver(
     36    rtems_device_major_number   major,
     37    rtems_driver_address_table *driver_table,
     38    rtems_device_major_number  *registered_major
     39)
     40{
     41  _Internal_error_Occurred(
     42    INTERNAL_ERROR_RTEMS_API,
     43    FALSE,
     44    RTEMS_NOT_CONFIGURED
     45  );
     46  return RTEMS_NOT_CONFIGURED;
     47}
     48 
     49rtems_status_code rtems_io_unregister_driver(
     50    rtems_device_major_number major
     51)
     52{
     53  _Internal_error_Occurred(
     54    INTERNAL_ERROR_RTEMS_API,
     55    FALSE,
     56    RTEMS_NOT_CONFIGURED
     57  );
     58  return RTEMS_NOT_CONFIGURED;
     59}
     60 
    3461rtems_status_code rtems_io_register_name(
    3562    char *device_name,
  • c/src/exec/sapi/src/exinit.c

    r8917506d r059a3714  
    206206    configuration_table->Device_driver_table,
    207207    configuration_table->number_of_device_drivers,
     208    configuration_table->maximum_drivers,
    208209    configuration_table->maximum_devices
    209210  );
  • c/src/exec/sapi/src/io.c

    r8917506d r059a3714  
    2525 *  _IO_Manager_initialization
    2626 *
    27  */
    28  
     27 *  The IO manager has been extended to support runtime driver
     28 *  registration. The driver table is now allocated in the
     29 *  workspace.
     30 *
     31 */
     32 
    2933void _IO_Manager_initialization(
    30   rtems_driver_address_table *driver_table,
    31   unsigned32                  number_of_drivers,
    32   unsigned32                  number_of_devices
     34    rtems_driver_address_table *driver_table,
     35    unsigned32                  drivers_in_table,
     36    unsigned32                  number_of_drivers,
     37    unsigned32                  number_of_devices
    3338)
    3439{
     
    3641  unsigned32           index;
    3742  rtems_driver_name_t *np;
     43
     44  if ( number_of_drivers < drivers_in_table )
     45      number_of_drivers = drivers_in_table;
     46 
     47  tmp = _Workspace_Allocate_or_fatal_error(
     48    sizeof( rtems_driver_address_table ) * ( number_of_drivers )
     49  );
    3850 
    39   _IO_Driver_address_table = driver_table;
    40   _IO_Number_of_drivers    = number_of_drivers;
    41   _IO_Number_of_devices    = number_of_devices;
    42  
     51  _IO_Driver_address_table = (rtems_driver_address_table *) tmp;
     52
     53  memset(
     54    _IO_Driver_address_table, 0,
     55    sizeof( rtems_driver_address_table ) * ( number_of_drivers )
     56  );
     57
     58  if ( drivers_in_table )
     59      for ( index = 0 ; index < drivers_in_table ; index++ )
     60        _IO_Driver_address_table[index] = driver_table[index];
     61 
     62  _IO_Number_of_drivers = number_of_drivers;
     63  _IO_Number_of_devices = number_of_devices;
     64 
    4365  tmp = _Workspace_Allocate_or_fatal_error(
    4466    sizeof( rtems_driver_name_t ) * ( number_of_devices + 1 )
     
    78100/*PAGE
    79101 *
     102 *  rtems_io_register_driver
     103 *
     104 *  Register a driver into the device driver table.
     105 *
     106 *  Input Paramters:
     107 *    major            - device major number (0 means allocate
     108 *                       a number)
     109 *    driver_table     - driver callout function table
     110 *    registered_major - the major number which is registered
     111 *
     112 *  Output Parameters:
     113 *    RTEMS_SUCCESSFUL - if successful
     114 *    error code       - if unsuccessful
     115 */
     116
     117rtems_status_code rtems_io_register_driver(
     118    rtems_device_major_number   major,
     119    rtems_driver_address_table *driver_table,
     120    rtems_device_major_number  *registered_major
     121)
     122{
     123    *registered_major = 0;
     124
     125    /*
     126     * Test for initialise/open being present to indicate the driver slot is
     127     * in use.
     128     */
     129
     130    if ( major >= _IO_Number_of_drivers )
     131      return RTEMS_INVALID_NUMBER;
     132
     133    if ( major == 0 )
     134    {
     135        for ( major = _IO_Number_of_drivers - 1 ; major ; major-- )
     136            if ( _IO_Driver_address_table[major].initialization_entry == 0 &&
     137                 _IO_Driver_address_table[major].open_entry == 0 )
     138                break;
     139
     140        if (( major == 0 ) &&
     141            ( _IO_Driver_address_table[major].initialization_entry == 0 &&
     142              _IO_Driver_address_table[major].open_entry == 0 ))
     143            return RTEMS_TOO_MANY;
     144    }
     145   
     146    if ( _IO_Driver_address_table[major].initialization_entry == 0 &&
     147         _IO_Driver_address_table[major].open_entry == 0 )
     148    {
     149        _IO_Driver_address_table[major] = *driver_table;
     150        *registered_major               = major;
     151
     152        rtems_io_initialize( major, 0, NULL);
     153
     154        return RTEMS_SUCCESSFUL;
     155    }
     156
     157    return RTEMS_RESOURCE_IN_USE;
     158}
     159
     160/*PAGE
     161 *
     162 *  rtems_io_unregister_driver
     163 *
     164 *  Unregister a driver from the device driver table.
     165 *
     166 *  Input Paramters:
     167 *    major            - device major number
     168 *
     169 *  Output Parameters:
     170 *    RTEMS_SUCCESSFUL - if successful
     171 *    error code       - if unsuccessful
     172 */
     173
     174rtems_status_code rtems_io_unregister_driver(
     175    rtems_device_major_number major
     176)
     177{
     178    if ( major < _IO_Number_of_drivers )
     179    {
     180        memset(
     181            &_IO_Driver_address_table[major],
     182            0,
     183            sizeof( rtems_driver_address_table )
     184        );
     185        return RTEMS_SUCCESSFUL;
     186    }
     187    return RTEMS_UNSATISFIED;
     188}
     189
     190/*PAGE
     191 *
    80192 *  rtems_io_register_name
    81193 *
     
    185297  rtems_device_major_number  major,
    186298  rtems_device_minor_number  minor,
    187   void             *argument
     299  void                      *argument
    188300)
    189301{
  • c/src/optman/sapi/no-io.c

    r8917506d r059a3714  
    2222void _IO_Manager_initialization(
    2323  rtems_driver_address_table *driver_table,
     24  unsigned32                  drivers_in_table,
    2425  unsigned32                  number_of_drivers,
    2526  unsigned32                  number_of_devices
     
    3233}
    3334
     35rtems_status_code rtems_io_register_driver(
     36    rtems_device_major_number   major,
     37    rtems_driver_address_table *driver_table,
     38    rtems_device_major_number  *registered_major
     39)
     40{
     41  _Internal_error_Occurred(
     42    INTERNAL_ERROR_RTEMS_API,
     43    FALSE,
     44    RTEMS_NOT_CONFIGURED
     45  );
     46  return RTEMS_NOT_CONFIGURED;
     47}
     48 
     49rtems_status_code rtems_io_unregister_driver(
     50    rtems_device_major_number major
     51)
     52{
     53  _Internal_error_Occurred(
     54    INTERNAL_ERROR_RTEMS_API,
     55    FALSE,
     56    RTEMS_NOT_CONFIGURED
     57  );
     58  return RTEMS_NOT_CONFIGURED;
     59}
     60 
    3461rtems_status_code rtems_io_register_name(
    3562    char *device_name,
  • cpukit/sapi/ChangeLog

    r8917506d r059a3714  
     12001-10-16      Chris Johns <ccj@acm.org>
     2
     3        * include/confdefs.h, include/rtems/config.h, include/rtems/io.h,
     4        optman/no-io.c, src/exinit.c, src/io.c: Added a device driver
     5        register/unregister interface to allow device drivers to be
     6        installed and removed at runtime. This means you do not need devices
     7        present in the device table when you build.
     8
    192001-10-16      Ralf Corsepius <corsepiu@faw.uni-ulm.de>
    210
  • cpukit/sapi/include/confdefs.h

    r8917506d r059a3714  
    301301
    302302/*
     303 *  Default the number of drivers per node.  This value may be
     304 *  overridden by the user.
     305 */
     306
     307#ifndef CONFIGURE_MAXIMUM_DRIVERS
     308#define CONFIGURE_MAXIMUM_DRIVERS   10
     309#endif
     310
     311/*
    303312 *  Default the number of devices per device driver.  This value may be
    304313 *  overridden by the user.
     
    9941003  CONFIGURE_TICKS_PER_TIMESLICE,
    9951004  CONFIGURE_MAXIMUM_DEVICES,
     1005  CONFIGURE_MAXIMUM_DRIVERS,
    9961006  sizeof (Device_drivers)/
    9971007    sizeof(rtems_driver_address_table),      /* number of device drivers */
  • cpukit/sapi/include/rtems/config.h

    r8917506d r059a3714  
    105105  unsigned32                        ticks_per_timeslice;
    106106  unsigned32                        maximum_devices;
     107  unsigned32                        maximum_drivers;
    107108  unsigned32                        number_of_device_drivers;
    108109  rtems_driver_address_table       *Device_driver_table;
  • cpukit/sapi/include/rtems/io.h

    r8917506d r059a3714  
    101101void _IO_Manager_initialization(
    102102  rtems_driver_address_table *driver_table,
     103  unsigned32                  drivers_in_table,
    103104  unsigned32                  number_of_drivers,
    104105  unsigned32                  number_of_devices
     106);
     107
     108/*
     109 *  rtems_io_register_driver
     110 *
     111 *  DESCRIPTION:
     112 *
     113 *  Register a driver into the device driver table.
     114 *
     115 */
     116
     117rtems_status_code rtems_io_register_driver(
     118    rtems_device_major_number   major,
     119    rtems_driver_address_table *driver_table,
     120    rtems_device_major_number  *registered_major
     121);
     122
     123/*
     124 *  rtems_io_unregister_driver
     125 *
     126 *  DESCRIPTION:
     127 *
     128 *  Unregister a driver from the device driver table.
     129 *
     130 */
     131
     132rtems_status_code rtems_io_unregister_driver(
     133    rtems_device_major_number major
    105134);
    106135
  • cpukit/sapi/src/exinit.c

    r8917506d r059a3714  
    206206    configuration_table->Device_driver_table,
    207207    configuration_table->number_of_device_drivers,
     208    configuration_table->maximum_drivers,
    208209    configuration_table->maximum_devices
    209210  );
  • cpukit/sapi/src/io.c

    r8917506d r059a3714  
    2525 *  _IO_Manager_initialization
    2626 *
    27  */
    28  
     27 *  The IO manager has been extended to support runtime driver
     28 *  registration. The driver table is now allocated in the
     29 *  workspace.
     30 *
     31 */
     32 
    2933void _IO_Manager_initialization(
    30   rtems_driver_address_table *driver_table,
    31   unsigned32                  number_of_drivers,
    32   unsigned32                  number_of_devices
     34    rtems_driver_address_table *driver_table,
     35    unsigned32                  drivers_in_table,
     36    unsigned32                  number_of_drivers,
     37    unsigned32                  number_of_devices
    3338)
    3439{
     
    3641  unsigned32           index;
    3742  rtems_driver_name_t *np;
     43
     44  if ( number_of_drivers < drivers_in_table )
     45      number_of_drivers = drivers_in_table;
     46 
     47  tmp = _Workspace_Allocate_or_fatal_error(
     48    sizeof( rtems_driver_address_table ) * ( number_of_drivers )
     49  );
    3850 
    39   _IO_Driver_address_table = driver_table;
    40   _IO_Number_of_drivers    = number_of_drivers;
    41   _IO_Number_of_devices    = number_of_devices;
    42  
     51  _IO_Driver_address_table = (rtems_driver_address_table *) tmp;
     52
     53  memset(
     54    _IO_Driver_address_table, 0,
     55    sizeof( rtems_driver_address_table ) * ( number_of_drivers )
     56  );
     57
     58  if ( drivers_in_table )
     59      for ( index = 0 ; index < drivers_in_table ; index++ )
     60        _IO_Driver_address_table[index] = driver_table[index];
     61 
     62  _IO_Number_of_drivers = number_of_drivers;
     63  _IO_Number_of_devices = number_of_devices;
     64 
    4365  tmp = _Workspace_Allocate_or_fatal_error(
    4466    sizeof( rtems_driver_name_t ) * ( number_of_devices + 1 )
     
    78100/*PAGE
    79101 *
     102 *  rtems_io_register_driver
     103 *
     104 *  Register a driver into the device driver table.
     105 *
     106 *  Input Paramters:
     107 *    major            - device major number (0 means allocate
     108 *                       a number)
     109 *    driver_table     - driver callout function table
     110 *    registered_major - the major number which is registered
     111 *
     112 *  Output Parameters:
     113 *    RTEMS_SUCCESSFUL - if successful
     114 *    error code       - if unsuccessful
     115 */
     116
     117rtems_status_code rtems_io_register_driver(
     118    rtems_device_major_number   major,
     119    rtems_driver_address_table *driver_table,
     120    rtems_device_major_number  *registered_major
     121)
     122{
     123    *registered_major = 0;
     124
     125    /*
     126     * Test for initialise/open being present to indicate the driver slot is
     127     * in use.
     128     */
     129
     130    if ( major >= _IO_Number_of_drivers )
     131      return RTEMS_INVALID_NUMBER;
     132
     133    if ( major == 0 )
     134    {
     135        for ( major = _IO_Number_of_drivers - 1 ; major ; major-- )
     136            if ( _IO_Driver_address_table[major].initialization_entry == 0 &&
     137                 _IO_Driver_address_table[major].open_entry == 0 )
     138                break;
     139
     140        if (( major == 0 ) &&
     141            ( _IO_Driver_address_table[major].initialization_entry == 0 &&
     142              _IO_Driver_address_table[major].open_entry == 0 ))
     143            return RTEMS_TOO_MANY;
     144    }
     145   
     146    if ( _IO_Driver_address_table[major].initialization_entry == 0 &&
     147         _IO_Driver_address_table[major].open_entry == 0 )
     148    {
     149        _IO_Driver_address_table[major] = *driver_table;
     150        *registered_major               = major;
     151
     152        rtems_io_initialize( major, 0, NULL);
     153
     154        return RTEMS_SUCCESSFUL;
     155    }
     156
     157    return RTEMS_RESOURCE_IN_USE;
     158}
     159
     160/*PAGE
     161 *
     162 *  rtems_io_unregister_driver
     163 *
     164 *  Unregister a driver from the device driver table.
     165 *
     166 *  Input Paramters:
     167 *    major            - device major number
     168 *
     169 *  Output Parameters:
     170 *    RTEMS_SUCCESSFUL - if successful
     171 *    error code       - if unsuccessful
     172 */
     173
     174rtems_status_code rtems_io_unregister_driver(
     175    rtems_device_major_number major
     176)
     177{
     178    if ( major < _IO_Number_of_drivers )
     179    {
     180        memset(
     181            &_IO_Driver_address_table[major],
     182            0,
     183            sizeof( rtems_driver_address_table )
     184        );
     185        return RTEMS_SUCCESSFUL;
     186    }
     187    return RTEMS_UNSATISFIED;
     188}
     189
     190/*PAGE
     191 *
    80192 *  rtems_io_register_name
    81193 *
     
    185297  rtems_device_major_number  major,
    186298  rtems_device_minor_number  minor,
    187   void             *argument
     299  void                      *argument
    188300)
    189301{
Note: See TracChangeset for help on using the changeset viewer.