Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / target / inc / adf_os_types.h
1 /**
2  * @ingroup adf_os_public
3  * @file adf_os_types.h
4  * This file defines types used in the OS abstraction API.
5  */
6
7 #ifndef _ADF_OS_TYPES_H
8 #define _ADF_OS_TYPES_H
9
10
11 #include <adf_os_stdtypes.h>
12 #include <adf_os_types_pvt.h>
13
14 #define ADF_OS_MAX_SCATTER  __ADF_OS_MAX_SCATTER
15 /**
16  * @brief Max number of scatter-gather segments.
17  */ 
18 #define ADF_OS_MAX_SGLIST   4
19
20 /**
21  * @brief denotes structure is packed.
22  */ 
23 #define adf_os_packed       __adf_os_packed
24
25 /**
26  * @brief handles opaque to each other
27  */
28 typedef void *      adf_net_handle_t;
29 typedef void *      adf_drv_handle_t;
30 typedef void *      adf_os_handle_t;
31
32 /*
33  * XXX FIXME For compilation only.
34  *
35  */
36 typedef void *      adf_os_pm_t;
37
38 /**
39  * @brief Platform/bus generic handle. Used for bus specific functions.
40  */
41 typedef __adf_os_device_t              adf_os_device_t;
42
43 /**
44  * @brief size of an object
45  */
46 typedef __adf_os_size_t                adf_os_size_t;
47
48 /**
49  * @brief offset for API's that need them.
50  */
51 typedef __adf_os_off_t      adf_os_off_t;
52
53 /**
54  * @brief DMA mapping object.
55  */ 
56 typedef __adf_os_dma_map_t  adf_os_dma_map_t;
57
58 /**
59  * @brief DMA address.
60  */ 
61 typedef __adf_os_dma_addr_t     adf_os_dma_addr_t;
62
63 /**
64  * @brief DMA size.
65  */ 
66 typedef __adf_os_dma_size_t     adf_os_dma_size_t;
67
68 /**
69  * @brief Information inside a DMA map.
70  */ 
71 typedef struct adf_os_dmamap_info{
72     a_uint32_t                  nsegs;      /**< total number mapped segments*/
73     struct __dma_segs{
74         adf_os_dma_addr_t       paddr;      /**< physical(dma'able) address of the segment*/
75         adf_os_dma_size_t       len;        /**< length of the segment*/
76     } dma_segs[ADF_OS_MAX_SCATTER]; 
77
78 }adf_os_dmamap_info_t;
79
80 /**
81  * @brief Representation of a scatter-gather list.
82  */ 
83 typedef struct adf_os_sglist{
84     a_uint32_t                  nsegs;      /**< total number of segments*/
85     struct __sg_segs{
86         a_uint8_t              *vaddr;      /**< Virtual address of the segment*/
87         a_uint32_t              len;        /**< Length of the segment*/
88     } sg_segs[ADF_OS_MAX_SGLIST];
89
90 }adf_os_sglist_t;
91
92 /**
93  *  @brief All operations specified below are performed from
94  *  the host memory point of view, where a read
95  *  implies data coming from the device to the host
96  *  memory, and a write implies data going from the
97  *  host memory to the device.  Alternately, the
98  *  operations can be thought of in terms of driver
99  *  operations, where reading a network packet or
100  *  storage sector corresponds to a read operation in
101  *  bus_dma.
102  * 
103  *  ADF_SYNC_PREREAD       Perform any synchronization
104  *                         required prior to an update
105  *                         of host memory by the DMA
106  *                         read operation.
107  *  ADF_SYNC_PREWRITE      Perform any synchronization
108  *                         required after an update of
109  *                         host memory by the CPU and
110  *                         prior to DMA write
111  *                         operations.
112  *  ADF_SYNC_POSTREAD      Perform any synchronization
113  *                         required after DMA read
114  *                         operations and prior to CPU
115  *                         access to host
116  *                         memory.
117  *  ADF_SYNC_POSTWRITE     Perform any synchronization
118  *                         required after DMA write
119  *                                   operations.
120  */
121
122 typedef enum adf_os_cache_sync{
123     ADF_SYNC_PREREAD=__ADF_SYNC_PREREAD,
124     ADF_SYNC_PREWRITE=__ADF_SYNC_PREWRITE,
125     ADF_SYNC_POSTREAD=__ADF_SYNC_POSTREAD,
126     ADF_SYNC_POSTWRITE=__ADF_SYNC_POSTWRITE
127 }adf_os_cache_sync_t;
128
129 /**
130  * @brief Generic status to be used by adf_drv.
131  */
132 typedef enum {
133     A_STATUS_OK,
134     A_STATUS_FAILED,
135     A_STATUS_ENOENT,
136     A_STATUS_ENOMEM,
137     A_STATUS_EINVAL,
138     A_STATUS_EINPROGRESS,
139     A_STATUS_ENOTSUPP,
140     A_STATUS_EBUSY,
141     A_STATUS_E2BIG,
142     A_STATUS_EADDRNOTAVAIL,
143     A_STATUS_ENXIO,
144     A_STATUS_EFAULT,
145     A_STATUS_EIO,
146 } a_status_t;
147
148 /**
149  * @brief An ecore needs to provide a table of all pci device/vendor id's it 
150  * supports
151  *
152  * This table should be terminated by a NULL entry , i.e. {0}
153  */
154 typedef struct {
155     a_uint32_t vendor;
156     a_uint32_t device;
157     a_uint32_t subvendor;
158     a_uint32_t subdevice;
159 }adf_os_pci_dev_id_t;
160
161 #define ADF_OS_PCI_ANY_ID  (~0)
162
163 /**
164  * @brief Typically core's can use this macro to create a table of various device
165  * ID's
166  */
167 #define ADF_OS_PCI_DEVICE(_vendor, _device)   \
168     (_vendor), (_device), ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID
169
170
171 #define adf_os_iomem_t   __adf_os_iomem_t;
172 /**
173  * @brief These define the hw resources the OS has allocated for the device
174  * Note that start defines a mapped area.
175  */
176 typedef enum {
177     ADF_OS_RESOURCE_TYPE_MEM,
178     ADF_OS_RESOURCE_TYPE_IO,
179 }adf_os_resource_type_t;
180
181 /**
182  * @brief Representation of a h/w resource.
183  */ 
184 typedef struct {
185     a_uint64_t             start;
186     a_uint64_t             end;
187     adf_os_resource_type_t type;
188 }adf_os_resource_t;
189
190 #define ADF_OS_DEV_ID_TABLE_MAX    256
191
192 /**
193  * @brief Representation of bus registration data.
194  */ 
195 typedef union {
196     adf_os_pci_dev_id_t  *pci;
197     void              *raw;
198 }adf_os_bus_reg_data_t;
199
200 /**
201  * @brief Representation of data required for attach.
202  */ 
203 typedef union {
204     adf_os_pci_dev_id_t pci;
205     void *raw;
206 }adf_os_attach_data_t;
207
208 #define ADF_OS_REGIONS_MAX     5
209
210 /**
211  * @brief Types of buses.
212  */ 
213 typedef enum {
214     ADF_OS_BUS_TYPE_PCI = 1,
215     ADF_OS_BUS_TYPE_GENERIC,
216 }adf_os_bus_type_t;
217
218 /**
219  * @brief IRQ handler response codes.
220  */ 
221 typedef enum {
222     ADF_OS_IRQ_NONE,
223     ADF_OS_IRQ_HANDLED,
224 }adf_os_irq_resp_t;
225
226 /**
227  * @brief DMA mask types.
228  */ 
229 typedef enum {
230     ADF_OS_DMA_MASK_32BIT,
231     ADF_OS_DMA_MASK_64BIT,
232 }adf_os_dma_mask_t;
233
234
235 /**
236  * @brief DMA directions
237  *        ADF_OS_DMA_TO_DEVICE (data going from device to memory)
238  *        ADF_OS_DMA_FROM_DEVICE (data going from memory to device)
239  */
240 typedef enum {
241     ADF_OS_DMA_TO_DEVICE = __ADF_OS_DMA_TO_DEVICE, 
242     ADF_OS_DMA_FROM_DEVICE = __ADF_OS_DMA_FROM_DEVICE, 
243 } adf_os_dma_dir_t;
244
245 /*
246  * Protoypes shared between public and private headers
247  */
248
249
250 /**
251  * @brief work queue(kernel thread)/DPC function callback
252  */
253 typedef void (*adf_os_defer_fn_t)(void *);
254
255 /**
256  * @brief Prototype of the critical region function that is to be
257  * executed with spinlock held and interrupt disalbed
258  */
259 typedef a_bool_t (*adf_os_irqlocked_func_t)(void *);
260
261
262 /**
263  * @brief Prototype of timer function
264  */
265 typedef void (*adf_os_timer_func_t)(void *);
266
267 /**
268  * @brief Prototype of IRQ function.
269  */ 
270 typedef adf_os_irq_resp_t (*adf_os_drv_intr)(adf_drv_handle_t hdl);                  
271
272 /**
273  * @brief The OS print routine.
274  */ 
275 #define adf_os_print         __adf_os_print
276
277 /**
278  * @brief driver info structure needed while we do the register
279  *        for the driver to the shim.
280  */
281 typedef struct _adf_drv_info{
282     /**
283      * @brief driver specific functions
284      */
285     adf_drv_handle_t (*drv_attach)  (adf_os_resource_t *res, int count, 
286                                      adf_os_attach_data_t *data, 
287                                      adf_os_device_t osdev);
288     void       (*drv_detach)  (adf_drv_handle_t hdl);
289     void       (*drv_suspend) (adf_drv_handle_t hdl, adf_os_pm_t pm);
290     void       (*drv_resume)  (adf_drv_handle_t hdl);
291     /**
292      * @brief driver specific data
293      */
294     adf_os_bus_type_t          bus_type;
295     adf_os_bus_reg_data_t      bus_data;
296     unsigned char              *mod_name;
297     unsigned char              *ifname;
298 }adf_drv_info_t;
299
300 #endif