Setting up repository
[linux-libre-firmware.git] / ath9k_htc / sboot / magpie_1_1 / sboot / htc / inc / htc_api.h
1 /*\r
2  * Copyright (c) 2013 Qualcomm Atheros, Inc.\r
3  * All rights reserved.\r
4  *\r
5  * Redistribution and use in source and binary forms, with or without\r
6  * modification, are permitted (subject to the limitations in the\r
7  * disclaimer below) provided that the following conditions are met:\r
8  *\r
9  *  * Redistributions of source code must retain the above copyright\r
10  *    notice, this list of conditions and the following disclaimer.\r
11  *\r
12  *  * Redistributions in binary form must reproduce the above copyright\r
13  *    notice, this list of conditions and the following disclaimer in the\r
14  *    documentation and/or other materials provided with the\r
15  *    distribution.\r
16  *\r
17  *  * Neither the name of Qualcomm Atheros nor the names of its\r
18  *    contributors may be used to endorse or promote products derived\r
19  *    from this software without specific prior written permission.\r
20  *\r
21  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE\r
22  * GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT\r
23  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED\r
24  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\r
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\r
30  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
31  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\r
32  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\r
33  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
34  */\r
35 /*\r
36  * @File: htc_api.h\r
37  * \r
38  * @Abstract: host-target communications API\r
39  * \r
40  * @Notes: \r
41  */\r
42 \r
43 #ifndef __HTC_API_H__\r
44 #define __HTC_API_H__\r
45 \r
46 #include <osapi.h>\r
47 #include <htc.h>\r
48 //#include <htc_buf.h>\r
49 //#include <htc_services.h>\r
50 #include <adf_nbuf.h>\r
51 #include <buf_pool_api.h>\r
52 \r
53 #define HTC_HDR_SZ          HTC_HDR_LENGTH\r
54 #define HTC_BUFSZ_MAX_SEND  2048\r
55 \r
56 typedef void (* HTC_SERVICE_ProcessRecvMsg)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t, adf_nbuf_t, void *ServiceCtx);\r
57 typedef void (* HTC_SERVICE_ProcessSendBufferComplete)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t, void *ServiceCtx);\r
58  \r
59 /* HTC service structure :\r
60  * the caller is required to allocate storage for the service structure and register the\r
61  * structure using HTC_RegisterService()  The service must set the following fields:\r
62  *    ProcessRecvMsg\r
63  *    ProcessSendBufferComplete\r
64  *    ProcessConnect\r
65  *    ServiceID\r
66  *    MaxSvcMsgSize (for message validation)\r
67  * */\r
68 typedef struct _HTC_SERVICE {\r
69     struct _HTC_SERVICE *pNext;\r
70         /* Callback for processing receive messages.  HTC calls this callback whenever a \r
71          * message arrives on the endpoint assigned to this service.\r
72          * HTC_BUFFER is a chain of buffers containing a full application message.\r
73          * HTC_BUFFER->buffer points to the start of the msg buffer (past the HTC header) */\r
74     //void (* ProcessRecvMsg)(HTC_ENDPOINT_ID EndpointID, HTC_BUFFER *); \r
75     void (* ProcessRecvMsg)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t, adf_nbuf_t, void *ServiceCtx); \r
76         /* callback to process completed send buffers */\r
77     //void (* ProcessSendBufferComplete)(HTC_ENDPOINT_ID EndpointID, HTC_BUFFER *); \r
78     void (* ProcessSendBufferComplete)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t, void *ServiceCtx); \r
79         /* optional callback when a connection request occurs.\r
80          * The EndpointID is the assigned endpoint, the callback returns a connect \r
81          * response status code to allow or disallow the connection.\r
82          * pDataIn points to the optional meta data supplied in the connection request\r
83          * pDataOut points to a buffer to send back meta data \r
84          * If no callback is supplied, HTC assumes the connect is allowed  */\r
85     A_UINT8 (* ProcessConnect)(struct _HTC_SERVICE *pService,\r
86                                HTC_ENDPOINT_ID     EndpointID, \r
87                                A_UINT8 *pDataIn, \r
88                                int      LengthIn,\r
89                                A_UINT8 *pDataOut,\r
90                                int     *pLengthOut); \r
91     A_UINT16  ServiceID;        /* service ID to match connection requests */\r
92     A_UINT16  ServiceFlags;     /* service flags */\r
93     A_UINT16  MaxSvcMsgSize;    /* maximum length of service-specific messages exchanged on the endpoint */\r
94     A_UINT16  TrailerSpcCheckLimit;  /* amount of space in each send buffer that HTC can check for trailer\r
95                                         data. This should be set to the smallest HTC buffer that can be sent \r
96                                         through the service. The service can disable trailer data insertion\r
97                                         by setting this value to 0. */\r
98     void      *ServiceCtx;\r
99 } HTC_SERVICE;\r
100 \r
101 #define HTC_SERVICE_FLAGS_CONNECTED         (1 << 0)  /* service has at least 1 connection */\r
102 \r
103 #define IS_SERVICE_CONNECTED(s) ((s)->ServiceFlags & HTC_SERVICE_FLAGS_CONNECTED)\r
104 \r
105    /* configuration settings for the WMI service */\r
106 typedef struct _HTC_CONFIG {\r
107     int         CreditSize;    /*  */\r
108     int         CreditNumber;\r
109     //int         ControlDownLinkPipeID;\r
110     //int         ControlUpLinkPipeID;\r
111     adf_os_handle_t   OSHandle;\r
112     hif_handle_t      HIFHandle;\r
113     pool_handle_t     PoolHandle;\r
114 } HTC_CONFIG;\r
115 \r
116 typedef struct _HTC_BUF_CONTEXT {\r
117     A_UINT8         end_point;\r
118     A_UINT8         htc_flags;      /* htc flags (used by HTC layer only) */     \r
119 } HTC_BUF_CONTEXT;\r
120 \r
121 typedef void* htc_handle_t;\r
122 \r
123 /*\r
124  * setup complete function, supplied by HTC caller at HTC_init time.\r
125  * HTC calls this function after the host has indicated that the service connection\r
126  * phase is complete.\r
127  * \r
128  */\r
129 typedef void (* HTC_SETUP_COMPLETE_CB)(void);\r
130 \r
131 struct htc_apis {\r
132     htc_handle_t (* _HTC_Init)(HTC_SETUP_COMPLETE_CB, HTC_CONFIG *pConfig);    \r
133     void (* _HTC_Shutdown)(htc_handle_t);\r
134     void (* _HTC_RegisterService)(htc_handle_t, HTC_SERVICE *);\r
135     void (* _HTC_Ready)(htc_handle_t);\r
136     void (* _HTC_ReturnBuffers)(htc_handle_t handle, HTC_ENDPOINT_ID EndpointID, adf_nbuf_t);\r
137     void (* _HTC_ReturnBuffersList)(htc_handle_t handle, HTC_ENDPOINT_ID EndpointID, adf_nbuf_queue_t);\r
138     void (* _HTC_SendMsg)(htc_handle_t handle, HTC_ENDPOINT_ID EndpointID, adf_nbuf_t);        \r
139     int  (* _HTC_GetReservedHeadroom)(htc_handle_t handle);\r
140     \r
141     //void (* _HTC_PauseRecv)(HTC_ENDPOINT_ID EndpointID);\r
142     //void (* _HTC_ResumeRecv)(HTC_ENDPOINT_ID EndpointID);\r
143     //void (* _HTC_AddBufferResources)(int buffers);\r
144     \r
145     /* These APIs below are for patch purpose only */\r
146     void (*_HTC_MsgRecvHandler)(adf_nbuf_t hdr_buf, adf_nbuf_t buf, void *context);\r
147     void (*_HTC_SendDoneHandler)(adf_nbuf_t buf, void *context);\r
148     void (*_HTC_ControlSvcProcessMsg)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t hdr_buf, adf_nbuf_t buf, void *arg);\r
149     void (*_HTC_ControlSvcProcessSendComplete)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t pBuffers, void *arg);\r
150     \r
151     void *pReserved;  /* for expansion if need be */\r
152 };\r
153 \r
154 extern void htc_module_install(struct htc_apis *pAPIs);\r
155 \r
156 #endif /* _HTC_API_H__ */\r