[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit
Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/cp/ps/modem/tools/inc/commgt_api.h b/cp/ps/modem/tools/inc/commgt_api.h
new file mode 100755
index 0000000..a8a8a6f
--- /dev/null
+++ b/cp/ps/modem/tools/inc/commgt_api.h
@@ -0,0 +1,681 @@
+/**
+ *
+ * @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
+ * 2019/03/11 1.5 dai.kang Ö§³ÖÎïÀí²ãlog + ap<->cp logÇø¼ä¶¯Ì¬·ÖÅä
+ * 2019/05/13 1.6 dai.kang psÓëphy¼äµÄ»·ÐÎbufferÉÏÏÂÐзֿªÉêÇ룻ap²àbuffer¿Õ¼äλÖõ÷Õû
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+
+#ifndef COMM_AGT_H_
+#define COMM_AGT_H_
+
+#include "ram_config.h"
+#include "ZspTrace.h"
+
+#define MAX_PACKET_LEN (0x10000)
+#define MAX_ENCODE_PACKET_LEN (MAX_PACKET_LEN * 2)
+
+// Buffer »ùµØÖ·
+extern UINT32 g_zToolAgtBaseDDR;
+
+#define COMM_SEND_BUFFER_BASE_ADDR (g_zToolAgtBaseDDR)
+#define COMM_SEND_BUFFER_SIZE (0x77000)
+
+#define COMM_RECV_BUFFER_BASE_ADDR (COMM_SEND_BUFFER_BASE_ADDR + COMM_SEND_BUFFER_SIZE)
+#define COMM_RECV_BUFFER_SIZE (0x0)
+
+#define COMM_READ_BUFFER_BASE_ADDR (COMM_RECV_BUFFER_BASE_ADDR + COMM_RECV_BUFFER_SIZE)
+#define COMM_READ_BUFFER_SIZE (0x0)
+
+#define COMM_ENCODE_BUFFER_BASE_ADDR (COMM_READ_BUFFER_BASE_ADDR + COMM_READ_BUFFER_SIZE)
+#define COMM_ENCODE_BUFFER_SIZE (0x0)
+
+#define COMM_DECODE_BUFFER_BASE_ADDR (COMM_ENCODE_BUFFER_BASE_ADDR + COMM_ENCODE_BUFFER_SIZE)
+#define COMM_DECODE_BUFFER_SIZE (0x0)
+
+// GSM buff
+#define ZCAT_GSM_BUFFER_BASE_ADDR (COMM_DECODE_BUFFER_BASE_ADDR + COMM_DECODE_BUFFER_SIZE)
+
+#ifdef _USE_L1G
+#define ZCAT_GSM_BUFFER_SIZE (0x8000)
+#else
+#define ZCAT_GSM_BUFFER_SIZE (0x0)
+#endif
+
+#define COMM_ARM1_ALL_ADDR (ZCAT_GSM_BUFFER_BASE_ADDR + ZCAT_GSM_BUFFER_SIZE)
+#define COMM_ARM1_ALL_SIZE (0x100)
+#define COMM_ARM1_TICK_ADDR (COMM_ARM1_ALL_ADDR)
+#define COMM_ARM1_TICK_SIZE (0x4)
+#define COMM_ARM1_ORITIME_ADDR (COMM_ARM1_TICK_ADDR + COMM_ARM1_TICK_SIZE)
+#define COMM_ARM1_ORITIME_SIZE (0x4)
+#define COMM_ARM1_ORITICK_ADDR (COMM_ARM1_ORITIME_ADDR + COMM_ARM1_ORITIME_SIZE)
+#define COMM_ARM1_ORITICK_SIZE (0x4)
+
+#if ((COMM_ARM1_TICK_SIZE + COMM_ARM1_ORITIME_SIZE + COMM_ARM1_ORITICK_SIZE) > COMM_ARM1_ALL_SIZE)
+#error "tool ram overflow!"
+#endif
+
+// PS CPU <-->PHY CPU
+#define COMM_PS_TO_PHY_BASE_ADDR (COMM_ARM1_ALL_ADDR + COMM_ARM1_ALL_SIZE)
+#define COMM_PS_TO_PHY_SIZE (0x100)
+
+#define COMM_PHY_TO_PS_BASE_ADDR (COMM_PS_TO_PHY_BASE_ADDR + COMM_PS_TO_PHY_SIZE)
+#define COMM_PHY_TO_PS_SIZE (0x100)
+
+#define ZCAT_KERNEL_TO_CP_BASE_ADDR (COMM_PHY_TO_PS_BASE_ADDR + COMM_PHY_TO_PS_SIZE)
+#define ZCAT_KERNEL_TO_CP_BUFFER_SIZE (0x4000)
+
+#define ZCAT_APP_TO_CP_BASE_ADDR (ZCAT_KERNEL_TO_CP_BASE_ADDR + ZCAT_KERNEL_TO_CP_BUFFER_SIZE)
+#define ZCAT_APP_TO_CP_BUFFER_SIZE (0x4000)
+
+#define COMM_CP_TO_AP_BASE_ADDR (ZCAT_APP_TO_CP_BASE_ADDR + ZCAT_APP_TO_CP_BUFFER_SIZE)
+#ifdef CONFIG_SINGLECORE
+#define COMM_CP_TO_AP_SIZE (0)
+#else
+#define COMM_CP_TO_AP_SIZE (0x20000)
+#endif
+
+#define COMM_AP_TO_CP_BASE_ADDR (COMM_CP_TO_AP_BASE_ADDR + COMM_CP_TO_AP_SIZE)
+#ifdef CONFIG_SINGLECORE
+#define COMM_AP_TO_CP_SIZE (0)
+#else
+#define COMM_AP_TO_CP_SIZE (0x8000)
+#endif
+
+#define TOOL_AGENT_RAM_SIZE (COMM_SEND_BUFFER_SIZE + COMM_RECV_BUFFER_SIZE + COMM_READ_BUFFER_SIZE + COMM_ENCODE_BUFFER_SIZE + \
+ COMM_DECODE_BUFFER_SIZE + ZCAT_GSM_BUFFER_SIZE + COMM_ARM1_ALL_SIZE + COMM_PS_TO_PHY_SIZE + \
+ COMM_PHY_TO_PS_SIZE + ZCAT_KERNEL_TO_CP_BUFFER_SIZE + ZCAT_APP_TO_CP_BUFFER_SIZE + COMM_CP_TO_AP_SIZE + \
+ COMM_AP_TO_CP_SIZE)
+
+/* MODEM PRINT Ä£¿é±àºÅ */
+#define SUBMDL_TOOLAGENT_SET (85)
+#define SUBMDL_ZCATAGT (SUBMDL_TOOLAGENT_SET + 0) /* ZCAT¹¤¾ß´úÀí */
+#define SUBMDL_TOOLCOMMON (SUBMDL_TOOLAGENT_SET + 1) /* TOOL COMMON */
+#define SUBMDL_COMM (SUBMDL_TOOLAGENT_SET + 2) /* ¹¤¾ßͨѶ¹ÜÀí */
+#define SUBMDL_NVAGT (SUBMDL_TOOLAGENT_SET + 3) /* NV¹¤¾ß´úÀí */
+
+/* ͨѶģ¿éºÅ */
+#define MDL_TOOLS_BASE (100)
+#define MDL_WINTRACE (MDL_TOOLS_BASE + 1) /* WinTrace */
+#define MDL_NVEDIT (MDL_TOOLS_BASE + 3) /* NvTool */
+#define MDL_VUART1 (MDL_TOOLS_BASE + 4) /* Virtual of Serial Comm1,used in SimEnv */
+#define MDL_EFSTOOL (MDL_TOOLS_BASE + 7) /* EfsTool */
+#define MDL_PTET (MDL_TOOLS_BASE + 10) /* ÐÒéÕ»²âÊÔ¹¤¾ß */
+#define MDL_ZCAT (MDL_TOOLS_BASE + 15) /* ZCAT¹¤¾ß */
+#define MDL_NVTOOL (MDL_TOOLS_BASE + 16) /* NvTool */
+#define MDL_AUDIO (MDL_TOOLS_BASE + 17) /* audio */
+
+#define MDL_SIMTH (MDL_TOOLS_BASE + 18) /* TH */
+
+/*ÓëwincommÎÕÊÖ: Ó¦´ðÊÇ·ñ¿ªÆôHDLC±àÂë*/
+#define COMM_HEADER_PAD_HDLC (0xAB)
+#define COMM_HEADER_MSG_TYPE_HDLC (0x4)
+#define COMM_HEADER_RESERVED_HDLC (0xBBBB)
+#define COMM_ACK_HDLC_READY (0x2)
+
+#ifdef _OS_WIN
+#define MDL_PHONE (MDL_VUART1) /* windows ·ÂÕæ»·¾³ */
+#else
+#define MDL_PHONE (1) /* ÊÖ»ú */
+#endif
+
+#define ZCAT_MODE_INVALID (UINT32)0
+
+typedef enum
+{
+ ZCAT_MODE_AP_USB = 0xC1,
+ ZCAT_MODE_AP_NET,
+ ZCAT_MODE_AP_TF,
+ ZCAT_MODE_AP_FS,
+ ZCAT_MODE_CP_USB,
+ ZCAT_MODE_CP_TF,
+ ZCAT_MODE_CP_NET,
+ ZCAT_MODE_CP_FS,
+#ifdef _USE_VEHICLE_DC
+ ZCAT_MODE_CAP_EMMC
+#endif
+
+} E_ZCAT_MODE;
+
+typedef enum
+{
+ ZCAT_IPC_SYN = 0xA0,
+ ZCAT_IPC_ACK,
+ ZCAT_IPC_ESTABLISHED,
+ ZCAT_IPC_SET_TTY,
+ ZCAT_IPC_SET_PERIPHERAL_MODE,
+ ZCAT_IPC_STOP,
+ ZCAT_IPC_START,
+ ZCAT_IPC_EXIT,
+#ifdef _USE_VEHICLE_DC
+ ZCAT_IPC_ALLOC_CAP_SMLOGBUF,
+#endif
+} E_ZCAT_IPC_HANDSHAKE;
+
+
+#define COMM_AP_FD 1001
+#define COMM_SINGLE_CORE_FD 1002
+#define COMM_CP_TF_FD 1234
+
+#define ZCAT_MEM_TYPE_KERNEL 0
+#define ZCAT_MEM_TYPE_USER 1
+
+#define HDLC_DECODE_CONTINUE (0x00)
+#define HDLC_DECODE_OK (0x01)
+#define HDLC_DECODE_FIRST_ESCAPE (0x02)
+#define HDLC_DECODE_DROP (0x03)
+
+
+/* zcatÈ«¾ÖÐÅÏ¢ */
+typedef struct
+{
+ int status;
+ int peripheral_mode;
+ char usblog_path[8];
+} T_ZCAT_CONFIG_INFO;
+
+
+// Ä£¿é»Øµ÷º¯Êý
+typedef VOID (*ModuleFunc)(UINT32 msgID/*ÎÞÓÃ*/, const UINT8 *buf, UINT32 msgLen);
+
+typedef enum
+{
+ LINK_CONNECT, /* Á´Â·½¨Á¢ÏûÏ¢ */
+ LINK_BREAK, /* Á´Â·¶Ï¿ªÏûÏ¢ */
+
+ MAX_LINK_INFO
+} LINK_INFO;
+
+typedef enum
+{
+ COMM_RET_SUCCESS, /* Êý¾Ý³É¹¦¼ÓÈë¶ÓÁÐ,µÈ´ý·¢ËÍ */
+ COMM_ERR_NOTINIT, /* ·¢ËÍʧ°Ü,ͨѶ´úÀíûÓгõʼ»¯ */
+ COMM_ERR_LINKBREAK, /* ·¢ËÍʧ°Ü,Á´Â·ÒѾ¶Ï¿ª */
+ COMM_ERR_DATALEN, /* ·¢ËÍʧ°Ü,ÏûÏ¢ÄÚÈݳ¤¶È³¬¹ý×î´ó³¤¶È */
+ COMM_ERR_MEM, /* ·¢ËÍʧ°Ü,ÄÚ´æ²Ù×÷ʧ°Ü */
+ COMM_ERR_MUTEX, /* ·¢ËÍʧ°Ü,»¥³âÌå³öÏÖ´íÎó */
+
+ MAX_COMM_ERR
+} COMM_RET;
+
+typedef enum
+{
+ FUNC_RET_FAILURE,
+ FUNC_RET_SUCCESS,
+
+ MAX_FUNC_RET
+} FUNC_RET;
+
+// Comm½á¹¹¶¨Òå
+typedef struct
+{
+ UINT8 msg_type; /* ÏûÏ¢ÀàÐÍ */
+ UINT8 pad; /* Ìî³äλ */
+ UINT16 reserved; /* ±£Áô×ֶΣ¬ÌîΪ0xAAAA */
+ UINT8 tgt_mdl_no; /* Ä¿±ê(½ÓÊÕÏûÏ¢)Ä£¿éÄ£¿éºÅ */
+ UINT8 tgt_submdl_no; /* Ä¿±ê(½ÓÊÕÏûÏ¢)Ä£¿é×ÓÄ£¿éºÅ */
+ UINT8 src_mdl_no; /* Ô´(·¢ËÍÏûÏ¢)Ä£¿éÄ£¿éºÅ */
+ UINT8 src_submdl_no; /* Ô´(·¢ËÍÏûÏ¢)Ä£¿é×ÓÄ£¿éºÅ */
+ UINT32 buf_len; /* ÏûÏ¢Êý¾Ý³¤¶È(²»º¬ÏûϢͷ) */
+} T_COMM_TYPE;
+
+/* ´òÓ¡»º³åÇø */
+typedef struct
+{
+ UINT32 capacity; /* »º³åÇøÈÝÁ¿*/
+ volatile UINT32 readPoint; /* ¶ÁÖ¸Õë */
+ volatile UINT32 writePoint; /* дָÕë */
+ UINT32 symbol; /* ¿ØÖÆ¿é±êʶ·û */
+ UINT8 buf[1]; /* ´òÓ¡»º³åÇø */
+} T_RINGBUFFER;
+
+typedef struct
+{
+ UINT8 *buf;
+ UINT32 bufIndex; // Ö¸ÕëÆ«ÒÆ
+ UINT32 bufSize;
+} T_HDLC_BUFFER_TYPE;
+
+
+/**
+ * @brief ´Ócomm»·Ðλº³åÖÐÉêÇëÒ»¿éÄÚ´æ
+ * @param[in] size ÉêÇëµÄʵ¼ÊÓÐÓÃÊý¾ÝµÄ¿Õ¼ä´óС
+ * @return Èç¹û³É¹¦£¬·µ»ØÄÚ´æÖ¸Õ룬·ñÔò·µ»ØNULL
+ * @note ÉêÇëµÄÄÚ´æÖ»ÓÃÓÚcommµÄÊý¾Ý·¢ËÍ£¬É÷ÓÃ!!! \n
+ Èç¹û·¢Ëͳɹ¦Ôò²»ÐèÊÍ·Å£»\n
+ δ·¢ËÍ»ò·¢ËͲ»³É¹¦Ôò±ØÐëµ÷ÓÃComm_Free½øÐÐÊÍ·Å£¬·ñÔòËÀÇÌÇÌ
+ * @see
+ */
+VOID* Comm_Malloc(UINT32 size);
+
+/**
+ * @brief ÊÍ·ÅÓÉComm_MallocÉêÇëµÄÄÚ´æ
+ * @param[in] mem_ptr ´ýÊͷŵÄcomm»º³åÇøÖÐÄÚ´æ¿éµÄÖ¸Õë
+ * @return void
+ * @note
+ * @see
+ */
+VOID Comm_Free(VOID *mem_ptr);
+
+/**
+ * @brief ZCATͨѶ¹ÜÀíÄ£¿é³õʼ»¯
+ * @param[in] void
+ * @return ³É¹¦·µ»ØZOSS_SUCCESS£»Ê§°Ü·µ»ØZOSS_ERROR
+ * @note
+ * @see
+ */
+UINT32 Comm_Init(VOID);
+
+/**
+ * @brief ZCATͨѶ¹ÜÀíÄ£¿é×¢Ïú½Ó¿Ú,
+ * @param[in] void
+ * @return void
+ * @note
+ * @see
+ */
+void Comm_Release(void);
+
+
+/**
+ * @brief ZCAT×ÓÄ£¿é×¢²á½Ó¿Ú \n
+ * Ìṩ¸ø¸÷¸ö×ÓÄ£¿éµ÷Óã¬×¢²á×ÓÄ£¿éÐÅÏ¢
+ * @param[in] submdl_no ×¢²áµÄ×ÓÄ£¿éºÅ£¬ÒѾÔÚpub_mdldef.hÖж¨ÒåºÃ
+ * @param[in] uart_name ÕâÀïÒòΪÐèÇó±ä¸ü£¬µ¼Ö²ÎÊýuart_nameÎÞЧ,ÇëÒ»ÂÉÌîuart/0
+ * @param[in] moduleFunc ¸÷¸ö×ÓÄ£¿é»Øµ÷º¯Êý
+ * @return ³É¹¦·µ»ØZOSS_SUCCESS, ʧ°Ü·µ»ØZOSS_ERROR
+ * @note
+ * @see
+ */
+UINT32 zTools_CommReg(UINT8 submdl_no, const CHAR *uart_name, ModuleFunc moduleFunc);
+
+/**
+ * @brief ZCAT×ÓÄ£¿é×¢Ïú½Ó¿Ú \n
+ * Ìṩ¸ø¸÷¸ö×ÓÄ£¿éµ÷Óã¬×¢Ïú×ÓÄ£¿éÐÅÏ¢
+ * @param[in] submdl_no ½«Òª×¢ÏúµÄ×ÓÄ£¿éºÅ
+ * @return ³É¹¦·µ»ØZOSS_SUCCESS, ʧ°Ü·µ»ØZOSS_ERROR
+ * @note
+ * @see
+ */
+UINT32 zTools_CommUnReg(UINT8 submdl_no);
+
+/**
+ * @brief Ìṩ¸ø²»Í¬×ÓÄ£¿éÏò"ÍâÉè"·¢ËÍÊý¾ÝµÄ¹¦ÄÜ \n
+ * ¸øTraceAgtÄ£¿éʹÓÃ,Õâ¸öÊÇÒì²½½Ó¿Ú£¬Ö»¹Ü·¢ËͶø²»¹ÜÊÇ·ñÄܹ»ÊÕµ½
+ * ·¢ËÍÊý¾ÝÒ»°ãÏȵ½"ͳһ»º´æ"ÖУ¬È»ºó֪ͨ·¢ËÍÏß³ÌÓÐÊý¾Ý´ý·¢ËÍ
+ * @param[in] buf ·¢ËÍÊý¾Ý(±ØÐëÊÇÓÉComm_MallocÉêÇëµÄÄÚ´æ!!!)
+ * @param[in] buf_len ·¢ËÍÊý¾ÝµÄ³¤¶È
+ * @param[in] tgt_mdl_no Ä¿±êÄ£¿éºÅ£¬ÊÖ»ú»òPCµÈ
+ * @param[in] tgt_submdl_no Ä¿±ê×ÓÄ£¿éºÅ
+ * @param[in] src_submdl_no Ô´×ÓÄ£¿éºÅ
+ * @return ³É¹¦·µ»ØZOSS_SUCCESS, ·ñÔò·µ»ØZOSS_ERROR
+ * @note
+ * @see
+ */
+UINT32 zTools_SendData(UINT8 *buf, UINT32 buf_len,
+ UINT8 tgt_mdl_no, UINT8 tgt_submdl_no, UINT8 src_submdl_no);
+
+/**
+ * @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);
+
+/**
+ * @brief HDLC±àÂë
+ * @param[out] dest Ä¿±êT_HDLC_BUFFER_TYPEÖ¸Õë
+ * @param[in] src Ô´T_HDLC_BUFFER_TYPEÖ¸Õë
+ * @return ³É¹¦·µ»ØTRUE£»Ê§°Ü·µ»ØFALSE
+ * @note
+ * @see
+ */
+BOOL hdlc_encode(T_HDLC_BUFFER_TYPE *dest, const T_HDLC_BUFFER_TYPE *src);
+
+/**
+ * @brief ½«Êý¾Ý½øÐÐHDLC½âÂëÖÁÖ¸¶¨µÄµ¥ÏòFIFOÖÐ
+ * FIFOÖ»ÄÜ´ÓÍ·(0λÖÃ)°´Õû°ü¶Á³öÊý¾Ý»ò¶ªÆú£¬½âÂëʱ°´Ë³ÐòдÈëµ½FIFO£¬
+ * ÿÕÒµ½Ò»´ÎÕû°ü£¬Í£Ö¹Ð´È룬Ȼºó¶Á³öÊý¾Ý»òÕß¶ªÆú
+ * ¹ý³ÌÖÐÓò»µ½readPoint£¬Ê¼ÖÕΪ0
+ * @param[out] dest ½âÂëºó´æ´¢µÄFIFOÖ¸Õë
+ * @param[in] src ´ý½âÂëµÄ»º´æÖ¸Õë
+ * @param[in] len ´ý½âÂëµÄ»º´æ³¤¶È
+ * @return ·µ»Ø½âÂëµÄʵ¼Ê³¤¶È
+ * @note
+ * @see
+ */
+UINT32 hdlc_decode(T_RINGBUFFER *dest, unsigned char *src, unsigned int len);
+
+/**************************************************************************
+ CommAgt¹«¹²½Ó¿ÚÉùÃ÷
+**************************************************************************/
+
+/**************************************************************************
+*Ä£¿é½ÓÊÕÏûÏ¢»Øµ÷º¯Êý
+*²ÎÊý˵Ã÷:
+* (IN)
+* ucLinkMsg Á´Â·×´Ì¬
+* LINK_CONNECT Á´Â·½¨Á¢
+* LINK_BREAK Á´Â·¶Ï¿ª
+**************************************************************************/
+typedef void (* LINKRPTFUNC)(LINK_INFO ucLinkMsg);
+
+/**************************************************************************
+*ÆÕͨ×ÓÄ£¿é(²»ÓùØÐÄÏûÏ¢ID)½ÓÊÕÊý¾Ý»Øµ÷º¯Êý
+*²ÎÊý˵Ã÷:
+* (IN)
+* ucSrcModNo Ô´Ä£¿éºÅ
+* ucSrcSubModNo Ô´×ÓÄ£¿éºÅ
+* pBuf ÏûÏ¢Êý¾ÝÖ¸Õë
+* wLen ÏûÏ¢Êý¾Ý³¤¶È
+**************************************************************************/
+typedef void (* RECVFUNC)(unsigned char ucSrcModNo, unsigned char ucSrcSubModNo, const char *pBuf, unsigned short wLen);
+
+/**************************************************************************
+*À©Õ¹×ÓÄ£¿é(ʹÓÃÏûÏ¢ID)½ÓÊÕÊý¾Ý»Øµ÷º¯Êý
+*²ÎÊý˵Ã÷:
+* (IN)
+* ucSrcModNo Ô´Ä£¿éºÅ
+* ucSrcSubModNo Ô´×ÓÄ£¿éºÅ
+* dwMsgID ÏûÏ¢±àºÅ
+* pBuf ÏûÏ¢Êý¾ÝÖ¸Õë
+* wLen ÏûÏ¢Êý¾Ý³¤¶È
+**************************************************************************/
+typedef void (* RECVFUNCEX)(unsigned char ucSrcModNo, unsigned char ucSrcSubModNo, unsigned int dwMsgID, const char *pBuf, unsigned short wLen);
+
+/**************************************************************************
+*ÐéÄâ´®¿ÚÄ£¿é½ÓÊÕÊý¾Ý»Øµ÷º¯Êý,ʹÓÃÏûÏ¢ID
+*²ÎÊý˵Ã÷:
+* (IN)
+* ucSrcModNo Ô´Ä£¿éºÅ
+* ucSrcSubModNo Ô´×ÓÄ£¿éºÅ
+* ucTarSubModNo Ä¿±ê×ÓÄ£¿éºÅ
+* dwMsgID ÏûÏ¢±àºÅ
+* pBuf ÏûÏ¢Êý¾ÝÖ¸Õë
+* wLen ÏûÏ¢Êý¾Ý³¤¶È
+**************************************************************************/
+typedef void (* RECVFUNCUART)(unsigned char ucSrcModNo, unsigned char ucSrcSubModNo, unsigned char ucTarModNo, unsigned char ucTarSubModNo, unsigned int dwMsgID, const char *pBuf, unsigned short wLen);
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º Comm_Register
+* ¹¦ÄÜÃèÊö£º ÆÕͨģ¿é(²»ÓùØÐÄÏûÏ¢ID)×¢²á½Ó¿Ú(97ÓÃ)
+* ²ÎÊý˵Ã÷£º (IN)
+* ucModNo Ä£¿éºÅ
+* linkRptFunc Ä£¿é½ÓÊÕÏûÏ¢»Øµ÷º¯Êý
+* (OUT)
+* ·µ »Ø Öµ£º VOID
+* ÆäËü˵Ã÷£º ûÓзµ»ØÖµ
+**************************************************************************/
+FUNC_RET Comm_Register(unsigned char ucModNo, LINKRPTFUNC linkRptFunc);
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º Comm_RegisterSub
+* ¹¦ÄÜÃèÊö£º ÆÕͨģ¿é(²»ÓùØÐÄÏûÏ¢ID)×ÓÄ£¿é×¢²á½Ó¿Ú(97ÓÃ)
+* ²ÎÊý˵Ã÷£º (IN)
+* ucModNo Ä£¿éºÅ
+* ucSubModNo ×ÓÄ£¿éºÅ
+* recvFunc ×ÓÄ£¿é½ÓÊÕÊý¾Ý»Øµ÷º¯Êý
+* (OUT)
+* ·µ »Ø Öµ£º
+* FUNC_RET_SUCCESS ×¢²á³É¹¦
+* FUNC_RET_FAILURE ×¢²áʧ°Ü,Á½ÖÖ¿ÉÄÜÇé¿ö,Ò»ÊÇ×ÓÄ£¿éºÅÖØ¸´ÁË,¶þÊÇ×¢²áµÄ×ÓÄ£¿éÊýÒѾµ½×î´óÏÞ¶È
+* ÆäËü˵Ã÷£º Ö»ÊÇ×¢²áÔÚͨѶ´úÀíÖÐ
+**************************************************************************/
+FUNC_RET Comm_RegisterSub(unsigned char ucModNo, unsigned char ucSubModNo, RECVFUNC recvFunc);
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º Comm_SendMsg
+* ¹¦ÄÜÃèÊö£º ÆÕͨģ¿é(²»ÓùØÐÄÏûÏ¢ID)·¢ËÍÏûÏ¢½Ó¿Ú(97ÓÃ)
+* ²ÎÊý˵Ã÷£º (IN)
+* ucTarModNo Ä¿±êÄ£¿éºÅ
+* ucTarSubModNo Ä¿±ê×ÓÄ£¿éºÅ
+* ucSrcModNo Ô´Ä£¿éºÅ
+* ucSrcSubModNo Ô´×ÓÄ£¿éºÅ
+* pBuf ÏûÏ¢Êý¾ÝÖ¸Õë
+* wLen ÏûÏ¢Êý¾Ý³¤¶È,²»ÄÜ´óÓÚMAX_COMM_LEN
+* (OUT)
+* ·µ »Ø Öµ£º
+* COMM_RET_SUCCESS ·¢Ëͳɹ¦
+* COMM_ERR_NOTINIT ·¢ËÍʧ°Ü,ͨѶ´úÀíÉÐδ³õʼ»¯
+* COMM_ERR_LINKBREAK ·¢ËÍʧ°Ü,ÒòΪÁ´Â·Î´Á¬½Ó(ÓÃÓÚPC²à)»ò¶Ë¿Úδ´ò¿ª(ÓÃÓÚÊÖ»ú²à)
+* COMM_ERR_DATALEN ·¢ËÍʧ°Ü,ÏûÏ¢ÄÚÈݳ¬¹ý×î´ó³¤¶È
+* COMM_ERR_MEM ·¢ËÍʧ°Ü,ÄÚ´æ²Ù×÷ʧ°Ü
+* COMM_ERR_MUTEX ·¢ËÍʧ°Ü,»¥³âÌå³öÏÖ´íÎó
+* ÆäËü˵Ã÷£º
+**************************************************************************/
+COMM_RET Comm_SendMsg(unsigned char ucTarModNo, unsigned char ucTarSubModNo, \
+ unsigned char ucSrcModNo, unsigned char ucSrcSubModNo, \
+ const char * pBuf, unsigned short wLen);
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º Comm_GetStatus
+* ¹¦ÄÜÃèÊö£º »ñȡͨѶ´úÀíÓëͨѶ¹¤¾ßµÄÁ´Â·×´Ì¬
+* ²ÎÊý˵Ã÷£º (IN)
+* ucModNo Ä£¿éºÅ
+* (OUT)
+* ·µ »Ø Öµ£º
+* FUNC_RET_SUCCESS Á´Â·ÒÑÁ¬½Ó
+* FUNC_RET_FAILURE Á´Â·Î´Á¬½Ó
+* ÆäËü˵Ã÷£º
+**************************************************************************/
+FUNC_RET Comm_GetStatus(unsigned char ucModNo);
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º Comm_UnRegister
+* ¹¦ÄÜÃèÊö£º Ä£¿é×¢Ïú½Ó¿Ú
+* ²ÎÊý˵Ã÷£º (IN)
+* ucModNo Ä£¿éºÅ
+* (OUT)
+* ·µ »Ø Öµ£º
+* FUNC_RET_SUCCESS ×¢Ïú³É¹¦
+* FUNC_RET_FAILURE ×¢Ïúʧ°Ü
+* ÆäËü˵Ã÷£º
+**************************************************************************/
+FUNC_RET Comm_UnRegister(unsigned char ucModNo);
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º Comm_UnRegisterSub
+* ¹¦ÄÜÃèÊö£º ÆÕͨģ¿é(²»ÓùØÐÄÏûÏ¢ID)×ÓÄ£¿é×¢Ïú½Ó¿Ú
+* ²ÎÊý˵Ã÷£º (IN)
+* ucModNo Ä£¿éºÅ
+* ucSubModNo ×ÓÄ£¿éºÅ
+* (OUT)
+* ·µ »Ø Öµ£º
+* FUNC_RET_SUCCESS ×¢Ïú³É¹¦
+* FUNC_RET_FAILURE ×¢Ïúʧ°Ü
+* ÆäËü˵Ã÷£º
+**************************************************************************/
+FUNC_RET Comm_UnRegisterSub(unsigned char ucModNo, unsigned char ucSubModNo);
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º Comm_RegisterEx
+* ¹¦ÄÜÃèÊö£º À©Õ¹Ä£¿é(ʹÓÃÏûÏ¢ID)×¢²á½Ó¿Ú
+* ²ÎÊý˵Ã÷£º (IN)
+* ucModNo Ä£¿éºÅ
+* linkRptFunc Ä£¿é½ÓÊÕÏûÏ¢»Øµ÷º¯Êý
+* (OUT)
+* ·µ »Ø Öµ£º VOID
+* ÆäËü˵Ã÷£º ûÓзµ»ØÖµ
+**************************************************************************/
+FUNC_RET Comm_RegisterEx(unsigned char ucModNo, LINKRPTFUNC linkRptFunc);
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º Comm_RegisterSubEx
+* ¹¦ÄÜÃèÊö£º À©Õ¹Ä£¿é(ʹÓÃÏûÏ¢ID)×ÓÄ£¿é×¢²á½Ó¿Ú
+* ²ÎÊý˵Ã÷£º (IN)
+* ucModNo Ä£¿éºÅ
+* ucSubModNo ×ÓÄ£¿éºÅ
+* recvFunc ×ÓÄ£¿é½ÓÊÕÊý¾Ý»Øµ÷º¯Êý
+* (OUT)
+* ·µ »Ø Öµ£º
+* FUNC_RET_SUCCESS ×¢²á³É¹¦
+* FUNC_RET_FAILURE ×¢²áʧ°Ü,Á½ÖÖ¿ÉÄÜÇé¿ö,Ò»ÊÇ×ÓÄ£¿éºÅÖØ¸´ÁË,¶þÊÇ×¢²áµÄ×ÓÄ£¿éÊýÒѾµ½×î´óÏÞ¶È
+* ÆäËü˵Ã÷£º Ö»ÊÇ×¢²áÔÚͨѶ´úÀíÖÐ
+**************************************************************************/
+FUNC_RET Comm_RegisterSubEx(unsigned char ucModNo, unsigned char ucSubModNo, RECVFUNCEX recvFunc);
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º Comm_SendMsgEx
+* ¹¦ÄÜÃèÊö£º À©Õ¹Ä£¿é(ʹÓÃÏûÏ¢ID)·¢ËÍÏûÏ¢½Ó¿Ú
+* ²ÎÊý˵Ã÷£º (IN)
+* ucTarModNo Ä¿±êÄ£¿éºÅ
+* ucTarSubModNo Ä¿±ê×ÓÄ£¿éºÅ
+* ucSrcModNo Ô´Ä£¿éºÅ
+* ucSrcSubModNo Ô´×ÓÄ£¿éºÅ
+* dwMsgID ÏûÏ¢±àºÅ
+* pBuf ÏûÏ¢ÄÚÈÝÖ¸Õë
+* wLen ÏûÏ¢ÄÚÈݳ¤¶È,²»ÄÜ´óÓÚMAX_COMM_LEN - MSG_HEADER_LEN
+* (OUT)
+* ·µ »Ø Öµ£º
+* COMM_RET_SUCCESS ·¢Ëͳɹ¦
+* COMM_ERR_NOTINIT ·¢ËÍʧ°Ü,ͨѶ´úÀíÉÐδ³õʼ»¯
+* COMM_ERR_LINKBREAK ·¢ËÍʧ°Ü,ÒòΪÁ´Â·Î´Á¬½Ó(ÓÃÓÚPC²à)»ò¶Ë¿Úδ´ò¿ª(ÓÃÓÚÊÖ»ú²à)
+* COMM_ERR_DATALEN ·¢ËÍʧ°Ü,ÏûÏ¢ÄÚÈݳ¬¹ý×î´ó³¤¶È
+* COMM_ERR_MEM ·¢ËÍʧ°Ü,ÄÚ´æ²Ù×÷ʧ°Ü
+* COMM_ERR_MUTEX ·¢ËÍʧ°Ü,»¥³âÌå³öÏÖ´íÎó
+* ÆäËü˵Ã÷£º
+**************************************************************************/
+COMM_RET Comm_SendMsgEx(unsigned char ucTarModNo, unsigned char ucTarSubModNo, \
+ unsigned char ucSrcModNo, unsigned char ucSrcSubModNo, \
+ unsigned int dwMsgID, const char * pBuf, unsigned short wLen);
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º Comm_RegisterUart
+* ¹¦ÄÜÃèÊö£º ÐéÄâ´®¿ÚÄ£¿é×¢²á½Ó¿Ú,Ö§³ÖÏûÏ¢ID,ÕâÖ־Ͳ»ÓÃ×¢²á×ÓÄ£¿éÁË
+* ²ÎÊý˵Ã÷£º (IN)
+* ucModNo Ä£¿éºÅ
+* linkRptFunc Ä£¿é½ÓÊÕÏûÏ¢»Øµ÷º¯Êý
+* recvFunc Ä£¿é½ÓÊÕÊý¾Ý»Øµ÷º¯Êý
+* (OUT)
+* ·µ »Ø Öµ£º VOID
+* ÆäËü˵Ã÷£º ûÓзµ»ØÖµ
+**************************************************************************/
+FUNC_RET Comm_RegisterUart(unsigned char ucModNo, LINKRPTFUNC linkRptFunc, RECVFUNCUART recvFunc);
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º Comm_TaskSendToPhone
+* ¹¦ÄÜÃèÊö£º ±¾½Ó¿ÚÌṩ¸øÐÒéÕ»µÄ²âÊÔ¹¤¾ßʹÓÃ,Ä£ÄâÈÎÎñ¸ø·¢Ë͵ÄÈÎÎñ»Ø¸´ÏûÏ¢µÄ½Ó¿Ú
+* ²ÎÊý˵Ã÷£º(IN)
+* msg_id ·¢ËÍÏûÏ¢±àºÅ£¬Õâ¸ö¿ÉÒÔÓÉÓû§×Ô¼º¶¨Òå
+* buf ÏûÏ¢Êý¾ÝÖ¸Õë
+* buf_len ÏûÏ¢Êý¾Ý³¤¶È
+* tgtMdlNo Ä¿±êÄ£¿éºÅ£¬ÊÖ»ú»òPCµÈ
+* tgtSubMdlNo Ä¿±ê×ÓÄ£¿éºÅ
+* srcSubMdlNo Ô´×ÓÄ£¿éºÅ
+* srcTask Ô´ÈÎÎñID
+* tgtTask Ä¿±êÈÎÎñID
+* (OUT)
+* ·µ »Ø Öµ£º Èç¹û·¢Ëͳɹ¦£¬·µ»ØZOSS_SUCCESS,·ñÔò·µ»ØZOSS_ERROR
+* ÆäËü˵Ã÷£º ÎÞ
+**************************************************************************/
+unsigned int Comm_TaskSendToPhone(unsigned int msg_id, const unsigned char *buf, unsigned short bufLen, \
+ unsigned char tgtMdlNo, unsigned char tgtSubMdlNo, unsigned char srcSubMdlNo, void * srcTask, void * tgtTask);
+
+
+/**
+ * @brief ·¢ËÍÊý¾Ýµ½"ͳһ»º´æ"ÖÐ
+ * @param[in] buf ·¢ËÍÊý¾Ý(±ØÐëÊÇÓÉComm_MallocÉêÇëµÄÄÚ´æ!!!)
+ * @param[in] buf_len ·¢ËÍÊý¾ÝµÄ³¤¶È
+ * @param[in] tgt_mdl_no Ä¿±êÄ£¿éºÅ£¬ÊÖ»ú»òPCµÈ
+ * @param[in] tgt_submdl_no Ä¿±ê×ÓÄ£¿éºÅ
+ * @param[in] src_submdl_no Ô´×ÓÄ£¿éºÅ
+ * @return ³É¹¦·µ»ØZOSS_SUCCESS, ·ñÔò·µ»ØZOSS_ERROR
+ * @note
+ * @see
+ */
+VOID Comm_HeaderInit(T_COMM_TYPE *commHeader, UINT32 buf_len,
+ UINT8 tgt_mdl_no, UINT8 tgt_submdl_no, UINT8 src_submdl_no);
+#endif /*COMM_PUB_H_*/
+