[PATCH 3/3] Optional Extensions initialization

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


Update #2408.
---
 cpukit/sapi/Makefile.am                   |  2 +-
 cpukit/sapi/include/rtems/extensionimpl.h | 13 +--------
 cpukit/sapi/src/exinit.c                  |  2 --
 cpukit/sapi/src/extension.c               | 16 +++++++----
 cpukit/sapi/src/extensiondata.c           | 25 -----------------
 cpukit/score/include/rtems/sysinit.h      |  1 +
 doc/user/init.t                           |  4 +++
 testsuites/sptests/spsysinit01/init.c     | 46 +++++++++++++++++++++++--------
 8 files changed, 53 insertions(+), 56 deletions(-)
 delete mode 100644 cpukit/sapi/src/extensiondata.c

diff --git a/cpukit/sapi/Makefile.am b/cpukit/sapi/Makefile.am
index ca7b421..e930a4c 100644
--- a/cpukit/sapi/Makefile.am
+++ b/cpukit/sapi/Makefile.am
@@ -31,7 +31,7 @@ libsapi_a_SOURCES = src/extension.c src/extensioncreate.c \
     src/exshutdown.c src/io.c src/ioclose.c src/iocontrol.c src/iodata.c \
     src/ioinitialize.c src/ioopen.c src/ioread.c src/ioregisterdriver.c \
     src/iounregisterdriver.c src/iowrite.c src/posixapi.c  \
-    src/rtemsapi.c src/extensiondata.c src/getversionstring.c \
+    src/rtemsapi.c src/getversionstring.c \
     src/chainappendnotify.c src/chaingetnotify.c src/chaingetwait.c \
     src/chainprependnotify.c src/rbheap.c src/interrtext.c \
     src/fatal2.c src/fatalsrctext.c
