blob: f141c424e594e7f8fd8f11e030bf865f5e598037 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/**
2 *
3 * @file commgt_api.h
4 * @brief
5 * This file is part of tools.
6 * ¹¤¾ßCommAgt½Ó¿Ú¹«¹²ÉùÃ÷
7 *
8 * @details
9 * @author Tools Team.
10 * @email
11 * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
12 * @warning
13 * @date 2019/02/02
14 * @version 1.4
15 * @pre
16 * @post
17 *
18 * @par
19 * Change History :
20 * ---------------------------------------------------------------------------
21 * date version author description
22 * ---------------------------------------------------------------------------
23 * 2013/01/14 1.0 lu.xieji Create file
24 * 2018/09/24 1.1 jiang.fenglin ºË¼äͨÐŹ²ÏíÄÚ´æÓÉ1Mµ÷ÕûΪ512K
25 * 2018/09/25 1.2 dai.kang »·Ðλº³åÇøÄÚ´æÓÉ3.5Mµ÷ÕûΪ2M
26 * 2018/12/25 1.3 dai.kang »·Ðλº³åÇøÄÚ´æÓɾ²Ì¬·ÖÅäµ÷ÕûΪzOss_GetUB¶¯Ì¬·Ö±ð
27 * 2019/02/02 1.4 jiang.fenglin ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen
28 * ---------------------------------------------------------------------------
29 *
30 *
31 */
32
33#ifndef RINGBUF_H_
34#define RINGBUF_H_
35
36#include "logcat_drv.h"
37
38#define ZCAT_MEM_TYPE_KERNEL 0
39#define ZCAT_MEM_TYPE_USER 1
40
41// ´óС¶ÔÆë
42#define ALIGNED_SIZE(size, alignment) (((size) + (alignment)) & ~(alignment))
43
44/* ´òÓ¡»º³åÇø */
45typedef struct
46{
47 UINT32 capacity; /* »º³åÇøÈÝÁ¿*/
48 volatile UINT32 readPoint; /* ¶ÁÖ¸Õë */
49 volatile UINT32 writePoint; /* дָÕë */
50 UINT32 symbol; /* ¿ØÖÆ¿é±êʶ·û */
51 UINT8 buf[1]; /* ´òÓ¡»º³åÇø */
52} T_RINGBUFFER;
53
54
55/**
56 * @brief ´´½¨ÐèÒªµÄ»º³åÇø
57 * Èç¹ûbuf²»ÎªNULL£¬ÔòÔÚÖ¸¶¨µØÖ·´´½¨»º³åÇø£»·ñÔò£¬ÉêÇëÒ»¿éÄÚ´æ×÷Ϊ»º³åÇø
58 * @param[in] buf »º³åÇøµØÖ·
59 * @param[in] bufSize »º³åÇø´óС
60 * @return ³É¹¦·µ»ØÖ¸Ïò»º³åÇø½á¹¹ÌåµÄÖ¸Õ룬·ñÔò·µ»ØNULL
61 * @note
62 * @see
63 */
64T_RINGBUFFER* CreateRingBuffer(UINT8 *buf, UINT32 bufSize);
65
66/**
67 * @brief ´´½¨ÐèÒªµÄ»º³åÇø,²¢ÇÒÖ¸¶¨±ê¼ÇλµÄÖµ
68 * Èç¹ûbuf²»ÎªNULL£¬ÔòÔÚÖ¸¶¨µØÖ·´´½¨»º³åÇø£»·ñÔò£¬ÉêÇëÒ»¿éÄÚ´æ×÷Ϊ»º³åÇø
69 * @param[in] buf »º³åÇøµØÖ·
70 * @param[in] bufSize »º³åÇø´óС
71 * @param[in] bufSize ±ê¼Çλ
72 * @return ³É¹¦·µ»ØÖ¸Ïò»º³åÇø½á¹¹ÌåµÄÖ¸Õ룬·ñÔò·µ»ØNULL
73 * @note
74 * @see
75 */
76T_RINGBUFFER* CreateRingBufferWithSymbol(UINT8 *buf, UINT32 bufSize, UINT32 symbol);
77
78/**
79 * @brief Åжϻº³åÇøÊÇ·ñÓÐЧ
80 * @param[in] ringBuf »·Ðλº³å
81 * @return ÊÇ·µ»ØTRUE,·ñ·µ»ØFALSE
82 * @note
83 * @see
84 */
85BOOL IsRingBufferValid(T_RINGBUFFER *ringBuf);
86
87/**
88 * @brief ½«»º³åÇøÖÿÕ
89 * @param[in] ringBuf »·Ðλº³åÇøÖ¸Õë
90 * @return void
91 * @note
92 * @see
93 */
94VOID EmptyRingBuffer(T_RINGBUFFER *ringBuf);
95
96/**
97 * @brief ½«Êý¾ÝдÈë»·Ðλº³å
98 * @param[in] ringBuf »·Ðλº³åÖ¸Õë
99 * @param[in] buf Êý¾Ý»º´æÖ¸Õë
100 * @param[in] len Êý¾Ý³¤¶È
101 * @param[in] flags Êý¾Ý»º´æÄÚ´æÀàÐÍ£º0:ÄÚºË̬,1:Óû§Ì¬
102 * @return ·µ»ØÐ´ÈëµÄʵ¼Ê³¤¶È
103 * @note
104 * @see
105 */
106UINT32 WriteRingBuffer(T_RINGBUFFER *ringBuf, UINT8 *buf, UINT32 len, UINT32 flags);
107
108/**
109 * @brief ¶Áȡһ¶Î»·Ðλº³åÇøµÄÊý¾Ýµ½Ä¿±ê»º´æ
110 * @param[in] ringBuf »·Ðλº³åÇøÖ¸Õë
111 * @param[in] buf Ä¿±ê»º´æÖ¸Õë
112 * @param[in] len Ä¿±ê»º´æ³¤¶È
113 * @param[in] flags Ä¿±ê»º´æÄÚ´æÀàÐÍ£º0:ÄÚºË̬,1:Óû§Ì¬
114 * @return ·µ»Ø¶ÁÈ¡³¤¶È
115 * @note
116 * @see
117 */
118UINT32 ReadRingBuffer(T_RINGBUFFER *ringBuf, UINT8 *buf, UINT32 len, UINT32 flags);
119
120/**
121 * @brief »ñÈ¡µ±Ç°Ring BufferÖпÕÏÐÇøµÄ´óС
122 * @param[in] ringBuf »·Ðλº³åÇøÖ¸Õë
123 * @return ·µ»Ø×Ö½ÚÊý
124 * @note
125 * @see
126 */
127UINT32 GetRingBufferSize(T_RINGBUFFER *ringBuf);
128
129
130#endif /*RINGBUF_H_*/
131