📄 ssp_dmem.c
字号:
#ifdef __cplusplusextern "C"{#endif #include "syscfg.h"#include "aos.h"#include "ssp_dmem.h"#include "ssp_slab.h"BUF_SIZES_S g_astBufSizes[] ={ {"size12", 12, U32_BUTT}, {"size32", 32, U32_BUTT}, {"size64", 64, U32_BUTT}, {"size128", 128, U32_BUTT}, {"size256", 256, U32_BUTT}, {"size360", 360, U32_BUTT}, {"size512", 512, U32_BUTT}, {"size1024", 1024, U32_BUTT}, {"size1664", 1664, U32_BUTT}, {"size2048", 2048, U32_BUTT}, {"size4096", 4096, U32_BUTT}, {"size8192", 8192, U32_BUTT}, {"size16384", 16384, U32_BUTT}, {"size32768", 32768, U32_BUTT}, {"size65536", 65536, U32_BUTT}, {"size131072", 131072, U32_BUTT}, {"size266240", 266240, U32_BUTT}, {"size1200128", 0x125000, U32_BUTT}, {"null", 0, U32_BUTT}};U32 m_dmem_init( ){ U32 i, result; for( i = 0; g_astBufSizes[i].size > 0; i++ ) { result = mem_buf_create( g_astBufSizes[i].name, g_astBufSizes[i].size, &g_astBufSizes[i].buf_id ); if( AOS_SUCC != result ) { return result; } } return AOS_SUCC;}VOID* aos_comm_dmem_alloc( MPE mpe, U32 sid, U32 ulSize ){#ifdef _EIA2000V7 VOID *pbuf; pbuf = aos_dmem_alloc_x(mpe,sid,4096,__FILE__,__LINE__); if( pbuf ) { pbuf += 2048; (U32)pbuf &= (~2047); } return pbuf;#else return aos_dmem_alloc_x(mpe,sid,ulSize,__FILE__,__LINE__);#endif}VOID* aos_dmem_alloc_x( MPE mpe, U32 sid, U32 ulSize, S8 *pszFile, U32 ulLine ){ U32 i; U32 s; VOID *result; if( ulSize == 0 ) { return NULL; } if(pszFile == NULL) { return NULL; } for( i=0; g_astBufSizes[i].size>0;i++ ) { if( ulSize > g_astBufSizes[i].size ) { continue; } s = aos_int_lock(); result = mem_buf_alloc(g_astBufSizes[i].buf_id,mpe,sid,pszFile,ulLine); aos_int_unlock(s); return result; } aos_printf( MPE_MM, "MM:allocates fail,size is too large,mpe=%d,sid=%d,size=%d,file=%s,line=%d", mpe,sid,ulSize,pszFile,ulLine ); return (VOID*)NULL;}U32 aos_dmem_free_x( VOID *pMemBlock, S8 *pszFile, U32 ulLine ){ U32 result; AOS_SYS_CALL( result=mem_buf_free(pMemBlock,pszFile,ulLine); ); return result;}U32 aos_dmem_free_r( VOID *pMemBlock ){ U32 result; AOS_SYS_CALL( result=mem_buf_free(pMemBlock,__FILE__,__LINE__); ); return result;}U32 aos_dmem_ref_inc( VOID *pMemBlock ){ U32 result; AOS_SYS_CALL( result = mem_buf_inc_ref(pMemBlock); ); return result;}U32 aos_dmem_ref_get( VOID *pMemBlock, U32 *pulRef ){ U32 result; AOS_SYS_CALL( result=mem_buf_get_ref( pMemBlock, pulRef ); ); return result;}#ifdef __cplusplus}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -