summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2011-11-24 16:54:28 +0100
committerDaniel Hellstrom <daniel@gaisler.com>2015-04-17 01:10:15 +0200
commit04cf2c5556428e836e7c024258851e24f10b2693 (patch)
tree1f9b072f6a07a4b0f4e508ca10f1cfa9746267fa /cpukit
parentsptests/sp68: Avoid use of internal variables (diff)
downloadrtems-04cf2c5556428e836e7c024258851e24f10b2693.tar.bz2
IO_MANAGER: early dynamic driver registration
Adds the possibility to register drivers before the IO Manager has completed the initialization. Sometimes the BSP may want to register a driver dynamically early in the boot process.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/sapi/src/io.c4
-rw-r--r--cpukit/sapi/src/ioregisterdriver.c14
2 files changed, 17 insertions, 1 deletions
diff --git a/cpukit/sapi/src/io.c b/cpukit/sapi/src/io.c
index c14f5e760e..b27bed9b44 100644
--- a/cpukit/sapi/src/io.c
+++ b/cpukit/sapi/src/io.c
@@ -21,10 +21,14 @@
#include <rtems/io.h>
+int _IO_Manager_drivers_inititalized = 0;
+
void _IO_Initialize_all_drivers( void )
{
rtems_device_major_number major;
+ _IO_Manager_drivers_inititalized = 1;
+
for ( major=0 ; major < _IO_Number_of_drivers ; major ++ )
(void) rtems_io_initialize( major, 0, NULL );
}
diff --git a/cpukit/sapi/src/ioregisterdriver.c b/cpukit/sapi/src/ioregisterdriver.c
index 65cc56f513..ca1ecb93ae 100644
--- a/cpukit/sapi/src/ioregisterdriver.c
+++ b/cpukit/sapi/src/ioregisterdriver.c
@@ -25,6 +25,8 @@
#include <rtems/rtems/intr.h>
#include <rtems/score/threaddispatch.h>
+extern int _IO_Manager_drivers_inititalized;
+
static inline bool rtems_io_is_empty_table(
const rtems_driver_address_table *table
)
@@ -108,5 +110,15 @@ rtems_status_code rtems_io_register_driver(
_Thread_Enable_dispatch();
- return rtems_io_initialize( major, 0, NULL );
+ if ( _IO_Manager_drivers_inititalized ) {
+ /* Other drivers have already been initialized, we initialize
+ * the driver directly.
+ */
+ return rtems_io_initialize( major, 0, NULL );
+ } else {
+ /* The driver will be initialized together with all other drivers
+ * in a later stage by _IO_Initialize_all_drivers().
+ */
+ return RTEMS_SUCCESSFUL;
+ }
}