--- /dev/null
+/*\r
+ * Copyright (c) 2013 Qualcomm Atheros, Inc.\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted (subject to the limitations in the\r
+ * disclaimer below) provided that the following conditions are met:\r
+ *\r
+ * * Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ *\r
+ * * Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the\r
+ * distribution.\r
+ *\r
+ * * Neither the name of Qualcomm Atheros nor the names of its\r
+ * contributors may be used to endorse or promote products derived\r
+ * from this software without specific prior written permission.\r
+ *\r
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE\r
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT\r
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED\r
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\r
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\r
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\r
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+/*\r
+ * @File: htc_api.h\r
+ * \r
+ * @Abstract: host-target communications API\r
+ * \r
+ * @Notes: \r
+ */\r
+\r
+#ifndef __HTC_API_H__\r
+#define __HTC_API_H__\r
+\r
+#include <osapi.h>\r
+#include <htc.h>\r
+//#include <htc_buf.h>\r
+//#include <htc_services.h>\r
+#include <adf_nbuf.h>\r
+#include <buf_pool_api.h>\r
+\r
+#define HTC_HDR_SZ HTC_HDR_LENGTH\r
+#define HTC_BUFSZ_MAX_SEND 2048\r
+\r
+typedef void (* HTC_SERVICE_ProcessRecvMsg)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t, adf_nbuf_t, void *ServiceCtx);\r
+typedef void (* HTC_SERVICE_ProcessSendBufferComplete)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t, void *ServiceCtx);\r
+ \r
+/* HTC service structure :\r
+ * the caller is required to allocate storage for the service structure and register the\r
+ * structure using HTC_RegisterService() The service must set the following fields:\r
+ * ProcessRecvMsg\r
+ * ProcessSendBufferComplete\r
+ * ProcessConnect\r
+ * ServiceID\r
+ * MaxSvcMsgSize (for message validation)\r
+ * */\r
+typedef struct _HTC_SERVICE {\r
+ struct _HTC_SERVICE *pNext;\r
+ /* Callback for processing receive messages. HTC calls this callback whenever a \r
+ * message arrives on the endpoint assigned to this service.\r
+ * HTC_BUFFER is a chain of buffers containing a full application message.\r
+ * HTC_BUFFER->buffer points to the start of the msg buffer (past the HTC header) */\r
+ //void (* ProcessRecvMsg)(HTC_ENDPOINT_ID EndpointID, HTC_BUFFER *); \r
+ void (* ProcessRecvMsg)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t, adf_nbuf_t, void *ServiceCtx); \r
+ /* callback to process completed send buffers */\r
+ //void (* ProcessSendBufferComplete)(HTC_ENDPOINT_ID EndpointID, HTC_BUFFER *); \r
+ void (* ProcessSendBufferComplete)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t, void *ServiceCtx); \r
+ /* optional callback when a connection request occurs.\r
+ * The EndpointID is the assigned endpoint, the callback returns a connect \r
+ * response status code to allow or disallow the connection.\r
+ * pDataIn points to the optional meta data supplied in the connection request\r
+ * pDataOut points to a buffer to send back meta data \r
+ * If no callback is supplied, HTC assumes the connect is allowed */\r
+ A_UINT8 (* ProcessConnect)(struct _HTC_SERVICE *pService,\r
+ HTC_ENDPOINT_ID EndpointID, \r
+ A_UINT8 *pDataIn, \r
+ int LengthIn,\r
+ A_UINT8 *pDataOut,\r
+ int *pLengthOut); \r
+ A_UINT16 ServiceID; /* service ID to match connection requests */\r
+ A_UINT16 ServiceFlags; /* service flags */\r
+ A_UINT16 MaxSvcMsgSize; /* maximum length of service-specific messages exchanged on the endpoint */\r
+ A_UINT16 TrailerSpcCheckLimit; /* amount of space in each send buffer that HTC can check for trailer\r
+ data. This should be set to the smallest HTC buffer that can be sent \r
+ through the service. The service can disable trailer data insertion\r
+ by setting this value to 0. */\r
+ void *ServiceCtx;\r
+} HTC_SERVICE;\r
+\r
+#define HTC_SERVICE_FLAGS_CONNECTED (1 << 0) /* service has at least 1 connection */\r
+\r
+#define IS_SERVICE_CONNECTED(s) ((s)->ServiceFlags & HTC_SERVICE_FLAGS_CONNECTED)\r
+\r
+ /* configuration settings for the WMI service */\r
+typedef struct _HTC_CONFIG {\r
+ int CreditSize; /* */\r
+ int CreditNumber;\r
+ //int ControlDownLinkPipeID;\r
+ //int ControlUpLinkPipeID;\r
+ adf_os_handle_t OSHandle;\r
+ hif_handle_t HIFHandle;\r
+ pool_handle_t PoolHandle;\r
+} HTC_CONFIG;\r
+\r
+typedef struct _HTC_BUF_CONTEXT {\r
+ A_UINT8 end_point;\r
+ A_UINT8 htc_flags; /* htc flags (used by HTC layer only) */ \r
+} HTC_BUF_CONTEXT;\r
+\r
+typedef void* htc_handle_t;\r
+\r
+/*\r
+ * setup complete function, supplied by HTC caller at HTC_init time.\r
+ * HTC calls this function after the host has indicated that the service connection\r
+ * phase is complete.\r
+ * \r
+ */\r
+typedef void (* HTC_SETUP_COMPLETE_CB)(void);\r
+\r
+struct htc_apis {\r
+ htc_handle_t (* _HTC_Init)(HTC_SETUP_COMPLETE_CB, HTC_CONFIG *pConfig); \r
+ void (* _HTC_Shutdown)(htc_handle_t);\r
+ void (* _HTC_RegisterService)(htc_handle_t, HTC_SERVICE *);\r
+ void (* _HTC_Ready)(htc_handle_t);\r
+ void (* _HTC_ReturnBuffers)(htc_handle_t handle, HTC_ENDPOINT_ID EndpointID, adf_nbuf_t);\r
+ void (* _HTC_ReturnBuffersList)(htc_handle_t handle, HTC_ENDPOINT_ID EndpointID, adf_nbuf_queue_t);\r
+ void (* _HTC_SendMsg)(htc_handle_t handle, HTC_ENDPOINT_ID EndpointID, adf_nbuf_t); \r
+ int (* _HTC_GetReservedHeadroom)(htc_handle_t handle);\r
+ \r
+ //void (* _HTC_PauseRecv)(HTC_ENDPOINT_ID EndpointID);\r
+ //void (* _HTC_ResumeRecv)(HTC_ENDPOINT_ID EndpointID);\r
+ //void (* _HTC_AddBufferResources)(int buffers);\r
+ \r
+ /* These APIs below are for patch purpose only */\r
+ void (*_HTC_MsgRecvHandler)(adf_nbuf_t hdr_buf, adf_nbuf_t buf, void *context);\r
+ void (*_HTC_SendDoneHandler)(adf_nbuf_t buf, void *context);\r
+ void (*_HTC_ControlSvcProcessMsg)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t hdr_buf, adf_nbuf_t buf, void *arg);\r
+ void (*_HTC_ControlSvcProcessSendComplete)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t pBuffers, void *arg);\r
+ \r
+ void *pReserved; /* for expansion if need be */\r
+};\r
+\r
+extern void htc_module_install(struct htc_apis *pAPIs);\r
+\r
+#endif /* _HTC_API_H__ */\r