From 7246c8e9978e63058a688db708d8235f841a8d80 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 2 Mar 2009 18:10:34 +0000 Subject: 2009-03-02 Joel Sherrill * libcsupport/src/malloc_initialize.c, score/Makefile.am, score/include/rtems/score/protectedheap.h, score/inline/rtems/score/heap.inl: Get total heap size correct when using unified C Program Heap and RTEMS Workspace. * score/src/pheapgetsize.c: New file. --- cpukit/ChangeLog | 8 ++++++++ cpukit/libcsupport/src/malloc_initialize.c | 5 +++-- cpukit/score/Makefile.am | 6 +++--- cpukit/score/include/rtems/score/protectedheap.h | 12 ++++++++++++ cpukit/score/inline/rtems/score/heap.inl | 15 +++++++++++++++ cpukit/score/src/pheapgetsize.c | 24 ++++++++++++++++++++++++ 6 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 cpukit/score/src/pheapgetsize.c diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 843e3a4c0c..e9a078d6f1 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,11 @@ +2009-03-02 Joel Sherrill + + * libcsupport/src/malloc_initialize.c, score/Makefile.am, + score/include/rtems/score/protectedheap.h, + score/inline/rtems/score/heap.inl: Get total heap size correct when + using unified C Program Heap and RTEMS Workspace. + * score/src/pheapgetsize.c: New file. + 2009-03-02 Joel Sherrill PR 1388/cpukit diff --git a/cpukit/libcsupport/src/malloc_initialize.c b/cpukit/libcsupport/src/malloc_initialize.c index 1105724a67..eb477b23ca 100644 --- a/cpukit/libcsupport/src/malloc_initialize.c +++ b/cpukit/libcsupport/src/malloc_initialize.c @@ -101,8 +101,11 @@ void RTEMS_Malloc_Initialize( ); if ( !status ) rtems_fatal_error_occurred( status ); + } + MSBUMP( space_available, _Protected_heap_Get_size(RTEMS_Malloc_Heap->final) ); + #if defined(RTEMS_HEAP_DEBUG) if ( _Protected_heap_Walk( RTEMS_Malloc_Heap, 0, false ) ) { printk( "Malloc heap not initialized correctly\n" ); @@ -112,6 +115,4 @@ void RTEMS_Malloc_Initialize( rtems_fatal_error_occurred( RTEMS_NO_MEMORY ); } #endif - - MSBUMP(space_available, length); } diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index 472f3bd53a..7b5f76b162 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -129,9 +129,9 @@ endif ## PROTECTED_HEAP_C_FILES libscore_a_SOURCES += src/pheapallocatealigned.c src/pheapallocate.c \ - src/pheapextend.c src/pheapfree.c src/pheapgetblocksize.c \ - src/pheapgetfreeinfo.c src/pheapgetinfo.c src/pheapinit.c \ - src/pheapresizeblock.c src/pheapwalk.c + src/pheapextend.c src/pheapfree.c src/pheapgetsize.c \ + src/pheapgetblocksize.c src/pheapgetfreeinfo.c src/pheapgetinfo.c \ + src/pheapinit.c src/pheapresizeblock.c src/pheapwalk.c ## THREAD_C_FILES libscore_a_SOURCES += src/thread.c src/threadchangepriority.c \ diff --git a/cpukit/score/include/rtems/score/protectedheap.h b/cpukit/score/include/rtems/score/protectedheap.h index be657155ae..f9407b27db 100644 --- a/cpukit/score/include/rtems/score/protectedheap.h +++ b/cpukit/score/include/rtems/score/protectedheap.h @@ -205,6 +205,18 @@ void _Protected_heap_Get_free_information( Heap_Information *info ); +/** + * This function returns the maximum size of the protected heap. + * + * @param[in] the_heap points to the heap being operated upon + * + * @return This method returns the total amount of memory + * allocated to the heap. + */ +uint32_t _Protected_heap_Get_size( + Heap_Control *the_heap +); + #ifdef __cplusplus } #endif diff --git a/cpukit/score/inline/rtems/score/heap.inl b/cpukit/score/inline/rtems/score/heap.inl index 8238687726..ccff0bacb8 100644 --- a/cpukit/score/inline/rtems/score/heap.inl +++ b/cpukit/score/inline/rtems/score/heap.inl @@ -368,6 +368,21 @@ RTEMS_INLINE_ROUTINE bool _Heap_Is_block_in ( return _Addresses_Is_in_range( the_block, the_heap->start, the_heap->final ); } +/** + * This function returns the maximum size of the heap. + * + * @param[in] the_heap points to the heap being operated upon + * + * @return This method returns the total amount of memory + * allocated to the heap. + */ +RTEMS_INLINE_ROUTINE uint32_t _Heap_Get_size ( + Heap_Control *the_heap +) +{ + return the_heap->final - the_heap->start; +} + /**@}*/ #endif diff --git a/cpukit/score/src/pheapgetsize.c b/cpukit/score/src/pheapgetsize.c new file mode 100644 index 0000000000..c283d34c13 --- /dev/null +++ b/cpukit/score/src/pheapgetsize.c @@ -0,0 +1,24 @@ +/** + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * 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$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +uint32_t _Protected_heap_Get_size( + Heap_Control *the_heap +) +{ + return _Heap_Get_size( the_heap ); +} -- cgit v1.2.3