?? cm_mem.x
字號(hào):
/********************************************************************20**
Name: Common Memory Manager
Type: C include file
Desc: Data structure definitions that are used by
the Common Memory Manager.
File: cm_mem.x
Sid: cm_mem.x 1.4 - 10/02/98 16:24:39
Prg: rm
*********************************************************************21*/
#ifndef __CMMEMX_
#define __CMMEMX_
#ifdef __cplusplus
extern "C" {
#endif
/* typedefs */
typedef struct cmMmRegCfg CmMmRegCfg;
typedef struct cmMmBktCfg CmMmBktCfg;
typedef struct cmMmRegCb CmMmRegCb;
typedef struct cmMmMapBkt CmMmMapBkt;
typedef struct cmMmHeapCb CmMmHeapCb;
typedef struct cmMmBkt CmMmBkt;
typedef struct cmHEntry CmHEntry;
typedef Data CmMmEntry;
/* forward definitions */
/************************************************************************
Common Memory Manager Configuration Data Structures
************************************************************************/
/* Bucket configuration structure. */
struct cmMmBktCfg
{
Size size; /* Size of the memory block */
U16 numBlks; /* Number of the block in the bucket */
};
/* Memory Region configuration structure. */
struct cmMmRegCfg
{
Size size; /* Size of the memory */
Data *vAddr; /* Start address of the memory */
U8 lType; /* Lock Type to be used */
U8 chFlag; /* Flag defines the memory region characteristics */
Data *pAddr; /* Physical address of the memory block: Valid
if CMM_REG_PHY_VALID bit of chFlag is set */
Size bktQnSize; /* Quatum size of the memory block */
U16 numBkts; /* Number of buckets in the Bucket Pool */
CmMmBktCfg bktCfg[CMM_MAX_BKT_ENT]; /* Bucket configuration structure */
};
/************************************************************************
Common Memory Manager Implementation Data Structures
************************************************************************/
/* Memory bucket structure */
struct cmMmBkt /* Bucket Structure */
{
CmMmEntry *next; /* Pointer to the next memory block */
Size size; /* Size of the block */
U16 numBlks; /* Total number of blocks in the bucket */
U16 numAlloc; /* Number of blocks allocated */
SLockId bktLock; /* Lock to protect the bucket pool */
};
/* Size-To-Bucket map table structure */
struct cmMmMapBkt
{
U16 bktIdx; /* The index to the memory bucket */
#if (ERRCLASS & ERRCLS_DEBUG)
U16 numReq; /* Number of the allocation request */
U16 numFailure; /* Number of allocation failure form the bucket */
#endif
};
/* Heap entry structure linked in the heap control block */
#undef USE_TRSRC_CODE
struct cmHEntry
{
CmHEntry *next; /* Pointer to the next entry block */
/* add by shang */
#ifndef USE_TRSRC_CODE
CmHEntry *prev; /* Pointer to the prev entry block */
#endif
/* add by shang over */
Size size; /* size of the heap entry block */
};
/* Heap control block */
struct cmMmHeapCb
{
Data *vStart; /* Memory start address */
Data *vEnd; /* Memory end address */
CmHEntry *next; /* Next heap block entry */
Size avlSize; /* Total available memory */
Size minSize; /* Minimum size that can be allocated */
SLockId heapLock; /* Lock to protect the heap pool */
#if (ERRCLASS & ERRCLS_DEBUG)
U16 numFragBlk; /* Number of fragmented block */
U16 numReq; /* Number of allocation request */
U16 numFailure; /* Number of allocation failure */
#endif
};
/* Memory region control block */
struct cmMmRegCb
{
Region region; /* Region Id of the memory */
SRegInfo regInfo; /* Region information block */
U8 chFlag; /* Flag defines the region characteristics */
Data *pAddr; /* Physical address of the memory block.
Valid if CMM_REG_PHY_VALID bit is set */
Size bktSize; /* Size of the memory used for the bucket pool */
U16 bktQnPwr; /* Quantum size of the bucket pool */
Size bktMaxBlkSize; /* Maximum size of block in the bucket pool */
U16 numBkts; /* Number of buckets in the Bucket Pool */
CmMmMapBkt mapTbl[CMM_MAX_MAP_ENT]; /* size-to-bucket map table */
CmMmBkt bktTbl[CMM_MAX_BKT_ENT]; /* Pointer to the memory bkt tbl */
Bool heapFlag; /* Set to true if the heap pool is configured */
Size heapSize; /* Size of the heap pool */
CmMmHeapCb heapCb; /* Heap pool control block */
};
/* functions prototypes */
EXTERN S16 cmMmRegInit ARGS((
Region region,
CmMmRegCb *regCb,
CmMmRegCfg *cfg));
EXTERN S16 cmMmRegDeInit ARGS(( CmMmRegCb *regCb));
#ifdef __cplusplus
}
#endif
#endif
/********************************************************************30**
End of file: cm_mem.x 1.4 - 10/02/98 16:24:39
*********************************************************************31*/
/********************************************************************40**
Notes:
*********************************************************************41*/
/********************************************************************50**
*********************************************************************51*/
/********************************************************************60**
Revision history:
*********************************************************************61*/
/********************************************************************90**
ver pat init description
------------ -------- ---- -----------------------------------------------
1.1 --- rm 1. initial release
1.2 --- kp 1. Removed prototypes for cmAlloc, cmFree and
cmCtl and moved them to cm_mem.c to remove
GCC compile warnings
1.3 --- kp 1. C++ compilable
1.4 --- rm 1. Remove the bktLock from cmMmRegCb and add it
cmMmRegCb.
*********************************************************************91*/
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -