2 * Copyright (c) 2013 Qualcomm Atheros, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted (subject to the limitations in the
7 * disclaimer below) provided that the following conditions are met:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
17 * * Neither the name of Qualcomm Atheros nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
22 * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
23 * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 * @ingroup adf_os_public
37 * @file adf_os_types.h
38 * This file defines types used in the OS abstraction API.
41 #ifndef _ADF_OS_TYPES_H
42 #define _ADF_OS_TYPES_H
45 #include <adf_os_stdtypes.h>
46 #include <adf_os_types_pvt.h>
48 #define ADF_OS_MAX_SCATTER __ADF_OS_MAX_SCATTER
50 * @brief Max number of scatter-gather segments.
52 #define ADF_OS_MAX_SGLIST 4
55 * @brief denotes structure is packed.
57 #define adf_os_packed __adf_os_packed
60 * @brief handles opaque to each other
62 typedef void * adf_net_handle_t;
63 typedef void * adf_drv_handle_t;
64 typedef void * adf_os_handle_t;
67 * XXX FIXME For compilation only.
70 typedef void * adf_os_pm_t;
73 * @brief Platform/bus generic handle. Used for bus specific functions.
75 typedef __adf_os_device_t adf_os_device_t;
78 * @brief size of an object
80 typedef __adf_os_size_t adf_os_size_t;
83 * @brief offset for API's that need them.
85 typedef __adf_os_off_t adf_os_off_t;
88 * @brief DMA mapping object.
90 typedef __adf_os_dma_map_t adf_os_dma_map_t;
95 typedef __adf_os_dma_addr_t adf_os_dma_addr_t;
100 typedef __adf_os_dma_size_t adf_os_dma_size_t;
103 * @brief Information inside a DMA map.
105 typedef struct adf_os_dmamap_info{
106 a_uint32_t nsegs; /**< total number mapped segments*/
108 adf_os_dma_addr_t paddr; /**< physical(dma'able) address of the segment*/
109 adf_os_dma_size_t len; /**< length of the segment*/
110 } dma_segs[ADF_OS_MAX_SCATTER];
112 }adf_os_dmamap_info_t;
115 * @brief Representation of a scatter-gather list.
117 typedef struct adf_os_sglist{
118 a_uint32_t nsegs; /**< total number of segments*/
120 a_uint8_t *vaddr; /**< Virtual address of the segment*/
121 a_uint32_t len; /**< Length of the segment*/
122 } sg_segs[ADF_OS_MAX_SGLIST];
127 * @brief All operations specified below are performed from
128 * the host memory point of view, where a read
129 * implies data coming from the device to the host
130 * memory, and a write implies data going from the
131 * host memory to the device. Alternately, the
132 * operations can be thought of in terms of driver
133 * operations, where reading a network packet or
134 * storage sector corresponds to a read operation in
137 * ADF_SYNC_PREREAD Perform any synchronization
138 * required prior to an update
139 * of host memory by the DMA
141 * ADF_SYNC_PREWRITE Perform any synchronization
142 * required after an update of
143 * host memory by the CPU and
146 * ADF_SYNC_POSTREAD Perform any synchronization
147 * required after DMA read
148 * operations and prior to CPU
151 * ADF_SYNC_POSTWRITE Perform any synchronization
152 * required after DMA write
156 typedef enum adf_os_cache_sync{
157 ADF_SYNC_PREREAD=__ADF_SYNC_PREREAD,
158 ADF_SYNC_PREWRITE=__ADF_SYNC_PREWRITE,
159 ADF_SYNC_POSTREAD=__ADF_SYNC_POSTREAD,
160 ADF_SYNC_POSTWRITE=__ADF_SYNC_POSTWRITE
161 }adf_os_cache_sync_t;
164 * @brief Generic status to be used by adf_drv.
172 A_STATUS_EINPROGRESS,
176 A_STATUS_EADDRNOTAVAIL,
183 * @brief An ecore needs to provide a table of all pci device/vendor id's it
186 * This table should be terminated by a NULL entry , i.e. {0}
191 a_uint32_t subvendor;
192 a_uint32_t subdevice;
193 }adf_os_pci_dev_id_t;
195 #define ADF_OS_PCI_ANY_ID (~0)
198 * @brief Typically core's can use this macro to create a table of various device
201 #define ADF_OS_PCI_DEVICE(_vendor, _device) \
202 (_vendor), (_device), ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID
205 #define adf_os_iomem_t __adf_os_iomem_t;
207 * @brief These define the hw resources the OS has allocated for the device
208 * Note that start defines a mapped area.
211 ADF_OS_RESOURCE_TYPE_MEM,
212 ADF_OS_RESOURCE_TYPE_IO,
213 }adf_os_resource_type_t;
216 * @brief Representation of a h/w resource.
221 adf_os_resource_type_t type;
224 #define ADF_OS_DEV_ID_TABLE_MAX 256
227 * @brief Representation of bus registration data.
230 adf_os_pci_dev_id_t *pci;
232 }adf_os_bus_reg_data_t;
235 * @brief Representation of data required for attach.
238 adf_os_pci_dev_id_t pci;
240 }adf_os_attach_data_t;
242 #define ADF_OS_REGIONS_MAX 5
245 * @brief Types of buses.
248 ADF_OS_BUS_TYPE_PCI = 1,
249 ADF_OS_BUS_TYPE_GENERIC,
253 * @brief IRQ handler response codes.
261 * @brief DMA mask types.
264 ADF_OS_DMA_MASK_32BIT,
265 ADF_OS_DMA_MASK_64BIT,
270 * @brief DMA directions
271 * ADF_OS_DMA_TO_DEVICE (data going from device to memory)
272 * ADF_OS_DMA_FROM_DEVICE (data going from memory to device)
275 ADF_OS_DMA_TO_DEVICE = __ADF_OS_DMA_TO_DEVICE,
276 ADF_OS_DMA_FROM_DEVICE = __ADF_OS_DMA_FROM_DEVICE,
280 * Protoypes shared between public and private headers
285 * @brief work queue(kernel thread)/DPC function callback
287 typedef void (*adf_os_defer_fn_t)(void *);
290 * @brief Prototype of the critical region function that is to be
291 * executed with spinlock held and interrupt disalbed
293 typedef a_bool_t (*adf_os_irqlocked_func_t)(void *);
297 * @brief Prototype of timer function
299 typedef void (*adf_os_timer_func_t)(void *);
302 * @brief Prototype of IRQ function.
304 typedef adf_os_irq_resp_t (*adf_os_drv_intr)(adf_drv_handle_t hdl);
307 * @brief The OS print routine.
309 #define adf_os_print __adf_os_print
312 * @brief driver info structure needed while we do the register
313 * for the driver to the shim.
315 typedef struct _adf_drv_info{
317 * @brief driver specific functions
319 adf_drv_handle_t (*drv_attach) (adf_os_resource_t *res, int count,
320 adf_os_attach_data_t *data,
321 adf_os_device_t osdev);
322 void (*drv_detach) (adf_drv_handle_t hdl);
323 void (*drv_suspend) (adf_drv_handle_t hdl, adf_os_pm_t pm);
324 void (*drv_resume) (adf_drv_handle_t hdl);
326 * @brief driver specific data
328 adf_os_bus_type_t bus_type;
329 adf_os_bus_reg_data_t bus_data;
330 unsigned char *mod_name;
331 unsigned char *ifname;