ChibiOS/RT
6.0.3
|
Core Memory Manager related APIs and services.
The core memory manager is a simplified allocator that only allows to allocate memory blocks without the possibility to free them.
This allocator is meant as a memory blocks provider for the other allocators such as:
By having a centralized memory provider the various allocators can coexist and share the main memory.
This allocator, alone, is also useful for very simple applications that just require a simple way to get memory blocks.
CH_CFG_USE_MEMCORE
option must be enabled in chconf.h
. Macros | |
#define | CH_CFG_MEMCORE_SIZE 0 |
Managed RAM size. More... | |
Typedefs | |
typedef void *(* | memgetfunc_t) (size_t size, unsigned align) |
Memory get function. More... | |
typedef void *(* | memgetfunc2_t) (size_t size, unsigned align, size_t offset) |
Enhanced memory get function. More... | |
Data Structures | |
struct | memcore_t |
Type of memory core object. More... | |
Functions | |
void | _core_init (void) |
Low level memory manager initialization. More... | |
void * | chCoreAllocAlignedWithOffsetI (size_t size, unsigned align, size_t offset) |
Allocates a memory block. More... | |
void * | chCoreAllocAlignedWithOffset (size_t size, unsigned align, size_t offset) |
Allocates a memory block. More... | |
size_t | chCoreGetStatusX (void) |
Core memory status. More... | |
static void * | chCoreAllocAlignedI (size_t size, unsigned align) |
Allocates a memory block. More... | |
static void * | chCoreAllocAligned (size_t size, unsigned align) |
Allocates a memory block. More... | |
static void * | chCoreAllocI (size_t size) |
Allocates a memory block. More... | |
static void * | chCoreAlloc (size_t size) |
Allocates a memory block. More... | |
Variables | |
memcore_t | ch_memcore |
Memory core descriptor. More... | |
#define CH_CFG_MEMCORE_SIZE 0 |
Managed RAM size.
Size of the RAM area to be managed by the OS. If set to zero then the whole available RAM is used. The core memory is made available to the heap allocator and/or can be used directly through the simplified core memory allocator.
heap_base
and heap_end
symbols. CH_CFG_USE_MEMCORE
. Definition at line 53 of file chmemcore.h.
typedef void*(* memgetfunc_t) (size_t size, unsigned align) |
Memory get function.
Definition at line 71 of file chmemcore.h.
typedef void*(* memgetfunc2_t) (size_t size, unsigned align, size_t offset) |
Enhanced memory get function.
Definition at line 76 of file chmemcore.h.
void _core_init | ( | void | ) |
Low level memory manager initialization.
Definition at line 81 of file chmemcore.c.
References CH_CFG_MEMCORE_SIZE, memcore_t::endmem, and memcore_t::nextmem.
Referenced by chSysInit().
void * chCoreAllocAlignedWithOffsetI | ( | size_t | size, |
unsigned | align, | ||
size_t | offset | ||
) |
Allocates a memory block.
This function allocates a block of offset
+ size
bytes. The returned pointer has offset
bytes before its address and size
bytes after.
[in] | size | the size of the block to be allocated. |
[in] | align | desired memory alignment |
[in] | offset | aligned pointer offset |
NULL | allocation failed, core memory exhausted. |
Definition at line 112 of file chmemcore.c.
References chDbgCheck, chDbgCheckClassI(), memcore_t::endmem, MEM_ALIGN_NEXT, MEM_IS_VALID_ALIGNMENT, and memcore_t::nextmem.
Referenced by chCoreAllocAligned(), chCoreAllocAlignedI(), chCoreAllocAlignedWithOffset(), and chCoreAllocI().
void * chCoreAllocAlignedWithOffset | ( | size_t | size, |
unsigned | align, | ||
size_t | offset | ||
) |
Allocates a memory block.
This function allocates a block of offset
+ size
bytes. The returned pointer has offset
bytes before its address and size
bytes after.
[in] | size | the size of the block to be allocated. |
[in] | align | desired memory alignment |
[in] | offset | aligned pointer offset |
NULL | allocation failed, core memory exhausted. |
Definition at line 148 of file chmemcore.c.
References chCoreAllocAlignedWithOffsetI(), chSysLock(), and chSysUnlock().
Referenced by _heap_init(), and chCoreAlloc().
size_t chCoreGetStatusX | ( | void | ) |
Core memory status.
Definition at line 167 of file chmemcore.c.
References memcore_t::endmem, and memcore_t::nextmem.
|
inlinestatic |
Allocates a memory block.
The allocated block is guaranteed to be properly aligned to the specified alignment.
[in] | size | the size of the block to be allocated. |
[in] | align | desired memory alignment |
NULL | allocation failed, core memory exhausted. |
Definition at line 135 of file chmemcore.h.
References chCoreAllocAlignedWithOffsetI().
Referenced by _factory_init().
|
inlinestatic |
Allocates a memory block.
The allocated block is guaranteed to be properly aligned to the specified alignment.
[in] | size | the size of the block to be allocated |
[in] | align | desired memory alignment |
NULL | allocation failed, core memory exhausted. |
Definition at line 152 of file chmemcore.h.
References chCoreAllocAlignedWithOffsetI(), chSysLock(), and chSysUnlock().
|
inlinestatic |
Allocates a memory block.
The allocated block is guaranteed to be properly aligned for a pointer data type.
[in] | size | the size of the block to be allocated. |
NULL | allocation failed, core memory exhausted. |
Definition at line 173 of file chmemcore.h.
References chCoreAllocAlignedWithOffsetI().
|
inlinestatic |
Allocates a memory block.
The allocated block is guaranteed to be properly aligned for a pointer data type.
[in] | size | the size of the block to be allocated. |
NULL | allocation failed, core memory exhausted. |
Definition at line 189 of file chmemcore.h.
References chCoreAllocAlignedWithOffset().
memcore_t ch_memcore |
Memory core descriptor.
Definition at line 58 of file chmemcore.c.