forked from Imagelibrary/rtems
score: Split stack allocator configuration
This allows the linker garbage collection to perform its work. Update #3835.
This commit is contained in:
@@ -922,6 +922,7 @@ librtemscpu_a_SOURCES += score/src/schedulercbsgetserverid.c
|
|||||||
librtemscpu_a_SOURCES += score/src/schedulercbssetparameters.c
|
librtemscpu_a_SOURCES += score/src/schedulercbssetparameters.c
|
||||||
librtemscpu_a_SOURCES += score/src/schedulercbsreleasejob.c
|
librtemscpu_a_SOURCES += score/src/schedulercbsreleasejob.c
|
||||||
librtemscpu_a_SOURCES += score/src/schedulercbsunblock.c
|
librtemscpu_a_SOURCES += score/src/schedulercbsunblock.c
|
||||||
|
librtemscpu_a_SOURCES += score/src/stackallocator.c
|
||||||
librtemscpu_a_SOURCES += score/src/pheapallocate.c
|
librtemscpu_a_SOURCES += score/src/pheapallocate.c
|
||||||
librtemscpu_a_SOURCES += score/src/pheapextend.c
|
librtemscpu_a_SOURCES += score/src/pheapextend.c
|
||||||
librtemscpu_a_SOURCES += score/src/pheapfree.c
|
librtemscpu_a_SOURCES += score/src/pheapfree.c
|
||||||
|
|||||||
@@ -1202,34 +1202,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
|
|||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the very much optional task stack allocator initialization
|
|
||||||
*/
|
|
||||||
#ifndef CONFIGURE_TASK_STACK_ALLOCATOR_INIT
|
|
||||||
#define CONFIGURE_TASK_STACK_ALLOCATOR_INIT NULL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Configure the very much optional task stack allocator and deallocator.
|
|
||||||
*/
|
|
||||||
#if !defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
|
|
||||||
&& !defined(CONFIGURE_TASK_STACK_DEALLOCATOR)
|
|
||||||
/**
|
|
||||||
* This specifies the task stack allocator method.
|
|
||||||
*/
|
|
||||||
#define CONFIGURE_TASK_STACK_ALLOCATOR _Workspace_Allocate
|
|
||||||
/**
|
|
||||||
* This specifies the task stack deallocator method.
|
|
||||||
*/
|
|
||||||
#define CONFIGURE_TASK_STACK_DEALLOCATOR _Workspace_Free
|
|
||||||
#elif (defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
|
|
||||||
&& !defined(CONFIGURE_TASK_STACK_DEALLOCATOR)) \
|
|
||||||
|| (!defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
|
|
||||||
&& defined(CONFIGURE_TASK_STACK_DEALLOCATOR))
|
|
||||||
#error "CONFIGURE_TASK_STACK_ALLOCATOR and CONFIGURE_TASK_STACK_DEALLOCATOR must be both defined or both undefined"
|
|
||||||
#endif
|
|
||||||
/**@}*/ /* end of thread/interrupt stack configuration */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup Configuration
|
* @addtogroup Configuration
|
||||||
*/
|
*/
|
||||||
@@ -2728,6 +2700,31 @@ struct _reent *__getreent(void)
|
|||||||
|
|
||||||
const uintptr_t _Stack_Space_size = _CONFIGURE_STACK_SPACE_SIZE;
|
const uintptr_t _Stack_Space_size = _CONFIGURE_STACK_SPACE_SIZE;
|
||||||
|
|
||||||
|
#if defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
|
||||||
|
&& defined(CONFIGURE_TASK_STACK_DEALLOCATOR)
|
||||||
|
#ifdef CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE
|
||||||
|
const bool _Stack_Allocator_avoids_workspace = true;
|
||||||
|
#else
|
||||||
|
const bool _Stack_Allocator_avoids_workspace = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIGURE_TASK_STACK_ALLOCATOR_INIT
|
||||||
|
const Stack_Allocator_initialize _Stack_Allocator_initialize =
|
||||||
|
CONFIGURE_TASK_STACK_ALLOCATOR_INIT;
|
||||||
|
#else
|
||||||
|
const Stack_Allocator_initialize _Stack_Allocator_initialize = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const Stack_Allocator_allocate _Stack_Allocator_allocate =
|
||||||
|
CONFIGURE_TASK_STACK_ALLOCATOR;
|
||||||
|
|
||||||
|
const Stack_Allocator_free _Stack_Allocator_free =
|
||||||
|
CONFIGURE_TASK_STACK_DEALLOCATOR;
|
||||||
|
#elif defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
|
||||||
|
|| defined(CONFIGURE_TASK_STACK_DEALLOCATOR)
|
||||||
|
#error "CONFIGURE_TASK_STACK_ALLOCATOR and CONFIGURE_TASK_STACK_DEALLOCATOR must be both defined or both undefined"
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the primary Configuration Table for this application.
|
* This is the primary Configuration Table for this application.
|
||||||
*/
|
*/
|
||||||
@@ -2738,21 +2735,11 @@ struct _reent *__getreent(void)
|
|||||||
CONFIGURE_TICKS_PER_TIMESLICE, /* ticks per timeslice quantum */
|
CONFIGURE_TICKS_PER_TIMESLICE, /* ticks per timeslice quantum */
|
||||||
CONFIGURE_IDLE_TASK_BODY, /* user's IDLE task */
|
CONFIGURE_IDLE_TASK_BODY, /* user's IDLE task */
|
||||||
CONFIGURE_IDLE_TASK_STACK_SIZE, /* IDLE task stack size */
|
CONFIGURE_IDLE_TASK_STACK_SIZE, /* IDLE task stack size */
|
||||||
CONFIGURE_TASK_STACK_ALLOCATOR_INIT, /* stack allocator init */
|
|
||||||
CONFIGURE_TASK_STACK_ALLOCATOR, /* stack allocator */
|
|
||||||
CONFIGURE_TASK_STACK_DEALLOCATOR, /* stack deallocator */
|
|
||||||
#ifdef CONFIGURE_UNIFIED_WORK_AREAS /* true for unified work areas */
|
#ifdef CONFIGURE_UNIFIED_WORK_AREAS /* true for unified work areas */
|
||||||
true,
|
true,
|
||||||
#else
|
#else
|
||||||
false,
|
false,
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE /* true to avoid
|
|
||||||
work space for thread stack
|
|
||||||
allocation */
|
|
||||||
true,
|
|
||||||
#else
|
|
||||||
false,
|
|
||||||
#endif
|
|
||||||
#ifdef RTEMS_SMP
|
#ifdef RTEMS_SMP
|
||||||
#ifdef _CONFIGURE_SMP_APPLICATION
|
#ifdef _CONFIGURE_SMP_APPLICATION
|
||||||
true,
|
true,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
#include <rtems/score/isr.h>
|
#include <rtems/score/isr.h>
|
||||||
#include <rtems/score/memory.h>
|
#include <rtems/score/memory.h>
|
||||||
|
#include <rtems/score/stack.h>
|
||||||
#include <rtems/score/userextdata.h>
|
#include <rtems/score/userextdata.h>
|
||||||
#include <rtems/score/watchdogticks.h>
|
#include <rtems/score/watchdogticks.h>
|
||||||
#include <rtems/rtems/config.h>
|
#include <rtems/rtems/config.h>
|
||||||
@@ -55,28 +56,19 @@ extern "C" {
|
|||||||
_Objects_Maximum_per_allocation(resource)
|
_Objects_Maximum_per_allocation(resource)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Task stack allocator initialization hook.
|
* @copydoc Stack_Allocator_initialize
|
||||||
*
|
|
||||||
* @param[in] stack_space_size is the size of the stack space in bytes.
|
|
||||||
*/
|
*/
|
||||||
typedef void (*rtems_stack_allocate_init_hook)( size_t stack_space_size );
|
typedef Stack_Allocator_initialize rtems_stack_allocate_init_hook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Task stack allocator hook.
|
* @copydoc Stack_Allocator_allocate
|
||||||
*
|
|
||||||
* @param[in] stack_size is the Size of the task stack in bytes.
|
|
||||||
*
|
|
||||||
* @retval NULL Not enough memory.
|
|
||||||
* @retval other Pointer to task stack.
|
|
||||||
*/
|
*/
|
||||||
typedef void *(*rtems_stack_allocate_hook)( size_t stack_size );
|
typedef Stack_Allocator_allocate rtems_stack_allocate_hook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Task stack deallocator hook.
|
* @copydoc Stack_Allocator_free
|
||||||
*
|
|
||||||
* @param[in] addr is a pointer to previously allocated task stack.
|
|
||||||
*/
|
*/
|
||||||
typedef void (*rtems_stack_free_hook)( void *addr );
|
typedef Stack_Allocator_free rtems_stack_free_hook;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following records define the Configuration Table. The
|
* The following records define the Configuration Table. The
|
||||||
@@ -129,21 +121,6 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
uint32_t idle_task_stack_size;
|
uint32_t idle_task_stack_size;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Optional task stack allocator initialization hook.
|
|
||||||
*/
|
|
||||||
rtems_stack_allocate_init_hook stack_allocate_init_hook;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Optional task stack allocator hook.
|
|
||||||
*/
|
|
||||||
rtems_stack_allocate_hook stack_allocate_hook;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Optional task stack free hook.
|
|
||||||
*/
|
|
||||||
rtems_stack_free_hook stack_free_hook;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Specifies if a unified work area is used or not.
|
* @brief Specifies if a unified work area is used or not.
|
||||||
*
|
*
|
||||||
@@ -152,15 +129,6 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
bool unified_work_area;
|
bool unified_work_area;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Specifies if the stack allocator avoids the work space.
|
|
||||||
*
|
|
||||||
* If this element is @a true, then the stack allocator must not allocate the
|
|
||||||
* thread stacks from the RTEMS Workspace, otherwise it should allocate the
|
|
||||||
* thread stacks from the RTEMS Workspace.
|
|
||||||
*/
|
|
||||||
bool stack_allocator_avoids_work_space;
|
|
||||||
|
|
||||||
#ifdef RTEMS_SMP
|
#ifdef RTEMS_SMP
|
||||||
bool smp_enabled;
|
bool smp_enabled;
|
||||||
#endif
|
#endif
|
||||||
@@ -183,8 +151,17 @@ extern const rtems_configuration_table Configuration;
|
|||||||
#define rtems_configuration_get_unified_work_area() \
|
#define rtems_configuration_get_unified_work_area() \
|
||||||
(Configuration.unified_work_area)
|
(Configuration.unified_work_area)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return if the stack allocator avoids the work space.
|
||||||
|
*
|
||||||
|
* @retval true The stack allocator must not allocate the thread stacks from the
|
||||||
|
* RTEMS Workspace
|
||||||
|
*
|
||||||
|
* @retval false The stack allocator should allocate the thread stacks from the
|
||||||
|
* RTEMS Workspace.
|
||||||
|
*/
|
||||||
#define rtems_configuration_get_stack_allocator_avoids_work_space() \
|
#define rtems_configuration_get_stack_allocator_avoids_work_space() \
|
||||||
(Configuration.stack_allocator_avoids_work_space)
|
(_Stack_Allocator_avoids_workspace)
|
||||||
|
|
||||||
uintptr_t rtems_configuration_get_stack_space_size( void );
|
uintptr_t rtems_configuration_get_stack_space_size( void );
|
||||||
|
|
||||||
@@ -215,13 +192,13 @@ uint32_t rtems_configuration_get_maximum_extensions( void );
|
|||||||
((size_t) _ISR_Stack_size)
|
((size_t) _ISR_Stack_size)
|
||||||
|
|
||||||
#define rtems_configuration_get_stack_allocate_init_hook() \
|
#define rtems_configuration_get_stack_allocate_init_hook() \
|
||||||
(Configuration.stack_allocate_init_hook)
|
(_Stack_Allocator_initialize)
|
||||||
|
|
||||||
#define rtems_configuration_get_stack_allocate_hook() \
|
#define rtems_configuration_get_stack_allocate_hook() \
|
||||||
(Configuration.stack_allocate_hook)
|
(_Stack_Allocator_allocate)
|
||||||
|
|
||||||
#define rtems_configuration_get_stack_free_hook() \
|
#define rtems_configuration_get_stack_free_hook() \
|
||||||
(Configuration.stack_free_hook)
|
(_Stack_Allocator_free)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This macro assists in accessing the field which indicates whether
|
* This macro assists in accessing the field which indicates whether
|
||||||
|
|||||||
@@ -57,6 +57,30 @@ typedef struct {
|
|||||||
void *area;
|
void *area;
|
||||||
} Stack_Control;
|
} Stack_Control;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The stack allocator initialization handler.
|
||||||
|
*
|
||||||
|
* @param stack_space_size The size of the stack space in bytes.
|
||||||
|
*/
|
||||||
|
typedef void ( *Stack_Allocator_initialize )( size_t stack_space_size );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Stack allocator allocate handler.
|
||||||
|
*
|
||||||
|
* @param stack_size The size of the stack area to allocate in bytes.
|
||||||
|
*
|
||||||
|
* @retval NULL Not enough memory.
|
||||||
|
* @retval other Pointer to begin of stack area.
|
||||||
|
*/
|
||||||
|
typedef void *( *Stack_Allocator_allocate )( size_t stack_size );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Stack allocator free handler.
|
||||||
|
*
|
||||||
|
* @param] addr A pointer to previously allocated stack area or NULL.
|
||||||
|
*/
|
||||||
|
typedef void ( *Stack_Allocator_free )( void *addr );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The minimum stack size.
|
* @brief The minimum stack size.
|
||||||
*
|
*
|
||||||
@@ -71,6 +95,34 @@ extern uint32_t rtems_minimum_stack_size;
|
|||||||
*/
|
*/
|
||||||
extern const uintptr_t _Stack_Space_size;
|
extern const uintptr_t _Stack_Space_size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Indicates if the stack allocator avoids the workspace.
|
||||||
|
*
|
||||||
|
* Application provided via <rtems/confdefs.h>.
|
||||||
|
*/
|
||||||
|
extern const bool _Stack_Allocator_avoids_workspace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The stack allocator initialization handler.
|
||||||
|
*
|
||||||
|
* Application provided via <rtems/confdefs.h>.
|
||||||
|
*/
|
||||||
|
extern const Stack_Allocator_initialize _Stack_Allocator_initialize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The stack allocator allocate handler.
|
||||||
|
*
|
||||||
|
* Application provided via <rtems/confdefs.h>.
|
||||||
|
*/
|
||||||
|
extern const Stack_Allocator_allocate _Stack_Allocator_allocate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The stack allocator free handler.
|
||||||
|
*
|
||||||
|
* Application provided via <rtems/confdefs.h>.
|
||||||
|
*/
|
||||||
|
extern const Stack_Allocator_free _Stack_Allocator_free;
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
41
cpukit/score/src/stackallocator.c
Normal file
41
cpukit/score/src/stackallocator.c
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 embedded brains GmbH
|
||||||
|
*
|
||||||
|
* 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/score/stack.h>
|
||||||
|
#include <rtems/score/wkspace.h>
|
||||||
|
|
||||||
|
const bool _Stack_Allocator_avoids_workspace = false;
|
||||||
|
|
||||||
|
const Stack_Allocator_initialize _Stack_Allocator_initialize = NULL;
|
||||||
|
|
||||||
|
const Stack_Allocator_allocate _Stack_Allocator_allocate = _Workspace_Allocate;
|
||||||
|
|
||||||
|
const Stack_Allocator_free _Stack_Allocator_free = _Workspace_Free;
|
||||||
Reference in New Issue
Block a user