8 #include "adf_os_mem.h"
14 void htc_setup_comp(void)
18 /* target WMI command related globals */
19 static void dispatch_magpie_sys_cmds(void *pContext, A_UINT16 Command,
20 A_UINT16 SeqNo, A_UINT8 *buffer, int Length);
22 static WMI_DISPATCH_ENTRY Magpie_Sys_DispatchEntries[] =
24 {dispatch_magpie_sys_cmds, WMI_ECHO_CMDID, 0},
25 {dispatch_magpie_sys_cmds, WMI_ACCESS_MEMORY_CMDID, 0}
28 static WMI_DECLARE_DISPATCH_TABLE(Magpie_Sys_Commands_Tbl, Magpie_Sys_DispatchEntries);
30 htc_handle_t htc_handle;
32 extern void HTC_Loopback_Init(htc_handle_t handle);
33 extern void _wmi_cmd_rsp(void *pContext, WMI_COMMAND_ID cmd_id,
34 A_UINT16 SeqNo, A_UINT8 *buffer, int Length);
36 static void handle_echo_command(void *pContext, A_UINT16 SeqNo,
37 A_UINT8 *buffer, int Length)
39 _wmi_cmd_rsp(pContext, WMI_ECHO_CMDID, SeqNo, buffer, Length);
42 static void dispatch_magpie_sys_cmds(void *pContext, A_UINT16 Command,
43 A_UINT16 SeqNo, A_UINT8 *buffer, int Length)
48 handle_echo_command(pContext, SeqNo, buffer, Length);
51 case WMI_ACCESS_MEMORY_CMDID:
56 void _wmi_cmd_rsp(void *pContext, WMI_COMMAND_ID cmd_id, A_UINT16 SeqNo,
57 A_UINT8 *buffer, int Length)
59 adf_nbuf_t netbuf = ADF_NBUF_NULL;
62 netbuf = WMI_AllocEvent(pContext, WMI_EVT_CLASS_CMD_REPLY, sizeof(WMI_CMD_HDR) + Length);
64 if (netbuf == ADF_NBUF_NULL) {
65 adf_os_print("%s: buffer allocation for event_id %x failed!\n", __FUNCTION__, cmd_id);
70 if (Length != 0 && buffer != NULL) {
71 pData = (A_UINT8 *)adf_nbuf_put_tail(netbuf, Length);
72 adf_os_mem_copy(pData, buffer, Length);
75 WMI_SendEvent(pContext, netbuf, cmd_id, SeqNo, Length);
79 void Magpie_init(void)
81 A_PRINTF("[+++Magpie_init]\n\r");
83 A_PRINTF("[+++VBUF_init(%d)]\n\r", MAX_BUF_NUM);
84 VBUF_init(MAX_BUF_NUM);
86 A_PRINTF("[+++VBUF_init(%d)]\n\r", MAX_DESC_NUM);
87 VDESC_init(MAX_DESC_NUM);
89 #if MAGPIE_ENABLE_WLAN == 0
90 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
91 hif_handle = HIF_init(0);
93 #if ZM_FM_LOOPBACK == 1
94 HIF_config_pipe(hif_handle, HIF_USB_PIPE_TX, 5);
95 HIF_config_pipe(hif_handle, HIF_USB_PIPE_COMMAND, 2);
97 #if SYSTEM_MODULE_HP_EP5
98 HIF_config_pipe(hif_handle, HIF_USB_PIPE_HP_TX, 3);
100 #if SYSTEM_MODULE_HP_EP6
101 HIF_config_pipe(hif_handle, HIF_USB_PIPE_MP_TX, 3);
104 A_PRINTF("[+++HIF_init(0)]\n\r");
106 HIF_start(hif_handle);
108 #else /* ZM_FM_LOOPBACK == 0 */
110 htcConf.CreditSize = 320;
111 htcConf.CreditNumber = 10;
113 htcConf.ControlDownLinkPipeID = HIF_USB_PIPE_INTERRUPT; // Target -> Host
114 htcConf.ControlUpLinkPipeID = HIF_USB_PIPE_COMMAND; // Host -> Target
116 htcConf.ControlDownLinkPipeID = HIF_USB_PIPE_RX;
117 htcConf.ControlUpLinkPipeID = HIF_USB_PIPE_TX;
119 htcConf.HIFHandle = hif_handle;
120 htcConf.OSHandle = 0; // not used
121 htcConf.PoolHandle = pool_handle;
123 htc_handle = HTC_init(htc_setup_comp, &htcConf);
124 // Initialize HTC services
125 HTC_Loopback_Init(htc_handle);
127 adf_os_mem_zero(&wmiConfig, sizeof(WMI_SVC_CONFIG));
128 wmiConfig.HtcHandle = htc_handle;
129 wmiConfig.PoolHandle = pool_handle;
130 wmiConfig.MaxCmdReplyEvts = 1;
131 wmiConfig.MaxEventEvts = 1;
133 wmi_handle = WMI_Init(&wmiConfig);
134 Magpie_Sys_Commands_Tbl.pContext = wmi_handle;
135 WMI_RegisterDispatchTable(Magpie_Sys_Commands_Tbl.pContext, &Magpie_Sys_Commands_Tbl);
137 #endif/* ZM_FM_LOOPBACK == 0 */
138 #endif /* MAGPIE_ENABLE_WLAN */
141 #endif /* #if MAGPIE==1 */
143 #endif /* #if defined(_RAM_) */