[rtems commit] Optional Initial Extensions initialization

Sebastian Huber sebh at rtems.org
Wed Feb 3 09:29:56 UTC 2016


Module:    rtems
Branch:    master
Commit:    a853c8518d7b8ccf54491018857ed86548f3ea24
Changeset: http://git.rtems.org/rtems/commit/?id=a853c8518d7b8ccf54491018857ed86548f3ea24

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Dec 10 15:44:02 2015 +0100

Optional Initial Extensions initialization

Update #2408.

---

 cpukit/sapi/include/confdefs.h        |  8 ++++++++
 cpukit/sapi/src/exinit.c              |  2 --
 cpukit/score/include/rtems/sysinit.h  |  3 ++-
 cpukit/score/src/threaddispatch.c     |  2 ++
 cpukit/score/src/userext.c            | 23 ++++++++---------------
 doc/user/init.t                       |  8 ++++++--
 testsuites/sptests/spsysinit01/init.c | 17 +++++++++++++++++
 7 files changed, 43 insertions(+), 20 deletions(-)

diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index 8635ca0..8f5906d 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -26,8 +26,10 @@
  * Include the executive's configuration
  */
 #include <rtems.h>
+#include <rtems/sysinit.h>
 #include <rtems/score/apimutex.h>
 #include <rtems/score/percpu.h>
+#include <rtems/score/userextimpl.h>
 #include <rtems/score/wkspace.h>
 
 #ifdef CONFIGURE_DISABLE_BSP_SETTINGS
@@ -2394,6 +2396,12 @@ const rtems_libio_helper rtems_fs_init_helper =
   #define CONFIGURE_INITIAL_EXTENSION_TABLE Configuration_Initial_Extensions
   #define CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS \
     RTEMS_ARRAY_SIZE(Configuration_Initial_Extensions)
+
+  RTEMS_SYSINIT_ITEM(
+    _User_extensions_Handler_initialization,
+    RTEMS_SYSINIT_INITIAL_EXTENSIONS,
+    RTEMS_SYSINIT_ORDER_MIDDLE
+  );
 #else
   #define CONFIGURE_INITIAL_EXTENSION_TABLE NULL
   #define CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS 0
diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c
index faaf283..685197d 100644
--- a/cpukit/sapi/src/exinit.c
+++ b/cpukit/sapi/src/exinit.c
@@ -47,7 +47,6 @@
 #include <rtems/score/timecounter.h>
 #include <rtems/score/threadimpl.h>
 #include <rtems/score/todimpl.h>
-#include <rtems/score/userextimpl.h>
 #include <rtems/score/watchdogimpl.h>
 #include <rtems/score/wkspace.h>
 
@@ -113,7 +112,6 @@ static void rtems_initialize_data_structures(void)
 
   _Thread_Dispatch_initialization();
 
-  _User_extensions_Handler_initialization();
   _ISR_Handler_initialization();
 
   _API_Mutex_Initialization( 2 );
