unified: Support heap memory pool
Fleshes out the prototype heap memory pool support to make it fully operational. Noteworthy changes are listed below: Tweaks arguments to k_malloc() and k_free() to be more like malloc() and free(). Similarly, modifies k_free() to take no action when passed a NULL pointer. Now stores the complete block descriptor at the start of any block allocated from the heap memory pool. This increases memory overhead by 4 bytes per block, but streamlines the allocation and freeing algorithms. It also ensures that the routines will work if the block descriptor internals are changed in the future. Now allows the heap memory pool to be defined using the HEAP_MEM_POOL_SIZE configuration option. This will be the official configuration approach in the unified kernel. Also allows the heap memory pool to be defined using the (undocumented) HEAP_SIZE entry in the MDEF. This is provided for legacy reasons only. Co-locates memory pool initialization code to keep the line that causes memory pool initialization to be done during booting right next to the routine that does the initialization. Change-Id: Ifea9d88142fb434d4bea38bb1fcc4856a3853d8d Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
This commit is contained in:
parent
904cf97263
commit
480a131ad9
4 changed files with 87 additions and 61 deletions
|
@ -1814,10 +1814,10 @@ extern void k_mem_pool_free(struct k_mem_block *block);
|
|||
extern void k_mem_pool_defrag(struct k_mem_pool *pool);
|
||||
|
||||
/**
|
||||
* @brief Allocate memory from heap pool
|
||||
* @brief Allocate memory from heap
|
||||
*
|
||||
* This routine provides traditional malloc semantics; internally it uses
|
||||
* the memory pool APIs on a dedicated HEAP pool
|
||||
* This routine provides traditional malloc() semantics. The memory is
|
||||
* allocated from the heap memory pool.
|
||||
*
|
||||
* @param size Size of memory requested by the caller (in bytes)
|
||||
*
|
||||
|
@ -1826,7 +1826,10 @@ extern void k_mem_pool_defrag(struct k_mem_pool *pool);
|
|||
extern void *k_malloc(size_t size);
|
||||
|
||||
/**
|
||||
* @brief Free memory allocated through k_malloc()
|
||||
* @brief Free memory allocated from heap
|
||||
*
|
||||
* This routine provides traditional free() semantics. The memory being
|
||||
* returned must have been allocated from the heap memory pool.
|
||||
*
|
||||
* @param ptr Pointer to previously allocated memory
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue