diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-09-14 14:48:38 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-09-14 14:48:38 +0000 |
commit | 7c411bda5ba29eb8fb5be3841626a485c0d650cb (patch) | |
tree | 049b9b8b77421704c34c29ad0d9a940ff0025f4c /cpukit/libcsupport/src/malloc_initialize.c | |
parent | 2009-09-13 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-7c411bda5ba29eb8fb5be3841626a485c0d650cb.tar.bz2 |
2009-09-14 Sebastian Huber <Sebastian.Huber@embedded-brains.de>
* score/src/wkspace.c: Removed work space area consistency checks.
* libblock/include/rtems/ide_part_table.h: Functions are now
deprecated.
* libcsupport/include/rtems/libcsupport.h, libcsupport/src/calloc.c,
libcsupport/src/malloc_boundary.c,
libcsupport/src/malloc_initialize.c,
libcsupport/src/malloc_report_statistics_plugin.c,
libcsupport/src/malloc_statistics_helpers.c,
libcsupport/src/malloc_walk.c, libcsupport/src/realloc.c,
rtems/inline/rtems/rtems/region.inl: Update for heap API changes.
2009-09-14 Christian Mauderer <christian.mauderer@embedded-brains.de>
* libcsupport/src/vprintk.c: Fixed warnings. Print nothing in case the
pointer to the string is NULL.
Diffstat (limited to 'cpukit/libcsupport/src/malloc_initialize.c')
-rw-r--r-- | cpukit/libcsupport/src/malloc_initialize.c | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/cpukit/libcsupport/src/malloc_initialize.c b/cpukit/libcsupport/src/malloc_initialize.c index 0c7c664856..913daf1a27 100644 --- a/cpukit/libcsupport/src/malloc_initialize.c +++ b/cpukit/libcsupport/src/malloc_initialize.c @@ -1,7 +1,10 @@ -/* - * RTEMS Malloc Family Implementation --Initialization - * +/** + * @file * + * @brief Malloc initialization implementation. + */ + +/* * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * @@ -24,9 +27,9 @@ /* FIXME: Dummy function */ #ifndef RTEMS_NEWLIB void RTEMS_Malloc_Initialize( - void *start, - size_t length, - size_t sbrk_amount + void *heap_begin, + uintptr_t heap_size, + size_t sbrk_amount ) { } @@ -35,43 +38,43 @@ rtems_malloc_statistics_t rtems_malloc_statistics; extern bool rtems_unified_work_area; void RTEMS_Malloc_Initialize( - void *start, - size_t length, - size_t sbrk_amount + void *heap_begin, + uintptr_t heap_size, + size_t sbrk_amount ) { - uint32_t status; - void *starting_address; - #if defined(RTEMS_MALLOC_BOUNDARY_HELPERS) /* * If configured, initialize the boundary support */ - if (rtems_malloc_boundary_helpers) + if ( rtems_malloc_boundary_helpers != NULL ) { (*rtems_malloc_boundary_helpers->initialize)(); + } #endif /* * If configured, initialize the statistics support */ - if ( rtems_malloc_statistics_helpers ) + if ( rtems_malloc_statistics_helpers != NULL ) { (*rtems_malloc_statistics_helpers->initialize)(); + } /* * Initialize the garbage collection list to start with nothing on it. */ malloc_deferred_frees_initialize(); - starting_address = start; - /* * Initialize the optional sbrk support for extending the heap */ - if (rtems_malloc_sbrk_helpers) { - starting_address = (*rtems_malloc_sbrk_helpers->initialize)( - start, + if ( rtems_malloc_sbrk_helpers != NULL ) { + void *new_heap_begin = (*rtems_malloc_sbrk_helpers->initialize)( + heap_begin, sbrk_amount ); + + heap_size -= (uintptr_t) new_heap_begin - (uintptr_t) heap_begin; + heap_begin = new_heap_begin; } /* @@ -92,9 +95,12 @@ void RTEMS_Malloc_Initialize( * left over from another process. This would be a security violation. */ - if ( !rtems_unified_work_area && - rtems_configuration_get_do_zero_of_workspace() ) - memset( starting_address, 0, length ); + if ( + !rtems_unified_work_area + && rtems_configuration_get_do_zero_of_workspace() + ) { + memset( heap_begin, 0, heap_size ); + } /* * Unfortunately we cannot use assert if this fails because if this @@ -103,14 +109,15 @@ void RTEMS_Malloc_Initialize( */ if ( !rtems_unified_work_area ) { - status = _Protected_heap_Initialize( + uintptr_t status = _Protected_heap_Initialize( RTEMS_Malloc_Heap, - starting_address, - length, + heap_begin, + heap_size, CPU_HEAP_ALIGNMENT ); - if ( !status ) - rtems_fatal_error_occurred( status ); + if ( status == 0 ) { + rtems_fatal_error_occurred( RTEMS_NO_MEMORY ); + } } MSBUMP( space_available, _Protected_heap_Get_size(RTEMS_Malloc_Heap) ); @@ -118,9 +125,9 @@ void RTEMS_Malloc_Initialize( #if defined(RTEMS_HEAP_DEBUG) if ( _Protected_heap_Walk( RTEMS_Malloc_Heap, 0, false ) ) { printk( "Malloc heap not initialized correctly\n" ); - rtems_print_buffer( start, 32 ); + rtems_print_buffer( heap_begin, 32 ); printk( "\n" ); - rtems_print_buffer( (start + length) - 48, 48 ); + rtems_print_buffer( (heap_begin + heap_size) - 48, 48 ); rtems_fatal_error_occurred( RTEMS_NO_MEMORY ); } #endif |