# HG changeset patch # User nickg # Date 1245925859 0 # Node ID 22da989aafa4e2e8a3bc06c989d9e7e2ccbbd444 # Parent 7c9e64d8c436cbb2aeb2c65821d8ed15f536f653 Add support for memalloc heaps in RedBoot. See ChangeLogs for details. diff --git a/packages/redboot/current/ChangeLog b/packages/redboot/current/ChangeLog --- a/packages/redboot/current/ChangeLog +++ b/packages/redboot/current/ChangeLog @@ -1,3 +1,12 @@ +2009-06-24 Nick Garnett + + * cdl/redboot.cdl: + * src/main.c (cyg_start): Added options and code to reinitialize + the heap, if it exists, to an arena cut off the end of the + workspace. + [Imported from eCosPro sources, mainly to support use of + filesystems in RedBoot]. + 2009-06-02 Ross Younger * redboot.cdl: REDBOOT_IO_FILEIO requires CYGPKG_IO diff --git a/packages/redboot/current/cdl/redboot.cdl b/packages/redboot/current/cdl/redboot.cdl --- a/packages/redboot/current/cdl/redboot.cdl +++ b/packages/redboot/current/cdl/redboot.cdl @@ -1284,6 +1284,32 @@ cdl_package CYGPKG_REDBOOT { size of one flash sector." } } + + cdl_component CYGMEM_REDBOOT_WORKSPACE_HEAP { + display "Allocate heap in RedBoot workspace" + flavor bool + active_if CYGPKG_MEMALLOC + active_if CYGPKG_MEMALLOC_MALLOC_ALLOCATORS + default_value 0 + description " + If the MEMALLOC package is present, it usually allocates + the whole of memory not used by the program to the heap. + In RedBoot this is not a good idea, since we need space to + load application programs. Setting this option causes RedBoot + to allocate the heap at the top of RAM by reserving part of + RedBoot's workspace memory, leaving the rest of memory free." + + cdl_option CYGMEM_REDBOOT_WORKSPACE_HEAP_SIZE { + display "Size of RedBoot heap" + flavor data + default_value 0x10000 + legal_values 0x4000 to 0x80000000 + description " + Size of RedBoot heap. This defines how much memory is to be + allocated for the heap." + } + } + cdl_option CYGNUM_REDBOOT_GETC_BUFFER { display "Buffer size in getc when loading images" flavor data diff --git a/packages/redboot/current/src/main.c b/packages/redboot/current/src/main.c --- a/packages/redboot/current/src/main.c +++ b/packages/redboot/current/src/main.c @@ -301,6 +301,17 @@ cyg_start(void) workspace_end = ram_end; } +#if defined(CYGMEM_REDBOOT_WORKSPACE_HEAP) + { + extern cyg_bool cyg_memalloc_heap_reinit( cyg_uint8 *base, cyg_uint32 size ); + + workspace_end -= CYGMEM_REDBOOT_WORKSPACE_HEAP_SIZE; + + if( !cyg_memalloc_heap_reinit( (cyg_uint8 *)workspace_end, CYGMEM_REDBOOT_WORKSPACE_HEAP_SIZE ) ) + diag_printf("Heap reinitialization failed\n"); + } +#endif + workspace_end_init=workspace_end; // Nothing has ever been loaded into memory diff --git a/packages/services/memalloc/common/current/ChangeLog b/packages/services/memalloc/common/current/ChangeLog --- a/packages/services/memalloc/common/current/ChangeLog +++ b/packages/services/memalloc/common/current/ChangeLog @@ -1,3 +1,13 @@ +2009-06-24 Nick Garnett + + * src/malloc.cxx (cyg_memalloc_heap_reinit): Added this function + to reinitialize the heap to a new arena. This should be done + during system startup and is present mainly for the use of + RedBoot. + Permit configurations with multi-region heaps to build. + [Imported from eCosPro sources, mainly to support use of + filesystems in RedBoot]. + 2009-02-03 Simon Kallweit * include/mvarimpl.inl: @@ -395,7 +405,7 @@ 2000-07-04 Jonathan Larmour