18#ifndef _RTEMS_SCORE_HEAP_H
19#define _RTEMS_SCORE_HEAP_H
21#include <rtems/score/cpu.h>
29 #define HEAP_PROTECTION
193#ifndef HEAP_PROTECTION
194 #define HEAP_PROTECTION_HEADER_SIZE 0
196 #define HEAP_PROTECTOR_COUNT 2
198 #define HEAP_BEGIN_PROTECTOR_0 ((uintptr_t) 0xfd75a98f)
199 #define HEAP_BEGIN_PROTECTOR_1 ((uintptr_t) 0xbfa1f177)
200 #define HEAP_END_PROTECTOR_0 ((uintptr_t) 0xd6b8855e)
201 #define HEAP_END_PROTECTOR_1 ((uintptr_t) 0x13a44a5b)
203 #define HEAP_FREE_PATTERN ((uintptr_t) 0xe7093cdf)
205 #define HEAP_PROTECTION_OBOLUS ((Heap_Block *) 1)
207 typedef void (*_Heap_Protection_handler)(
212 typedef void (*_Heap_Protection_error_handler)(
219 _Heap_Protection_handler block_initialize;
220 _Heap_Protection_handler block_check;
221 _Heap_Protection_error_handler block_error;
225 uintptr_t delayed_free_block_count;
226 uintptr_t delayed_free_fraction;
232 uintptr_t protector [HEAP_PROTECTOR_COUNT];
236 } Heap_Protection_block_begin;
239 uintptr_t protector [HEAP_PROTECTOR_COUNT];
240 } Heap_Protection_block_end;
242 #define HEAP_PROTECTION_HEADER_SIZE \
243 (sizeof(Heap_Protection_block_begin) + sizeof(Heap_Protection_block_end))
250#define HEAP_BLOCK_HEADER_SIZE \
251 (2 * sizeof(uintptr_t) + HEAP_PROTECTION_HEADER_SIZE)
272 #ifdef HEAP_PROTECTION
273 Heap_Protection_block_begin Protection_begin;
291 #ifdef HEAP_PROTECTION
292 Heap_Protection_block_end Protection_end;
321 uintptr_t min_block_size;
322 uintptr_t area_begin;
327 #ifdef HEAP_PROTECTION
328 Heap_Protection Protection;
356 uintptr_t page_size_or_unused
418 uintptr_t remainder = value % alignment;
420 if ( remainder != 0 ) {
421 return value - remainder + alignment;
450 if ( page_size != 0 ) {
453 page_size = CPU_ALIGNMENT;
475 if ( page_size != 0 ) {
478 page_size = CPU_ALIGNMENT;
481 if ( page_size < alignment ) {
482 page_size = alignment;
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
RTEMS_INLINE_ROUTINE uintptr_t _Heap_Size_with_overhead(uintptr_t page_size, uintptr_t size, uintptr_t alignment)
Returns the size with administration and alignment overhead for one allocation.
Definition: heap.h:469
uintptr_t _Heap_No_extend(Heap_Control *unused_0, void *unused_1, uintptr_t unused_2, uintptr_t unused_3)
This function returns always zero.
#define HEAP_BLOCK_HEADER_SIZE
The block header consists of the two size fields (Heap_Block::prev_size and Heap_Block::size_and_flag...
Definition: heap.h:250
RTEMS_INLINE_ROUTINE uintptr_t _Heap_Min_block_size(uintptr_t page_size)
Returns the minimal Heap Block size for the given page_size.
Definition: heap.h:434
uintptr_t _Heap_Extend(Heap_Control *heap, void *area_begin, uintptr_t area_size, uintptr_t unused)
Extends the memory available for the heap.
Definition: heapextend.c:119
uintptr_t(* Heap_Initialization_or_extend_handler)(Heap_Control *heap, void *area_begin, uintptr_t area_size, uintptr_t page_size_or_unused)
Heap initialization and extend handler type.
Definition: heap.h:352
Heap_Error_reason
The heap error reason.
Definition: heap.h:142
RTEMS_INLINE_ROUTINE uintptr_t _Heap_Area_overhead(uintptr_t page_size)
Returns the worst case overhead to manage a memory area.
Definition: heap.h:446
RTEMS_INLINE_ROUTINE uintptr_t _Heap_Align_up(uintptr_t value, uintptr_t alignment)
Aligns the value to a given alignment, rounding up.
Definition: heap.h:413
@ HEAP_ERROR_BAD_USED_BLOCK
The next block of a supposed to be used block does not indicate that the block is used.
Definition: heap.h:163
@ HEAP_ERROR_BROKEN_PROTECTOR
There is an unexpected value in the heap block protector area.
Definition: heap.h:146
@ HEAP_ERROR_DOUBLE_FREE
There is was an attempt to free the same block twice.
Definition: heap.h:157
@ HEAP_ERROR_BAD_FREE_BLOCK
A supposed to be free block is not inside the heap memory area.
Definition: heap.h:168
@ HEAP_ERROR_FREE_PATTERN
There is an unexpected value in the free pattern of a free heap block.
Definition: heap.h:152
Heap Handler Information API.
Heap area structure for table based heap initialization and extension.
Definition: heap.h:338
Description for free or used blocks.
Definition: heap.h:256
Heap_Block * prev
Pointer to the previous free block or part of the allocated area.
Definition: heap.h:312
uintptr_t prev_size
Size of the previous block or part of the allocated area of the previous block.
Definition: heap.h:270
uintptr_t size_and_flag
Contains the size of the current block and a flag which indicates if the previous block is free or us...
Definition: heap.h:289
Heap_Block * next
Pointer to the next free block or part of the allocated area.
Definition: heap.h:304
Control block used to manage a heap.
Definition: heap.h:318
Context of a heap error.
Definition: heap.h:176
Heap_Error_reason reason
The heap error reason.
Definition: heap.h:190
Heap_Block * block
The heap block causing the error.
Definition: heap.h:185
Heap_Control * heap
The heap of the block.
Definition: heap.h:180
Run-time heap statistics.
Definition: heapinfo.h:40
Definition: intercom.c:58
unsigned size
Definition: tte.h:1