| /**
|
| *
|
| * @file commgt_api.h
|
| * @brief
|
| * This file is part of tools.
|
| * ¹¤¾ßCommAgt½Ó¿Ú¹«¹²ÉùÃ÷
|
| *
|
| * @details
|
| * @author Tools Team.
|
| * @email
|
| * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
|
| * @warning
|
| * @date 2019/02/02
|
| * @version 1.4
|
| * @pre
|
| * @post
|
| *
|
| * @par
|
| * Change History :
|
| * ---------------------------------------------------------------------------
|
| * date version author description
|
| * ---------------------------------------------------------------------------
|
| * 2013/01/14 1.0 lu.xieji Create file
|
| * 2018/09/24 1.1 jiang.fenglin ºË¼äͨÐŹ²ÏíÄÚ´æÓÉ1Mµ÷ÕûΪ512K
|
| * 2018/09/25 1.2 dai.kang »·Ðλº³åÇøÄÚ´æÓÉ3.5Mµ÷ÕûΪ2M
|
| * 2018/12/25 1.3 dai.kang »·Ðλº³åÇøÄÚ´æÓɾ²Ì¬·ÖÅäµ÷ÕûΪzOss_GetUB¶¯Ì¬·Ö±ð
|
| * 2019/02/02 1.4 jiang.fenglin ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen
|
| * ---------------------------------------------------------------------------
|
| *
|
| *
|
| */
|
|
|
| #ifndef RINGBUF_H_
|
| #define RINGBUF_H_
|
|
|
| #include "logcat_drv.h"
|
|
|
| #define ZCAT_MEM_TYPE_KERNEL 0
|
| #define ZCAT_MEM_TYPE_USER 1
|
|
|
| // ´óС¶ÔÆë
|
| #define ALIGNED_SIZE(size, alignment) (((size) + (alignment)) & ~(alignment))
|
|
|
| /* ´òÓ¡»º³åÇø */
|
| typedef struct
|
| {
|
| UINT32 capacity; /* »º³åÇøÈÝÁ¿*/
|
| volatile UINT32 readPoint; /* ¶ÁÖ¸Õë */
|
| volatile UINT32 writePoint; /* дָÕë */
|
| UINT32 symbol; /* ¿ØÖÆ¿é±êʶ·û */
|
| UINT8 buf[1]; /* ´òÓ¡»º³åÇø */
|
| } T_RINGBUFFER;
|
|
|
|
|
| /**
|
| * @brief ´´½¨ÐèÒªµÄ»º³åÇø
|
| * Èç¹ûbuf²»ÎªNULL£¬ÔòÔÚÖ¸¶¨µØÖ·´´½¨»º³åÇø£»·ñÔò£¬ÉêÇëÒ»¿éÄÚ´æ×÷Ϊ»º³åÇø
|
| * @param[in] buf »º³åÇøµØÖ·
|
| * @param[in] bufSize »º³åÇø´óС
|
| * @return ³É¹¦·µ»ØÖ¸Ïò»º³åÇø½á¹¹ÌåµÄÖ¸Õ룬·ñÔò·µ»ØNULL
|
| * @note
|
| * @see
|
| */
|
| T_RINGBUFFER* CreateRingBuffer(UINT8 *buf, UINT32 bufSize);
|
|
|
| /**
|
| * @brief ´´½¨ÐèÒªµÄ»º³åÇø,²¢ÇÒÖ¸¶¨±ê¼ÇλµÄÖµ
|
| * Èç¹ûbuf²»ÎªNULL£¬ÔòÔÚÖ¸¶¨µØÖ·´´½¨»º³åÇø£»·ñÔò£¬ÉêÇëÒ»¿éÄÚ´æ×÷Ϊ»º³åÇø
|
| * @param[in] buf »º³åÇøµØÖ·
|
| * @param[in] bufSize »º³åÇø´óС
|
| * @param[in] bufSize ±ê¼Çλ
|
| * @return ³É¹¦·µ»ØÖ¸Ïò»º³åÇø½á¹¹ÌåµÄÖ¸Õ룬·ñÔò·µ»ØNULL
|
| * @note
|
| * @see
|
| */
|
| T_RINGBUFFER* CreateRingBufferWithSymbol(UINT8 *buf, UINT32 bufSize, UINT32 symbol);
|
|
|
| /**
|
| * @brief Åжϻº³åÇøÊÇ·ñÓÐЧ
|
| * @param[in] ringBuf »·Ðλº³å
|
| * @return ÊÇ·µ»ØTRUE,·ñ·µ»ØFALSE
|
| * @note
|
| * @see
|
| */
|
| BOOL IsRingBufferValid(T_RINGBUFFER *ringBuf);
|
|
|
| /**
|
| * @brief ½«»º³åÇøÖÿÕ
|
| * @param[in] ringBuf »·Ðλº³åÇøÖ¸Õë
|
| * @return void
|
| * @note
|
| * @see
|
| */
|
| VOID EmptyRingBuffer(T_RINGBUFFER *ringBuf);
|
|
|
| /**
|
| * @brief ½«Êý¾ÝдÈë»·Ðλº³å
|
| * @param[in] ringBuf »·Ðλº³åÖ¸Õë
|
| * @param[in] buf Êý¾Ý»º´æÖ¸Õë
|
| * @param[in] len Êý¾Ý³¤¶È
|
| * @param[in] flags Êý¾Ý»º´æÄÚ´æÀàÐÍ£º0:ÄÚºË̬,1:Óû§Ì¬
|
| * @return ·µ»ØÐ´ÈëµÄʵ¼Ê³¤¶È
|
| * @note
|
| * @see
|
| */
|
| UINT32 WriteRingBuffer(T_RINGBUFFER *ringBuf, UINT8 *buf, UINT32 len, UINT32 flags);
|
|
|
| /**
|
| * @brief ¶Áȡһ¶Î»·Ðλº³åÇøµÄÊý¾Ýµ½Ä¿±ê»º´æ
|
| * @param[in] ringBuf »·Ðλº³åÇøÖ¸Õë
|
| * @param[in] buf Ä¿±ê»º´æÖ¸Õë
|
| * @param[in] len Ä¿±ê»º´æ³¤¶È
|
| * @param[in] flags Ä¿±ê»º´æÄÚ´æÀàÐÍ£º0:ÄÚºË̬,1:Óû§Ì¬
|
| * @return ·µ»Ø¶ÁÈ¡³¤¶È
|
| * @note
|
| * @see
|
| */
|
| UINT32 ReadRingBuffer(T_RINGBUFFER *ringBuf, UINT8 *buf, UINT32 len, UINT32 flags);
|
|
|
| /**
|
| * @brief »ñÈ¡µ±Ç°Ring BufferÖпÕÏÐÇøµÄ´óС
|
| * @param[in] ringBuf »·Ðλº³åÇøÖ¸Õë
|
| * @return ·µ»Ø×Ö½ÚÊý
|
| * @note
|
| * @see
|
| */
|
| UINT32 GetRingBufferSize(T_RINGBUFFER *ringBuf);
|
|
|
|
|
| #endif /*RINGBUF_H_*/
|
|
|