Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / build / magpie_1_1 / inc / Magpie_api.h
1 /*
2  * @File: Magpie_api.h
3  * 
4  * @Abstract: Magpie FW api
5  * 
6  * @Notes:
7  * 
8  * Copyright (c) 2008 Atheros Communications Inc.
9  * All rights reserved.
10  *
11  */
12
13 #ifndef _MAGPIE_API_H
14 #define _MAGPIE_API_H
15
16 #define MAGPIE_FW_BUILD
17
18 #include "cmnos_api.h"
19 #ifdef MAGPIE_FW_BUILD
20 #include "vbuf_api.h"
21 #include "vdesc_api.h"
22 #include "usbfifo_api.h"
23 //#include "allocram_api.h"
24 #endif
25
26 #include "hif_api.h"
27 #include "htc_api.h"
28 #include "wmi_svc_api.h"
29 #include "buf_pool_api.h"
30 #include "dma_engine_api.h"
31 #include "dma_lib.h"
32
33 #if (SYSTEM_MODULE_SFLASH != 0)
34 #include "sflash_api.h"
35 #endif
36
37 #define A_INDIR(sym)   _A_MAGPIE_INDIRECTION_TABLE->sym
38
39 #if SYSTEM_MODULE_DBG
40 /* debug Support */
41 #define DBG_MODULE_INSTALL()            cmnos_dbg_module_install(&_A_MAGPIE_INDIRECTION_TABLE->dbg)
42 #define A_DBG_INIT()                    A_INDIR(dbg._dbg_init())
43 #define A_DBG_TASK()                    A_INDIR(dbg._dbg_task())
44 #else
45 #define A_DBG_INIT()
46 #define A_DBG_TASK()
47 #endif
48
49 /* Serial Flash support */
50 #if (SYSTEM_MODULE_SFLASH != 0)
51 #define SFLASH_MODULE_INSTALL()                 cmnos_sflash_module_install(&_A_MAGPIE_INDIRECTION_TABLE->sflash)
52 #define A_SFLASH_INIT()                         A_INDIR(sflash._sflash_init())
53 #define A_SFLASH_ERASE(erase_type, addr)        A_INDIR(sflash._sflash_erase(erase_type, addr))
54 #define A_SFLASH_PROG(addr, len, buf)           A_INDIR(sflash._sflash_program(addr, len, buf))
55 #define A_SFLASH_READ(fast, addr, len, buf)     A_INDIR(sflash._sflash_read(fast, addr, len, buf))
56 #define A_SFLASH_RDSR()                         A_INDIR(sflash._sflash_rdsr())
57 #else
58 #define A_SFLASH_INIT()
59 #define A_SFLASH_ERASE(erase_type, addr)
60 #define A_SFLASH_PROG(addr, len, buf)
61 #define A_SFLASH_READ(fast, addr, len, buf)
62 #define A_SFLASH_RDSR()
63 #endif
64
65 /* DMA Engine Interface */
66 #define DMA_ENGINE_MODULE_INSTALL()                 dma_engine_module_install(&_A_MAGPIE_INDIRECTION_TABLE->dma_engine);
67 #define DMA_Engine_init()                           A_INDIR(dma_engine._init())
68 #define DMA_Engine_config_rx_queue(q, nDesc, size)  A_INDIR(dma_engine._config_rx_queue(q, nDesc, size))
69 #define DMA_Engine_xmit_buf(q, buf)                 A_INDIR(dma_engine._xmit_buf(q, buf))
70 #define DMA_Engine_flush_xmit(q)                    A_INDIR(dma_engine._flush_xmit(q))
71 #define DMA_Engine_reap_recv_buf(q)                 A_INDIR(dma_engine._reap_recv_buf(q))
72 #define DMA_Engine_return_recv_buf(q,buf)           A_INDIR(dma_engine._return_recv_buf(q, buf))
73 #define DMA_Engine_reap_xmited_buf(q)               A_INDIR(dma_engine._reap_xmited_buf(q))
74 #define DMA_Engine_swap_data(desc)                  A_INDIR(dma_engine._swap_data(desc))
75 #define DMA_Engine_init_rx_queue(q)                 A_INDIR(dma_engine._init_rx_queue(q))
76 #define DMA_Engine_init_tx_queue(q)                 A_INDIR(dma_engine._init_tx_queue(q))
77 #define DMA_Engine_has_compl_packets(q)             A_INDIR(dma_engine._has_compl_packets(q))
78 #define DMA_Engine_desc_dump(q)                     A_INDIR(dma_engine._desc_dump(q))
79 #define DMA_Engine_get_packet(q)                    A_INDIR(dma_engine._get_packet(q))
80 #define DMA_Engine_reclaim_packet(q,desc)           A_INDIR(dma_engine._reclaim_packet(q,desc))
81 #define DMA_Engine_put_packet(q,desc)               A_INDIR(dma_engine._put_packet(q,desc))
82
83 /*DMA Library support for GMAC & PCI(E)*/
84 #define DMA_LIB_MODULE_INSTALL()                    dma_lib_module_install(&_A_MAGPIE_INDIRECTION_TABLE->dma_lib)
85 #define dma_lib_tx_init(eng_no, if_type)            A_INDIR(dma_lib.tx_init(eng_no, if_type))
86 #define dma_lib_rx_init(eng_no, if_type)            A_INDIR(dma_lib.rx_init(eng_no, if_type))
87 #define dma_lib_rx_config(eng_no, desc, gran)       A_INDIR(dma_lib.rx_config(eng_no, desc, gran))
88 #define dma_lib_tx_start(eng_no)                    A_INDIR(dma_lib.tx_start(eng_no)) 
89 #define dma_lib_rx_start(eng_no)                    A_INDIR(dma_lib.rx_start(eng_no)) 
90 #define dma_lib_intr_status(if_type)                A_INDIR(dma_lib.intr_status(if_type))
91 #define dma_lib_hard_xmit(eng_no, buf)              A_INDIR(dma_lib.hard_xmit(eng_no, buf))
92 #define dma_lib_flush_xmit(eng_no)                  A_INDIR(dma_lib.flush_xmit(eng_no))
93 #define dma_lib_xmit_done(eng_no)                   A_INDIR(dma_lib.xmit_done(eng_no))
94 #define dma_lib_reap_xmitted(eng_no)                A_INDIR(dma_lib.reap_xmitted(eng_no))
95 #define dma_lib_reap_recv(eng_no)                   A_INDIR(dma_lib.reap_recv(eng_no))
96 #define dma_lib_return_recv(eng_no, buf)            A_INDIR(dma_lib.return_recv(eng_no, buf))
97 #define dma_lib_recv_pkt(eng_no)                    A_INDIR(dma_lib.recv_pkt(eng_no))
98
99 /* HIF PCI Api's */
100 #define hif_pci_boot_init()                 A_INDIR(hif_pci.pci_boot_init())
101 #define hif_pci_init(pConfig)               A_INDIR(hif_pci.pci_init(pConfig))
102 #define hif_pci_reset()                     A_INDIR(hif_pci.pci_reset())
103 #define hif_pci_enable()                    A_INDIR(hif_pci.pci_enable())
104 #define hif_pci_get_pipe(eng)               A_INDIR(hif_pci.pci_get_pipe(eng))
105 #define hif_pci_get_tx_eng(pipe)            A_INDIR(hif_pci.pci_get_tx_eng(pipe))
106 #define hif_pci_get_rx_eng(pipe)            A_INDIR(hif_pci.pci_get_rx_eng(pipe))
107 #define hif_pci_reap_recv(sc, eng_no)       A_INDIR(hif_pci.pci_reap_recv(sc, eng_no))
108 #define hif_pci_reap_xmitted(sc, eng_no)    A_INDIR(hif_pci.pci_reap_xmitted(sc, eng_no))
109
110 /* HIF support */
111 #define HIF_MODULE_INSTALL()                        generic_hif_module_install(&_A_MAGPIE_INDIRECTION_TABLE->hif)
112 #define HIF_init(pConfig)                           A_INDIR(hif._init(pConfig))
113 #define HIF_shutdown(h)                             A_INDIR(hif._shutdown(h))
114 #define HIF_register_callback(h, pConfig)           A_INDIR(hif._register_callback(h, pConfig))
115 #define HIF_start(h)                                A_INDIR(hif._start(h))  
116 #define HIF_config_pipe(h, pipe, desc_list)         A_INDIR(hif._config_pipe(h, pipe, desc_list)) 
117 #define HIF_send_buffer(h, pipe, buf)               A_INDIR(hif._send_buffer(h, pipe, buf)) 
118 #define HIF_return_recv_buf(h, pipe, buf)           A_INDIR(hif._return_recv_buf(h, pipe, buf)) 
119 #define HIF_isr_handler(h)                          A_INDIR(hif._isr_handler(h)) 
120 #define HIF_is_pipe_supported(h, pipe)              A_INDIR(hif._is_pipe_supported(h, pipe))
121 #define HIF_get_max_msg_len(h, pipe)                A_INDIR(hif._get_max_msg_len(h, pipe))
122 #define HIF_get_reserved_headroom(h)                A_INDIR(hif._get_reserved_headroom(h))
123 #define HIF_get_default_pipe(h,u,d)                 A_INDIR(hif._get_default_pipe(h,u,d))
124 typedef void (*HIF_INSTALL_FUNC_T)(struct hif_api *apis);
125
126 /* VBUF APIs */
127 #ifdef MAGPIE_FW_BUILD
128 #define VBUF_MODULE_INSTALL()                       vbuf_module_install(&_A_MAGPIE_INDIRECTION_TABLE->vbuf)
129 #define VBUF_init(nBuf)                             A_INDIR(vbuf._init(nBuf))
130 #define VBUF_alloc_vbuf()                           A_INDIR(vbuf._alloc_vbuf())
131 #define VBUF_free_vbuf(buf)                         A_INDIR(vbuf._free_vbuf(buf))
132 #endif
133
134 /* VDESC APIs */
135 #ifdef MAGPIE_FW_BUILD
136 #define VDESC_MODULE_INSTALL()                      vdesc_module_install(&_A_MAGPIE_INDIRECTION_TABLE->vdesc)
137 #define VDESC_init(nDesc)                           A_INDIR(vdesc._init(nDesc))
138 #define VDESC_alloc_vdesc()                         A_INDIR(vdesc._alloc_vdesc())
139 #define VDESC_get_hw_desc(desc)                     A_INDIR(vdesc._get_hw_desc(desc))
140 #define VDESC_swap_vdesc(dst, src)                  A_INDIR(vdesc._swap_vdesc(dst, src))
141 #endif
142
143 #define HTC_MODULE_INSTALL()                        htc_module_install(&_A_MAGPIE_INDIRECTION_TABLE->htc)
144 #define HTC_init(SetupComplete, pConfig)            A_INDIR(htc._HTC_Init(SetupComplete, pConfig))
145 #define HTC_Shutdown(h)                             A_INDIR(htc._HTC_Shutdown(h))
146 #define HTC_RegisterService(h, s)                   A_INDIR(htc._HTC_RegisterService(h, s))
147 #define HTC_Ready(h)                                A_INDIR(htc._HTC_Ready(h))
148 #define HTC_SendMsg(h, endpt, buf)                  A_INDIR(htc._HTC_SendMsg(h, endpt, buf))
149 #define HTC_ReturnBuffers(h, endpt, buf)            A_INDIR(htc._HTC_ReturnBuffers(h, endpt, buf))
150 #define HTC_ReturnBuffersList(h, endpt, hd)         A_INDIR(htc._HTC_ReturnBuffersList(h, endpt, hd))
151 #define HTC_GetReservedHeadroom(h)                  A_INDIR(htc._HTC_GetReservedHeadroom(h))
152
153 #define HTC_NotifyTargetInserted(h)
154 #define HTC_NotifyTargetDetached(h)                   
155
156 /* WMI SVC module */
157 #define WMI_SERVICE_MODULE_INSTALL()                WMI_service_module_install(&_A_MAGPIE_INDIRECTION_TABLE->wmi_svc_api)
158 #define WMI_Init(pCfg)                              A_INDIR(wmi_svc_api._WMI_Init(pCfg))
159 #define WMI_RegisterDispatchTable(h,pT)             A_INDIR(wmi_svc_api._WMI_RegisterDispatchTable(h, pT))
160 #define WMI_AllocEvent(h,ec,len)                    A_INDIR(wmi_svc_api._WMI_AllocEvent(h, ec, len))
161 #define WMI_SendEvent(h,ev,id,seq,len)              A_INDIR(wmi_svc_api._WMI_SendEvent(h, ev, id, seq, len))
162 #define WMI_GetPendingEventsCount()                 A_INDIR(wmi_svc_api._WMI_GetPendingEventsCount())
163 #define WMI_GetControlEp()                          A_INDIR(wmi_svc_api._WMI_GetControlEp())
164 #define WMI_SendCompleteHandler(ep, buf)            A_INDIR(wmi_svc_api._WMI_SendCompleteHandler(ep, buf))
165 #define WMI_Shutdown(h)                             A_INDIR(wmi_svc_api._WMI_Shutdown(h))
166
167 /* USB FIFO module */
168 #define USBFIFO_MODULE_INSTALL()                    usbfifo_module_install(&_A_MAGPIE_INDIRECTION_TABLE->usbfifo_api)
169 #define USBFIFO_init(pConfig)                       A_INDIR(usbfifo_api._init(pConfig))
170 #define USBFIFO_enable_event_isr()                  A_INDIR(usbfifo_api._enable_event_isr())
171
172 /* BUF pool module */
173 #define BUF_POOL_MODULE_INSTALL()                       buf_pool_module_install(&_A_MAGPIE_INDIRECTION_TABLE->buf_pool)
174 #define BUF_Pool_init(h)                                A_INDIR(buf_pool._init(h))
175 #define BUF_Pool_shutdown(h)                            A_INDIR(buf_pool._shutdown(h))
176 #define BUF_Pool_create_pool(h, id, nItems, nSize)      A_INDIR(buf_pool._create_pool(h, id, nItems, nSize))
177 #define BUF_Pool_alloc_buf(h, id, reserve)              A_INDIR(buf_pool._alloc_buf(h, id, reserve))
178 #define BUF_Pool_alloc_buf_align(h, id, reserve,align)  A_INDIR(buf_pool._alloc_buf_align(h, id, reserve,align))
179 #define BUF_Pool_free_buf(h, id, buf)                   A_INDIR(buf_pool._free_buf(h, id, buf))
180
181 /*
182  * This defines the layout of the indirection table, which
183  * is used to access exported APIs of various modules.  The
184  * layout is shared across ROM and RAM code.  RAM code may
185  * call into ROM and ROM code may call into RAM.  Because
186  * of the latter, existing offsets must not change for the
187  * lifetime of a revision of ROM; but new members may be
188  * added at the end.
189  */
190 typedef struct _A_magpie_indirection_table {
191     _A_cmnos_indirection_table_t        cmnos;
192
193 //#if SYSTEM_MODULE_DBG
194     struct dbg_api                      dbg;        // move to firmware not in cmnos
195 //#endif
196     struct hif_api                      hif;
197     struct htc_apis                     htc;
198     WMI_SVC_APIS                        wmi_svc_api;     
199     struct usbfifo_api                  usbfifo_api;
200     struct buf_pool_api                 buf_pool;
201 #ifdef MAGPIE_FW_BUILD    
202     struct vbuf_api                     vbuf;
203     struct vdesc_api                    vdesc;
204     struct allocram_api                 allocram;
205 #endif        
206     struct dma_engine_api               dma_engine;
207     struct dma_lib_api                  dma_lib;
208
209 #if SYSTEM_MODULE_PCI
210     struct hif_pci_api                  hif_pci;
211 #endif
212     // structure to be added after this....
213 #if (SYSTEM_MODULE_SFLASH != 0)
214     struct sflash_api           sflash;
215 #endif
216 } _A_magpie_indirection_table_t;
217
218 extern _A_magpie_indirection_table_t _indir_tbl;
219 #define _A_MAGPIE_INDIRECTION_TABLE_SIZE sizeof(_A_magpie_indirection_table_t)
220 #if defined(__mips__)
221 #define _A_MAGPIE_INDIRECTION_TABLE ((_A_magpie_indirection_table_t *)0x700)
222 #else
223 #define _A_MAGPIE_INDIRECTION_TABLE (&_indir_tbl)
224 #endif
225
226 #endif