|
ChibiOS/RT 7.0.6
|
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. 
Data Structures | |
| struct | memcore_t |
| Type of memory core object. More... | |
Macros | |
| #define | CH_CFG_MEMCORE_SIZE 0 |
| Managed RAM size. | |
| #define | chCoreAllocAlignedWithOffsetI chCoreAllocFromTopI |
| Allocates a memory block. | |
| #define | chCoreAllocAlignedWithOffset chCoreAllocFromTop |
| Allocates a memory block. | |
Typedefs | |
| typedef void *(* | memgetfunc_t) (size_t size, unsigned align) |
| Memory get function. | |
| typedef void *(* | memgetfunc2_t) (size_t size, unsigned align, size_t offset) |
| Enhanced memory get function. | |
Functions | |
| void | __core_init (void) |
| Low level memory manager initialization. | |
| void * | chCoreAllocFromBaseI (size_t size, unsigned align, size_t offset) |
| Allocates a memory block starting from the lowest address upward. | |
| void * | chCoreAllocFromTopI (size_t size, unsigned align, size_t offset) |
| Allocates a memory block starting from the top address downward. | |
| void * | chCoreAllocFromBase (size_t size, unsigned align, size_t offset) |
| Allocates a memory block starting from the lowest address upward. | |
| void * | chCoreAllocFromTop (size_t size, unsigned align, size_t offset) |
| Allocates a memory block starting from the top address downward. | |
| size_t | chCoreGetStatusX (void) |
| Core memory status. | |
| static void * | chCoreAllocAlignedI (size_t size, unsigned align) |
| Allocates a memory block. | |
| static void * | chCoreAllocAligned (size_t size, unsigned align) |
| Allocates a memory block. | |
| static void * | chCoreAllocI (size_t size) |
| Allocates a memory block. | |
| static void * | chCoreAlloc (size_t size) |
| Allocates a memory block. | |
Variables | |
| memcore_t | ch_memcore |
| Memory core descriptor. | |
| #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 52 of file chmemcore.h.
| #define chCoreAllocAlignedWithOffsetI chCoreAllocFromTopI |
Allocates a memory block.
Definition at line 101 of file chmemcore.h.
Referenced by chCoreAllocAlignedI(), and chCoreAllocI().
| #define chCoreAllocAlignedWithOffset chCoreAllocFromTop |
Allocates a memory block.
Definition at line 109 of file chmemcore.h.
Referenced by __heap_init(), chCoreAlloc(), and chCoreAllocAligned().
| typedef void *(* memgetfunc_t) (size_t size, unsigned align) |
Memory get function.
Definition at line 70 of file chmemcore.h.
| typedef void *(* memgetfunc2_t) (size_t size, unsigned align, size_t offset) |
Enhanced memory get function.
Definition at line 75 of file chmemcore.h.
| void __core_init | ( | void | ) |
Low level memory manager initialization.
Definition at line 80 of file chmemcore.c.
References CH_CFG_MEMCORE_SIZE, and ch_memcore.
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 111 of file chmemcore.c.
References ch_memcore, chDbgCheck, chDbgCheckClassI, MEM_ALIGN_NEXT, and MEM_IS_VALID_ALIGNMENT.
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 159 of file chmemcore.c.
References ch_memcore, chDbgCheck, chDbgCheckClassI, MEM_ALIGN_PREV, and MEM_IS_VALID_ALIGNMENT.
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 207 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 231 of file chmemcore.c.
References chCoreAllocFromTopI(), chSysLock(), and chSysUnlock().

| size_t chCoreGetStatusX | ( | void | ) |
Core memory status.
Definition at line 248 of file chmemcore.c.
References ch_memcore.
|
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 149 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 167 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 184 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 201 of file chmemcore.h.
References chCoreAllocAlignedWithOffset.
| memcore_t ch_memcore |
Memory core descriptor.
Definition at line 57 of file chmemcore.c.
Referenced by __core_init(), chCoreAllocFromBaseI(), chCoreAllocFromTopI(), and chCoreGetStatusX().