[PATCH 35/38] Use linker set for MPCI initialization

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Jan 26 15:38:01 UTC 2016


Update #2408.
---
 .../lib/libbsp/powerpc/beatnik/startup/bspstart.c  |  3 -
 .../lib/libbsp/powerpc/mvme5500/startup/bspstart.c |  1 -
 cpukit/sapi/Makefile.am                            |  1 -
 cpukit/sapi/include/rtems/config.h                 | 11 +++-
 cpukit/sapi/include/rtems/init.h                   |  9 ---
 cpukit/sapi/include/rtems/sptables.h               | 70 --------------------
 cpukit/sapi/preinstall.am                          |  4 --
 cpukit/sapi/src/exinit.c                           | 54 +--------------
 cpukit/score/include/rtems/score/basedefs.h        | 14 ----
 cpukit/score/include/rtems/score/mpciimpl.h        | 27 --------
 cpukit/score/include/rtems/sysinit.h               |  7 +-
 cpukit/score/src/mpci.c                            | 77 ++++++++++++++++++++--
 testsuites/sptests/spsize/size.c                   |  3 +-
 testsuites/sptests/spsysinit01/init.c              | 13 ----
 14 files changed, 89 insertions(+), 205 deletions(-)
 delete mode 100644 cpukit/sapi/include/rtems/sptables.h

diff --git a/c/src/lib/libbsp/powerpc/beatnik/startup/bspstart.c b/c/src/lib/libbsp/powerpc/beatnik/startup/bspstart.c
index dc0214a..989cd7b 100644
--- a/c/src/lib/libbsp/powerpc/beatnik/startup/bspstart.c
+++ b/c/src/lib/libbsp/powerpc/beatnik/startup/bspstart.c
@@ -46,9 +46,6 @@
 #include <bsp/vectors.h>
 #include <bsp/vpd.h>
 
-/* for RTEMS_VERSION :-( I dont like the preassembled string */
-#include <rtems/sptables.h>
-
 #define SHOW_MORE_INIT_SETTINGS
 
 BSP_output_char_function_type     BSP_output_char = BSP_output_char_via_serial;
diff --git a/c/src/lib/libbsp/powerpc/mvme5500/startup/bspstart.c b/c/src/lib/libbsp/powerpc/mvme5500/startup/bspstart.c
index c37de68..1fb238b 100644
--- a/c/src/lib/libbsp/powerpc/mvme5500/startup/bspstart.c
+++ b/c/src/lib/libbsp/powerpc/mvme5500/startup/bspstart.c
@@ -41,7 +41,6 @@
 
 #include <rtems/bspIo.h>
 #include <rtems/counter.h>
-#include <rtems/sptables.h>
 
 /*
 #define SHOW_MORE_INIT_SETTINGS
diff --git a/cpukit/sapi/Makefile.am b/cpukit/sapi/Makefile.am
index 9170809..d6da88c 100644
--- a/cpukit/sapi/Makefile.am
+++ b/cpukit/sapi/Makefile.am
@@ -19,7 +19,6 @@ include_rtems_HEADERS += include/rtems/profiling.h
 include_rtems_HEADERS += include/rtems/rbheap.h
 include_rtems_HEADERS += include/rtems/rbtree.h
 include_rtems_HEADERS += include/rtems/scheduler.h
-include_rtems_HEADERS += include/rtems/sptables.h
 include_rtems_HEADERS += include/rtems/timecounter.h
 include_rtems_HEADERS += include/rtems/timespec.h
 
diff --git a/cpukit/sapi/include/rtems/config.h b/cpukit/sapi/include/rtems/config.h
index d73e9b8..1b48ea9 100644
--- a/cpukit/sapi/include/rtems/config.h
+++ b/cpukit/sapi/include/rtems/config.h
@@ -260,7 +260,7 @@ extern const rtems_configuration_table Configuration;
   /**
    *  This points to the multiprocessing configuration table.
    */
