![]() |
ChibiOS/RT Architecture - Reference Manual - Guides |
|
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.
In order to use the core memory manager APIs the CH_USE_MEMCORE option must be enabled in chconf.h.
Defines | |
| #define | MEM_ALIGN_MASK (sizeof(stkalign_t) - 1) |
| Alignment mask constant. | |
| #define | MEM_ALIGN_SIZE(p) (((size_t)(p) + MEM_ALIGN_MASK) & ~MEM_ALIGN_MASK) |
| Alignment helper macro. | |
| #define | MEM_IS_ALIGNED(p) (((size_t)(p) & MEM_ALIGN_MASK) == 0) |
Returns whatever a pointer or memory size is aligned to the type align_t. | |
Typedefs | |
| typedef void *(* | memgetfunc_t )(size_t size) |
| Memory get function. | |
Functions | |
| void | core_init (void) |
| Low level memory manager initialization. | |
| void * | chCoreAlloc (size_t size) |
| Allocates a memory block. | |
| void * | chCoreAllocI (size_t size) |
| Allocates a memory block. | |
| size_t | chCoreStatus (void) |
| Core memory status. | |
| #define MEM_ALIGN_MASK (sizeof(stkalign_t) - 1) |
Alignment mask constant.
Definition at line 48 of file chmemcore.h.
| #define MEM_ALIGN_SIZE | ( | p | ) | (((size_t)(p) + MEM_ALIGN_MASK) & ~MEM_ALIGN_MASK) |
Alignment helper macro.
Definition at line 53 of file chmemcore.h.
Referenced by chCoreAllocI(), chHeapAlloc(), chPoolInit(), and core_init().
| #define MEM_IS_ALIGNED | ( | p | ) | (((size_t)(p) & MEM_ALIGN_MASK) == 0) |
Returns whatever a pointer or memory size is aligned to the type align_t.
Definition at line 59 of file chmemcore.h.
Referenced by chHeapInit(), and chPoolFreeI().
| typedef void*(* memgetfunc_t)(size_t size) |
Memory get function.
chMemAlloc() function. Definition at line 43 of file chmemcore.h.
| void core_init | ( | void | ) |
Low level memory manager initialization.
Definition at line 62 of file chmemcore.c.
References CH_MEMCORE_SIZE, and MEM_ALIGN_SIZE.
Referenced by chSysInit().
| void * chCoreAlloc | ( | size_t | size | ) |
Allocates a memory block.
The size of the returned block is aligned to the alignment type stkalign_t so it is not possible to allocate less than sizeof(stkalign_t).
| [in] | size | the size of the block to be allocated |
| NULL | allocation failed, core memory exhausted. |
Definition at line 88 of file chmemcore.c.
References chCoreAllocI(), chSysLock, and chSysUnlock.

| void * chCoreAllocI | ( | size_t | size | ) |
Allocates a memory block.
The size of the returned block is aligned to the alignment type align_t so it is not possible to allocate less than sizeof(align_t).
| [in] | size | the size of the block to be allocated. |
| NULL | allocation failed, core memory exhausted. |
Definition at line 107 of file chmemcore.c.
References MEM_ALIGN_SIZE.
Referenced by chCoreAlloc().
| size_t chCoreStatus | ( | void | ) |
Core memory status.
Definition at line 123 of file chmemcore.c.
1.7.1