lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /*******************************************************************************
|
| 2 | * Copyright (C) 2008, ZTE Corporation.
|
| 3 | *
|
| 4 | * File Name: drvs_ring.h
|
| 5 | * File Mark:
|
| 6 | * Description:
|
| 7 | * Others:
|
| 8 | * Version: V1.0
|
| 9 | * Author: qinxiao
|
| 10 | * Date: 2009-09-03
|
| 11 | * History 1: created
|
| 12 | * Date:
|
| 13 | * Version:
|
| 14 | * Author:
|
| 15 | * Modification:
|
| 16 | ********************************************************************************/
|
| 17 | #ifndef DRVS_RING_H
|
| 18 | #define DRVS_RING_H
|
| 19 |
|
| 20 | #ifdef __cplusplus
|
| 21 | extern "C"
|
| 22 | {
|
| 23 | #endif
|
| 24 |
|
| 25 | /****************************************************************************
|
| 26 | * Include files
|
| 27 | ****************************************************************************/
|
| 28 |
|
| 29 | /****************************************************************************
|
| 30 | * Macros
|
| 31 | ****************************************************************************/
|
| 32 |
|
| 33 | /****************************************************************************
|
| 34 | * Types
|
| 35 | ****************************************************************************/
|
| 36 | typedef struct _T_Hal_Ring
|
| 37 | {
|
| 38 | UINT32 writePos; /* offset from start of buffer where to write next */
|
| 39 | UINT32 readPos; /* offset from start of buffer where to read next */
|
| 40 | UINT32 bufSize; /* size of ring in bytes */
|
| 41 | UINT8 *pBuf; /* pointer to start of buffer */
|
| 42 | }T_Hal_Ring;
|
| 43 |
|
| 44 | /****************************************************************************
|
| 45 | * Constants
|
| 46 | ****************************************************************************/
|
| 47 |
|
| 48 | /****************************************************************************
|
| 49 | * Global Variables
|
| 50 | ****************************************************************************/
|
| 51 |
|
| 52 | /****************************************************************************
|
| 53 | * Function Prototypes
|
| 54 | ****************************************************************************/
|
| 55 | /******************************************************************************
|
| 56 | * Function: hal_RingIsEmpty
|
| 57 | * Description: Åжϻ·Ðλº³åÊÇ·ñΪ¿Õ
|
| 58 | * Parameters:
|
| 59 | * Input:
|
| 60 | * pRing - :»·Ðλº³åÖ¸Õë
|
| 61 | * Output:
|
| 62 | * None
|
| 63 | * Returns:
|
| 64 | * ¿Õ:TRUE; ·Ç¿Õ:FALSE
|
| 65 | *
|
| 66 | * Others:
|
| 67 | ******************************************************************************/
|
| 68 | BOOL hal_RingIsEmpty( T_Hal_Ring *pRing);
|
| 69 |
|
| 70 | /******************************************************************************
|
| 71 | * Function: hal_RingIsFull
|
| 72 | * Description: Åжϻ·Ðλº³åÊÇ·ñÒÑÂú
|
| 73 | * Parameters:
|
| 74 | * Input:
|
| 75 | * pRing -- »·Ðλº³åÖ¸Õë
|
| 76 | * Output:
|
| 77 | * None
|
| 78 | * Returns:
|
| 79 | * Âú:TRUE; ·ÇÂú:FALSE
|
| 80 | *
|
| 81 | * Others:
|
| 82 | ******************************************************************************/
|
| 83 | BOOL hal_RingIsFull(T_Hal_Ring *pRing);
|
| 84 |
|
| 85 | /******************************************************************************
|
| 86 | * Function: hal_RingCreate
|
| 87 | * Description: ´´½¨»·Ðλº³å
|
| 88 | * Parameters:
|
| 89 | * Input:
|
| 90 | * nbytes -- »·Ðλº³åµÄ´óС£¬µ¥Î»£º×Ö½Ú
|
| 91 | * Output:
|
| 92 | * None
|
| 93 | * Returns:
|
| 94 | * ³É¹¦£º»·Ðλº³åID; ʧ°Ü:hal_NULL
|
| 95 | *
|
| 96 | * Others:
|
| 97 | ******************************************************************************/
|
| 98 | T_Hal_Ring *hal_RingCreate(UINT32 nBytes);
|
| 99 |
|
| 100 | /******************************************************************************
|
| 101 | * Function: hal_RingDelete
|
| 102 | * Description: ɾ³ý»·Ðλº³å
|
| 103 | * Parameters:
|
| 104 | * Input:
|
| 105 | * pRing -- »·Ðλº³åÖ¸Õë
|
| 106 | * Output:
|
| 107 | * None
|
| 108 | * Returns:
|
| 109 | * None
|
| 110 | *
|
| 111 | * Others:
|
| 112 | ******************************************************************************/
|
| 113 | VOID hal_RingDelete(T_Hal_Ring * pRing);
|
| 114 |
|
| 115 | /******************************************************************************
|
| 116 | * Function: hal_RingRead
|
| 117 | * Description: ¶ÁÈ¡»·Ðλº³å¶ÓÁеÄÊý¾Ý
|
| 118 | * Parameters:
|
| 119 | * Input:
|
| 120 | * pRing -- »·Ðλº³åÖ¸Õë
|
| 121 | * pBuffer -- Êä³ö»º³åÖ¸Õë
|
| 122 | * maxbytes -- ÐèÒª¶ÁÈ¡µÄ×î´ó×Ö½ÚÊý
|
| 123 | * Output:
|
| 124 | * buffer -- Êä³ö»º³åÖ¸Õë
|
| 125 | * Returns:
|
| 126 | * ʵ¼Ê¶ÁÈ¡µÄ×Ö½ÚÊý
|
| 127 | *
|
| 128 | * Others: ·µ»ØÖµ¿ÉÄÜÓëÐèÒª¶ÁÈ¡µÄ×Ö½ÚÊý²»Ò»Ö¡£Èç¹û»º³åΪ¿Õ£¬Ôò·µ»Ø0.
|
| 129 | ******************************************************************************/
|
| 130 | UINT32 hal_RingRead(T_Hal_Ring *pRing, UINT8 *pBuffer, UINT32 maxBytes);
|
| 131 |
|
| 132 | /******************************************************************************
|
| 133 | * Function: hal_RingWrite
|
| 134 | * Description: Ïò»·Ðλº³åдÈëÊý¾Ý
|
| 135 | * Parameters:
|
| 136 | * Input:
|
| 137 | * pRing -- »·Ðλº³åÖ¸Õë
|
| 138 | * pBuffer -- Êä³ö»º³åÖ¸Õë
|
| 139 | * nBytes -- ´ýдÈëÊý¾ÝµÄ´óС
|
| 140 | * Output:
|
| 141 | * None
|
| 142 | * Returns:
|
| 143 | * ʵ¼ÊдÈëµÄ×Ö½ÚÊý
|
| 144 | *
|
| 145 | * Others: ·µ»ØÖµ¿ÉÄÜÓëÐèҪдÈëµÄ×Ö½ÚÊý²»Ò»Ö¡£Èç¹û»º³åΪÂú£¬Ôò·µ»Ø0.
|
| 146 | ******************************************************************************/
|
| 147 | UINT32 hal_RingWrite(T_Hal_Ring * pRing, UINT8 *pBuffer, UINT32 nBytes);
|
| 148 |
|
| 149 | /******************************************************************************
|
| 150 | * Function: hal_RingFreeBytes
|
| 151 | * Description: »ñÈ¡»·Ðλº³åÊ£Óà¿ÉÀûÓÃ×Ö½ÚÊý
|
| 152 | * Parameters:
|
| 153 | * Input:
|
| 154 | * pRing -- »·Ðλº³åÖ¸Õë
|
| 155 | * Output:
|
| 156 | * None
|
| 157 | * Returns:
|
| 158 | * Ê£Óà¿ÉÀûÓÿռä×Ö½ÚÊý
|
| 159 | *
|
| 160 | * Others:
|
| 161 | ******************************************************************************/
|
| 162 | UINT32 hal_RingFreeBytes(T_Hal_Ring *pRing);
|
| 163 |
|
| 164 | /******************************************************************************
|
| 165 | * Function: hal_RingUsedBytes
|
| 166 | * Description: »ñÈ¡»·Ðλº³åÒÑʹÓõÄ×Ö½ÚÊý
|
| 167 | * Parameters:
|
| 168 | * Input:
|
| 169 | * pRing -- »·Ðλº³åÖ¸Õë
|
| 170 | * Output:
|
| 171 | * None
|
| 172 | * Returns:
|
| 173 | * ÒÑʹÓõÄ×Ö½ÚÊý
|
| 174 | *
|
| 175 | * Others:
|
| 176 | ******************************************************************************/
|
| 177 | UINT32 hal_RingUsedBytes(T_Hal_Ring *pRing);
|
| 178 |
|
| 179 | /******************************************************************************
|
| 180 | * Function: hal_RingFlush
|
| 181 | * Description: Çå³ý»·Ðλº³åµÄËùÓÐÊý¾Ý
|
| 182 | * Parameters:
|
| 183 | * Input:
|
| 184 | * pRing -- »·Ðλº³åÖ¸Õë
|
| 185 | * Output:
|
| 186 | * None
|
| 187 | * Returns:
|
| 188 | * None
|
| 189 | * Others:
|
| 190 | ******************************************************************************/
|
| 191 | VOID hal_RingFlush(T_Hal_Ring * pRing);
|
| 192 | #if 0
|
| 193 | /******************************************************************************
|
| 194 | * Function: hal_RingMoveAhead
|
| 195 | * Description: ½«»·Ðλº³åµÄдָÕëÒÆ¶¯¼¸¸ö×Ö½Ú
|
| 196 | * Parameters:
|
| 197 | * Input:
|
| 198 | * pRing -- »·Ðλº³åÖ¸Õë
|
| 199 | * nBytes -- ÐèÒªÒÆ¶¯µÄ×Ö½ÚÊý,ÕýÊýÏòÇ°ÒÆ¶¯£¬¸ºÊýÏòºóÒÆ¶¯£»
|
| 200 | * ·¶Î§:-»·Ðλº³å×î´ó×Ö½ÚÊý-- +»·Ðλº³å×î´ó×Ö½ÚÊý
|
| 201 | * Output:
|
| 202 | * None
|
| 203 | * Returns:
|
| 204 | * None
|
| 205 | * Others: µ±Ð´Ö¸Õ볬³ö¶ÓÁÐ×î´ó³¤¶Èʱ£¬»á×Ô¶¯»·ÐÎ.
|
| 206 | ******************************************************************************/
|
| 207 | VOID hal_RingMoveWritePos(T_Hal_Ring * pRing, SINT32 nBytes);
|
| 208 |
|
| 209 | /******************************************************************************
|
| 210 | * Function: hal_RingMoveAhead
|
| 211 | * Description: Ïò»·Ðλº³åµ±Ç°Ð´Ö¸ÕëµÄÆ«ÒÆ´¦£¬Ð´ÈëÒ»¸öÊý¾Ý
|
| 212 | * ²»Òƶ¯Ð´Ö¸Õë
|
| 213 | * Parameters:
|
| 214 | * Input:
|
| 215 | * pRing -- »·Ðλº³åÖ¸Õë
|
| 216 | * byte:´ýдÈëµÄÊý¾Ý
|
| 217 | * offset -- Æ«ÒÆÁ¿, ÕýÊýÏòÇ°ÒÆ¶¯, ¸ºÊýÏòºóÒÆ¶¯;
|
| 218 | * ·¶Î§:-»·Ðλº³å×î´ó×Ö½ÚÊý-- +»·Ðλº³å×î´ó×Ö½ÚÊý,
|
| 219 | * Output:
|
| 220 | * None
|
| 221 | * Returns:
|
| 222 | * None
|
| 223 | * Others: µ±Ð´Ö¸Õ볬³ö¶ÓÁÐ×î´ó³¤¶Èʱ£¬»á×Ô¶¯»·ÐÎ.
|
| 224 | ******************************************************************************/
|
| 225 | VOID hal_RingPutAhead(T_Hal_Ring * pRing, UINT8 byte, SINT32 offset);
|
| 226 |
|
| 227 | /******************************************************************************
|
| 228 | * Function: hal_RingGetPossibleReadBlock
|
| 229 | * Description: »ñÈ¡»·Ðλº³å¿É¶ÁÈ¡µÄ×Ö½ÚÊýºÍÖ¸Õë
|
| 230 | * Parameters:
|
| 231 | * Input:
|
| 232 | * pRing -- »·Ðλº³åÖ¸Õë
|
| 233 | * Output:
|
| 234 | * nBytes -- ¿É¶ÁÈ¡×Ö½ÚÊý
|
| 235 | * UINT8 * -- bufferÖ¸Õë
|
| 236 | * Returns:
|
| 237 | * ÒÑʹÓõÄ×Ö½ÚÊý
|
| 238 | *
|
| 239 | * Others:
|
| 240 | ******************************************************************************/
|
| 241 | UINT8 *hal_RingGetPossibleReadBlock(T_Hal_Ring * pRing, UINT32 *nBytes);
|
| 242 |
|
| 243 | VOID hal_RingMoveReadPos(T_Hal_Ring * pRing, SINT32 nBytes);
|
| 244 | #endif
|
| 245 |
|
| 246 | #ifdef __cplusplus
|
| 247 | }
|
| 248 | #endif
|
| 249 |
|
| 250 | #endif
|
| 251 |
|