From b2a0214d4395787eca8e74375d283bf26c9ca4a1 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 7 Jun 2010 09:35:01 +0000 Subject: 2010-06-07 Sebastian Huber * score/include/rtems/score/heap.h: Declare _Heap_Get_first_and_last_block(). Removed Heap_Extend_status. Changed return type of _Heap_Extend() to bool. * score/inline/rtems/score/heap.inl: Define _Heap_Set_last_block_size(). * score/src/heap.c: Define and use _Heap_Get_first_and_last_block(). * score/src/heapgetinfo.c: Removed assert statements. Do not count the last block. This ensures that all size values are an integral multiple of the page size which is consistent with the other statistics. * score/src/heapextend.c: Implemented support for scattered heap areas. * score/src/heapwalk.c: Dump also last block. Changes for new first and last block values. * ./score/src/pheapextend.c, rtems/src/regionextend.c: Update for _Heap_Extend() changes. --- cpukit/score/include/rtems/score/heap.h | 49 +++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 14 deletions(-) (limited to 'cpukit/score/include/rtems/score/heap.h') diff --git a/cpukit/score/include/rtems/score/heap.h b/cpukit/score/include/rtems/score/heap.h index c2286bf2af..286cc94218 100644 --- a/cpukit/score/include/rtems/score/heap.h +++ b/cpukit/score/include/rtems/score/heap.h @@ -92,7 +92,10 @@ extern "C" { * heap->area_beginheap area begin address * * first_block->prev_size - * page size (the value is arbitrary) + * + * subordinate heap area end address (this will be used to maintain a + * linked list of scattered heap areas) + * * * * first_block->size @@ -310,15 +313,6 @@ typedef struct { Heap_Information Used; } Heap_Information_block; -/** - * @brief See _Heap_Extend(). - */ -typedef enum { - HEAP_EXTEND_SUCCESSFUL, - HEAP_EXTEND_ERROR, - HEAP_EXTEND_NOT_IMPLEMENTED -} Heap_Extend_status; - /** * @brief See _Heap_Resize_block(). */ @@ -328,6 +322,29 @@ typedef enum { HEAP_RESIZE_FATAL_ERROR } Heap_Resize_status; +/** + * @brief Gets the first and last block for the heap area with begin + * @a heap_area_begin and size @a heap_area_size. + * + * A page size of @a page_size and minimal block size of @a min_block_size will + * be used for calculation. + * + * Nothing will be written to this area. + * + * In case of success the pointers to the first and last block will be returned + * via @a first_block_ptr and @a last_block_ptr. + * + * Returns @c true if the area is big enough, and @c false otherwise. + */ +bool _Heap_Get_first_and_last_block( + uintptr_t heap_area_begin, + uintptr_t heap_area_size, + uintptr_t page_size, + uintptr_t min_block_size, + Heap_Block **first_block_ptr, + Heap_Block **last_block_ptr +); + /** * @brief Initializes the heap control block @a heap to manage the area * starting at @a area_begin of size @a area_size bytes. @@ -350,11 +367,15 @@ uintptr_t _Heap_Initialize( * starting at @a area_begin of size @a area_size bytes. * * The extended space available for allocation will be returned in - * @a amount_extended. + * @a amount_extended. This pointer may be @c NULL. + * + * The memory area must be big enough to contain some maintainance blocks. It + * must not overlap parts of the current heap areas. Disconnected subordinate + * heap areas will lead to used blocks which cover the gaps. * - * The memory area must start at the end of the currently used memory area. + * Returns @c true in case of success, and @c false otherwise. */ -Heap_Extend_status _Heap_Extend( +bool _Heap_Extend( Heap_Control *heap, void *area_begin, uintptr_t area_size, @@ -368,7 +389,7 @@ Heap_Extend_status _Heap_Extend( * memory area will begin at an address aligned by this value. * * If the boundary parameter @a boundary is not equal to zero, the allocated - * memory area will fulfill a boundary constraint. The boudnary value + * memory area will fulfill a boundary constraint. The boundary value * specifies the set of addresses which are aligned by the boundary value. The * interior of the allocated memory area will not contain an element of this * set. The begin or end address of the area may be a member of the set. -- cgit v1.2.3