-  SAPI_EXTERN rtems_multiprocessing_table  *_Configuration_MP_table;
+  extern rtems_multiprocessing_table *_Configuration_MP_table;
 #endif
 
 #if defined(RTEMS_MULTIPROCESSING)
@@ -270,7 +270,14 @@ extern const rtems_configuration_table Configuration;
    * This is the RTEMS Multiprocessing Configuration Table expected to
    * be generated by confdefs.h.
    */
-  extern rtems_multiprocessing_table  Multiprocessing_configuration;
+  extern rtems_multiprocessing_table Multiprocessing_configuration;
+
+  /*
+   *  This is the default Multiprocessing Configuration Table.
+   *  It is used in single processor configurations.
+   */
+  extern const rtems_multiprocessing_table
+    _Initialization_Default_multiprocessing_table;
 #endif
 
 
diff --git a/cpukit/sapi/include/rtems/init.h b/cpukit/sapi/include/rtems/init.h
index b92bf85..fa3108e 100644
--- a/cpukit/sapi/include/rtems/init.h
+++ b/cpukit/sapi/include/rtems/init.h
@@ -36,15 +36,6 @@ extern "C" {
 #include <rtems/config.h>
 #include <rtems/rtems/intr.h>
 
-#if defined(RTEMS_MULTIPROCESSING)
-/**
- * The following defines the default Multiprocessing Configuration
- * Table.  This table is used in a single processor system.
- */
-extern const rtems_multiprocessing_table
-  _Initialization_Default_multiprocessing_table;
-#endif
-
 /**
  * @brief Initializes the system and starts multitasking.
  *
diff --git a/cpukit/sapi/include/rtems/sptables.h b/cpukit/sapi/include/rtems/sptables.h
deleted file mode 100644
index 733e613..0000000
--- a/cpukit/sapi/include/rtems/sptables.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * @file
- * 
- * @brief Pre-Initialized Tables Used when in a Single Processor Configuration
- *
- * This include file contains the executive's pre-initialized tables
- * used when in a single processor configuration.
- */
-
-/*
- *  COPYRIGHT (c) 1989-1999.
- *  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.
- */
-
-#ifndef _RTEMS_SPTABLES_H
-#define _RTEMS_SPTABLES_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <rtems/config.h>
-#include <rtems/fatal.h>
-#include <rtems/init.h>
-#include <rtems/io.h>
-
-#include <rtems/rtems/intr.h>
-#include <rtems/rtems/clock.h>
-#include <rtems/rtems/tasks.h>
-#include <rtems/rtems/dpmem.h>
-#include <rtems/rtems/event.h>
-#if defined(RTEMS_MULTIPROCESSING)
-#include <rtems/rtems/mp.h>
-#endif
-#include <rtems/rtems/part.h>
-#include <rtems/rtems/ratemon.h>
-#include <rtems/rtems/region.h>
-#include <rtems/rtems/signal.h>
-#include <rtems/rtems/timer.h>
-
-#if defined(RTEMS_MULTIPROCESSING)
-/*
- *  This is the default Multiprocessing Configuration Table.
- *  It is used in single processor configurations.
- */
-  #if defined(SAPI_INIT)
-    const rtems_multiprocessing_table
-	   _Initialization_Default_multiprocessing_table = {
-      1,                        /* local node number */
-      1,                        /* maximum number nodes in system */
-      0,                        /* maximum number global objects */
-      0,                        /* maximum number proxies */
-      STACK_MINIMUM_SIZE,       /* MPCI receive server stack size */
-      NULL,                     /* pointer to MPCI address table */
-    };
-  #else
-    extern const rtems_multiprocessing_table
-	   _Initialization_Default_multiprocessing_table;
-  #endif
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/cpukit/sapi/preinstall.am b/cpukit/sapi/preinstall.am
index 8a4e54f..969edfe 100644
--- a/cpukit/sapi/preinstall.am
+++ b/cpukit/sapi/preinstall.am
@@ -82,10 +82,6 @@ $(PROJECT_INCLUDE)/rtems/scheduler.h: include/rtems/scheduler.h $(PROJECT_INCLUD
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/scheduler.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/scheduler.h
 
-$(PROJECT_INCLUDE)/rtems/sptables.h: include/rtems/sptables.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
-	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/sptables.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/sptables.h
-
 $(PROJECT_INCLUDE)/rtems/timecounter.h: include/rtems/timecounter.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/timecounter.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/timecounter.h
diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c
index dca42d6..a52a546 100644
--- a/cpukit/sapi/src/exinit.c
+++ b/cpukit/sapi/src/exinit.c
@@ -20,11 +20,10 @@
 #endif
 
 /*
- *  SCORE_INIT and SAPI_INIT are defined so all of the super core and
- *  super API data will be included in this object file.
+ *  SCORE_INIT is defined so all of the super core
+ *  data will be included in this object file.
  */
 
-#define SAPI_INIT
 #define SCORE_INIT
 
 #include <rtems/system.h>
@@ -49,8 +48,6 @@
 #include <rtems/score/watchdogimpl.h>
 #include <rtems/score/wkspace.h>
 
-#include <rtems/sptables.h>
-
 static Objects_Information *
 _Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
 
@@ -76,31 +73,11 @@ static void rtems_initialize_data_structures(void)
    *           are disabled by boot_card().
    */
 
-  #if defined(RTEMS_MULTIPROCESSING)
-    /*
-     *  Initialize the system state based on whether this is an MP system.
-     *  In an MP configuration, internally we view single processor
-     *  systems as a very restricted multiprocessor system.
-     */
-    _Configuration_MP_table = rtems_configuration_get_user_multiprocessing_table();
-
-    if ( _Configuration_MP_table == NULL ) {
-      _Configuration_MP_table =
-	(void *)&_Initialization_Default_multiprocessing_table;
-    } else {
-      _System_state_Is_multiprocessing = true;
-    }
-  #endif
-
   /*
    * Initialize any target architecture specific support as early as possible
    */
   _CPU_Initialize();
 
-  #if defined(RTEMS_MULTIPROCESSING)
-    _Objects_MP_Handler_early_initialization();
-  #endif
-
   _Thread_Dispatch_initialization();
 
   _ISR_Handler_initialization();
@@ -115,21 +92,9 @@ static void rtems_initialize_data_structures(void)
 
   _Scheduler_Handler_initialization();
 
-  #if defined(RTEMS_MULTIPROCESSING)
-    _Objects_MP_Handler_initialization();
-    _MPCI_Handler_initialization( RTEMS_TIMEOUT );
-  #endif
-
   _SMP_Handler_initialize();
 }
 
-static void rtems_initialize_before_drivers(void)
-{
-  #if defined(RTEMS_MULTIPROCESSING)
-    _MPCI_Create_server();
-  #endif
-}
-
 static void rtems_initialize_device_drivers(void)
 {
   /*
@@ -146,15 +111,6 @@ static void rtems_initialize_device_drivers(void)
    */
   _IO_Initialize_all_drivers();
 
-  #if defined(RTEMS_MULTIPROCESSING)
-    if ( _System_state_Is_multiprocessing ) {
-      _MPCI_Initialization();
-      _MPCI_Internal_packets_Send_process_packet(
-	MPCI_PACKETS_SYSTEM_VERIFY
-      );
-    }
-  #endif
-
   /*
    *  Run the APIs and BSPs postdriver hooks.
    *
@@ -187,12 +143,6 @@ RTEMS_SYSINIT_ITEM(
 );
 
 RTEMS_SYSINIT_ITEM(
-  rtems_initialize_before_drivers,
-  RTEMS_SYSINIT_BEFORE_DRIVERS,
-  RTEMS_SYSINIT_ORDER_MIDDLE
-);
-
-RTEMS_SYSINIT_ITEM(
   rtems_initialize_device_drivers,
   RTEMS_SYSINIT_DEVICE_DRIVERS,
   RTEMS_SYSINIT_ORDER_MIDDLE
diff --git a/cpukit/score/include/rtems/score/basedefs.h b/cpukit/score/include/rtems/score/basedefs.h
index ea7d8c7..ef36e29 100644
--- a/cpukit/score/include/rtems/score/basedefs.h
+++ b/cpukit/score/include/rtems/score/basedefs.h
@@ -82,20 +82,6 @@
 #endif
 
 /**
- *  The following ensures that all data is declared in the space
- *  of the initialization routine for either the Initialization Manager
- *  or the initialization file for the appropriate API.  It is
- *  referenced as "external" in every other file.
- */
-#ifdef SAPI_INIT
-  #undef  SAPI_EXTERN
-  #define SAPI_EXTERN
-#else
-  #undef  SAPI_EXTERN
-  #define SAPI_EXTERN  extern
-#endif
-
-/**
  *  The following (in conjunction with compiler arguments) are used
  *  to choose between the use of static inline functions and macro
  *  functions.   The static inline implementation allows better
diff --git a/cpukit/score/include/rtems/score/mpciimpl.h b/cpukit/score/include/rtems/score/mpciimpl.h
index 600500c..33cb656 100644
--- a/cpukit/score/include/rtems/score/mpciimpl.h
+++ b/cpukit/score/include/rtems/score/mpciimpl.h
@@ -100,33 +100,6 @@ SCORE_EXTERN MPCI_Packet_processor
                _MPCI_Packet_processors[MP_PACKET_CLASSES_LAST+1];
 
 /**
- *  @brief Initialize the MPCI handler.
- *
- *  This routine performs the initialization necessary for this handler.
- *
- *  @param[in] timeout_status is the value which should be returned to
- *             blocking threads when they timeout on a remote operation.
- */
-void _MPCI_Handler_initialization(
-  uint32_t   timeout_status
-);
-
-/**
- *  @brief Create the MPCI server thread.
- *
- *  This routine creates the packet receive server used in MP systems.
- */
-void _MPCI_Create_server( void );
-
-/**
- *  @brief Initialize the MPCI driver.
- *
- *  This routine initializes the MPCI driver by
- *  invoking the user provided MPCI initialization callout.
- */
-void _MPCI_Initialization ( void );
-
-/**
  *  This routine registers the MPCI packet processor for the
  *  designated object class.
  *
diff --git a/cpukit/score/include/rtems/sysinit.h b/cpukit/score/include/rtems/sysinit.h
index 925593d..37f001a 100644
--- a/cpukit/score/include/rtems/sysinit.h
+++ b/cpukit/score/include/rtems/sysinit.h
@@ -29,8 +29,10 @@ extern "C" {
 #define RTEMS_SYSINIT_BSP_WORK_AREAS             000100
 #define RTEMS_SYSINIT_BSP_START                  000200
 #define RTEMS_SYSINIT_INITIAL_EXTENSIONS         000300
-#define RTEMS_SYSINIT_DATA_STRUCTURES            000301
+#define RTEMS_SYSINIT_MP_EARLY                   000301
+#define RTEMS_SYSINIT_DATA_STRUCTURES            000302
 #define RTEMS_SYSINIT_CPU_SET                    00030d
+#define RTEMS_SYSINIT_MP                         00030e
 #define RTEMS_SYSINIT_USER_EXTENSIONS            000320
 #define RTEMS_SYSINIT_CLASSIC_TASKS              000340
 #define RTEMS_SYSINIT_CLASSIC_TIMER              000341
@@ -59,13 +61,14 @@ extern "C" {
 #define RTEMS_SYSINIT_LIBIO                      000400
 #define RTEMS_SYSINIT_ROOT_FILESYSTEM            000401
 #define RTEMS_SYSINIT_DRVMGR                     000500
-#define RTEMS_SYSINIT_BEFORE_DRIVERS             000501
+#define RTEMS_SYSINIT_MP_SERVER                  000501
 #define RTEMS_SYSINIT_BSP_PRE_DRIVERS            000600
 #define RTEMS_SYSINIT_DRVMGR_LEVEL_1             000700
 #define RTEMS_SYSINIT_DEVICE_DRIVERS             000701
 #define RTEMS_SYSINIT_DRVMGR_LEVEL_2             000702
 #define RTEMS_SYSINIT_DRVMGR_LEVEL_3             000703
 #define RTEMS_SYSINIT_DRVMGR_LEVEL_4             000704
+#define RTEMS_SYSINIT_MP_FINALIZE                000705
 #define RTEMS_SYSINIT_STD_FILE_DESCRIPTORS       000800
 
 /*
diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c
index 5944da3..051366d 100644
--- a/cpukit/score/src/mpci.c
+++ b/cpukit/score/src/mpci.c
@@ -21,30 +21,65 @@
 #include <rtems/score/mpciimpl.h>
 #include <rtems/score/coresemimpl.h>
 #include <rtems/score/interr.h>
+#include <rtems/score/objectmp.h>
 #include <rtems/score/stackimpl.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/schedulerimpl.h>
 #include <rtems/score/threadimpl.h>
 #include <rtems/score/threadqimpl.h>
 #include <rtems/config.h>
+#include <rtems/sysinit.h>
 
 RTEMS_STATIC_ASSERT(
   sizeof(MPCI_Internal_packet) <= MP_PACKET_MINIMUM_PACKET_SIZE,
   MPCI_Internal_packet
 );
 
+rtems_multiprocessing_table *_Configuration_MP_table;
+
+const rtems_multiprocessing_table
+ _Initialization_Default_multiprocessing_table = {
+  1,                        /* local node number */
+  1,                        /* maximum number nodes in system */
+  0,                        /* maximum number global objects */
+  0,                        /* maximum number proxies */
+  STACK_MINIMUM_SIZE,       /* MPCI receive server stack size */
+  NULL                      /* pointer to MPCI address table */
+};
+
 /**
  *  This is the core semaphore which the MPCI Receive Server blocks on.
  */
 CORE_semaphore_Control _MPCI_Semaphore;
 
-void _MPCI_Handler_initialization(
-  uint32_t   timeout_status
-)
+static void _MPCI_Handler_early_initialization( void )
+{
+  /*
+   *  Initialize the system state based on whether this is an MP system.
+   *  In an MP configuration, internally we view single processor
+   *  systems as a very restricted multiprocessor system.
+   */
+  _Configuration_MP_table = rtems_configuration_get_user_multiprocessing_table();
+
+  if ( _Configuration_MP_table == NULL ) {
+    _Configuration_MP_table = RTEMS_DECONST(
+      rtems_multiprocessing_table *,
+      &_Initialization_Default_multiprocessing_table
+    );
+  } else {
+    _System_state_Is_multiprocessing = true;
+  }
+
+  _Objects_MP_Handler_early_initialization();
+}
+
+static void _MPCI_Handler_initialization( void )
 {
   CORE_semaphore_Attributes   attributes;
   MPCI_Control               *users_mpci_table;
 
+  _Objects_MP_Handler_initialization();
+
   users_mpci_table = _Configuration_MP_table->User_mpci_table;
 
   if ( _System_state_Is_multiprocessing && !users_mpci_table )
@@ -86,7 +121,7 @@ void _MPCI_Handler_initialization(
   );
 }
 
-void _MPCI_Create_server( void )
+static void _MPCI_Create_server( void )
 {
   Thread_Entry_information entry = {
     .adaptor = _Thread_Entry_adaptor_numeric,
@@ -129,7 +164,7 @@ void _MPCI_Create_server( void )
   _Thread_Start( _MPCI_Receive_server_tcb, &entry );
 }
 
-void _MPCI_Initialization ( void )
+static void _MPCI_Initialization( void )
 {
   (*_MPCI_table->initialization)();
 }
@@ -429,4 +464,36 @@ MPCI_Internal_packet *_MPCI_Internal_packets_Get_packet ( void )
   return ( (MPCI_Internal_packet *) _MPCI_Get_packet() );
 }
 
+static void _MPCI_Finalize( void )
+{
+  if ( _System_state_Is_multiprocessing ) {
+    _MPCI_Initialization();
+    _MPCI_Internal_packets_Send_process_packet( MPCI_PACKETS_SYSTEM_VERIFY );
+  }
+}
+
+RTEMS_SYSINIT_ITEM(
+  _MPCI_Handler_early_initialization,
+  RTEMS_SYSINIT_MP_EARLY,
+  RTEMS_SYSINIT_ORDER_MIDDLE
+);
+
+RTEMS_SYSINIT_ITEM(
+  _MPCI_Handler_initialization,
+  RTEMS_SYSINIT_MP,
+  RTEMS_SYSINIT_ORDER_MIDDLE
+);
+
+RTEMS_SYSINIT_ITEM(
+  _MPCI_Create_server,
+  RTEMS_SYSINIT_MP_SERVER,
+  RTEMS_SYSINIT_ORDER_MIDDLE
+);
+
+RTEMS_SYSINIT_ITEM(
+  _MPCI_Finalize,
+  RTEMS_SYSINIT_MP_FINALIZE,
+  RTEMS_SYSINIT_ORDER_MIDDLE
+);
+
 /* end of file */
diff --git a/testsuites/sptests/spsize/size.c b/testsuites/sptests/spsize/size.c
index b07f1a7..ffe9249 100644
--- a/testsuites/sptests/spsize/size.c
+++ b/testsuites/sptests/spsize/size.c
@@ -73,7 +73,6 @@ void print_formula(void);
  *
  * #include <rtems/copyrt.h>
  * #include <rtems/tables.h>
- * #include <rtems/sptables.h>
  */
 #define  HEAP_OVHD        16    /* wasted heap space per task stack */
 #define  NAME_PTR_SIZE     8    /* size of name and pointer table entries */
@@ -453,7 +452,7 @@ initialized +=
 /*copyrt.h*/    (strlen(_Copyright_Notice)+1)             +
 
 #if defined(RTEMS_MULTIPROCESSING)
-/*sptables.h*/  (sizeof _Initialization_Default_multiprocessing_table)  +
+                (sizeof _Initialization_Default_multiprocessing_table)  +
 #endif
                 (strlen(_RTEMS_version)+1);
 
diff --git a/testsuites/sptests/spsysinit01/init.c b/testsuites/sptests/spsysinit01/init.c
index 18727e1..cdaaacb 100644
--- a/testsuites/sptests/spsysinit01/init.c
+++ b/testsuites/sptests/spsysinit01/init.c
@@ -128,8 +128,6 @@ typedef enum {
   LIBIO_POST,
   ROOT_FILESYSTEM_PRE,
   ROOT_FILESYSTEM_POST,
-  BEFORE_DRIVERS_PRE,
-  BEFORE_DRIVERS_POST,
   BSP_PRE_DRIVERS_PRE,
   BSP_PRE_DRIVERS_POST,
   DEVICE_DRIVERS_PRE,
@@ -580,17 +578,6 @@ LAST(RTEMS_SYSINIT_ROOT_FILESYSTEM)
   next_step(ROOT_FILESYSTEM_POST);
 }
 
-FIRST(RTEMS_SYSINIT_BEFORE_DRIVERS)
-{
-  /* Omit test of build configuration specific pre and post conditions */
-  next_step(BEFORE_DRIVERS_PRE);
-}
-
-LAST(RTEMS_SYSINIT_BEFORE_DRIVERS)
-{
-  next_step(BEFORE_DRIVERS_POST);
-}
-
 FIRST(RTEMS_SYSINIT_BSP_PRE_DRIVERS)
 {
   /*
-- 
1.8.4.5




More information about the devel mailing list