mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 14:06:00 +08:00
config: Simplify initialization task config
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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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>
|
||||
#include <rtems/score/assert.h>
|
||||
#include <rtems/score/threadimpl.h>
|
||||
#include <rtems/score/interr.h>
|
||||
|
||||
/*
|
||||
* _RTEMS_tasks_Initialize_user_tasks_body
|
||||
*
|
||||
* This routine creates and starts all configured user
|
||||
* initialization threads.
|
||||
*
|
||||
* Input parameters: NONE
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*/
|
||||
|
||||
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;
|
||||
rtems_id id;
|
||||
rtems_status_code return_value;
|
||||
const rtems_initialization_tasks_table *user_task;
|
||||
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;
|
||||
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 );
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that we have a set of user tasks to iterate
|
||||
*/
|
||||
if ( !user_tasks )
|
||||
return;
|
||||
entry_point = user_task->entry_point;
|
||||
if ( entry_point == NULL ) {
|
||||
_Internal_error( INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 );
|
||||
}
|
||||
return_value = rtems_task_start(
|
||||
id,
|
||||
entry_point,
|
||||
user_task->argument
|
||||
);
|
||||
_Assert( rtems_is_status_successful( return_value ) );
|
||||
(void) return_value;
|
||||
|
||||
entry_point = user_tasks[ index ].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;
|
||||
|
||||
if ( _Thread_Global_constructor == 0 ) {
|
||||
_Thread_Global_constructor = id;
|
||||
}
|
||||
if ( _Thread_Global_constructor == 0 ) {
|
||||
_Thread_Global_constructor = id;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user