4 * @Abstract: Magpie FW api
8 * Copyright (c) 2008 Atheros Communications Inc.
16 #define MAGPIE_FW_BUILD
18 #include "cmnos_api.h"
19 #ifdef MAGPIE_FW_BUILD
21 #include "vdesc_api.h"
22 #include "usbfifo_api.h"
23 //#include "allocram_api.h"
28 #include "wmi_svc_api.h"
29 #include "buf_pool_api.h"
30 #include "dma_engine_api.h"
32 #if SYSTEM_MODULE_SFLASH
33 #include "sflash_api.h"
36 #define A_INDIR(sym) _A_MAGPIE_INDIRECTION_TABLE->sym
40 #define DBG_MODULE_INSTALL() cmnos_dbg_module_install(&_A_MAGPIE_INDIRECTION_TABLE->dbg)
41 #define A_DBG_INIT() A_INDIR(dbg._dbg_init())
42 #define A_DBG_TASK() A_INDIR(dbg._dbg_task())
48 /* Serial Flash support */
49 #define SFLASH_MODULE_INSTALL() cmnos_sflash_module_install(&_A_MAGPIE_INDIRECTION_TABLE->sflash)
50 #define A_SFLASH_INIT() A_INDIR(sflash._sflash_init())
51 #define A_SFLASH_ERASE(erase_type, addr) A_INDIR(sflash._sflash_erase(erase_type, addr))
52 #define A_SFLASH_PROG(addr, len, buf) A_INDIR(sflash._sflash_program(addr, len, buf))
53 #define A_SFLASH_READ(fast, addr, len, buf) A_INDIR(sflash._sflash_read(fast, addr, len, buf))
54 #define A_SFLASH_RDSR() A_INDIR(sflash._sflash_rdsr())
57 /* DMA Engine Interface */
58 #define DMA_ENGINE_MODULE_INSTALL() dma_engine_module_install(&_A_MAGPIE_INDIRECTION_TABLE->dma_engine);
59 #define DMA_Engine_init() A_INDIR(dma_engine._init())
60 #define DMA_Engine_config_rx_queue(q, nDesc, size) A_INDIR(dma_engine._config_rx_queue(q, nDesc, size))
61 #define DMA_Engine_xmit_buf(q, buf) A_INDIR(dma_engine._xmit_buf(q, buf))
62 #define DMA_Engine_flush_xmit(q) A_INDIR(dma_engine._flush_xmit(q))
63 #define DMA_Engine_reap_recv_buf(q) A_INDIR(dma_engine._reap_recv_buf(q))
64 #define DMA_Engine_return_recv_buf(q,buf) A_INDIR(dma_engine._return_recv_buf(q, buf))
65 #define DMA_Engine_reap_xmited_buf(q) A_INDIR(dma_engine._reap_xmited_buf(q))
66 #define DMA_Engine_swap_data(desc) A_INDIR(dma_engine._swap_data(desc))
67 #define DMA_Engine_init_rx_queue(q) A_INDIR(dma_engine._init_rx_queue(q))
68 #define DMA_Engine_init_tx_queue(q) A_INDIR(dma_engine._init_tx_queue(q))
69 #define DMA_Engine_has_compl_packets(q) A_INDIR(dma_engine._has_compl_packets(q))
70 #define DMA_Engine_desc_dump(q) A_INDIR(dma_engine._desc_dump(q))
71 #define DMA_Engine_get_packet(q) A_INDIR(dma_engine._get_packet(q))
72 #define DMA_Engine_reclaim_packet(q,desc) A_INDIR(dma_engine._reclaim_packet(q,desc))
73 #define DMA_Engine_put_packet(q,desc) A_INDIR(dma_engine._put_packet(q,desc))
75 /*DMA Library support for GMAC & PCI(E)*/
76 #define DMA_LIB_MODULE_INSTALL() dma_lib_module_install(&_A_MAGPIE_INDIRECTION_TABLE->dma_lib)
77 #define dma_lib_tx_init(eng_no, if_type) A_INDIR(dma_lib.tx_init(eng_no, if_type))
78 #define dma_lib_rx_init(eng_no, if_type) A_INDIR(dma_lib.rx_init(eng_no, if_type))
79 #define dma_lib_rx_config(eng_no, desc, gran) A_INDIR(dma_lib.rx_config(eng_no, desc, gran))
80 #define dma_lib_tx_start(eng_no) A_INDIR(dma_lib.tx_start(eng_no))
81 #define dma_lib_rx_start(eng_no) A_INDIR(dma_lib.rx_start(eng_no))
82 #define dma_lib_intr_status(if_type) A_INDIR(dma_lib.intr_status(if_type))
83 #define dma_lib_hard_xmit(eng_no, buf) A_INDIR(dma_lib.hard_xmit(eng_no, buf))
84 #define dma_lib_flush_xmit(eng_no) A_INDIR(dma_lib.flush_xmit(eng_no))
85 #define dma_lib_xmit_done(eng_no) A_INDIR(dma_lib.xmit_done(eng_no))
86 #define dma_lib_reap_xmitted(eng_no) A_INDIR(dma_lib.reap_xmitted(eng_no))
87 #define dma_lib_reap_recv(eng_no) A_INDIR(dma_lib.reap_recv(eng_no))
88 #define dma_lib_return_recv(eng_no, buf) A_INDIR(dma_lib.return_recv(eng_no, buf))
89 #define dma_lib_recv_pkt(eng_no) A_INDIR(dma_lib.recv_pkt(eng_no))
92 #define HIF_MODULE_INSTALL() generic_hif_module_install(&_A_MAGPIE_INDIRECTION_TABLE->hif)
93 #define HIF_init(pConfig) A_INDIR(hif._init(pConfig))
94 #define HIF_shutdown(h) A_INDIR(hif._shutdown(h))
95 #define HIF_register_callback(h, pConfig) A_INDIR(hif._register_callback(h, pConfig))
96 #define HIF_start(h) A_INDIR(hif._start(h))
97 #define HIF_config_pipe(h, pipe, desc_list) A_INDIR(hif._config_pipe(h, pipe, desc_list))
98 #define HIF_send_buffer(h, pipe, buf) A_INDIR(hif._send_buffer(h, pipe, buf))
99 #define HIF_return_recv_buf(h, pipe, buf) A_INDIR(hif._return_recv_buf(h, pipe, buf))
100 #define HIF_isr_handler(h) A_INDIR(hif._isr_handler(h))
101 #define HIF_is_pipe_supported(h, pipe) A_INDIR(hif._is_pipe_supported(h, pipe))
102 #define HIF_get_max_msg_len(h, pipe) A_INDIR(hif._get_max_msg_len(h, pipe))
103 #define HIF_get_reserved_headroom(h) A_INDIR(hif._get_reserved_headroom(h))
104 #define HIF_get_default_pipe(h,u,d) A_INDIR(hif._get_default_pipe(h,u,d))
107 #ifdef MAGPIE_FW_BUILD
108 #define VBUF_MODULE_INSTALL() vbuf_module_install(&_A_MAGPIE_INDIRECTION_TABLE->vbuf)
109 #define VBUF_init(nBuf) A_INDIR(vbuf._init(nBuf))
110 #define VBUF_alloc_vbuf() A_INDIR(vbuf._alloc_vbuf())
111 #define VBUF_free_vbuf(buf) A_INDIR(vbuf._free_vbuf(buf))
115 #ifdef MAGPIE_FW_BUILD
116 #define VDESC_MODULE_INSTALL() vdesc_module_install(&_A_MAGPIE_INDIRECTION_TABLE->vdesc)
117 #define VDESC_init(nDesc) A_INDIR(vdesc._init(nDesc))
118 #define VDESC_alloc_vdesc() A_INDIR(vdesc._alloc_vdesc())
119 #define VDESC_get_hw_desc(desc) A_INDIR(vdesc._get_hw_desc(desc))
120 #define VDESC_swap_vdesc(dst, src) A_INDIR(vdesc._swap_vdesc(dst, src))
123 #define HTC_MODULE_INSTALL() htc_module_install(&_A_MAGPIE_INDIRECTION_TABLE->htc)
124 #define HTC_init(SetupComplete, pConfig) A_INDIR(htc._HTC_Init(SetupComplete, pConfig))
125 #define HTC_Shutdown(h) A_INDIR(htc._HTC_Shutdown(h))
126 #define HTC_RegisterService(h, s) A_INDIR(htc._HTC_RegisterService(h, s))
127 #define HTC_Ready(h) A_INDIR(htc._HTC_Ready(h))
128 #define HTC_SendMsg(h, endpt, buf) A_INDIR(htc._HTC_SendMsg(h, endpt, buf))
129 #define HTC_ReturnBuffers(h, endpt, buf) A_INDIR(htc._HTC_ReturnBuffers(h, endpt, buf))
130 #define HTC_ReturnBuffersList(h, endpt, hd) A_INDIR(htc._HTC_ReturnBuffersList(h, endpt, hd))
131 #define HTC_GetReservedHeadroom(h) A_INDIR(htc._HTC_GetReservedHeadroom(h))
133 #define HTC_NotifyTargetInserted(h)
134 #define HTC_NotifyTargetDetached(h)
137 #define WMI_SERVICE_MODULE_INSTALL() WMI_service_module_install(&_A_MAGPIE_INDIRECTION_TABLE->wmi_svc_api)
138 #define WMI_Init(pCfg) A_INDIR(wmi_svc_api._WMI_Init(pCfg))
139 #define WMI_RegisterDispatchTable(h,pT) A_INDIR(wmi_svc_api._WMI_RegisterDispatchTable(h, pT))
140 #define WMI_AllocEvent(h,ec,len) A_INDIR(wmi_svc_api._WMI_AllocEvent(h, ec, len))
141 #define WMI_SendEvent(h,ev,id,seq,len) A_INDIR(wmi_svc_api._WMI_SendEvent(h, ev, id, seq, len))
142 #define WMI_GetPendingEventsCount() A_INDIR(wmi_svc_api._WMI_GetPendingEventsCount())
143 #define WMI_GetControlEp() A_INDIR(wmi_svc_api._WMI_GetControlEp())
144 #define WMI_SendCompleteHandler(ep, buf) A_INDIR(wmi_svc_api._WMI_SendCompleteHandler(ep, buf))
145 #define WMI_Shutdown(h) A_INDIR(wmi_svc_api._WMI_Shutdown(h))
147 /* USB FIFO module */
148 #define USBFIFO_MODULE_INSTALL() usbfifo_module_install(&_A_MAGPIE_INDIRECTION_TABLE->usbfifo_api)
149 #define USBFIFO_init(pConfig) A_INDIR(usbfifo_api._init(pConfig))
150 #define USBFIFO_enable_event_isr() A_INDIR(usbfifo_api._enable_event_isr())
152 /* BUF pool module */
153 #define BUF_POOL_MODULE_INSTALL() buf_pool_module_install(&_A_MAGPIE_INDIRECTION_TABLE->buf_pool)
154 #define BUF_Pool_init(h) A_INDIR(buf_pool._init(h))
155 #define BUF_Pool_shutdown(h) A_INDIR(buf_pool._shutdown(h))
156 #define BUF_Pool_create_pool(h, id, nItems, nSize) A_INDIR(buf_pool._create_pool(h, id, nItems, nSize))
157 #define BUF_Pool_alloc_buf(h, id, reserve) A_INDIR(buf_pool._alloc_buf(h, id, reserve))
158 #define BUF_Pool_alloc_buf_align(h, id, reserve,align) A_INDIR(buf_pool._alloc_buf_align(h, id, reserve,align))
159 #define BUF_Pool_free_buf(h, id, buf) A_INDIR(buf_pool._free_buf(h, id, buf))
162 * This defines the layout of the indirection table, which
163 * is used to access exported APIs of various modules. The
164 * layout is shared across ROM and RAM code. RAM code may
165 * call into ROM and ROM code may call into RAM. Because
166 * of the latter, existing offsets must not change for the
167 * lifetime of a revision of ROM; but new members may be
170 typedef struct _A_magpie_indirection_table {
171 _A_cmnos_indirection_table_t cmnos;
173 //#if SYSTEM_MODULE_DBG
174 struct dbg_api dbg; // move to firmware not in cmnos
178 WMI_SVC_APIS wmi_svc_api;
179 struct usbfifo_api usbfifo_api;
180 struct buf_pool_api buf_pool;
181 #ifdef MAGPIE_FW_BUILD
182 struct vbuf_api vbuf;
183 struct vdesc_api vdesc;
184 struct allocram_api allocram;
186 struct dma_engine_api dma_engine;
187 struct dma_lib_api dma_lib;
189 // structure to be added after this....
190 struct sflash_api sflash;
191 } _A_magpie_indirection_table_t;
193 extern _A_magpie_indirection_table_t _indir_tbl;
194 #define _A_MAGPIE_INDIRECTION_TABLE_SIZE sizeof(_A_magpie_indirection_table_t)
195 #if defined(__mips__)
196 #define _A_MAGPIE_INDIRECTION_TABLE ((_A_magpie_indirection_table_t *)0x700)
198 #define _A_MAGPIE_INDIRECTION_TABLE (&_indir_tbl)