Changeset 263f4bec in rtems for cpukit/sapi


Ignore:
Timestamp:
Apr 7, 2014, 12:50:37 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
4bc8d2e
Parents:
3a4d28a
git-author:
Sebastian Huber <sebastian.huber@…> (04/07/14 12:50:37)
git-committer:
Sebastian Huber <sebastian.huber@…> (04/10/14 10:37:40)
Message:

score: Statically initialize IO manager

This simplifies the RTEMS initialization and helps to avoid a memory
overhead. The workspace demands of the IO manager were not included in
the <rtems/confdefs.h> workspace size estimate. This is also fixed as a
side-effect.

Update documentation and move "Specifying Application Defined Device
Driver Table" to the section end. This sub-section is not that
important for the user. Mentioning this at the beginning may lead to
confusion.

Location:
cpukit/sapi
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/sapi/include/confdefs.h

    r3a4d28a r263f4bec  
    7171
    7272extern rtems_initialization_tasks_table Initialization_tasks[];
    73 extern rtems_driver_address_table       Device_drivers[];
    7473#if defined(RTEMS_MULTIPROCESSING)
    7574  extern rtems_multiprocessing_table      Multiprocessing_configuration;
     
    12031202#ifndef CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
    12041203
     1204/**
     1205 * This specifies the maximum number of device drivers that
     1206 * can be installed in the system at one time.  It must account
     1207 * for both the statically and dynamically installed drivers.
     1208 */
     1209#ifndef CONFIGURE_MAXIMUM_DRIVERS
     1210  #define CONFIGURE_MAXIMUM_DRIVERS
     1211#endif
     1212
    12051213#ifdef CONFIGURE_INIT
    1206   rtems_driver_address_table Device_drivers[] = {
     1214  rtems_driver_address_table
     1215    _IO_Driver_address_table[ CONFIGURE_MAXIMUM_DRIVERS ] = {
    12071216    #ifdef CONFIGURE_BSP_PREREQUISITE_DRIVERS
    12081217      CONFIGURE_BSP_PREREQUISITE_DRIVERS,
     
    12551264    #endif
    12561265  };
     1266
     1267  const size_t _IO_Number_of_drivers =
     1268    RTEMS_ARRAY_SIZE( _IO_Driver_address_table );
    12571269#endif
    12581270
    12591271#endif  /* CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE */
    1260 
    1261 /*
    1262  *  Default the number of drivers per node.  This value may be
    1263  *  overridden by the user.
    1264  */
    1265 
    1266 #define CONFIGURE_NUMBER_OF_DRIVERS \
    1267   RTEMS_ARRAY_SIZE(Device_drivers)
    1268 
    1269 /**
    1270  * This specifies the maximum number of device drivers that
    1271  * can be installed in the system at one time.  It must account
    1272  * for both the statically and dynamically installed drivers.
    1273  */
    1274 #ifndef CONFIGURE_MAXIMUM_DRIVERS
    1275   #define CONFIGURE_MAXIMUM_DRIVERS CONFIGURE_NUMBER_OF_DRIVERS
    1276 #endif
    1277 
    12781272
    12791273#ifdef CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER
     
    24762470      #endif
    24772471    #endif
    2478     CONFIGURE_MAXIMUM_DRIVERS,                /* maximum device drivers */
    2479     CONFIGURE_NUMBER_OF_DRIVERS,              /* static device drivers */
    2480     Device_drivers,                           /* pointer to driver table */
    24812472    CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS,   /* number of static extensions */
    24822473    CONFIGURE_INITIAL_EXTENSION_TABLE,        /* pointer to static extensions */
  • cpukit/sapi/include/rtems/config.h

    r3a4d28a r263f4bec  
    5858
    5959#include <rtems/extension.h>
    60 #include <rtems/io.h>
    6160#if defined(RTEMS_MULTIPROCESSING)
    6261#include <rtems/score/mpci.h>
     
    243242  #endif
    244243
    245   uint32_t                       maximum_drivers;
    246   uint32_t                       number_of_device_drivers;
    247   rtems_driver_address_table    *Device_driver_table;
    248244  uint32_t                       number_of_initial_extensions;
    249245  const rtems_extensions_table  *User_extension_table;
     
    336332   (Configuration.do_zero_of_workspace)
    337333
    338 #define rtems_configuration_get_maximum_drivers() \
    339         (Configuration.maximum_drivers)
    340 
    341 #define rtems_configuration_get_number_of_device_drivers() \
    342         (Configuration.number_of_device_drivers)
    343 
    344 #define rtems_configuration_get_device_driver_table() \
    345         (Configuration.Device_driver_table)
    346 
    347334#define rtems_configuration_get_number_of_initial_extensions() \
    348335        (Configuration.number_of_initial_extensions)
  • cpukit/sapi/include/rtems/io.h

    r3a4d28a r263f4bec  
    251251) RTEMS_COMPILER_DEPRECATED_ATTRIBUTE;
    252252
    253 SAPI_IO_EXTERN uint32_t _IO_Number_of_drivers;
    254 
    255 SAPI_IO_EXTERN rtems_driver_address_table *_IO_Driver_address_table;
    256 
    257 /**
    258  * @brief Initialization of device drivers.
    259  *
    260  * NOTE: The IO manager has been extended to support runtime driver
    261  * registration. The driver table is now allocated in the
    262  * workspace.
    263  */
    264 void _IO_Manager_initialization( void );
     253extern const size_t _IO_Number_of_drivers;
     254
     255extern rtems_driver_address_table _IO_Driver_address_table[];
    265256
    266257/**
  • cpukit/sapi/src/exinit.c

    r3a4d28a r263f4bec  
    3333#include <rtems/extensionimpl.h>
    3434#include <rtems/init.h>
    35 #include <rtems/io.h>
    3635#include <rtems/score/sysstate.h>
    3736
     
    143142  _Extension_Manager_initialization();
    144143
    145   _IO_Manager_initialization();
    146 
    147144  _POSIX_API_Initialize();
    148145
  • cpukit/sapi/src/io.c

    r3a4d28a r263f4bec  
    2020#endif
    2121
    22 #include <rtems/system.h>
    23 #include <rtems/config.h>
    2422#include <rtems/io.h>
    25 #include <rtems/score/isr.h>
    26 #include <rtems/score/thread.h>
    27 #include <rtems/score/wkspace.h>
    28 
    29 #include <string.h>
    30 
    31 void _IO_Manager_initialization(void)
    32 {
    33   uint32_t                    index;
    34   rtems_driver_address_table *driver_table;
    35   uint32_t                    drivers_in_table;
    36   uint32_t                    number_of_drivers;
    37 
    38   driver_table      = rtems_configuration_get_device_driver_table();
    39   drivers_in_table  = rtems_configuration_get_number_of_device_drivers();
    40   number_of_drivers = rtems_configuration_get_maximum_drivers();
    41 
    42   /*
    43    *  If the user claims there are less drivers than are actually in
    44    *  the table, then let's just go with the table's count.
    45    */
    46   if ( number_of_drivers <= drivers_in_table )
    47     number_of_drivers = drivers_in_table;
    48 
    49   /*
    50    *  If the maximum number of driver is the same as the number in the
    51    *  table, then we do not have to copy the driver table.  They can't
    52    *  register any dynamically.
    53    */
    54   if ( number_of_drivers == drivers_in_table ) {
    55     _IO_Driver_address_table = driver_table;
    56     _IO_Number_of_drivers = number_of_drivers;
    57     return;
    58   }
    59 
    60   /*
    61    *  The application requested extra slots in the driver table, so we
    62    *  have to allocate a new driver table and copy theirs to it.
    63    */
    64 
    65   _IO_Driver_address_table = (rtems_driver_address_table *)
    66       _Workspace_Allocate_or_fatal_error(
    67         sizeof( rtems_driver_address_table ) * ( number_of_drivers )
    68       );
    69   _IO_Number_of_drivers = number_of_drivers;
    70 
    71   memset(
    72     _IO_Driver_address_table, 0,
    73     sizeof( rtems_driver_address_table ) * ( number_of_drivers )
    74   );
    75 
    76   for ( index = 0 ; index < drivers_in_table ; index++ )
    77     _IO_Driver_address_table[index] = driver_table[index];
    78 }
    7923
    8024void _IO_Initialize_all_drivers( void )
Note: See TracChangeset for help on using the changeset viewer.