From eea21eaca117ecd98afea164e1808d6530ef487f Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 13 Dec 2019 06:18:36 +0100 Subject: bsps: Rework work area initialization The work area initialization was done by the BSP through bsp_work_area_initialize(). This approach predated the system initialization through the system initialization linker set. The workspace and C program heap were unconditionally initialized. The aim is to support RTEMS application configurations which do not need the workspace and C program heap. In these configurations, the workspace and C prgram heap should not get initialized. Change all bsp_work_area_initialize() to implement _Memory_Get() instead. Move the dirty memory, sbrk(), per-CPU data, workspace, and malloc() heap initialization into separate system initialization steps. This makes it also easier to test the individual initialization steps. This change adds a dependency to _Heap_Extend() to all BSPs. This dependency will be removed in a follow up change. Update #3838. --- bsps/include/bsp/bootcard.h | 62 +-------------------------------------------- 1 file changed, 1 insertion(+), 61 deletions(-) (limited to 'bsps/include/bsp/bootcard.h') diff --git a/bsps/include/bsp/bootcard.h b/bsps/include/bsp/bootcard.h index 6121ff9ba1..e3eed8da46 100644 --- a/bsps/include/bsp/bootcard.h +++ b/bsps/include/bsp/bootcard.h @@ -21,11 +21,10 @@ #ifndef LIBBSP_SHARED_BOOTCARD_H #define LIBBSP_SHARED_BOOTCARD_H -#include - #include #include #include +#include #include #include @@ -71,65 +70,6 @@ void bsp_reset(void); */ void boot_card(const char *cmdline) RTEMS_NO_RETURN; -#ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK - /** - * @brief Gives the BSP a chance to reduce the work area size with sbrk() - * adding more later. - * - * bsp_sbrk_init() may reduce the work area size passed in. The routine - * returns the 'sbrk_amount' to be used when extending the heap. Note that - * the return value may be zero. - * - * In case the @a area size is altered, then the remaining size of the - * @a area must be greater than or equal to @a min_size. - */ - ptrdiff_t bsp_sbrk_init(Heap_Area *area, uintptr_t min_size); -#endif - -static inline void bsp_work_area_initialize_default( - void *area_begin, - uintptr_t area_size -) -{ - Heap_Area area = { - .begin = area_begin, - .size = area_size - }; - - #if BSP_DIRTY_MEMORY == 1 - memset(area.begin, 0xCF, area.size); - #endif - - #ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK - { - uintptr_t overhead = _Heap_Area_overhead(CPU_HEAP_ALIGNMENT); - uintptr_t work_space_size = rtems_configuration_get_work_space_size(); - ptrdiff_t sbrk_amount = bsp_sbrk_init( - &area, - work_space_size - + overhead - + (rtems_configuration_get_unified_work_area() ? 0 : overhead) - ); - - rtems_heap_set_sbrk_amount(sbrk_amount); - } - #endif - - _Workspace_Handler_initialization(&area, 1, NULL); - RTEMS_Malloc_Initialize(&area, 1, NULL); -} - -static inline void bsp_work_area_initialize_with_table( - Heap_Area *areas, - size_t area_count -) -{ - _Workspace_Handler_initialization(areas, area_count, _Heap_Extend); - RTEMS_Malloc_Initialize(areas, area_count, _Heap_Extend); -} - -void bsp_work_area_initialize(void); - struct Per_CPU_Control; /** -- cgit v1.2.3