ChibiOS/RT Logo ChibiOS/RT

Architecture - Reference Manual - Guides

Core Memory Manager
[Memory Management]

Collaboration diagram for Core Memory Manager:


Description

Core Memory Manager related APIs and services.

Operation mode

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 Documentation

#define MEM_ALIGN_MASK   (sizeof(stkalign_t) - 1)

Alignment mask constant.

Definition at line 48 of file chmemcore.h.

#define MEM_ALIGN_SIZE (  )     (((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 (  )     (((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 Documentation

typedef void*(* memgetfunc_t)(size_t size)

Memory get function.

Note:
This type must be assignment compatible with the chMemAlloc() function.

Definition at line 43 of file chmemcore.h.


Function Documentation

void core_init ( void   ) 

Low level memory manager initialization.

Note:
Internal use only.

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).

Parameters:
[in] size the size of the block to be allocated
Returns:
A pointer to the allocated memory block.
Return values:
NULL allocation failed, core memory exhausted.

Definition at line 88 of file chmemcore.c.

References chCoreAllocI(), chSysLock, and chSysUnlock.

Referenced by heap_init().

Here is the call graph for this function:

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).

Parameters:
[in] size the size of the block to be allocated.
Returns:
A pointer to the allocated memory block.
Return values:
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.

Returns:
The size, in bytes, of the free core memory.

Definition at line 123 of file chmemcore.c.


Generated on Sun Jul 11 13:13:15 2010 for ChibiOS/RT by doxygen 1.6.3