/******************************************************************************* | |
* Copyright (C) 2008, ZTE Corporation. | |
* | |
* File Name: drvs_ring.h | |
* File Mark: | |
* Description: | |
* Others: | |
* Version: V1.0 | |
* Author: qinxiao | |
* Date: 2009-09-03 | |
* History 1: created | |
* Date: | |
* Version: | |
* Author: | |
* Modification: | |
********************************************************************************/ | |
#ifndef DRVS_RING_H | |
#define DRVS_RING_H | |
#ifdef __cplusplus | |
extern "C" | |
{ | |
#endif | |
/**************************************************************************** | |
* Include files | |
****************************************************************************/ | |
/**************************************************************************** | |
* Macros | |
****************************************************************************/ | |
/**************************************************************************** | |
* Types | |
****************************************************************************/ | |
typedef struct _T_Hal_Ring | |
{ | |
UINT32 writePos; /* offset from start of buffer where to write next */ | |
UINT32 readPos; /* offset from start of buffer where to read next */ | |
UINT32 bufSize; /* size of ring in bytes */ | |
UINT8 *pBuf; /* pointer to start of buffer */ | |
}T_Hal_Ring; | |
/**************************************************************************** | |
* Constants | |
****************************************************************************/ | |
/**************************************************************************** | |
* Global Variables | |
****************************************************************************/ | |
/**************************************************************************** | |
* Function Prototypes | |
****************************************************************************/ | |
/****************************************************************************** | |
* Function: hal_RingIsEmpty | |
* Description: Åжϻ·Ðλº³åÊÇ·ñΪ¿Õ | |
* Parameters: | |
* Input: | |
* pRing - :»·Ðλº³åÖ¸Õë | |
* Output: | |
* None | |
* Returns: | |
* ¿Õ:TRUE; ·Ç¿Õ:FALSE | |
* | |
* Others: | |
******************************************************************************/ | |
BOOL hal_RingIsEmpty( T_Hal_Ring *pRing); | |
/****************************************************************************** | |
* Function: hal_RingIsFull | |
* Description: Åжϻ·Ðλº³åÊÇ·ñÒÑÂú | |
* Parameters: | |
* Input: | |
* pRing -- »·Ðλº³åÖ¸Õë | |
* Output: | |
* None | |
* Returns: | |
* Âú:TRUE; ·ÇÂú:FALSE | |
* | |
* Others: | |
******************************************************************************/ | |
BOOL hal_RingIsFull(T_Hal_Ring *pRing); | |
/****************************************************************************** | |
* Function: hal_RingCreate | |
* Description: ´´½¨»·Ðλº³å | |
* Parameters: | |
* Input: | |
* nbytes -- »·Ðλº³åµÄ´óС£¬µ¥Î»£º×Ö½Ú | |
* Output: | |
* None | |
* Returns: | |
* ³É¹¦£º»·Ðλº³åID; ʧ°Ü:hal_NULL | |
* | |
* Others: | |
******************************************************************************/ | |
T_Hal_Ring *hal_RingCreate(UINT32 nBytes); | |
/****************************************************************************** | |
* Function: hal_RingDelete | |
* Description: ɾ³ý»·Ðλº³å | |
* Parameters: | |
* Input: | |
* pRing -- »·Ðλº³åÖ¸Õë | |
* Output: | |
* None | |
* Returns: | |
* None | |
* | |
* Others: | |
******************************************************************************/ | |
VOID hal_RingDelete(T_Hal_Ring * pRing); | |
/****************************************************************************** | |
* Function: hal_RingRead | |
* Description: ¶ÁÈ¡»·Ðλº³å¶ÓÁеÄÊý¾Ý | |
* Parameters: | |
* Input: | |
* pRing -- »·Ðλº³åÖ¸Õë | |
* pBuffer -- Êä³ö»º³åÖ¸Õë | |
* maxbytes -- ÐèÒª¶ÁÈ¡µÄ×î´ó×Ö½ÚÊý | |
* Output: | |
* buffer -- Êä³ö»º³åÖ¸Õë | |
* Returns: | |
* ʵ¼Ê¶ÁÈ¡µÄ×Ö½ÚÊý | |
* | |
* Others: ·µ»ØÖµ¿ÉÄÜÓëÐèÒª¶ÁÈ¡µÄ×Ö½ÚÊý²»Ò»Ö¡£Èç¹û»º³åΪ¿Õ£¬Ôò·µ»Ø0. | |
******************************************************************************/ | |
UINT32 hal_RingRead(T_Hal_Ring *pRing, UINT8 *pBuffer, UINT32 maxBytes); | |
/****************************************************************************** | |
* Function: hal_RingWrite | |
* Description: Ïò»·Ðλº³åдÈëÊý¾Ý | |
* Parameters: | |
* Input: | |
* pRing -- »·Ðλº³åÖ¸Õë | |
* pBuffer -- Êä³ö»º³åÖ¸Õë | |
* nBytes -- ´ýдÈëÊý¾ÝµÄ´óС | |
* Output: | |
* None | |
* Returns: | |
* ʵ¼ÊдÈëµÄ×Ö½ÚÊý | |
* | |
* Others: ·µ»ØÖµ¿ÉÄÜÓëÐèҪдÈëµÄ×Ö½ÚÊý²»Ò»Ö¡£Èç¹û»º³åΪÂú£¬Ôò·µ»Ø0. | |
******************************************************************************/ | |
UINT32 hal_RingWrite(T_Hal_Ring * pRing, UINT8 *pBuffer, UINT32 nBytes); | |
/****************************************************************************** | |
* Function: hal_RingFreeBytes | |
* Description: »ñÈ¡»·Ðλº³åÊ£Óà¿ÉÀûÓÃ×Ö½ÚÊý | |
* Parameters: | |
* Input: | |
* pRing -- »·Ðλº³åÖ¸Õë | |
* Output: | |
* None | |
* Returns: | |
* Ê£Óà¿ÉÀûÓÿռä×Ö½ÚÊý | |
* | |
* Others: | |
******************************************************************************/ | |
UINT32 hal_RingFreeBytes(T_Hal_Ring *pRing); | |
/****************************************************************************** | |
* Function: hal_RingUsedBytes | |
* Description: »ñÈ¡»·Ðλº³åÒÑʹÓõÄ×Ö½ÚÊý | |
* Parameters: | |
* Input: | |
* pRing -- »·Ðλº³åÖ¸Õë | |
* Output: | |
* None | |
* Returns: | |
* ÒÑʹÓõÄ×Ö½ÚÊý | |
* | |
* Others: | |
******************************************************************************/ | |
UINT32 hal_RingUsedBytes(T_Hal_Ring *pRing); | |
/****************************************************************************** | |
* Function: hal_RingFlush | |
* Description: Çå³ý»·Ðλº³åµÄËùÓÐÊý¾Ý | |
* Parameters: | |
* Input: | |
* pRing -- »·Ðλº³åÖ¸Õë | |
* Output: | |
* None | |
* Returns: | |
* None | |
* Others: | |
******************************************************************************/ | |
VOID hal_RingFlush(T_Hal_Ring * pRing); | |
#if 0 | |
/****************************************************************************** | |
* Function: hal_RingMoveAhead | |
* Description: ½«»·Ðλº³åµÄдָÕëÒÆ¶¯¼¸¸ö×Ö½Ú | |
* Parameters: | |
* Input: | |
* pRing -- »·Ðλº³åÖ¸Õë | |
* nBytes -- ÐèÒªÒÆ¶¯µÄ×Ö½ÚÊý,ÕýÊýÏòÇ°ÒÆ¶¯£¬¸ºÊýÏòºóÒÆ¶¯£» | |
* ·¶Î§:-»·Ðλº³å×î´ó×Ö½ÚÊý-- +»·Ðλº³å×î´ó×Ö½ÚÊý | |
* Output: | |
* None | |
* Returns: | |
* None | |
* Others: µ±Ð´Ö¸Õ볬³ö¶ÓÁÐ×î´ó³¤¶Èʱ£¬»á×Ô¶¯»·ÐÎ. | |
******************************************************************************/ | |
VOID hal_RingMoveWritePos(T_Hal_Ring * pRing, SINT32 nBytes); | |
/****************************************************************************** | |
* Function: hal_RingMoveAhead | |
* Description: Ïò»·Ðλº³åµ±Ç°Ð´Ö¸ÕëµÄÆ«ÒÆ´¦£¬Ð´ÈëÒ»¸öÊý¾Ý | |
* ²»Òƶ¯Ð´Ö¸Õë | |
* Parameters: | |
* Input: | |
* pRing -- »·Ðλº³åÖ¸Õë | |
* byte:´ýдÈëµÄÊý¾Ý | |
* offset -- Æ«ÒÆÁ¿, ÕýÊýÏòÇ°ÒÆ¶¯, ¸ºÊýÏòºóÒÆ¶¯; | |
* ·¶Î§:-»·Ðλº³å×î´ó×Ö½ÚÊý-- +»·Ðλº³å×î´ó×Ö½ÚÊý, | |
* Output: | |
* None | |
* Returns: | |
* None | |
* Others: µ±Ð´Ö¸Õ볬³ö¶ÓÁÐ×î´ó³¤¶Èʱ£¬»á×Ô¶¯»·ÐÎ. | |
******************************************************************************/ | |
VOID hal_RingPutAhead(T_Hal_Ring * pRing, UINT8 byte, SINT32 offset); | |
/****************************************************************************** | |
* Function: hal_RingGetPossibleReadBlock | |
* Description: »ñÈ¡»·Ðλº³å¿É¶ÁÈ¡µÄ×Ö½ÚÊýºÍÖ¸Õë | |
* Parameters: | |
* Input: | |
* pRing -- »·Ðλº³åÖ¸Õë | |
* Output: | |
* nBytes -- ¿É¶ÁÈ¡×Ö½ÚÊý | |
* UINT8 * -- bufferÖ¸Õë | |
* Returns: | |
* ÒÑʹÓõÄ×Ö½ÚÊý | |
* | |
* Others: | |
******************************************************************************/ | |
UINT8 *hal_RingGetPossibleReadBlock(T_Hal_Ring * pRing, UINT32 *nBytes); | |
VOID hal_RingMoveReadPos(T_Hal_Ring * pRing, SINT32 nBytes); | |
#endif | |
#ifdef __cplusplus | |
} | |
#endif | |
#endif | |