41#ifndef MANAGER_H_INCLUDED
42#define MANAGER_H_INCLUDED
44#include <sdk/config.h>
55#include "memutils/common_utils/common_errcode.h"
56#include "memutils/memory_manager/MemPool.h"
86 static err_t
initFirst(
void* manager_area, uint32_t area_size);
94 static err_t
initPerCpu(
void* manager_area, uint32_t pool_num);
96 static err_t
initPerCpu(
void* manager_area,
MemPool ** static_pools[], uint8_t* pool_num, uint8_t* layout_no);
132 static bool isStaticPoolAvailable(uint8_t sec_no) {
return getCurrentLayoutNo(sec_no) != BadLayoutNo; }
134#ifdef USE_MEMMGR_DYNAMIC_POOL
137 static PoolId createDynamicPool(
const PoolAttr& attr,
void* work_area, uint32_t area_size);
138 static void destroyDynamicPool(PoolId
id);
139 static uint32_t getDynamicPoolWorkSize(
const PoolAttr& attr) {
return DYN_POOL_WORK_SIZE(attr); }
144 static uint32_t getStaticPoolsUsedSegs(uint8_t sec,MemHandleBase* mhs, uint32_t num_mhs);
145 static uint32_t getUsedSegs(uint8_t sec,PoolId
id, MemHandleBase* mhs, uint32_t num_mhs) {
146 return findPool(
id)->getUsedSegs(mhs, num_mhs);
151 static bool isPoolAvailable(PoolId
id) {
return getPoolObject(
id) != NULL; }
152 static PoolType getPoolType(PoolId
id) {
return findPool(
id)->getPoolType(); }
153 static PoolAddr getPoolAddr(PoolId
id) {
return findPool(
id)->getPoolAddr(); }
154 static PoolSize getPoolSize(PoolId
id) {
return findPool(
id)->getPoolSize(); }
155 static NumSeg getPoolNumSegs(PoolId
id) {
return findPool(
id)->getPoolNumSegs(); }
156 static NumSeg getPoolNumAvailSegs(PoolId
id) {
return findPool(
id)->getPoolNumAvailSegs(); }
157#ifdef CONFIG_MEMUTILS_MEMORY_MANAGER_USE_FENCE
158 static bool isPoolFenceEnable(PoolId
id) {
return findPool(
id)->isPoolFenceEnable(); }
160#ifdef USE_MEMMGR_MULTI_CORE
161 static LockId getPoolLockId(PoolId
id) {
return findPool(
id)->getPoolLockId(); }
164#ifdef USE_MEMMGR_DEBUG_OUTPUT
168#ifdef CONFIG_MEMUTILS_MEMORY_MANAGER_USE_FENCE
171 static uint32_t verifyFixedAreaFences();
172 static uint32_t verifyStaticPoolsFence(uint8_t sec);
173 static uint32_t verifyPoolFence(PoolId
id) {
return findPool(
id)->verifyPoolFence(); }
179 static MemPool* createPool(
const PoolSectionAttr& attr, FastMemAlloc& fma);
180 static void destroyPool(MemPool* pool);
181 static void initFixedAreaFences();
187 static MemPool* getPoolObject(PoolId
id) {
188 if (
id.pool < theManager->m_pool_num[
id.sec]) {
189 return theManager->m_static_pools[
id.sec][
id.pool];
190#ifdef USE_MEMMGR_DYNAMIC_POOL
191 }
else if (id < theManager->m_pool_num + NUM_DYN_POOLS) {
192 return theManager->m_dynamic_pools[
id.pool - theManager->m_pool_num];
200 static MemPool* findPool(PoolId
id) {
201 MemPool* p = getPoolObject(
id);
208 friend class MemHandleBase;
209#ifdef USE_MEMMGR_SEG_DELETER
210 static err_t allocSeg(PoolId
id,
size_t size_for_check, MemHandleProxy &proxy,
bool use_deleter);
212 static err_t allocSeg(PoolId
id,
size_t size_for_check, MemHandleProxy &proxy);
214 static void freeSeg(MemHandleBase& mh);
215 static PoolAddr getSegAddr(
const MemHandleBase& mh);
216 static PoolSize getSegSize(
const MemHandleBase& mh);
217 static SegRefCnt getSegRefCnt(PoolId
id, NumSeg seg_no) {
return findPool(
id)->getSegRefCnt(seg_no); }
218 static void incSegRefCnt(PoolId
id, NumSeg seg_no) { findPool(
id)->incSegRefCnt(seg_no); }
221 static Manager* theManager;
223 uint8_t m_signature[3];
226 uint32_t m_fix_fene_num;
228 uint8_t* m_layout_no;
230 MemPool*** m_static_pools;
232#ifdef USE_MEMMGR_DYNAMIC_POOL
233 MemPool* m_dynamic_pools[NUM_DYN_POOLS];
235 PoolId m_pool_no_array[NUM_DYN_POOLS];
Definition: cpp_util.h:45
Memory Management Class for "Memory Manager Lite". User can create only one instance.
Definition: Manager.h:73
static NumLayout getCurrentLayoutNo(uint8_t sec_no)
Definition: Manager.h:131
static err_t initPerCpu(void *manager_area, uint32_t pool_num)
static void destroyStaticPools(uint8_t sec_no)
static err_t initFirst(void *manager_area, uint32_t area_size)
static err_t createStaticPools(uint8_t sec_no, NumLayout layout_no, void *work_area, uint32_t area_size, const PoolSectionAttr *pool_attr)
Definition: RuntimeQue.h:57
namespace for "Memory Manager".
uint8_t PoolType
Definition: MemMgrTypes.h:95
uint8_t NumLayout
Definition: MemMgrTypes.h:82
Definition: MemMgrTypes.h:149
Definition: MemMgrTypes.h:177