2 * Copyright (c) 2007 Atheros Communications Inc.
5 * This file contains the API for the Wireless Module Interface (WMI) Service
10 #define WMI_SVC_API_H_
16 #include <buf_pool_api.h>
18 #define WMI_SVC_MAX_BUFFERED_EVENT_SIZE 100
19 #define WMI_SVC_MSG_SIZE 1536 /* maximum size of any WMI control or event message */
22 typedef enum WMI_EVT_CLASS {
23 WMI_EVT_CLASS_NONE = -1,
24 WMI_EVT_CLASS_CMD_EVENT = 0,
25 WMI_EVT_CLASS_CMD_REPLY = 1,
29 /* command handler callback when a message is dispatched */
30 typedef void (* WMI_CMD_HANDLER)(void *pContext, /* application supplied context from dispatch table */
31 A_UINT16 Command, /* command ID that was dispatched */
33 A_UINT8 *pCmdBuffer, /* command data, 256 bytes max, 32-bit aligned */
34 int Length); /* length of command (excludes WMI header) */
36 /* configuration settings for the WMI service */
37 typedef struct _WMI_SVC_CONFIG {
38 htc_handle_t HtcHandle;
39 pool_handle_t PoolHandle;
40 int MaxCmdReplyEvts; /* total buffers for command replies */
41 int MaxEventEvts; /* total buffers for low priority events */
44 /* command dispatch entry */
45 typedef struct _WMI_DISPATCH_ENTRY {
46 WMI_CMD_HANDLER pCmdHandler; /* dispatch function */
47 A_UINT16 CmdID; /* WMI command to dispatch from */
48 A_UINT16 CheckLength; /* expected length of command, set to 0 to bypass check */
51 /* dispatch table that is used to register a set of dispatch entries */
52 typedef struct _WMI_DISPATCH_TABLE {
53 struct _WMI_DISPATCH_TABLE *pNext; /* next dispatch, WMI-reserved */
54 void *pContext; /* optional context that is passed to command handlers
55 assigned to this dispatch table */
56 int NumberOfEntries; /* number of elements pointed to by pTable */
57 WMI_DISPATCH_ENTRY *pTable; /* start of table */
60 #define WMI_DISPATCH_ENTRY_COUNT(table) \
61 (sizeof((table)) / sizeof(WMI_DISPATCH_ENTRY))
63 /* handy macro to declare a dispatch table */
64 #define WMI_DECLARE_DISPATCH_TABLE(name,dispatchEntries) \
65 WMI_DISPATCH_TABLE name = \
66 { NULL, NULL, WMI_DISPATCH_ENTRY_COUNT(dispatchEntries), dispatchEntries }
68 /* macro to programatically set the dispatch table context */
69 #define WMI_SET_DISPATCH_CONTEXT(pDispTable, pCtxt) (pDispTable)->pContext = (pCtxt)
71 typedef struct _WMI_BUF_CONTEXT {
72 HTC_BUF_CONTEXT HtcBufCtx;
74 WMI_EVT_CLASS EventClass; /* the event class this packet belongs to */
75 A_UINT16 Flags; /* internal flags reserved for WMI */
78 /* ROM-version, eventually. For now, in RAM */
80 typedef void* wmi_handle_t;
83 typedef struct _wmi_svc_apis {
84 wmi_handle_t (* _WMI_Init)(WMI_SVC_CONFIG *pWmiConfig);
85 void (* _WMI_RegisterDispatchTable)(wmi_handle_t h, WMI_DISPATCH_TABLE *pDispatchTable);
86 adf_nbuf_t (* _WMI_AllocEvent)(wmi_handle_t h, WMI_EVT_CLASS EventClass, int Length);
87 void (* _WMI_SendEvent)(wmi_handle_t h, adf_nbuf_t pEvt, A_UINT16 EventId, A_UINT16 SeqNo, int Length);
88 int (* _WMI_GetPendingEventsCount)(wmi_handle_t handle);
89 void (* _WMI_SendCompleteHandler)(HTC_ENDPOINT_ID Endpt, adf_nbuf_t pHTCBuf, void *arg);
90 int (* _WMI_GetControlEp)(wmi_handle_t h);
91 void (* _WMI_Shutdown)(wmi_handle_t h);
94 void (*_WMI_RecvMessageHandler)(HTC_ENDPOINT_ID EndPt, adf_nbuf_t hdr_buf, adf_nbuf_t pHTCBuf, void *arg);
95 A_UINT8 (*_WMI_ServiceConnect)(HTC_SERVICE *pService, HTC_ENDPOINT_ID eid,
101 void *pReserved; /* for expansion if need be */
104 extern void WMI_service_module_install(WMI_SVC_APIS *pAPIs);
106 #endif /*WMI_SVC_API_H_*/