2 * @ingroup adf_os_public
4 * This file defines types used in the OS abstraction API.
7 #ifndef _ADF_OS_TYPES_H
8 #define _ADF_OS_TYPES_H
11 #include <adf_os_stdtypes.h>
12 #include <adf_os_types_pvt.h>
14 #define ADF_OS_MAX_SCATTER __ADF_OS_MAX_SCATTER
16 * @brief Max number of scatter-gather segments.
18 #define ADF_OS_MAX_SGLIST 4
21 * @brief denotes structure is packed.
23 #define adf_os_packed __adf_os_packed
26 * @brief handles opaque to each other
28 typedef void * adf_net_handle_t;
29 typedef void * adf_drv_handle_t;
30 typedef void * adf_os_handle_t;
33 * XXX FIXME For compilation only.
36 typedef void * adf_os_pm_t;
39 * @brief Platform/bus generic handle. Used for bus specific functions.
41 typedef __adf_os_device_t adf_os_device_t;
44 * @brief size of an object
46 typedef __adf_os_size_t adf_os_size_t;
49 * @brief offset for API's that need them.
51 typedef __adf_os_off_t adf_os_off_t;
54 * @brief DMA mapping object.
56 typedef __adf_os_dma_map_t adf_os_dma_map_t;
61 typedef __adf_os_dma_addr_t adf_os_dma_addr_t;
66 typedef __adf_os_dma_size_t adf_os_dma_size_t;
69 * @brief Information inside a DMA map.
71 typedef struct adf_os_dmamap_info{
72 a_uint32_t nsegs; /**< total number mapped segments*/
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];
78 }adf_os_dmamap_info_t;
81 * @brief Representation of a scatter-gather list.
83 typedef struct adf_os_sglist{
84 a_uint32_t nsegs; /**< total number of segments*/
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];
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
103 * ADF_SYNC_PREREAD Perform any synchronization
104 * required prior to an update
105 * of host memory by the DMA
107 * ADF_SYNC_PREWRITE Perform any synchronization
108 * required after an update of
109 * host memory by the CPU and
112 * ADF_SYNC_POSTREAD Perform any synchronization
113 * required after DMA read
114 * operations and prior to CPU
117 * ADF_SYNC_POSTWRITE Perform any synchronization
118 * required after DMA write
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;
130 * @brief Generic status to be used by adf_drv.
138 A_STATUS_EINPROGRESS,
142 A_STATUS_EADDRNOTAVAIL,
149 * @brief An ecore needs to provide a table of all pci device/vendor id's it
152 * This table should be terminated by a NULL entry , i.e. {0}
157 a_uint32_t subvendor;
158 a_uint32_t subdevice;
159 }adf_os_pci_dev_id_t;
161 #define ADF_OS_PCI_ANY_ID (~0)
164 * @brief Typically core's can use this macro to create a table of various device
167 #define ADF_OS_PCI_DEVICE(_vendor, _device) \
168 (_vendor), (_device), ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID
171 #define adf_os_iomem_t __adf_os_iomem_t;
173 * @brief These define the hw resources the OS has allocated for the device
174 * Note that start defines a mapped area.
177 ADF_OS_RESOURCE_TYPE_MEM,
178 ADF_OS_RESOURCE_TYPE_IO,
179 }adf_os_resource_type_t;
182 * @brief Representation of a h/w resource.
187 adf_os_resource_type_t type;
190 #define ADF_OS_DEV_ID_TABLE_MAX 256
193 * @brief Representation of bus registration data.
196 adf_os_pci_dev_id_t *pci;
198 }adf_os_bus_reg_data_t;
201 * @brief Representation of data required for attach.
204 adf_os_pci_dev_id_t pci;
206 }adf_os_attach_data_t;
208 #define ADF_OS_REGIONS_MAX 5
211 * @brief Types of buses.
214 ADF_OS_BUS_TYPE_PCI = 1,
215 ADF_OS_BUS_TYPE_GENERIC,
219 * @brief IRQ handler response codes.
227 * @brief DMA mask types.
230 ADF_OS_DMA_MASK_32BIT,
231 ADF_OS_DMA_MASK_64BIT,
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)
241 ADF_OS_DMA_TO_DEVICE = __ADF_OS_DMA_TO_DEVICE,
242 ADF_OS_DMA_FROM_DEVICE = __ADF_OS_DMA_FROM_DEVICE,
246 * Protoypes shared between public and private headers
251 * @brief work queue(kernel thread)/DPC function callback
253 typedef void (*adf_os_defer_fn_t)(void *);
256 * @brief Prototype of the critical region function that is to be
257 * executed with spinlock held and interrupt disalbed
259 typedef a_bool_t (*adf_os_irqlocked_func_t)(void *);
263 * @brief Prototype of timer function
265 typedef void (*adf_os_timer_func_t)(void *);
268 * @brief Prototype of IRQ function.
270 typedef adf_os_irq_resp_t (*adf_os_drv_intr)(adf_drv_handle_t hdl);
273 * @brief The OS print routine.
275 #define adf_os_print __adf_os_print
278 * @brief driver info structure needed while we do the register
279 * for the driver to the shim.
281 typedef struct _adf_drv_info{
283 * @brief driver specific functions
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);
292 * @brief driver specific data
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;