mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 09:05:06 +08:00
userext: Simplify configuration
Avoid the use of the workspace and use statically allocated switch controls for the initial extensions.
This commit is contained in:
@@ -2124,7 +2124,7 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
|
||||
defined(CONFIGURE_INITIAL_EXTENSIONS) || \
|
||||
defined(CONFIGURE_STACK_CHECKER_ENABLED) || \
|
||||
(defined(RTEMS_NEWLIB) && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY))
|
||||
static const rtems_extensions_table Configuration_Initial_Extensions[] = {
|
||||
const User_extensions_Table _User_extensions_Initial_extensions[] = {
|
||||
#if CONFIGURE_RECORD_PER_PROCESSOR_ITEMS > 0 && \
|
||||
defined(CONFIGURE_RECORD_EXTENSIONS_ENABLED)
|
||||
RECORD_EXTENSION,
|
||||
@@ -2143,18 +2143,18 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
|
||||
#endif
|
||||
};
|
||||
|
||||
#define _CONFIGURE_INITIAL_EXTENSION_TABLE Configuration_Initial_Extensions
|
||||
#define _CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS \
|
||||
RTEMS_ARRAY_SIZE(Configuration_Initial_Extensions)
|
||||
const size_t _User_extensions_Initial_count =
|
||||
RTEMS_ARRAY_SIZE( _User_extensions_Initial_extensions );
|
||||
|
||||
User_extensions_Switch_control _User_extensions_Initial_switch_controls[
|
||||
RTEMS_ARRAY_SIZE( _User_extensions_Initial_extensions )
|
||||
];
|
||||
|
||||
RTEMS_SYSINIT_ITEM(
|
||||
_User_extensions_Handler_initialization,
|
||||
RTEMS_SYSINIT_INITIAL_EXTENSIONS,
|
||||
RTEMS_SYSINIT_ORDER_MIDDLE
|
||||
);
|
||||
#else
|
||||
#define _CONFIGURE_INITIAL_EXTENSION_TABLE NULL
|
||||
#define _CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS 0
|
||||
#endif
|
||||
|
||||
#if defined(RTEMS_NEWLIB) && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY)
|
||||
@@ -2486,17 +2486,6 @@ struct _reent *__getreent(void)
|
||||
#define _CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD \
|
||||
_CONFIGURE_MEMORY_FOR_INTERNAL_TASKS
|
||||
|
||||
/**
|
||||
* This macro reserves the memory required by the statically configured
|
||||
* user extensions.
|
||||
*/
|
||||
#define _CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS \
|
||||
(_CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS == 0 ? 0 : \
|
||||
_Configure_From_workspace( \
|
||||
_CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS \
|
||||
* sizeof(User_extensions_Switch_control) \
|
||||
))
|
||||
|
||||
/**
|
||||
* This calculates the memory required for the executive workspace.
|
||||
*
|
||||
@@ -2517,7 +2506,6 @@ struct _reent *__getreent(void)
|
||||
_CONFIGURE_MEMORY_FOR_POSIX_SHMS( \
|
||||
CONFIGURE_MAXIMUM_POSIX_SHMS) + \
|
||||
_CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS + \
|
||||
_CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS + \
|
||||
_CONFIGURE_MEMORY_FOR_MP + \
|
||||
CONFIGURE_MESSAGE_BUFFER_MEMORY + \
|
||||
(CONFIGURE_MEMORY_OVERHEAD * 1024) + \
|
||||
@@ -2923,8 +2911,6 @@ struct _reent *__getreent(void)
|
||||
false,
|
||||
#endif
|
||||
#endif
|
||||
_CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS, /* number of static extensions */
|
||||
_CONFIGURE_INITIAL_EXTENSION_TABLE, /* pointer to static extensions */
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
CONFIGURE_MULTIPROCESSING_TABLE, /* pointer to MP config table */
|
||||
#endif
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <rtems/score/object.h>
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/score/userextdata.h>
|
||||
#include <rtems/score/watchdogticks.h>
|
||||
#include <rtems/rtems/config.h>
|
||||
#include <rtems/posix/config.h>
|
||||
@@ -206,7 +207,6 @@ typedef struct {
|
||||
#endif
|
||||
|
||||
uint32_t number_of_initial_extensions;
|
||||
const rtems_extensions_table *User_extension_table;
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
rtems_multiprocessing_table *User_multiprocessing_table;
|
||||
#endif
|
||||
@@ -302,10 +302,10 @@ uint32_t rtems_configuration_get_maximum_extensions( void );
|
||||
(Configuration.do_zero_of_workspace)
|
||||
|
||||
#define rtems_configuration_get_number_of_initial_extensions() \
|
||||
(Configuration.number_of_initial_extensions)
|
||||
((uint32_t) _User_extensions_Initial_count)
|
||||
|
||||
#define rtems_configuration_get_user_extension_table() \
|
||||
(Configuration.User_extension_table)
|
||||
(&_User_extensions_Initial_extensions[ 0 ])
|
||||
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
#define rtems_configuration_get_user_multiprocessing_table() \
|
||||
|
||||
@@ -53,6 +53,28 @@ typedef struct {
|
||||
User_extensions_Table Callouts;
|
||||
} User_extensions_Control;
|
||||
|
||||
/**
|
||||
* @brief The count of initial user extensions.
|
||||
*
|
||||
* Application provided via <rtems/confdefs.h>.
|
||||
*/
|
||||
extern const size_t _User_extensions_Initial_count;
|
||||
|
||||
/**
|
||||
* @brief The table of initial user extensions.
|
||||
*
|
||||
* Application provided via <rtems/confdefs.h>.
|
||||
*/
|
||||
extern const User_extensions_Table _User_extensions_Initial_extensions[];
|
||||
|
||||
/**
|
||||
* @brief A spare switch control for each initial user extension.
|
||||
*
|
||||
* Application provided via <rtems/confdefs.h>.
|
||||
*/
|
||||
extern User_extensions_Switch_control
|
||||
_User_extensions_Initial_switch_controls[];
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -19,24 +19,18 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/config.h>
|
||||
#include <rtems/score/userextimpl.h>
|
||||
#include <rtems/score/wkspace.h>
|
||||
|
||||
void _User_extensions_Handler_initialization(void)
|
||||
{
|
||||
User_extensions_Switch_control *initial_extension_switch_controls;
|
||||
const User_extensions_Table *initial_table;
|
||||
uint32_t n;
|
||||
uint32_t i;
|
||||
User_extensions_Switch_control *initial_switch_controls;
|
||||
size_t n;
|
||||
size_t i;
|
||||
|
||||
n = rtems_configuration_get_number_of_initial_extensions();
|
||||
|
||||
initial_extension_switch_controls = _Workspace_Allocate_or_fatal_error(
|
||||
n * sizeof( *initial_extension_switch_controls )
|
||||
);
|
||||
|
||||
initial_table = rtems_configuration_get_user_extension_table();
|
||||
initial_table = _User_extensions_Initial_extensions;
|
||||
initial_switch_controls = _User_extensions_Initial_switch_controls;
|
||||
n = _User_extensions_Initial_count;
|
||||
|
||||
for ( i = 0 ; i < n ; ++i ) {
|
||||
User_extensions_thread_switch_extension callout;
|
||||
@@ -46,7 +40,7 @@ void _User_extensions_Handler_initialization(void)
|
||||
if ( callout != NULL ) {
|
||||
User_extensions_Switch_control *c;
|
||||
|
||||
c = &initial_extension_switch_controls[ i ];
|
||||
c = &initial_switch_controls[ i ];
|
||||
c->thread_switch = callout;
|
||||
_Chain_Initialize_node( &c->Node );
|
||||
_Chain_Append_unprotected( &_User_extensions_Switches_list, &c->Node );
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012, 2017 embedded brains GmbH. All rights reserved.
|
||||
* Copyright (c) 2012, 2019 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/config.h>
|
||||
#include <rtems/score/userextimpl.h>
|
||||
|
||||
#include <pthread.h>
|
||||
@@ -164,9 +163,8 @@ void _User_extensions_Iterate(
|
||||
|
||||
executing = _Thread_Get_executing();
|
||||
|
||||
initial_begin = rtems_configuration_get_user_extension_table();
|
||||
initial_end =
|
||||
initial_begin + rtems_configuration_get_number_of_initial_extensions();
|
||||
initial_begin = _User_extensions_Initial_extensions;
|
||||
initial_end = initial_begin + _User_extensions_Initial_count;
|
||||
|
||||
if ( direction == CHAIN_ITERATOR_FORWARD ) {
|
||||
initial_current = initial_begin;
|
||||
|
||||
Reference in New Issue
Block a user