[PATCH v2 02/44] config: Simplify initialization task config
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Feb 21 10:52:14 UTC 2020
With the removal of the CONFIGURE_HAS_OWN_INIT_TASK_TABLE configuration
option at most one Classic API user initialization task can be
configured.
Provide an RTEMS API configuration table for backward compatibility.
Update #3873.
---
cpukit/Makefile.am | 2 +
cpukit/include/rtems/confdefs.h | 59 ++++---------------
cpukit/include/rtems/config.h | 3 -
cpukit/include/rtems/rtems/config.h | 13 ++---
cpukit/include/rtems/rtems/tasksdata.h | 19 +++---
cpukit/libmisc/monitor/mon-config.c | 4 +-
cpukit/libmisc/monitor/mon-itask.c | 8 ++-
cpukit/rtems/src/getapiconfig.c | 46 +++++++++++++++
cpukit/rtems/src/taskinitdefault.c | 34 +++++++++++
cpukit/rtems/src/taskinitusers.c | 102 +++++++++++----------------------
10 files changed, 148 insertions(+), 142 deletions(-)
create mode 100644 cpukit/rtems/src/getapiconfig.c
create mode 100644 cpukit/rtems/src/taskinitdefault.c
diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index 44a0868cd5..1d3935776b 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -697,6 +697,7 @@ librtemscpu_a_SOURCES += rtems/src/eventreceive.c
librtemscpu_a_SOURCES += rtems/src/eventseize.c
librtemscpu_a_SOURCES += rtems/src/eventsend.c
librtemscpu_a_SOURCES += rtems/src/eventsurrender.c
+librtemscpu_a_SOURCES += rtems/src/getapiconfig.c
librtemscpu_a_SOURCES += rtems/src/getcurrentprocessor.c
librtemscpu_a_SOURCES += rtems/src/getprocessorcount.c
librtemscpu_a_SOURCES += rtems/src/intrbody.c
@@ -789,6 +790,7 @@ librtemscpu_a_SOURCES += rtems/src/taskgetaffinity.c
librtemscpu_a_SOURCES += rtems/src/taskgetpriority.c
librtemscpu_a_SOURCES += rtems/src/taskgetscheduler.c
librtemscpu_a_SOURCES += rtems/src/taskident.c
+librtemscpu_a_SOURCES += rtems/src/taskinitdefault.c
librtemscpu_a_SOURCES += rtems/src/taskinitusers.c
librtemscpu_a_SOURCES += rtems/src/taskissuspended.c
librtemscpu_a_SOURCES += rtems/src/taskiterate.c
diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h
index b5f8de4cd1..13ba4466f0 100644
--- a/cpukit/include/rtems/confdefs.h
+++ b/cpukit/include/rtems/confdefs.h
@@ -103,11 +103,6 @@ extern "C" {
* used remarkably reliably by most applications.
*/
-/**
- * This is the Classic API initialization tasks table.
- */
-extern rtems_initialization_tasks_table Initialization_tasks[];
-
/**
* This macro determines whether the RTEMS reentrancy support for
* the Newlib C Library is enabled.
@@ -1362,42 +1357,8 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
#define CONFIGURE_INIT_TASK_ARGUMENTS 0
#endif
-#ifdef CONFIGURE_INIT
- rtems_initialization_tasks_table Initialization_tasks[] = {
- { CONFIGURE_INIT_TASK_NAME,
- CONFIGURE_INIT_TASK_STACK_SIZE,
- CONFIGURE_INIT_TASK_PRIORITY,
- CONFIGURE_INIT_TASK_ATTRIBUTES,
- CONFIGURE_INIT_TASK_ENTRY_POINT,
- CONFIGURE_INIT_TASK_INITIAL_MODES,
- CONFIGURE_INIT_TASK_ARGUMENTS
- }
- };
-#endif
-
-/**
- * This is the name of the Initialization Tasks Table generated.
- */
-#define CONFIGURE_INIT_TASK_TABLE Initialization_tasks
-
-/*
- * This is the size of the Initialization Tasks Table generated.
- */
-#define CONFIGURE_INIT_TASK_TABLE_SIZE \
- RTEMS_ARRAY_SIZE(CONFIGURE_INIT_TASK_TABLE)
-
#else /* CONFIGURE_RTEMS_INIT_TASKS_TABLE */
-/*
- * This is the name of the Initialization Task when none is configured.
- */
-#define CONFIGURE_INIT_TASK_TABLE NULL
-
-/*
- * This is the size of the Initialization Task when none is configured.
- */
-#define CONFIGURE_INIT_TASK_TABLE_SIZE 0
-
/*
* This is the stack size of the Initialization Task when none is configured.
*/
@@ -2580,14 +2541,6 @@ struct _reent *__getreent(void)
EXTENSION_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_USER_EXTENSIONS );
#endif
- /**
- * This is the Classic API Configuration Table.
- */
- rtems_api_configuration_table Configuration_RTEMS_API = {
- CONFIGURE_INIT_TASK_TABLE_SIZE,
- CONFIGURE_INIT_TASK_TABLE
- };
-
#if CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS > 0
POSIX_Keys_Key_value_pair _POSIX_Keys_Key_value_pairs[
rtems_resource_maximum_per_allocation(
@@ -2779,8 +2732,18 @@ struct _reent *__getreent(void)
*/
#ifdef CONFIGURE_INIT
#if defined(CONFIGURE_RTEMS_INIT_TASKS_TABLE)
+ const rtems_initialization_tasks_table _RTEMS_tasks_User_task_table = {
+ CONFIGURE_INIT_TASK_NAME,
+ CONFIGURE_INIT_TASK_STACK_SIZE,
+ CONFIGURE_INIT_TASK_PRIORITY,
+ CONFIGURE_INIT_TASK_ATTRIBUTES,
+ CONFIGURE_INIT_TASK_ENTRY_POINT,
+ CONFIGURE_INIT_TASK_INITIAL_MODES,
+ CONFIGURE_INIT_TASK_ARGUMENTS
+ };
+
RTEMS_SYSINIT_ITEM(
- _RTEMS_tasks_Initialize_user_tasks_body,
+ _RTEMS_tasks_Initialize_user_task,
RTEMS_SYSINIT_CLASSIC_USER_TASKS,
RTEMS_SYSINIT_ORDER_MIDDLE
);
diff --git a/cpukit/include/rtems/config.h b/cpukit/include/rtems/config.h
index 51e437f48a..24a654e39c 100644
--- a/cpukit/include/rtems/config.h
+++ b/cpukit/include/rtems/config.h
@@ -248,9 +248,6 @@ uint32_t rtems_configuration_get_maximum_extensions( void );
1
#endif
-#define rtems_configuration_get_rtems_api_configuration() \
- (&Configuration_RTEMS_API)
-
#ifdef __cplusplus
}
#endif
diff --git a/cpukit/include/rtems/rtems/config.h b/cpukit/include/rtems/rtems/config.h
index 63449be922..a5078f6bb6 100644
--- a/cpukit/include/rtems/rtems/config.h
+++ b/cpukit/include/rtems/rtems/config.h
@@ -55,17 +55,9 @@ typedef struct {
* This field is the set of Classic API Initialization
* Tasks which are configured for this application.
*/
- rtems_initialization_tasks_table *User_initialization_tasks_table;
+ const rtems_initialization_tasks_table *User_initialization_tasks_table;
} rtems_api_configuration_table;
-/**
- * @brief RTEMS API Configuration Table
- *
- * This is the RTEMS API Configuration Table expected to be generated
- * by confdefs.h.
- */
-extern rtems_api_configuration_table Configuration_RTEMS_API;
-
/**@}*/
uint32_t rtems_configuration_get_maximum_barriers( void );
@@ -86,6 +78,9 @@ uint32_t rtems_configuration_get_maximum_timers( void );
uint32_t rtems_configuration_get_maximum_tasks( void );
+const rtems_api_configuration_table *
+rtems_configuration_get_rtems_api_configuration( void );
+
#ifdef __cplusplus
}
#endif
diff --git a/cpukit/include/rtems/rtems/tasksdata.h b/cpukit/include/rtems/rtems/tasksdata.h
index 19e6a8a618..55090f71b0 100644
--- a/cpukit/include/rtems/rtems/tasksdata.h
+++ b/cpukit/include/rtems/rtems/tasksdata.h
@@ -53,19 +53,18 @@ typedef struct {
} RTEMS_API_Control;
/**
- * @brief _RTEMS_tasks_Initialize_user_tasks_body
+ * @brief Initialization table for the first user task.
*
- * This routine creates and starts all configured user
- * initialization threads.
- *
- * Input parameters: NONE
- *
- * Output parameters: NONE
- *
- * RTEMS Task Manager
+ * This table is used by _RTEMS_tasks_Initialize_user_task() and initialized
+ * via <rtems/confdefs.h>.
*/
+extern const rtems_initialization_tasks_table _RTEMS_tasks_User_task_table;
-extern void _RTEMS_tasks_Initialize_user_tasks_body( void );
+/**
+ * @brief System initialization handler to create and start the first user
+ * task.
+ */
+extern void _RTEMS_tasks_Initialize_user_task( void );
/**
* The following instantiates the information control block used to
diff --git a/cpukit/libmisc/monitor/mon-config.c b/cpukit/libmisc/monitor/mon-config.c
index 95b7798173..d7728de33a 100644
--- a/cpukit/libmisc/monitor/mon-config.c
+++ b/cpukit/libmisc/monitor/mon-config.c
@@ -29,7 +29,9 @@ rtems_monitor_config_canonical(
const void *config_void
)
{
- rtems_api_configuration_table *r = &Configuration_RTEMS_API;
+ const rtems_api_configuration_table *r;
+
+ r = rtems_configuration_get_rtems_api_configuration();
canonical_config->work_space_size = rtems_configuration_get_work_space_size();
canonical_config->maximum_tasks = rtems_configuration_get_maximum_tasks();
diff --git a/cpukit/libmisc/monitor/mon-itask.c b/cpukit/libmisc/monitor/mon-itask.c
index 39103320ab..f4d3aea170 100644
--- a/cpukit/libmisc/monitor/mon-itask.c
+++ b/cpukit/libmisc/monitor/mon-itask.c
@@ -40,15 +40,17 @@ rtems_monitor_init_task_next(
rtems_id *next_id
)
{
- rtems_initialization_tasks_table *itask;
+ const rtems_api_configuration_table *config;
+ const rtems_initialization_tasks_table *itask;
uint32_t n = rtems_object_id_get_index(*next_id);
- if (n >= Configuration_RTEMS_API.number_of_initialization_tasks)
+ config = rtems_configuration_get_rtems_api_configuration();
+ if (n >= config->number_of_initialization_tasks)
goto failed;
_Objects_Allocator_lock();
- itask = Configuration_RTEMS_API.User_initialization_tasks_table + n;
+ itask = config->User_initialization_tasks_table + n;
/*
* dummy up a fake id and name for this item
diff --git a/cpukit/rtems/src/getapiconfig.c b/cpukit/rtems/src/getapiconfig.c
new file mode 100644
index 0000000000..77c60cfe1c
--- /dev/null
+++ b/cpukit/rtems/src/getapiconfig.c
@@ -0,0 +1,46 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/rtems/config.h>
+#include <rtems/rtems/tasksdata.h>
+
+static rtems_api_configuration_table config;
+
+const rtems_api_configuration_table *
+rtems_configuration_get_rtems_api_configuration( void )
+{
+ if ( _RTEMS_tasks_User_task_table.entry_point != NULL ) {
+ config.number_of_initialization_tasks = 1;
+ config.User_initialization_tasks_table = &_RTEMS_tasks_User_task_table;
+ }
+
+ return &config;
+}
diff --git a/cpukit/rtems/src/taskinitdefault.c b/cpukit/rtems/src/taskinitdefault.c
new file mode 100644
index 0000000000..b0ac3360ab
--- /dev/null
+++ b/cpukit/rtems/src/taskinitdefault.c
@@ -0,0 +1,34 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/rtems/tasks.h>
+
+const rtems_initialization_tasks_table _RTEMS_tasks_User_task_table;
diff --git a/cpukit/rtems/src/taskinitusers.c b/cpukit/rtems/src/taskinitusers.c
index f72428d77c..0645de324a 100644
--- a/cpukit/rtems/src/taskinitusers.c
+++ b/cpukit/rtems/src/taskinitusers.c
@@ -18,79 +18,45 @@
#include "config.h"
#endif
-#include <rtems/config.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/support.h>
-#include <rtems/rtems/modes.h>
-#include <rtems/score/assert.h>
-#include <rtems/score/stack.h>
#include <rtems/rtems/tasksimpl.h>
-#include <rtems/score/thread.h>
-#include <rtems/score/wkspace.h>
-
-/*
- * _RTEMS_tasks_Initialize_user_tasks_body
- *
- * This routine creates and starts all configured user
- * initialization threads.
- *
- * Input parameters: NONE
- *
- * Output parameters: NONE
- */
+#include <rtems/score/assert.h>
+#include <rtems/score/threadimpl.h>
+#include <rtems/score/interr.h>
-void _RTEMS_tasks_Initialize_user_tasks_body( void )
+void _RTEMS_tasks_Initialize_user_task( void )
{
- uint32_t index;
- uint32_t maximum;
- rtems_id id;
- rtems_status_code return_value;
- rtems_initialization_tasks_table *user_tasks;
- rtems_task_entry entry_point;
-
- /*
- * Move information into local variables
- */
- user_tasks = Configuration_RTEMS_API.User_initialization_tasks_table;
- maximum = Configuration_RTEMS_API.number_of_initialization_tasks;
-
- /*
- * Verify that we have a set of user tasks to iterate
- */
- if ( !user_tasks )
- return;
-
- /*
- * Now iterate over the initialization tasks and create/start them.
- */
- for ( index=0 ; index < maximum ; index++ ) {
- return_value = rtems_task_create(
- user_tasks[ index ].name,
- user_tasks[ index ].initial_priority,
- user_tasks[ index ].stack_size,
- user_tasks[ index ].mode_set,
- user_tasks[ index ].attribute_set,
- &id
- );
- if ( !rtems_is_status_successful( return_value ) ) {
- _Internal_error( INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED );
- }
+ rtems_id id;
+ rtems_status_code return_value;
+ const rtems_initialization_tasks_table *user_task;
+ rtems_task_entry entry_point;
+
+ user_task = &_RTEMS_tasks_User_task_table;
+ return_value = rtems_task_create(
+ user_task->name,
+ user_task->initial_priority,
+ user_task->stack_size,
+ user_task->mode_set,
+ user_task->attribute_set,
+ &id
+ );
+ if ( !rtems_is_status_successful( return_value ) ) {
+ _Internal_error( INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED );
+ }
- entry_point = user_tasks[ index ].entry_point;
- if ( entry_point == NULL ) {
- _Internal_error( INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL );
- }
+ entry_point = user_task->entry_point;
+ if ( entry_point == NULL ) {
+ _Internal_error( INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL );
+ }
- return_value = rtems_task_start(
- id,
- entry_point,
- user_tasks[ index ].argument
- );
- _Assert( rtems_is_status_successful( return_value ) );
- (void) return_value;
+ return_value = rtems_task_start(
+ id,
+ entry_point,
+ user_task->argument
+ );
+ _Assert( rtems_is_status_successful( return_value ) );
+ (void) return_value;
- if ( _Thread_Global_constructor == 0 ) {
- _Thread_Global_constructor = id;
- }
+ if ( _Thread_Global_constructor == 0 ) {
+ _Thread_Global_constructor = id;
}
}
--
2.16.4
More information about the devel
mailing list