forked from Imagelibrary/rtems
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.
This commit is contained in:
@@ -63,10 +63,9 @@ rtems_monitor_driver_next(
|
|||||||
rtems_id *next_id
|
rtems_id *next_id
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const rtems_configuration_table *c = &Configuration;
|
|
||||||
uint32_t n = rtems_object_id_get_index(*next_id);
|
uint32_t n = rtems_object_id_get_index(*next_id);
|
||||||
|
|
||||||
if (n >= c->number_of_device_drivers)
|
if (n >= _IO_Number_of_drivers)
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
_Thread_Disable_dispatch();
|
_Thread_Disable_dispatch();
|
||||||
@@ -79,7 +78,7 @@ rtems_monitor_driver_next(
|
|||||||
canonical_driver->name = rtems_build_name('-', '-', '-', '-');
|
canonical_driver->name = rtems_build_name('-', '-', '-', '-');
|
||||||
|
|
||||||
*next_id += 1;
|
*next_id += 1;
|
||||||
return (const void *) (c->Device_driver_table + n);
|
return (const void *) (&_IO_Driver_address_table[n]);
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
*next_id = RTEMS_OBJECT_ID_FINAL;
|
*next_id = RTEMS_OBJECT_ID_FINAL;
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern rtems_initialization_tasks_table Initialization_tasks[];
|
extern rtems_initialization_tasks_table Initialization_tasks[];
|
||||||
extern rtems_driver_address_table Device_drivers[];
|
|
||||||
#if defined(RTEMS_MULTIPROCESSING)
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
extern rtems_multiprocessing_table Multiprocessing_configuration;
|
extern rtems_multiprocessing_table Multiprocessing_configuration;
|
||||||
#endif
|
#endif
|
||||||
@@ -1202,8 +1201,18 @@ const rtems_libio_helper rtems_fs_init_helper =
|
|||||||
|
|
||||||
#ifndef CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
|
#ifndef CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This specifies the maximum number of device drivers that
|
||||||
|
* can be installed in the system at one time. It must account
|
||||||
|
* for both the statically and dynamically installed drivers.
|
||||||
|
*/
|
||||||
|
#ifndef CONFIGURE_MAXIMUM_DRIVERS
|
||||||
|
#define CONFIGURE_MAXIMUM_DRIVERS
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIGURE_INIT
|
#ifdef CONFIGURE_INIT
|
||||||
rtems_driver_address_table Device_drivers[] = {
|
rtems_driver_address_table
|
||||||
|
_IO_Driver_address_table[ CONFIGURE_MAXIMUM_DRIVERS ] = {
|
||||||
#ifdef CONFIGURE_BSP_PREREQUISITE_DRIVERS
|
#ifdef CONFIGURE_BSP_PREREQUISITE_DRIVERS
|
||||||
CONFIGURE_BSP_PREREQUISITE_DRIVERS,
|
CONFIGURE_BSP_PREREQUISITE_DRIVERS,
|
||||||
#endif
|
#endif
|
||||||
@@ -1254,28 +1263,13 @@ const rtems_libio_helper rtems_fs_init_helper =
|
|||||||
NULL_DRIVER_TABLE_ENTRY
|
NULL_DRIVER_TABLE_ENTRY
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const size_t _IO_Number_of_drivers =
|
||||||
|
RTEMS_ARRAY_SIZE( _IO_Driver_address_table );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE */
|
#endif /* CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE */
|
||||||
|
|
||||||
/*
|
|
||||||
* Default the number of drivers per node. This value may be
|
|
||||||
* overridden by the user.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define CONFIGURE_NUMBER_OF_DRIVERS \
|
|
||||||
RTEMS_ARRAY_SIZE(Device_drivers)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This specifies the maximum number of device drivers that
|
|
||||||
* can be installed in the system at one time. It must account
|
|
||||||
* for both the statically and dynamically installed drivers.
|
|
||||||
*/
|
|
||||||
#ifndef CONFIGURE_MAXIMUM_DRIVERS
|
|
||||||
#define CONFIGURE_MAXIMUM_DRIVERS CONFIGURE_NUMBER_OF_DRIVERS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER
|
#ifdef CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER
|
||||||
/*
|
/*
|
||||||
* configure the priority of the ATA driver task
|
* configure the priority of the ATA driver task
|
||||||
@@ -2475,9 +2469,6 @@ const rtems_libio_helper rtems_fs_init_helper =
|
|||||||
false,
|
false,
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
CONFIGURE_MAXIMUM_DRIVERS, /* maximum device drivers */
|
|
||||||
CONFIGURE_NUMBER_OF_DRIVERS, /* static device drivers */
|
|
||||||
Device_drivers, /* pointer to driver table */
|
|
||||||
CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS, /* number of static extensions */
|
CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS, /* number of static extensions */
|
||||||
CONFIGURE_INITIAL_EXTENSION_TABLE, /* pointer to static extensions */
|
CONFIGURE_INITIAL_EXTENSION_TABLE, /* pointer to static extensions */
|
||||||
#if defined(RTEMS_MULTIPROCESSING)
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ typedef void *posix_api_configuration_table;
|
|||||||
#include <rtems/rtems/config.h>
|
#include <rtems/rtems/config.h>
|
||||||
|
|
||||||
#include <rtems/extension.h>
|
#include <rtems/extension.h>
|
||||||
#include <rtems/io.h>
|
|
||||||
#if defined(RTEMS_MULTIPROCESSING)
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
#include <rtems/score/mpci.h>
|
#include <rtems/score/mpci.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -242,9 +241,6 @@ typedef struct {
|
|||||||
bool smp_enabled;
|
bool smp_enabled;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t maximum_drivers;
|
|
||||||
uint32_t number_of_device_drivers;
|
|
||||||
rtems_driver_address_table *Device_driver_table;
|
|
||||||
uint32_t number_of_initial_extensions;
|
uint32_t number_of_initial_extensions;
|
||||||
const rtems_extensions_table *User_extension_table;
|
const rtems_extensions_table *User_extension_table;
|
||||||
#if defined(RTEMS_MULTIPROCESSING)
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
@@ -335,15 +331,6 @@ extern const rtems_configuration_table Configuration;
|
|||||||
#define rtems_configuration_get_do_zero_of_workspace() \
|
#define rtems_configuration_get_do_zero_of_workspace() \
|
||||||
(Configuration.do_zero_of_workspace)
|
(Configuration.do_zero_of_workspace)
|
||||||
|
|
||||||
#define rtems_configuration_get_maximum_drivers() \
|
|
||||||
(Configuration.maximum_drivers)
|
|
||||||
|
|
||||||
#define rtems_configuration_get_number_of_device_drivers() \
|
|
||||||
(Configuration.number_of_device_drivers)
|
|
||||||
|
|
||||||
#define rtems_configuration_get_device_driver_table() \
|
|
||||||
(Configuration.Device_driver_table)
|
|
||||||
|
|
||||||
#define rtems_configuration_get_number_of_initial_extensions() \
|
#define rtems_configuration_get_number_of_initial_extensions() \
|
||||||
(Configuration.number_of_initial_extensions)
|
(Configuration.number_of_initial_extensions)
|
||||||
|
|
||||||
|
|||||||
@@ -250,18 +250,9 @@ rtems_status_code rtems_io_lookup_name(
|
|||||||
rtems_driver_name_t *device_info
|
rtems_driver_name_t *device_info
|
||||||
) RTEMS_COMPILER_DEPRECATED_ATTRIBUTE;
|
) RTEMS_COMPILER_DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
SAPI_IO_EXTERN uint32_t _IO_Number_of_drivers;
|
extern const size_t _IO_Number_of_drivers;
|
||||||
|
|
||||||
SAPI_IO_EXTERN rtems_driver_address_table *_IO_Driver_address_table;
|
extern rtems_driver_address_table _IO_Driver_address_table[];
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialization of device drivers.
|
|
||||||
*
|
|
||||||
* NOTE: The IO manager has been extended to support runtime driver
|
|
||||||
* registration. The driver table is now allocated in the
|
|
||||||
* workspace.
|
|
||||||
*/
|
|
||||||
void _IO_Manager_initialization( void );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialization of all device drivers.
|
* @brief Initialization of all device drivers.
|
||||||
|
|||||||
@@ -32,7 +32,6 @@
|
|||||||
#include <rtems/debug.h>
|
#include <rtems/debug.h>
|
||||||
#include <rtems/extensionimpl.h>
|
#include <rtems/extensionimpl.h>
|
||||||
#include <rtems/init.h>
|
#include <rtems/init.h>
|
||||||
#include <rtems/io.h>
|
|
||||||
#include <rtems/score/sysstate.h>
|
#include <rtems/score/sysstate.h>
|
||||||
|
|
||||||
#include <rtems/score/apiext.h>
|
#include <rtems/score/apiext.h>
|
||||||
@@ -142,8 +141,6 @@ void rtems_initialize_data_structures(void)
|
|||||||
|
|
||||||
_Extension_Manager_initialization();
|
_Extension_Manager_initialization();
|
||||||
|
|
||||||
_IO_Manager_initialization();
|
|
||||||
|
|
||||||
_POSIX_API_Initialize();
|
_POSIX_API_Initialize();
|
||||||
|
|
||||||
_System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
|
_System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
|
||||||
|
|||||||
@@ -19,63 +19,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <rtems/system.h>
|
|
||||||
#include <rtems/config.h>
|
|
||||||
#include <rtems/io.h>
|
#include <rtems/io.h>
|
||||||
#include <rtems/score/isr.h>
|
|
||||||
#include <rtems/score/thread.h>
|
|
||||||
#include <rtems/score/wkspace.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
void _IO_Manager_initialization(void)
|
|
||||||
{
|
|
||||||
uint32_t index;
|
|
||||||
rtems_driver_address_table *driver_table;
|
|
||||||
uint32_t drivers_in_table;
|
|
||||||
uint32_t number_of_drivers;
|
|
||||||
|
|
||||||
driver_table = rtems_configuration_get_device_driver_table();
|
|
||||||
drivers_in_table = rtems_configuration_get_number_of_device_drivers();
|
|
||||||
number_of_drivers = rtems_configuration_get_maximum_drivers();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the user claims there are less drivers than are actually in
|
|
||||||
* the table, then let's just go with the table's count.
|
|
||||||
*/
|
|
||||||
if ( number_of_drivers <= drivers_in_table )
|
|
||||||
number_of_drivers = drivers_in_table;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the maximum number of driver is the same as the number in the
|
|
||||||
* table, then we do not have to copy the driver table. They can't
|
|
||||||
* register any dynamically.
|
|
||||||
*/
|
|
||||||
if ( number_of_drivers == drivers_in_table ) {
|
|
||||||
_IO_Driver_address_table = driver_table;
|
|
||||||
_IO_Number_of_drivers = number_of_drivers;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The application requested extra slots in the driver table, so we
|
|
||||||
* have to allocate a new driver table and copy theirs to it.
|
|
||||||
*/
|
|
||||||
|
|
||||||
_IO_Driver_address_table = (rtems_driver_address_table *)
|
|
||||||
_Workspace_Allocate_or_fatal_error(
|
|
||||||
sizeof( rtems_driver_address_table ) * ( number_of_drivers )
|
|
||||||
);
|
|
||||||
_IO_Number_of_drivers = number_of_drivers;
|
|
||||||
|
|
||||||
memset(
|
|
||||||
_IO_Driver_address_table, 0,
|
|
||||||
sizeof( rtems_driver_address_table ) * ( number_of_drivers )
|
|
||||||
);
|
|
||||||
|
|
||||||
for ( index = 0 ; index < drivers_in_table ; index++ )
|
|
||||||
_IO_Driver_address_table[index] = driver_table[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
void _IO_Initialize_all_drivers( void )
|
void _IO_Initialize_all_drivers( void )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3835,39 +3835,6 @@ custom device drivers.
|
|||||||
|
|
||||||
Note that network device drivers are not configured in the Device Driver Table.
|
Note that network device drivers are not configured in the Device Driver Table.
|
||||||
|
|
||||||
@c
|
|
||||||
@c === CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE ===
|
|
||||||
@c
|
|
||||||
@subsection Specifying Application Defined Device Driver Table
|
|
||||||
|
|
||||||
@findex CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
|
|
||||||
|
|
||||||
@table @b
|
|
||||||
@item CONSTANT:
|
|
||||||
@code{CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE}
|
|
||||||
|
|
||||||
@item DATA TYPE:
|
|
||||||
List of device driver initializers (@code{rtems_driver_address_table}).
|
|
||||||
|
|
||||||
@item RANGE:
|
|
||||||
Undefined or array of device drivers.
|
|
||||||
|
|
||||||
@item DEFAULT VALUE:
|
|
||||||
This is not defined by default, indicating the @code{<rtems/confdefs.h>}
|
|
||||||
is providing the device driver table.
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@subheading DESCRIPTION:
|
|
||||||
@code{CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE} is defined if the application
|
|
||||||
wishes to provide their own Device Driver Table.
|
|
||||||
|
|
||||||
The table must be an array of @code{rtems_driver_address_table} entries
|
|
||||||
named @code{Device_drivers}.
|
|
||||||
|
|
||||||
@subheading NOTES:
|
|
||||||
It is expected that there the application would only rarely need to do this.
|
|
||||||
|
|
||||||
@c
|
@c
|
||||||
@c === CONFIGURE_MAXIMUM_DRIVERS ===
|
@c === CONFIGURE_MAXIMUM_DRIVERS ===
|
||||||
@c
|
@c
|
||||||
@@ -4296,6 +4263,41 @@ device driver.
|
|||||||
@subheading NOTES:
|
@subheading NOTES:
|
||||||
This device driver is supported by all BSPs.
|
This device driver is supported by all BSPs.
|
||||||
|
|
||||||
|
@c
|
||||||
|
@c === CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE ===
|
||||||
|
@c
|
||||||
|
@subsection Specifying Application Defined Device Driver Table
|
||||||
|
|
||||||
|
@findex CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
|
||||||
|
|
||||||
|
@table @b
|
||||||
|
@item CONSTANT:
|
||||||
|
@code{CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE}
|
||||||
|
|
||||||
|
@item DATA TYPE:
|
||||||
|
Boolean feature macro.
|
||||||
|
|
||||||
|
@item RANGE:
|
||||||
|
Defined or undefined.
|
||||||
|
|
||||||
|
@item DEFAULT VALUE:
|
||||||
|
This is not defined by default, indicating the @code{<rtems/confdefs.h>}
|
||||||
|
is providing the device driver table.
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@subheading DESCRIPTION:
|
||||||
|
@code{CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE} is defined if the application
|
||||||
|
wishes to provide their own Device Driver Table.
|
||||||
|
|
||||||
|
The table must be an array of @code{rtems_driver_address_table} entries named
|
||||||
|
@code{_IO_Driver_address_table}. The application must also provide a const
|
||||||
|
variable @code{_IO_Number_of_drivers} of type @code{size_t} indicating the
|
||||||
|
number of entries in the @code{_IO_Driver_address_table}.
|
||||||
|
|
||||||
|
@subheading NOTES:
|
||||||
|
It is expected that there the application would only rarely need to do this.
|
||||||
|
|
||||||
@c
|
@c
|
||||||
@c === Multiprocessing Configuration ===
|
@c === Multiprocessing Configuration ===
|
||||||
@c
|
@c
|
||||||
|
|||||||
@@ -434,7 +434,6 @@ static rtems_task Init(rtems_task_argument argument)
|
|||||||
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5
|
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5
|
||||||
|
|
||||||
#define CONFIGURE_MAXIMUM_TASKS 1
|
#define CONFIGURE_MAXIMUM_TASKS 1
|
||||||
#define CONFIGURE_MAXIMUM_DRIVERS 2
|
|
||||||
|
|
||||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,7 @@ void do_test_zero_driver(void);
|
|||||||
#define STUB_DRIVER_MAJOR 0x2
|
#define STUB_DRIVER_MAJOR 0x2
|
||||||
#define ZERO_DRIVER_MAJOR 0x3
|
#define ZERO_DRIVER_MAJOR 0x3
|
||||||
#define NO_DRIVER_MAJOR 0x4
|
#define NO_DRIVER_MAJOR 0x4
|
||||||
#define INVALID_DRIVER_MAJOR \
|
#define INVALID_DRIVER_MAJOR UINT32_MAX
|
||||||
(rtems_configuration_get_number_of_device_drivers() + 1)
|
|
||||||
|
|
||||||
/* driver entries to use with io_register */
|
/* driver entries to use with io_register */
|
||||||
rtems_driver_address_table GoodDriver = DEVNULL_DRIVER_TABLE_ENTRY;
|
rtems_driver_address_table GoodDriver = DEVNULL_DRIVER_TABLE_ENTRY;
|
||||||
|
|||||||
@@ -290,9 +290,6 @@ uninitialized =
|
|||||||
|
|
||||||
/*intr.h*/ 0 +
|
/*intr.h*/ 0 +
|
||||||
|
|
||||||
/*io.h*/ (sizeof _IO_Number_of_drivers) +
|
|
||||||
(sizeof _IO_Driver_address_table) +
|
|
||||||
|
|
||||||
/*isr.h*/ (sizeof _ISR_Nest_level) +
|
/*isr.h*/ (sizeof _ISR_Nest_level) +
|
||||||
#if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE)
|
#if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE)
|
||||||
(sizeof _ISR_Vector_table) +
|
(sizeof _ISR_Vector_table) +
|
||||||
|
|||||||
Reference in New Issue
Block a user