From 24f8915a079446918abd4f7b2a8e1b8385930f85 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 12 Dec 2019 07:11:54 +0100 Subject: config: Add _MPCI_Configuration Replace the user MPCI configuration table with a system provided _MPCI_Configuration. Update #3735. --- bsps/include/shm_driver.h | 2 +- cpukit/Makefile.am | 1 + cpukit/include/rtems/confdefs.h | 16 +++++---- cpukit/include/rtems/config.h | 63 ++---------------------------------- cpukit/include/rtems/rtems/types.h | 5 +++ cpukit/include/rtems/score/mpci.h | 34 +++++++++++++++++++ cpukit/libmisc/monitor/mon-monitor.c | 3 +- cpukit/libmisc/monitor/mon-mpci.c | 15 +++------ cpukit/libmisc/monitor/mon-server.c | 4 +-- cpukit/score/src/mpci.c | 26 ++------------- cpukit/score/src/mpcidefault.c | 31 ++++++++++++++++++ cpukit/score/src/objectmp.c | 6 ++-- cpukit/score/src/thread.c | 2 +- testsuites/sptests/spsize/size.c | 9 +----- 14 files changed, 99 insertions(+), 118 deletions(-) create mode 100644 cpukit/score/src/mpcidefault.c diff --git a/bsps/include/shm_driver.h b/bsps/include/shm_driver.h index 3dca866aa1..f81945b3d8 100644 --- a/bsps/include/shm_driver.h +++ b/bsps/include/shm_driver.h @@ -433,7 +433,7 @@ struct shm_config_info { typedef struct shm_config_info shm_config_table; -#define SHM_MAXIMUM_NODES Multiprocessing_configuration.maximum_nodes +#define SHM_MAXIMUM_NODES _MPCI_Configuration.maximum_nodes /* global variables */ diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index 0b0bede2ad..2983fc5b9e 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -1064,6 +1064,7 @@ librtemscpu_a_SOURCES += rtems/src/semmp.c librtemscpu_a_SOURCES += rtems/src/signalmp.c librtemscpu_a_SOURCES += rtems/src/taskmp.c librtemscpu_a_SOURCES += score/src/mpci.c +librtemscpu_a_SOURCES += score/src/mpcidefault.c librtemscpu_a_SOURCES += score/src/objectmp.c librtemscpu_a_SOURCES += score/src/threadmp.c diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h index 4e65f5df68..692470c024 100644 --- a/cpukit/include/rtems/confdefs.h +++ b/cpukit/include/rtems/confdefs.h @@ -1842,7 +1842,15 @@ extern rtems_initialization_tasks_table Initialization_tasks[]; #endif #ifdef CONFIGURE_INIT - rtems_multiprocessing_table Multiprocessing_configuration = { + #if CONFIGURE_MP_NODE_NUMBER < 1 + #error "CONFIGURE_MP_NODE_NUMBER must be greater than or equal to one" + #endif + + #if CONFIGURE_MP_NODE_NUMBER > CONFIGURE_MP_MAXIMUM_NODES + #error "CONFIGURE_MP_NODE_NUMBER must be less than or equal to CONFIGURE_MP_MAXIMUM_NODES" + #endif + + const MPCI_Configuration _MPCI_Configuration = { CONFIGURE_MP_NODE_NUMBER, /* local node number */ CONFIGURE_MP_MAXIMUM_NODES, /* maximum # nodes */ CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS, /* maximum # global objects */ @@ -1852,11 +1860,8 @@ extern rtems_initialization_tasks_table Initialization_tasks[]; }; #endif - #define CONFIGURE_MULTIPROCESSING_TABLE &Multiprocessing_configuration - #define _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT 1 #else - #define CONFIGURE_MULTIPROCESSING_TABLE NULL #define _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT 0 #endif /* CONFIGURE_MP_APPLICATION */ #else @@ -2878,9 +2883,6 @@ struct _reent *__getreent(void) false, #endif #endif - #if defined(RTEMS_MULTIPROCESSING) - CONFIGURE_MULTIPROCESSING_TABLE, /* pointer to MP config table */ - #endif #ifdef RTEMS_SMP _CONFIGURE_MAXIMUM_PROCESSORS, #endif diff --git a/cpukit/include/rtems/config.h b/cpukit/include/rtems/config.h index 23fad8d83c..15e944dd2f 100644 --- a/cpukit/include/rtems/config.h +++ b/cpukit/include/rtems/config.h @@ -35,7 +35,7 @@ #include #include #if defined(RTEMS_MULTIPROCESSING) -#include +#include #endif #ifdef __cplusplus @@ -53,35 +53,6 @@ extern "C" { #define rtems_resource_maximum_per_allocation(resource) \ _Objects_Maximum_per_allocation(resource) -#if defined(RTEMS_MULTIPROCESSING) -/* - * The following records define the Multiprocessor Configuration - * Table. This table defines the multiprocessor system - * characteristics which must be known by RTEMS in a multiprocessor - * system. - */ -typedef struct { - /** This is the local node number. */ - uint32_t node; - /** This is the maximum number of nodes in system. */ - uint32_t maximum_nodes; - /** This is the maximum number of global objects. */ - uint32_t maximum_global_objects; - /** This is the maximum number of proxies. */ - uint32_t maximum_proxies; - - /** - * The MPCI Receive server is assumed to have a stack of at least - * minimum stack size. This field specifies the amount of extra - * stack this task will be given in bytes. - */ - uint32_t extra_mpci_receive_server_stack; - - /** This is a pointer to User/BSP provided MPCI Table. */ - rtems_mpci_table *User_mpci_table; -} rtems_multiprocessing_table; -#endif - /** * @brief Task stack allocator initialization hook. * @@ -206,9 +177,6 @@ typedef struct { bool smp_enabled; #endif - #if defined(RTEMS_MULTIPROCESSING) - rtems_multiprocessing_table *User_multiprocessing_table; - #endif #ifdef RTEMS_SMP uint32_t maximum_processors; #endif @@ -219,31 +187,6 @@ typedef struct { */ extern const rtems_configuration_table Configuration; -#if defined(RTEMS_MULTIPROCESSING) - /** - * This points to the multiprocessing configuration table. - */ - extern rtems_multiprocessing_table *_Configuration_MP_table; -#endif - -#if defined(RTEMS_MULTIPROCESSING) - /** - * @brief RTEMS multiprocessing configuration table. - * - * This is the RTEMS Multiprocessing Configuration Table expected to - * be generated by confdefs.h. - */ - 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 - - /* * Some handy macros to avoid dependencies on either the BSP * or the exact format of the configuration table. @@ -308,10 +251,10 @@ uint32_t rtems_configuration_get_maximum_extensions( void ); #if defined(RTEMS_MULTIPROCESSING) #define rtems_configuration_get_user_multiprocessing_table() \ - (Configuration.User_multiprocessing_table) + (&_MPCI_Configuration) #else #define rtems_configuration_get_user_multiprocessing_table() \ - NULL + NULL #endif /** diff --git a/cpukit/include/rtems/rtems/types.h b/cpukit/include/rtems/rtems/types.h index 47c3b4c04e..b0600eb0a8 100644 --- a/cpukit/include/rtems/rtems/types.h +++ b/cpukit/include/rtems/rtems/types.h @@ -221,6 +221,11 @@ typedef MPCI_Entry rtems_mpci_entry; */ typedef MPCI_Control rtems_mpci_table; +/** + * @brief Structure which is used to configure an MPCI handler. + */ +typedef MPCI_Configuration rtems_multiprocessing_table; + #endif /** @} */ diff --git a/cpukit/include/rtems/score/mpci.h b/cpukit/include/rtems/score/mpci.h index e5bcdbaced..a72b1f0d5b 100644 --- a/cpukit/include/rtems/score/mpci.h +++ b/cpukit/include/rtems/score/mpci.h @@ -128,6 +128,40 @@ typedef struct { MPCI_receive_entry receive_packet; } MPCI_Control; +/* + * The following records define the Multiprocessor Configuration + * Table. This table defines the multiprocessor system + * characteristics which must be known by RTEMS in a multiprocessor + * system. + */ +typedef struct { + /** This is the local node number. */ + uint32_t node; + /** This is the maximum number of nodes in system. */ + uint32_t maximum_nodes; + /** This is the maximum number of global objects. */ + uint32_t maximum_global_objects; + /** This is the maximum number of proxies. */ + uint32_t maximum_proxies; + + /** + * The MPCI Receive server is assumed to have a stack of at least + * minimum stack size. This field specifies the amount of extra + * stack this task will be given in bytes. + */ + uint32_t extra_mpci_receive_server_stack; + + /** This is a pointer to User/BSP provided MPCI Table. */ + MPCI_Control *User_mpci_table; +} MPCI_Configuration; + +/** + * @brief The MPCI configuration. + * + * Provided by the application via . + */ +extern const MPCI_Configuration _MPCI_Configuration; + /** @} */ #ifdef __cplusplus diff --git a/cpukit/libmisc/monitor/mon-monitor.c b/cpukit/libmisc/monitor/mon-monitor.c index a990548e61..9c099dc57c 100644 --- a/cpukit/libmisc/monitor/mon-monitor.c +++ b/cpukit/libmisc/monitor/mon-monitor.c @@ -360,8 +360,7 @@ void rtems_monitor_node_cmd( } if ((new_node >= 1) && - _Configuration_MP_table && - (new_node <= _Configuration_MP_table->maximum_nodes)) + (new_node <= _MPCI_Configuration.maximum_nodes)) rtems_monitor_default_node = new_node; } #endif diff --git a/cpukit/libmisc/monitor/mon-mpci.c b/cpukit/libmisc/monitor/mon-mpci.c index 1ede142e52..9616518473 100644 --- a/cpukit/libmisc/monitor/mon-mpci.c +++ b/cpukit/libmisc/monitor/mon-mpci.c @@ -28,13 +28,10 @@ rtems_monitor_mpci_canonical( const void *config_void ) { - const rtems_configuration_table *c = &Configuration; - rtems_multiprocessing_table *m; - rtems_mpci_table *mt; + const rtems_multiprocessing_table *m; + const rtems_mpci_table *mt; - m = c->User_multiprocessing_table; - if (m == 0) - return; + m = rtems_configuration_get_user_multiprocessing_table(); mt = m->User_mpci_table; canonical_mpci->node = m->node; @@ -70,19 +67,15 @@ rtems_monitor_mpci_next( rtems_id *next_id ) { - const rtems_configuration_table *c = &Configuration; int n = rtems_object_id_get_index(*next_id); if (n >= 1) goto failed; - if ( ! c->User_multiprocessing_table) - goto failed; - _Objects_Allocator_lock(); *next_id += 1; - return (void *) c; + return &Configuration; failed: *next_id = RTEMS_OBJECT_ID_FINAL; diff --git a/cpukit/libmisc/monitor/mon-server.c b/cpukit/libmisc/monitor/mon-server.c index 3cb6cdf7ce..d8a1687f0b 100644 --- a/cpukit/libmisc/monitor/mon-server.c +++ b/cpukit/libmisc/monitor/mon-server.c @@ -221,9 +221,9 @@ rtems_monitor_server_init( rtems_status_code status; if (_System_state_Is_multiprocessing && - (_Configuration_MP_table->maximum_nodes > 1)) + (_MPCI_Configuration.maximum_nodes > 1)) { - uint32_t maximum_nodes = _Configuration_MP_table->maximum_nodes; + uint32_t maximum_nodes = _MPCI_Configuration.maximum_nodes; /* * create the msg que our server will listen diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c index f488325fc5..513d096480 100644 --- a/cpukit/score/src/mpci.c +++ b/cpukit/score/src/mpci.c @@ -27,7 +27,6 @@ #include #include #include -#include #include RTEMS_STATIC_ASSERT( @@ -39,18 +38,6 @@ RTEMS_STATIC_ASSERT( bool _System_state_Is_multiprocessing; -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. */ @@ -72,14 +59,7 @@ static void _MPCI_Handler_early_initialization( void ) * 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 { + if ( _MPCI_Configuration.maximum_nodes > 1 ) { _System_state_Is_multiprocessing = true; } @@ -92,7 +72,7 @@ static void _MPCI_Handler_initialization( void ) _Objects_MP_Handler_initialization(); - users_mpci_table = _Configuration_MP_table->User_mpci_table; + users_mpci_table = _MPCI_Configuration.User_mpci_table; if ( _System_state_Is_multiprocessing && !users_mpci_table ) _Internal_error( INTERNAL_ERROR_NO_MPCI ); @@ -152,7 +132,7 @@ static void _MPCI_Create_server( void ) NULL, /* allocate the stack */ _Stack_Minimum() + CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK + - _Configuration_MP_table->extra_mpci_receive_server_stack, + _MPCI_Configuration.extra_mpci_receive_server_stack, CPU_ALL_TASKS_ARE_FP, PRIORITY_PSEUDO_ISR, false, /* no preempt */ diff --git a/cpukit/score/src/mpcidefault.c b/cpukit/score/src/mpcidefault.c new file mode 100644 index 0000000000..60f1ef31a7 --- /dev/null +++ b/cpukit/score/src/mpcidefault.c @@ -0,0 +1,31 @@ +/** + * @file + * + * @brief Multiprocessing Communications Interface (MPCI) Default Configuration + * @ingroup RTEMSScoreMPCI + */ + +/* + * COPYRIGHT (c) 1989-2014. + * 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 + +#include +#include + +const MPCI_Configuration _MPCI_Configuration = { + 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 */ +}; diff --git a/cpukit/score/src/objectmp.c b/cpukit/score/src/objectmp.c index 74ed22033a..1910b8ccba 100644 --- a/cpukit/score/src/objectmp.c +++ b/cpukit/score/src/objectmp.c @@ -161,8 +161,8 @@ void _Objects_MP_Handler_early_initialization(void) uint32_t node; uint32_t maximum_nodes; - node = _Configuration_MP_table->node; - maximum_nodes = _Configuration_MP_table->maximum_nodes; + node = _MPCI_Configuration.node; + maximum_nodes = _MPCI_Configuration.maximum_nodes; if ( node < 1 || node > maximum_nodes ) _Internal_error( INTERNAL_ERROR_INVALID_NODE ); @@ -175,7 +175,7 @@ void _Objects_MP_Handler_initialization( void ) { uint32_t maximum_global_objects; - maximum_global_objects = _Configuration_MP_table->maximum_global_objects; + maximum_global_objects = _MPCI_Configuration.maximum_global_objects; _Objects_MP_Maximum_global_objects = maximum_global_objects; diff --git a/cpukit/score/src/thread.c b/cpukit/score/src/thread.c index 812d9296af..32a5132eee 100644 --- a/cpukit/score/src/thread.c +++ b/cpukit/score/src/thread.c @@ -62,7 +62,7 @@ void _Thread_Handler_initialization(void) rtems_configuration_get_stack_allocate_init_hook(); #if defined(RTEMS_MULTIPROCESSING) uint32_t maximum_proxies = - _Configuration_MP_table->maximum_proxies; + _MPCI_Configuration.maximum_proxies; #endif if ( rtems_configuration_get_stack_allocate_hook() == NULL || diff --git a/testsuites/sptests/spsize/size.c b/testsuites/sptests/spsize/size.c index 1369cd7072..578576cba7 100644 --- a/testsuites/sptests/spsize/size.c +++ b/testsuites/sptests/spsize/size.c @@ -250,10 +250,7 @@ uninitialized = /*clock.h*/ 0 + -/*config.h*/ - #if defined(RTEMS_MULTIPROCESSING) - (sizeof _Configuration_MP_table) + - #endif +/*config.h*/ 0 + /*context.h*/ (sizeof _Thread_Dispatch_necessary) + @@ -433,10 +430,6 @@ uninitialized += (sizeof _CPU_Interrupt_stack_low) + initialized += /*copyrt.h*/ (strlen(_Copyright_Notice)+1) + - -#if defined(RTEMS_MULTIPROCESSING) - (sizeof _Initialization_Default_multiprocessing_table) + -#endif (strlen(_RTEMS_version)+1); -- cgit v1.2.3