From f2185d109930fb5db31a5c228a3f46178072f270 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 30 Sep 2020 11:31:58 +0200 Subject: Decouple the C Program Heap initialization Before this patch RTEMS_Malloc_Initialize() had a fixed dependency on _Workspace_Area. Introduce _Workspace_Malloc_initializer to have this dependency only if CONFIGURE_UNIFIED_WORK_AREAS is defined by the application configuration. --- cpukit/include/rtems/confdefs/wkspace.h | 3 +++ cpukit/include/rtems/malloc.h | 2 +- cpukit/include/rtems/score/wkspacedata.h | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) (limited to 'cpukit/include') diff --git a/cpukit/include/rtems/confdefs/wkspace.h b/cpukit/include/rtems/confdefs/wkspace.h index 89d7c21b2a..d40194cbec 100644 --- a/cpukit/include/rtems/confdefs/wkspace.h +++ b/cpukit/include/rtems/confdefs/wkspace.h @@ -126,6 +126,9 @@ const uintptr_t _Workspace_Size = CONFIGURE_EXECUTIVE_RAM_SIZE; #ifdef CONFIGURE_UNIFIED_WORK_AREAS const bool _Workspace_Is_unified = true; + + struct Heap_Control *( * const _Workspace_Malloc_initializer )( void ) = + _Workspace_Malloc_initialize_unified; #endif uint32_t rtems_minimum_stack_size = CONFIGURE_MINIMUM_TASK_STACK_SIZE; diff --git a/cpukit/include/rtems/malloc.h b/cpukit/include/rtems/malloc.h index 34bdbcb91e..13e94ac38a 100644 --- a/cpukit/include/rtems/malloc.h +++ b/cpukit/include/rtems/malloc.h @@ -43,7 +43,7 @@ extern "C" { */ extern Heap_Control *RTEMS_Malloc_Heap; -void RTEMS_Malloc_Initialize( +Heap_Control *RTEMS_Malloc_Initialize( const Memory_Information *mem, Heap_Initialization_or_extend_handler extend ); diff --git a/cpukit/include/rtems/score/wkspacedata.h b/cpukit/include/rtems/score/wkspacedata.h index 613a320dfe..fd6fd1c1cb 100644 --- a/cpukit/include/rtems/score/wkspacedata.h +++ b/cpukit/include/rtems/score/wkspacedata.h @@ -43,6 +43,8 @@ extern "C" { #endif +struct Heap_Control; + /** * @addtogroup RTEMSScoreWorkspace * @@ -65,6 +67,30 @@ extern const uintptr_t _Workspace_Size; */ extern const bool _Workspace_Is_unified; +/** + * @brief Initializes the C Program Heap separated from the RTEMS Workspace. + * + * @return Returns the heap control used for the C Program Heap. + */ +struct Heap_Control *_Workspace_Malloc_initialize_separate( void ); + +/** + * @brief Initializes the C Program Heap so that it is unified with the RTEMS + * Workspace. + * + * @return Returns the heap control used for the C Program Heap. + */ +struct Heap_Control *_Workspace_Malloc_initialize_unified( void ); + +/** + * @brief This constant provides the C Program Heap initialization handler. + * + * This constant is defined by the application configuration option + * #CONFIGURE_UNIFIED_WORK_AREAS via or a default + * configuration. + */ +extern struct Heap_Control *( * const _Workspace_Malloc_initializer )( void ); + /** @} */ #ifdef __cplusplus -- cgit v1.2.3