[PATCH 2/3] Optional Initial Extensions initialization

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Dec 11 07:59:32 UTC 2015


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 | 41 ++++++++++++++++++++++++-----------
 7 files changed, 54 insertions(+), 33 deletions(-)

diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index 9ef0bc6..a88a878 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
@@ -2412,6 +2414,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 08249dd..7e6fd53 100644
--- a/cpukit/sapi/src/exinit.c
+++ b/cpukit/sapi/src/exinit.c
@@ -46,7 +46,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>
 
@@ -100,7 +99,6 @@ static void rtems_initialize_data_structures(void)
 
   _Thread_Dispatch_initialization();
 
-  _User_extensions_Handler_initialization();
   _ISR_Handler_initialization();
 
   /*
diff --git a/cpukit/score/include/rtems/sysinit.h b/cpukit/score/include/rtems/sysinit.h
index f870613..1f9de23 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_CPU_SET                    00030c
 #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 fdd37e4..ed4a5ce 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_CPU_SET
 Initializes the global CPU set on SMP configurations in case the application
diff --git a/testsuites/sptests/spsysinit01/init.c b/testsuites/sptests/spsysinit01/init.c
index 76f8afd..8ee4c48 100644
--- a/testsuites/sptests/spsysinit01/init.c
+++ b/testsuites/sptests/spsysinit01/init.c
@@ -25,6 +25,7 @@
 #include <rtems/test.h>
 
 #include <rtems/score/sysstate.h>
+#include <rtems/score/userextimpl.h>
 #include <rtems/score/wkspace.h>
 
 const char rtems_test_name[] = "SPSYSINIT 1";
@@ -82,39 +83,51 @@ LAST(RTEMS_SYSINIT_BSP_START)
   next_step(3);
 }
 
+FIRST(RTEMS_SYSINIT_INITIAL_EXTENSIONS)
+{
+  assert(_Chain_Is_empty(&_User_extensions_Switches_list));
+  next_step(4);
+}
+
+LAST(RTEMS_SYSINIT_INITIAL_EXTENSIONS)
+{
+  assert(!_Chain_Is_empty(&_User_extensions_Switches_list));
+  next_step(5);
+}
+
 FIRST(RTEMS_SYSINIT_DATA_STRUCTURES)
 {
   assert(_System_state_Is_before_initialization(_System_state_Get()));
-  next_step(4);
+  next_step(6);
 }
 
 LAST(RTEMS_SYSINIT_DATA_STRUCTURES)
 {
   assert(_System_state_Is_before_multitasking(_System_state_Get()));
-  next_step(5);
+  next_step(7);
 }
 
 FIRST(RTEMS_SYSINIT_BSP_LIBC)
 {
   assert(rtems_libio_semaphore == 0);
-  next_step(6);
+  next_step(8);
 }
 
 LAST(RTEMS_SYSINIT_BSP_LIBC)
 {
   assert(rtems_libio_semaphore != 0);
-  next_step(7);
+  next_step(9);
 }
 
 FIRST(RTEMS_SYSINIT_BEFORE_DRIVERS)
 {
   /* Omit test of build configuration specific pre and post conditions */
-  next_step(8);
+  next_step(10);
 }
 
 LAST(RTEMS_SYSINIT_BEFORE_DRIVERS)
 {
-  next_step(9);
+  next_step(11);
 }
 
 FIRST(RTEMS_SYSINIT_BSP_PRE_DRIVERS)
@@ -123,41 +136,41 @@ FIRST(RTEMS_SYSINIT_BSP_PRE_DRIVERS)
    * Since the work performed here is BSP-specific, there is no way to test pre
    * and post conditions.
    */
-  next_step(10);
+  next_step(12);
 }
 
 LAST(RTEMS_SYSINIT_BSP_PRE_DRIVERS)
 {
-  next_step(11);
+  next_step(13);
 }
 
 FIRST(RTEMS_SYSINIT_DEVICE_DRIVERS)
 {
   assert(!_IO_All_drivers_initialized);
-  next_step(12);
+  next_step(14);
 }
 
 LAST(RTEMS_SYSINIT_DEVICE_DRIVERS)
 {
   assert(_IO_All_drivers_initialized);
-  next_step(13);
+  next_step(15);
 }
 
 FIRST(RTEMS_SYSINIT_BSP_POST_DRIVERS)
 {
   assert(rtems_libio_iop_freelist != NULL);
-  next_step(14);
+  next_step(16);
 }
 
 LAST(RTEMS_SYSINIT_BSP_POST_DRIVERS)
 {
   assert(rtems_libio_iop_freelist == NULL);
-  next_step(15);
+  next_step(17);
 }
 
 static void Init(rtems_task_argument arg)
 {
-  next_step(16);
+  next_step(18);
   rtems_test_endk();
   exit(0);
 }
@@ -169,6 +182,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
-- 
1.8.4.5




More information about the devel mailing list