ChibiOS
21.6.0
|
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... | |
#define | chCoreAllocAlignedWithOffsetI chCoreAllocFromTopI |
Allocates a memory block. More... | |
#define | chCoreAllocAlignedWithOffset chCoreAllocFromTop |
Allocates a memory block. 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 * | chCoreAllocFromBaseI (size_t size, unsigned align, size_t offset) |
Allocates a memory block starting from the lowest address upward. More... | |
void * | chCoreAllocFromTopI (size_t size, unsigned align, size_t offset) |
Allocates a memory block starting from the top address downward. More... | |
void * | chCoreAllocFromBase (size_t size, unsigned align, size_t offset) |
Allocates a memory block starting from the lowest address upward. More... | |
void * | chCoreAllocFromTop (size_t size, unsigned align, size_t offset) |
Allocates a memory block starting from the top address downward. 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.
#define chCoreAllocAlignedWithOffsetI chCoreAllocFromTopI |
Allocates a memory block.
Definition at line 102 of file chmemcore.h.
#define chCoreAllocAlignedWithOffset chCoreAllocFromTop |
Allocates a memory block.
Definition at line 110 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 memcore_t::basemem, CH_CFG_MEMCORE_SIZE, ch_memcore, and memcore_t::topmem.
Referenced by __oslib_init().
void * chCoreAllocFromBaseI | ( | size_t | size, |
unsigned | align, | ||
size_t | offset | ||
) |
Allocates a memory block starting from the lowest address upward.
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.
Referenced by chCoreAllocFromBase().
void * chCoreAllocFromTopI | ( | size_t | size, |
unsigned | align, | ||
size_t | offset | ||
) |
Allocates a memory block starting from the top address downward.
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 145 of file chmemcore.c.
Referenced by chCoreAllocFromTop().
void * chCoreAllocFromBase | ( | size_t | size, |
unsigned | align, | ||
size_t | offset | ||
) |
Allocates a memory block starting from the lowest address upward.
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 178 of file chmemcore.c.
References chCoreAllocFromBaseI(), chSysLock, and chSysUnlock.
void * chCoreAllocFromTop | ( | size_t | size, |
unsigned | align, | ||
size_t | offset | ||
) |
Allocates a memory block starting from the top address downward.
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 202 of file chmemcore.c.
References chCoreAllocFromTopI(), chSysLock, and chSysUnlock.
size_t chCoreGetStatusX | ( | void | ) |
Core memory status.
Definition at line 219 of file chmemcore.c.
References memcore_t::basemem, ch_memcore, and memcore_t::topmem.
|
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 150 of file chmemcore.h.
References chCoreAllocAlignedWithOffsetI.
|
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 168 of file chmemcore.h.
References chCoreAllocAlignedWithOffset.
|
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 185 of file chmemcore.h.
References chCoreAllocAlignedWithOffsetI, and PORT_NATURAL_ALIGN.
|
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 202 of file chmemcore.h.
References chCoreAllocAlignedWithOffset, and PORT_NATURAL_ALIGN.
memcore_t ch_memcore |
Memory core descriptor.
Definition at line 58 of file chmemcore.c.
Referenced by __core_init(), and chCoreGetStatusX().