1 /******************************************************************************
3 * Copyright (c) 2020 ICT/CAS.
5 * Licensed under the O-RAN Software License, Version 1.0 (the "Software License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * https://www.o-ran.org/software
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 *******************************************************************************/
24 #include "vos_types.h"
25 #include "vos_string.h"
27 extern ULONG gMsgbFreeCount;
31 UINT16 maxHeadLen; /* Head域预留的长度 */
32 UINT16 maxDataLen; /* Data域预留的长度 */
33 UINT16 headSpareLen; /* Head域空闲的长度 */
34 UINT16 tailOffset; /* 数据尾端到dataBuff[]起始位置的距离,包括1.整个Head域 2.Data域的使用部分 */
40 UINT8 dataBuff[0]; /* DataBuff域的起始地址,指向msgbInfo变量后面的地址,该成员不占用内存 */
44 INT32 msgbCheck(MsgbBuff_t *pMsgBuff);
45 MsgbBuff_t *msgbAllocWithDebug(UINT16 dataLen, UINT16 maxHeadLen, ULONG moduleId,unsigned char *file, unsigned long line);
46 UINT8 *msgbDataWithDebug(MsgbBuff_t *pMsgBuff,unsigned char *fun, unsigned long line);
47 UINT8 *msgbTailWithDebug(MsgbBuff_t *pMsgBuff,unsigned char *fun, unsigned long line);
48 UINT16 msgbDataUsedLenWithDebug(MsgbBuff_t *pMsgBuff,unsigned char *fun, unsigned long line);
49 UINT16 msgbDataAllocLenWithDebug(MsgbBuff_t *pMsgBuff,unsigned char *fun, unsigned long line);
50 UINT8 *msgbHeadPushWithDebug(MsgbBuff_t *pMsgBuff, UINT32 len,unsigned char *fun, unsigned long line);
51 UINT8 *msgbHeadPullWithDebug(MsgbBuff_t *pMsgBuff, UINT32 len,unsigned char *fun, unsigned long line);
52 UINT8 *msgbTailPushWithDebug(MsgbBuff_t *pMsgBuff, UINT32 len,unsigned char *fun, unsigned long line);
53 UINT8 *msgbTailPullWithDebug(MsgbBuff_t *pMsgBuff, UINT32 len,unsigned char *fun, unsigned long line);
56 #define msgbAlloc( dataLen, maxHeadLen, moduleId) msgbAllocWithDebug( dataLen, maxHeadLen, moduleId,(UCHAR *)__func__,__LINE__)
60 #define msgbData(pMsgBuff) msgbDataWithDebug(pMsgBuff,(UCHAR *)__func__,__LINE__)
62 #define msgbTail(pMsgBuff) msgbTailWithDebug(pMsgBuff,(UCHAR *)__func__,__LINE__)
64 #define msgbDataUsedLen(pMsgBuff) msgbDataUsedLenWithDebug(pMsgBuff,(UCHAR *)__func__,__LINE__)
66 #define msgbDataAllocLen(pMsgBuff) msgbDataAllocLenWithDebug(pMsgBuff,(UCHAR *)__func__,__LINE__)
68 extern UINT16 msgbHeadLeftRoom(MsgbBuff_t *pMsgBuff);
70 extern UINT16 msgbTailLeftRoom(MsgbBuff_t *pMsgBuff);
73 #define msgbFree(pMsgBuff)\
77 vos_err_print("input is NULL!\n");\
84 #define msgbHeadPush(pMsgBuff, len) msgbHeadPushWithDebug(pMsgBuff, len,(UCHAR *)__func__,__LINE__)
86 #define msgbHeadPull(pMsgBuff, len) msgbHeadPullWithDebug(pMsgBuff, len,(UCHAR *)__func__,__LINE__)
88 #define msgbTailPush(pMsgBuff, len) msgbTailPushWithDebug(pMsgBuff, len,(UCHAR *)__func__,__LINE__)
90 #define msgbTailPull(pMsgBuff, len) msgbTailPullWithDebug(pMsgBuff, len,(UCHAR *)__func__,__LINE__)