X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fcm%2Fcm_mblk.c;h=03c4583b8a30772cd5c99844a6fb76d814668007;hb=c98e69a3cfa10b1b47dafe94062dc68817cae6a1;hp=3413ca8f76961279a5e629f1c912d5949a587c8f;hpb=829bbd114f1c3dc00c1da47bca0a8207c049df3f;p=o-du%2Fl2.git diff --git a/src/cm/cm_mblk.c b/src/cm/cm_mblk.c index 3413ca8f7..03c4583b8 100644 --- a/src/cm/cm_mblk.c +++ b/src/cm/cm_mblk.c @@ -30,24 +30,13 @@ /* header include files (.h) */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ -#include "gen.h" /* general layer */ -#include "ssi.h" /* system services */ -#include "cm_mblk.h" /* Header file */ - -/* header/extern include files (.x) */ -#include "gen.x" /* general layer */ -#include "ssi.x" /* system services */ -#include "cm_lib.x" /* Common library */ -#include "cm_mblk.x" /* Typedef file */ +#include "common_def.h" /* Header file */ #ifdef SS_LOCKLESS_MEMORY -EXTERN pthread_t tmpRegTidMap[20]; +pthread_t tmpRegTidMap[20]; #define CM_MEM_GET_REGION(_region) \ { \ - U8 _regCnt; \ + uint8_t _regCnt; \ _region = 0xFF; \ \ for(_regCnt = 0; _regCnt < 12; _regCnt++) \ @@ -63,7 +52,7 @@ EXTERN pthread_t tmpRegTidMap[20]; -PRIVATE Void cmAddMemNode ARGS((CmMemListCp *lCp,CmMemList *node)); +static Void cmAddMemNode ARGS((CmMemListCp *lCp,CmMemList *node)); /* @@ -83,21 +72,13 @@ PRIVATE Void cmAddMemNode ARGS((CmMemListCp *lCp,CmMemList *node)); * */ -#ifdef ANSI -PUBLIC S16 cmAllocEvnt +S16 cmAllocEvnt ( Size evntSize, /* Size of the Event structure */ Size maxBlkSize, /* Chunk Memory size */ Mem *sMem, /* Static memory region and pool */ Ptr *ptr /* Location to place allocated event ptr */ ) -#else -PUBLIC S16 cmAllocEvnt (evntSize,maxBlkSize,sMem,ptr) -Size evntSize; /* Size of the Event structure */ -Size maxBlkSize; /* Memory size requested */ -Mem *sMem; /* Static Memory region and pool */ -Ptr *ptr; /* Location to place allocated event ptr */ -#endif { Data *allocPtr; /* Allocated Memory Pointer */ @@ -105,40 +86,39 @@ Ptr *ptr; /* Location to place allocated event ptr */ CmMemListCp *memCp; /* memory Link list control point */ CmMemCb *cb; /* Allocated Memory Control Block */ - TRC2(cmAllocEvnt) /* Validation check */ #ifndef LTE_ENB_PAL if( evntSize > maxBlkSize) { - printf("\nNot Allocating memory for Event\n"); + DU_LOG("\nERROR --> Not Allocating memory for Event\n"); #ifdef ALIGN_64BIT - printf("eventSize [%d] greater than maxBlkSize [%d]\n", + DU_LOG("\nERROR --> eventSize [%d] greater than maxBlkSize [%d]\n", evntSize, maxBlkSize); #else - printf("eventSize [%ld] greater than maxBlkSize [%ld]\n", + DU_LOG("\nERROR --> eventSize [%ld] greater than maxBlkSize [%ld]\n", evntSize, maxBlkSize); #endif - RETVALUE(RFAILED); + return RFAILED; } #endif /* Allocate memory for the first Memory Chunk */ /* Allocated memory should be maxBlkSize + sizeof(CmMemList) */ #ifdef SS_LOCKLESS_MEMORY - if(SGetStaticBuffer(sMem->region, sMem->pool, (Data **)&allocPtr, + if(SGetStaticBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,sMem->region, sMem->pool, (Data **)&allocPtr, (Size)(maxBlkSize + sizeof(CmMemList)), 0) != ROK) #else - if (SGetSBuf(sMem->region, sMem->pool, + if (SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,sMem->region, sMem->pool, (Data **)&allocPtr, (Size)(maxBlkSize + sizeof(CmMemList))) != ROK) #endif /* SS_LOCKLESS_MEMORY */ - RETVALUE(RFAILED); + return RFAILED; /* Reset the contents */ - cmMemset((U8 *)allocPtr, (U8 )0, - (PTR)(maxBlkSize + sizeof(CmMemList)) ); + memset(allocPtr, 0, + (maxBlkSize + sizeof(CmMemList)) ); /* The above allocated memory chunk is structured as follows @@ -180,7 +160,7 @@ Ptr *ptr; /* Location to place allocated event ptr */ *ptr = (Ptr) ((PTR)allocPtr + sizeof(CmMemList)); cb->runPtr = ((PTR)(*ptr) + evntSize); - RETVALUE(ROK); + return ROK; } /* End of cmAllocEvnt */ @@ -200,27 +180,18 @@ Ptr *ptr; /* Location to place allocated event ptr */ * */ -#ifdef ANSI -PUBLIC Void cmInitMemCp +Void cmInitMemCp ( CmMemListCp *memCp, /* Memory control pointer */ Size maxBlkSize, /* Chunk Memory size */ Mem *sMem /* Static memory region and pool */ ) -#else -PUBLIC Void cmInitMemCp (memCp,maxBlkSize,sMem) -CmMemListCp *memCp; /* Memory control pointer */ -Size maxBlkSize; /* Memory size requested */ -Mem *sMem; /* Static Memory region and pool */ -#endif { - TRC2(cmInitMemCp) - /* Intialise Memory Control Point */ CM_INIT_MEMCP(memCp,maxBlkSize,sMem); - RETVOID; + return; } /* End of cmInitMemCp */ @@ -240,19 +211,12 @@ Mem *sMem; /* Static Memory region and pool */ * */ -#ifdef ANSI -PUBLIC S16 cmGetMem +S16 cmGetMem ( Ptr memPtr, /* Pointer to memCp */ Size size, /* Memory size requested */ Ptr *allocPtr /* location to place pointer */ ) -#else -PUBLIC S16 cmGetMem (memPtr,size,allocPtr) -Ptr memPtr; /* Pointer to memCp */ -Size size; /* Memory size requested */ -Ptr *allocPtr; /* location to place pointer */ -#endif { CmMemCb *cb; /* Pointer to Memory Control Block */ @@ -261,7 +225,6 @@ Ptr *allocPtr; /* location to place pointer */ /* cm_mblk_c_001.101: added local variable */ Size blkSize; /* required block size */ - TRC2(cmGetMem) memCp = (CmMemListCp *)memPtr; cb = &memCp->memCb; @@ -283,13 +246,13 @@ Ptr *allocPtr; /* location to place pointer */ { /* if a chunk is already there */ if( (cb->memAllocated + size) <= - (U32)(cb->maxSize + sizeof(CmMemList)) ) + (uint32_t)(cb->maxSize + sizeof(CmMemList)) ) { /* Requested memory is available in present chunk */ *allocPtr = (Ptr) cb->runPtr; cb->memAllocated += size; cb->runPtr += size; - RETVALUE(ROK); + return ROK; } } @@ -297,21 +260,21 @@ Ptr *allocPtr; /* location to place pointer */ /* Allocate buffer */ /* cm_mblk_c_001.101: use blkSize instead of cb->maxSize */ #ifdef SS_LOCKLESS_MEMORY - if(SGetStaticBuffer(cb->sMem.region, cb->sMem.pool, + if(SGetStaticBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,cb->sMem.region, cb->sMem.pool, (Data **)&(cb->initPtr), (Size)(blkSize + sizeof(CmMemList)), 0) != ROK) #else - if (SGetSBuf(cb->sMem.region, cb->sMem.pool, + if (SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,cb->sMem.region, cb->sMem.pool, (Data **)&(cb->initPtr), (Size)(blkSize + sizeof(CmMemList)) ) != ROK) #endif /* SS_LOCKLESS_MEMORY */ - RETVALUE(RFAILED); + return RFAILED; /* Reset the contents */ /* Initialise above allocated structure */ /* cm_mblk_c_001.101: use blkSize instead of cb->maxSize */ - cmMemset((U8 *)cb->initPtr, (U8 )0, - (PTR)(blkSize + sizeof(CmMemList) )); + memset(&(cb->initPtr), 0, + (blkSize + sizeof(CmMemList) )); /* The above allocated memory chunk is structured as follows @@ -335,7 +298,7 @@ Ptr *allocPtr; /* location to place pointer */ *allocPtr = (Ptr) ((PTR)cb->initPtr + sizeof(CmMemList)); cb->runPtr = ((PTR)(*allocPtr) + size); - RETVALUE(ROK); + return ROK; } /* End of cmGetMem */ @@ -359,21 +322,13 @@ Ptr *allocPtr; /* location to place pointer */ * */ -#ifdef ANSI -PUBLIC S16 cmAllocEvntNoInit +S16 cmAllocEvntNoInit ( Size evntSize, /* Size of the Event structure */ Size maxBlkSize, /* Chunk Memory size */ Mem *sMem, /* Static memory region and pool */ Ptr *ptr /* Location to place allocated event ptr */ ) -#else -PUBLIC S16 cmAllocEvntNoInit (evntSize,maxBlkSize,sMem,ptr) -Size evntSize; /* Size of the Event structure */ -Size maxBlkSize; /* Memory size requested */ -Mem *sMem; /* Static Memory region and pool */ -Ptr *ptr; /* Location to place allocated event ptr */ -#endif { Data *allocPtr; /* Allocated Memory Pointer */ @@ -381,28 +336,27 @@ Ptr *ptr; /* Location to place allocated event ptr */ CmMemListCp *memCp; /* memory Link list control point */ CmMemCb *cb; /* Allocated Memory Control Block */ - TRC2(cmAllocEvntNoInit) /* Validation check */ if( evntSize > maxBlkSize) - RETVALUE(RFAILED); + return RFAILED; /* Allocate memory for the first Memory Chunk */ /* Allocated memory should be maxBlkSize + sizeof(CmMemList) */ #ifdef SS_LOCKLESS_MEMORY - if(SGetStaticBuffer(sMem->region, sMem->pool, (Data **)&allocPtr, + if(SGetStaticBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,sMem->region, sMem->pool, (Data **)&allocPtr, (Size)(maxBlkSize + sizeof(CmMemList)), 0) != ROK) #else - if (SGetSBuf(sMem->region, sMem->pool, + if (SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,sMem->region, sMem->pool, (Data **)&allocPtr, (Size)(maxBlkSize + sizeof(CmMemList))) != ROK) #endif /* SS_LOCKLESS_MEMORY */ - RETVALUE(RFAILED); + return RFAILED; /* Reset the contents */ - cmMemset((U8 *)allocPtr, (U8 )0, - (PTR)(sizeof(CmMemList)) ); + memset(allocPtr, 0, + (sizeof(CmMemList)) ); /* The above allocated memory chunk is structured as follows @@ -444,7 +398,7 @@ Ptr *ptr; /* Location to place allocated event ptr */ *ptr = (Ptr) ((PTR)allocPtr + sizeof(CmMemList)); cb->runPtr = ((PTR)(*ptr) + evntSize); - RETVALUE(ROK); + return ROK; } /* End of cmAllocEvntNoInit */ @@ -463,19 +417,12 @@ Ptr *ptr; /* Location to place allocated event ptr */ * */ -#ifdef ANSI -PUBLIC S16 cmGetMemNoInit +S16 cmGetMemNoInit ( Ptr memPtr, /* Pointer to memCp */ Size size, /* Memory size requested */ Ptr *allocPtr /* location to place pointer */ ) -#else -PUBLIC S16 cmGetMemNoInit (memPtr,size,allocPtr) -Ptr memPtr; /* Pointer to memCp */ -Size size; /* Memory size requested */ -Ptr *allocPtr; /* location to place pointer */ -#endif { CmMemCb *cb; /* Pointer to Memory Control Block */ @@ -484,7 +431,6 @@ Ptr *allocPtr; /* location to place pointer */ /* cm_mblk_c_001.101: added local variable */ Size blkSize; /* required block size */ - TRC2(cmGetMemNoInit) memCp = (CmMemListCp *)memPtr; cb = &memCp->memCb; @@ -506,15 +452,15 @@ Ptr *allocPtr; /* location to place pointer */ { /* if a chunk is already there */ if( (cb->memAllocated + size) <= - (U32)(cb->maxSize + sizeof(CmMemList)) ) + (uint32_t)(cb->maxSize + sizeof(CmMemList)) ) { /* Requested memory is available in present chunk */ *allocPtr = (Ptr) cb->runPtr; - //cmMemset((U8 *)*allocPtr, (U8 )0, + //memset(*allocPtr, (uint8_t )0, // (PTR)(size) ); cb->memAllocated += size; cb->runPtr += size; - RETVALUE(ROK); + return ROK; } } @@ -522,21 +468,21 @@ Ptr *allocPtr; /* location to place pointer */ /* Allocate buffer */ /* cm_mblk_c_001.101: use blkSize instead of cb->maxSize */ #ifdef SS_LOCKLESS_MEMORY - if(SGetStaticBuffer(cb->sMem.region, cb->sMem.pool, + if(SGetStaticBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,cb->sMem.region, cb->sMem.pool, (Data **)&(cb->initPtr), (Size)(blkSize + sizeof(CmMemList)), 0) != ROK) #else - if (SGetSBuf(cb->sMem.region, cb->sMem.pool, + if (SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,cb->sMem.region, cb->sMem.pool, (Data **)&(cb->initPtr), (Size)(blkSize + sizeof(CmMemList)) ) != ROK) #endif /* SS_LOCKLESS_MEMORY */ - RETVALUE(RFAILED); + return RFAILED; /* Reset the contents */ /* Initialise above allocated structure */ /* cm_mblk_c_001.101: use blkSize instead of cb->maxSize */ - cmMemset((U8 *)cb->initPtr, (U8 )0, - (PTR)(sizeof(CmMemList))); + memset(&(cb->initPtr), 0, + (sizeof(CmMemList))); /* The above allocated memory chunk is structured as follows +-------------------+ @@ -559,7 +505,7 @@ Ptr *allocPtr; /* location to place pointer */ *allocPtr = (Ptr) ((PTR)cb->initPtr + sizeof(CmMemList)); cb->runPtr = ((PTR)(*allocPtr) + size); - RETVALUE(ROK); + return ROK; } /* End of cmGetMemNoInit */ @@ -583,15 +529,10 @@ Ptr *allocPtr; /* location to place pointer */ * */ -#ifdef ANSI -PUBLIC Void cmFreeMem +Void cmFreeMem ( Ptr memPtr /* Link List CP */ ) -#else -PUBLIC Void cmFreeMem (memPtr) -Ptr memPtr; /* Link List CP */ -#endif { Mem sMem; /* Static Memory region and pool */ S32 count; /* Count of linked blocks */ @@ -600,7 +541,6 @@ Ptr memPtr; /* Link List CP */ CmMemList *prevNode; /* Pointer to previous node */ CmMemListCp *lcp; /* Memory Link List */ - TRC2(cmFreeMem) lcp = (CmMemListCp *)memPtr; @@ -627,10 +567,10 @@ Ptr memPtr; /* Link List CP */ if( node ) { #ifdef SS_LOCKLESS_MEMORY - SPutStaticBuffer(sMem.region, sMem.pool, + SPutStaticBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,sMem.region, sMem.pool, (Data *)node, (node->size + sizeof(CmMemList)), 0); #else - SPutSBuf(sMem.region,sMem.pool, + SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,sMem.region,sMem.pool, (Data *)node, (node->size + sizeof(CmMemList))); #endif /* SS_LOCKLESS_MEMORY */ } @@ -638,7 +578,7 @@ Ptr memPtr; /* Link List CP */ count--; } - RETVOID; + return; } /* End of cmFreeMem */ @@ -656,19 +596,12 @@ Ptr memPtr; /* Link List CP */ * File: cm_mblk.c * */ -#ifdef ANSI -PRIVATE Void cmAddMemNode +static Void cmAddMemNode ( CmMemListCp *lCp, /* list control point */ CmMemList *node /* node to be added */ ) -#else -PRIVATE Void cmAddMemNode (lCp, node) -CmMemListCp *lCp; /* list control point */ -CmMemList *node; /* node to be added */ -#endif { - TRC3(cmAddMemNode); lCp->count++; @@ -679,11 +612,11 @@ CmMemList *node; /* node to be added */ if (!node->prev) { lCp->first = node; - RETVOID; + return; } node->prev->next = node; - RETVOID; + return; } /* end of cmAddMemNode */ @@ -704,22 +637,15 @@ CmMemList *node; /* node to be added */ * */ -#ifdef ANSI -PUBLIC Void cmGetMemStatus +Void cmGetMemStatus ( Ptr memPtr, /* Memory control pointer */ CmMemStatus *status /* memory region,pool and status */ ) -#else -PUBLIC Void cmGetMemStatus (memPtr,status) -Ptr memPtr; /* Memory control pointer */ -CmMemStatus *status; /* memory region,pool and status */ -#endif { CmMemListCp *memCp; /* Memory Link List */ - TRC3(cmGetMemStatus) memCp = (CmMemListCp *)memPtr; @@ -730,7 +656,7 @@ CmMemStatus *status; /* memory region,pool and status */ status->maxBlkSize = memCp->memCb.maxSize; status->memAllocated = memCp->memCb.memAllocated; - RETVOID; + return; } /* End of cmGetMemStatus */