1 /* 2 * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef _KRECVBUF_H_ 17 #define _KRECVBUF_H_ 18 19 #include "stdio.h" 20 #include "stdlib.h" 21 #include "string.h" 22 23 #include "los_typedef.h" 24 #include "los_spinlock.h" 25 26 typedef enum { 27 BUF_UNUSED = 0, 28 BUF_USED = 1 29 } KRecvBufStatus; 30 31 typedef enum { 32 EVENTS_NEW_DATA = 0x01 33 } KRecvBufEvents; 34 35 typedef struct { 36 UINT32 wIdx; 37 UINT32 rIdx; 38 UINT32 size; 39 UINT32 remain; 40 SPIN_LOCK_S lock; 41 KRecvBufStatus status; 42 CHAR *fifo; 43 } KRecvBuf; 44 45 extern UINT32 KRecvBufInit(KRecvBuf *krbCB, CHAR *fifo, UINT32 size); 46 extern VOID KRecvBufDeinit(KRecvBuf *krbCB); 47 extern UINT32 KRecvBufWrite(KRecvBuf *krbCB, const CHAR *buf, UINT32 size); 48 extern UINT32 KRecvBufRead(KRecvBuf *krbCB, CHAR *buf, UINT32 size); 49 extern UINT32 KRecvBufUsedSize(KRecvBuf *krbCB); 50 51 extern VOID KRecvBufDump(KRecvBuf *krbCB); 52 53 #endif 54