diff options
author | Daniel Hellstrom <daniel@gaisler.com> | 2012-03-28 10:49:27 +0200 |
---|---|---|
committer | Gedare Bloom <gedare@rtems.org> | 2012-03-29 12:33:01 -0400 |
commit | 0729e2a7af22fa27defcd1daa90aad32721947b6 (patch) | |
tree | 1b499f51298536bcfb929b8b34fd3b225ee1b48a /c/src/lib/libbsp/sparc/shared/bspgetworkarea.c | |
parent | SMC91111: remove old unused LEON2/LEON3 intialization code (diff) | |
download | rtems-0729e2a7af22fa27defcd1daa90aad32721947b6.tar.bz2 |
SPARC: bsp_early_malloc() routine for startup memory allocation
If bsp_early_malloc() is called early during boot room will be
allocated after BSS END. If the function is called after boot
is will call malloc() instead. The returned memory is not freeable
and always 8-byte aligned.
If the bsp_early_malloc() isn't called the function is not
dragged in and the workspace will be unmodified in size.
Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
Diffstat (limited to 'c/src/lib/libbsp/sparc/shared/bspgetworkarea.c')
-rw-r--r-- | c/src/lib/libbsp/sparc/shared/bspgetworkarea.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/c/src/lib/libbsp/sparc/shared/bspgetworkarea.c b/c/src/lib/libbsp/sparc/shared/bspgetworkarea.c index c6e1491d81..45d3d0ed87 100644 --- a/c/src/lib/libbsp/sparc/shared/bspgetworkarea.c +++ b/c/src/lib/libbsp/sparc/shared/bspgetworkarea.c @@ -8,8 +8,6 @@ * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rtems.com/license/LICENSE. - * - * $Id$ */ /* #define BSP_GET_WORK_AREA_DEBUG */ @@ -22,6 +20,9 @@ /* Tells us where to put the workspace in case remote debugger is present. */ extern uint32_t rdb_start; +/* Must be aligned to 8, _end is aligned to 8 */ +unsigned int early_mem = (unsigned int)&end; + /* * This method returns the base address and size of the area which * is to be allocated between the RTEMS Workspace and the C Program @@ -37,8 +38,11 @@ void bsp_get_work_area( /* must be identical to STACK_SIZE in start.S */ #define STACK_SIZE (16 * 1024) - *work_area_start = &end; - *work_area_size = (void *)rdb_start - (void *)&end - STACK_SIZE; + /* Early dynamic memory allocator is placed just above _end */ + *work_area_start = (void *)early_mem; + *work_area_size = (void *)rdb_start - (void *)early_mem - STACK_SIZE; + early_mem = ~0; /* Signal bsp_early_malloc not to be used anymore */ + *heap_start = BSP_BOOTCARD_HEAP_USES_WORK_AREA; *heap_size = BSP_BOOTCARD_HEAP_SIZE_DEFAULT; |