|
ChibiOS/RT
2.5.1 |
|
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_USE_MEMCORE option must be enabled in chconf.h. 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. | |
Alignment support macros | |
| #define | MEM_ALIGN_SIZE sizeof(stkalign_t) |
| Alignment size constant. | |
| #define | MEM_ALIGN_MASK (MEM_ALIGN_SIZE - 1) |
| Alignment mask constant. | |
| #define | MEM_ALIGN_PREV(p) ((size_t)(p) & ~MEM_ALIGN_MASK) |
| Alignment helper macro. | |
| #define | MEM_ALIGN_NEXT(p) MEM_ALIGN_PREV((size_t)(p) + 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. | |
| void _core_init | ( | void | ) |
Low level memory manager initialization.
Definition at line 59 of file chmemcore.c.
References CH_MEMCORE_SIZE, MEM_ALIGN_NEXT, MEM_ALIGN_PREV, 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 so it is not possible to allocate less than MEM_ALIGN_SIZE.
| [in] | size | the size of the block to be allocated |
| NULL | allocation failed, core memory exhausted. |
Definition at line 84 of file chmemcore.c.
References chCoreAllocI(), chSysLock, and chSysUnlock.
Referenced by _heap_init().

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

| size_t chCoreStatus | ( | void | ) |
Core memory status.
Definition at line 125 of file chmemcore.c.
| #define MEM_ALIGN_SIZE sizeof(stkalign_t) |
| #define MEM_ALIGN_MASK (MEM_ALIGN_SIZE - 1) |
Alignment mask constant.
Definition at line 50 of file chmemcore.h.
| #define MEM_ALIGN_PREV | ( | p | ) | ((size_t)(p) & ~MEM_ALIGN_MASK) |
| #define MEM_ALIGN_NEXT | ( | p | ) | MEM_ALIGN_PREV((size_t)(p) + MEM_ALIGN_MASK) |
Alignment helper macro.
Definition at line 60 of file chmemcore.h.
Referenced by _core_init(), chCoreAllocI(), and chHeapAlloc().
| #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 66 of file chmemcore.h.
Referenced by chHeapInit().
| typedef void*(* memgetfunc_t)(size_t size) |
Memory get function.
chMemAlloc() function. Definition at line 37 of file chmemcore.h.