diff --git a/cpukit/sapi/include/rtems/extensionimpl.h b/cpukit/sapi/include/rtems/extensionimpl.h
index 487bdb4..e26731c 100644
--- a/cpukit/sapi/include/rtems/extensionimpl.h
+++ b/cpukit/sapi/include/rtems/extensionimpl.h
@@ -25,18 +25,7 @@
 extern "C" {
 #endif
 
-#ifndef SAPI_EXT_EXTERN
-#define SAPI_EXT_EXTERN extern
-#endif
-
-SAPI_EXT_EXTERN Objects_Information  _Extension_Information;
-
-/**
- *  @brief Initialize extension manager.
- *
- *  This routine initializes all extension manager related data structures.
- */
-void _Extension_Manager_initialization(void);
+extern Objects_Information  _Extension_Information;
 
 RTEMS_INLINE_ROUTINE Extension_Control *_Extension_Allocate( void )
 {
diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c
index 7e6fd53..64d8265 100644
--- a/cpukit/sapi/src/exinit.c
+++ b/cpukit/sapi/src/exinit.c
@@ -128,8 +128,6 @@ static void rtems_initialize_data_structures(void)
 
   _RTEMS_API_Initialize();
 
-  _Extension_Manager_initialization();
-
   _POSIX_API_Initialize();
 
   _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
diff --git a/cpukit/sapi/src/extension.c b/cpukit/sapi/src/extension.c
index 100f194..3378850 100644
--- a/cpukit/sapi/src/extension.c
+++ b/cpukit/sapi/src/extension.c
@@ -21,13 +21,13 @@
 #include "config.h"
 #endif
 
-#include <rtems/system.h>
-#include <rtems/config.h>
-#include <rtems/rtems/support.h>
-#include <rtems/score/thread.h>
 #include <rtems/extensionimpl.h>
+#include <rtems/config.h>
+#include <rtems/sysinit.h>
 
-void _Extension_Manager_initialization(void)
+Objects_Information _Extension_Information;
+
+static void _Extension_Manager_initialization(void)
 {
   _Objects_Initialize_information(
     &_Extension_Information,
@@ -44,3 +44,9 @@ void _Extension_Manager_initialization(void)
 #endif
   );
 }
+
+RTEMS_SYSINIT_ITEM(
+  _Extension_Manager_initialization,
+  RTEMS_SYSINIT_USER_EXTENSIONS,
+  RTEMS_SYSINIT_ORDER_MIDDLE
+);
diff --git a/cpukit/sapi/src/extensiondata.c b/cpukit/sapi/src/extensiondata.c
deleted file mode 100644
index 0d7e481..0000000
--- a/cpukit/sapi/src/extensiondata.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * @file
- *
- * @brief Extension Data
- *
- * @ingroup ClassicUserExtensions
- */
-
-/*
- *  COPYRIGHT (c) 1989-2007.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-/* instantiate extension data */
-#define SAPI_EXT_EXTERN
-
-#include <rtems/extensionimpl.h>
diff --git a/cpukit/score/include/rtems/sysinit.h b/cpukit/score/include/rtems/sysinit.h
index 1f9de23..e923bbc 100644
--- a/cpukit/score/include/rtems/sysinit.h
+++ b/cpukit/score/include/rtems/sysinit.h
@@ -31,6 +31,7 @@ extern "C" {
 #define RTEMS_SYSINIT_INITIAL_EXTENSIONS         000300
 #define RTEMS_SYSINIT_DATA_STRUCTURES            000301
 #define RTEMS_SYSINIT_CPU_SET                    00030c
+#define RTEMS_SYSINIT_USER_EXTENSIONS            00030e
 #define RTEMS_SYSINIT_BSP_LIBC                   000400
 #define RTEMS_SYSINIT_BEFORE_DRIVERS             000500
 #define RTEMS_SYSINIT_BSP_PRE_DRIVERS            000600
diff --git a/doc/user/init.t b/doc/user/init.t
index ed4a5ce..c8e882a 100644
--- a/doc/user/init.t
+++ b/doc/user/init.t
@@ -172,6 +172,10 @@ Multiprocessor Communications Interface (MPCI) Table.
 Initializes the global CPU set on SMP configurations in case the application
 uses this information.
 
+ at item RTEMS_SYSINIT_USER_EXTENSIONS
+Initializes the @ref{User Extensions Manager} in case it is used by the
+application.
+
 @item RTEMS_SYSINIT_BSP_LIBC
 Depending on the application configuration the IO library and root filesystem
 is initialized.  This step is mandatory.
diff --git a/testsuites/sptests/spsysinit01/init.c b/testsuites/sptests/spsysinit01/init.c
index 8ee4c48..708352e 100644
--- a/testsuites/sptests/spsysinit01/init.c
+++ b/testsuites/sptests/spsysinit01/init.c
@@ -24,6 +24,7 @@
 #include <rtems/sysinit.h>
 #include <rtems/test.h>
 
+#include <rtems/extensionimpl.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/userextimpl.h>
 #include <rtems/score/wkspace.h>
@@ -107,27 +108,39 @@ LAST(RTEMS_SYSINIT_DATA_STRUCTURES)
   next_step(7);
 }
 
+FIRST(RTEMS_SYSINIT_USER_EXTENSIONS)
+{
+  assert(_Extension_Information.maximum == 0);
+  next_step(8);
+}
+
+LAST(RTEMS_SYSINIT_USER_EXTENSIONS)
+{
+  assert(_Extension_Information.maximum != 0);
+  next_step(9);
+}
+
 FIRST(RTEMS_SYSINIT_BSP_LIBC)
 {
   assert(rtems_libio_semaphore == 0);
-  next_step(8);
+  next_step(10);
 }
 
 LAST(RTEMS_SYSINIT_BSP_LIBC)
 {
   assert(rtems_libio_semaphore != 0);
-  next_step(9);
+  next_step(11);
 }
 
 FIRST(RTEMS_SYSINIT_BEFORE_DRIVERS)
 {
   /* Omit test of build configuration specific pre and post conditions */
-  next_step(10);
+  next_step(12);
 }
 
 LAST(RTEMS_SYSINIT_BEFORE_DRIVERS)
 {
-  next_step(11);
+  next_step(13);
 }
 
 FIRST(RTEMS_SYSINIT_BSP_PRE_DRIVERS)
@@ -136,41 +149,50 @@ 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(12);
+  next_step(14);
 }
 
 LAST(RTEMS_SYSINIT_BSP_PRE_DRIVERS)
 {
-  next_step(13);
+  next_step(15);
 }
 
 FIRST(RTEMS_SYSINIT_DEVICE_DRIVERS)
 {
   assert(!_IO_All_drivers_initialized);
-  next_step(14);
+  next_step(16);
 }
 
 LAST(RTEMS_SYSINIT_DEVICE_DRIVERS)
 {
   assert(_IO_All_drivers_initialized);
-  next_step(15);
+  next_step(17);
 }
 
 FIRST(RTEMS_SYSINIT_BSP_POST_DRIVERS)
 {
   assert(rtems_libio_iop_freelist != NULL);
-  next_step(16);
+  next_step(18);
 }
 
 LAST(RTEMS_SYSINIT_BSP_POST_DRIVERS)
 {
   assert(rtems_libio_iop_freelist == NULL);
-  next_step(17);
+  next_step(19);
 }
 
 static void Init(rtems_task_argument arg)
 {
-  next_step(18);
+  static const rtems_extensions_table table;
+  static const rtems_name name = rtems_build_name('N', 'A', 'M', 'E');
+
+  rtems_status_code sc;
+  rtems_id id;
+
+  sc = rtems_extension_create(name, &table, &id);
+  assert(sc == RTEMS_SUCCESSFUL);
+
+  next_step(20);
   rtems_test_endk();
   exit(0);
 }
@@ -178,6 +200,8 @@ static void Init(rtems_task_argument arg)
 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
 
+#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
+
 #define CONFIGURE_MAXIMUM_TASKS 1
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
-- 
1.8.4.5




More information about the devel mailing list