diff --git a/cpukit/score/include/rtems/sysinit.h b/cpukit/score/include/rtems/sysinit.h
index e6fe62f..49c465b 100644
--- a/cpukit/score/include/rtems/sysinit.h
+++ b/cpukit/score/include/rtems/sysinit.h
@@ -28,7 +28,8 @@ extern "C" {
  */
 #define RTEMS_SYSINIT_BSP_WORK_AREAS             000100
 #define RTEMS_SYSINIT_BSP_START                  000200
-#define RTEMS_SYSINIT_DATA_STRUCTURES            000300
+#define RTEMS_SYSINIT_INITIAL_EXTENSIONS         000300
+#define RTEMS_SYSINIT_DATA_STRUCTURES            000301
 #define RTEMS_SYSINIT_IDLE_THREADS               000380
 #define RTEMS_SYSINIT_BSP_LIBC                   000400
 #define RTEMS_SYSINIT_BEFORE_DRIVERS             000500
diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c
index 3ae8335..00c2f09 100644
--- a/cpukit/score/src/threaddispatch.c
+++ b/cpukit/score/src/threaddispatch.c
@@ -30,6 +30,8 @@
 #include <rtems/score/wkspace.h>
 #include <rtems/config.h>
 
+CHAIN_DEFINE_EMPTY( _User_extensions_Switches_list );
+
 static Thread_Action *_Thread_Get_post_switch_action(
   Thread_Control *executing
 )
diff --git a/cpukit/score/src/userext.c b/cpukit/score/src/userext.c
index 1328f68..1ac622e 100644
--- a/cpukit/score/src/userext.c
+++ b/cpukit/score/src/userext.c
@@ -23,8 +23,6 @@
 #include <rtems/score/userextimpl.h>
 #include <rtems/score/wkspace.h>
 
-CHAIN_DEFINE_EMPTY( _User_extensions_Switches_list );
-
 typedef struct {
   User_extensions_Switch_control *switch_control;
 } User_extensions_Switch_context;
@@ -50,17 +48,12 @@ static void _User_extensions_Switch_visitor(
 
 void _User_extensions_Handler_initialization(void)
 {
-  uint32_t number_of_initial_extensions =
-    rtems_configuration_get_number_of_initial_extensions();
-
-  if ( number_of_initial_extensions > 0 ) {
-    User_extensions_Switch_control *initial_extension_switch_controls =
-      _Workspace_Allocate_or_fatal_error(
-        number_of_initial_extensions
-          * sizeof( *initial_extension_switch_controls )
-      );
-    User_extensions_Switch_context ctx = { initial_extension_switch_controls };
-
-    _User_extensions_Iterate( &ctx, _User_extensions_Switch_visitor );
-  }
+  User_extensions_Switch_control *initial_extension_switch_controls =
+    _Workspace_Allocate_or_fatal_error(
+      rtems_configuration_get_number_of_initial_extensions()
+        * sizeof( *initial_extension_switch_controls )
+    );
+  User_extensions_Switch_context ctx = { initial_extension_switch_controls };
+
+  _User_extensions_Iterate( &ctx, _User_extensions_Switch_visitor );
 }
diff --git a/doc/user/init.t b/doc/user/init.t
index c5ebc0d..5ab011e 100644
--- a/doc/user/init.t
+++ b/doc/user/init.t
@@ -157,12 +157,16 @@ initialized by the Board Support Package.  This step is mandatory.
 Basic initialization step provided by the Board Support Package.  This step is
 mandatory.
 
+ at item RTEMS_SYSINIT_INITIAL_EXTENSIONS
+Initializes the initial extensions if at least one is configured by the Board
+Support Package or application.
+
 @item RTEMS_SYSINIT_DATA_STRUCTURES
 This directive is called when the Board Support Package has completed its basic
 initialization and allows RTEMS to initialize the application environment based
 upon the information in the Configuration Table, User Initialization Tasks
-Table, Device Driver Table, User Extension Table, Multiprocessor Configuration
-Table, and the Multiprocessor Communications Interface (MPCI) Table.
+Table, Device Driver Table, Multiprocessor Configuration Table, and the
+Multiprocessor Communications Interface (MPCI) Table.
 
 @item RTEMS_SYSINIT_BSP_LIBC
 Depending on the application configuration the IO library and root filesystem
diff --git a/testsuites/sptests/spsysinit01/init.c b/testsuites/sptests/spsysinit01/init.c
index fd34264..2bc859b 100644
--- a/testsuites/sptests/spsysinit01/init.c
+++ b/testsuites/sptests/spsysinit01/init.c
@@ -26,6 +26,7 @@
 
 #include <rtems/score/apimutex.h>
 #include <rtems/score/sysstate.h>
+#include <rtems/score/userextimpl.h>
 #include <rtems/score/wkspace.h>
 
 const char rtems_test_name[] = "SPSYSINIT 1";
@@ -35,6 +36,8 @@ typedef enum {
   BSP_WORK_AREAS_POST,
   BSP_START_PRE,
   BSP_START_POST,
+  INITIAL_EXTENSIONS_PRE,
+  INITIAL_EXTENSIONS_POST,
   DATA_STRUCTURES_PRE,
   DATA_STRUCTURES_POST,
   IDLE_THREADS_PRE,
@@ -106,6 +109,18 @@ LAST(RTEMS_SYSINIT_BSP_START)
   next_step(BSP_START_POST);
 }
 
+FIRST(RTEMS_SYSINIT_INITIAL_EXTENSIONS)
+{
+  assert(_Chain_Is_empty(&_User_extensions_Switches_list));
+  next_step(INITIAL_EXTENSIONS_PRE);
+}
+
+LAST(RTEMS_SYSINIT_INITIAL_EXTENSIONS)
+{
+  assert(!_Chain_Is_empty(&_User_extensions_Switches_list));
+  next_step(INITIAL_EXTENSIONS_POST);
+}
+
 FIRST(RTEMS_SYSINIT_DATA_STRUCTURES)
 {
   assert(_RTEMS_Allocator_Mutex == NULL);
@@ -205,6 +220,8 @@ static void Init(rtems_task_argument arg)
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
 
+#define CONFIGURE_STACK_CHECKER_ENABLED
+
 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
 
 #define CONFIGURE_INIT



More information about the vc mailing list