bzr branch
http://darksoft.org/webbzr/alps/pcitool
365
by Suren A. Chilingaryan
Restructure driver headers |
1 |
#ifndef _PCIDRIVER_IOCTL_H_
|
2 |
#define _PCIDRIVER_IOCTL_H_
|
|
3 |
||
4 |
#include <linux/ioctl.h> |
|
5 |
||
6 |
#define PCIDRIVER_INTERFACE_VERSION 2 /**< Driver API version, only the pcilib with the same driver interface version is allowed */ |
|
7 |
||
8 |
/* Possible values for ioctl commands */
|
|
9 |
||
10 |
/* PCI mmap areas */
|
|
11 |
#define PCIDRIVER_BAR0 0
|
|
12 |
#define PCIDRIVER_BAR1 1
|
|
13 |
#define PCIDRIVER_BAR2 2
|
|
14 |
#define PCIDRIVER_BAR3 3
|
|
15 |
#define PCIDRIVER_BAR4 4
|
|
16 |
#define PCIDRIVER_BAR5 5
|
|
17 |
||
18 |
/* mmap mode of the device */
|
|
19 |
#define PCIDRIVER_MMAP_PCI 0
|
|
20 |
#define PCIDRIVER_MMAP_KMEM 1
|
|
21 |
||
22 |
/* Direction of a DMA operation */
|
|
23 |
#define PCIDRIVER_DMA_BIDIRECTIONAL 0
|
|
24 |
#define PCIDRIVER_DMA_TODEVICE 1 // PCILIB_KMEM_SYNC_TODEVICE |
|
25 |
#define PCIDRIVER_DMA_FROMDEVICE 2 // PCILIB_KMEM_SYNC_FROMDEVICE |
|
26 |
||
27 |
/* Possible sizes in a PCI command */
|
|
28 |
#define PCIDRIVER_PCI_CFG_SZ_BYTE 1
|
|
29 |
#define PCIDRIVER_PCI_CFG_SZ_WORD 2
|
|
30 |
#define PCIDRIVER_PCI_CFG_SZ_DWORD 3
|
|
31 |
||
32 |
/* Possible types of SG lists */
|
|
33 |
#define PCIDRIVER_SG_NONMERGED 0
|
|
34 |
#define PCIDRIVER_SG_MERGED 1
|
|
35 |
||
36 |
#define KMEM_REF_HW 0x80000000 /**< Special reference to indicate hardware access */ |
|
37 |
#define KMEM_REF_COUNT 0x0FFFFFFF /**< Mask of reference counter (mmap/munmap), couting in mmaped memory pages */ |
|
38 |
||
39 |
#define KMEM_MODE_REUSABLE 0x80000000 /**< Indicates reusable buffer */ |
|
40 |
#define KMEM_MODE_EXCLUSIVE 0x40000000 /**< Only a single process is allowed to mmap the buffer */ |
|
41 |
#define KMEM_MODE_PERSISTENT 0x20000000 /**< Persistent mode instructs kmem_free to preserve buffer in memory */ |
|
42 |
#define KMEM_MODE_COUNT 0x0FFFFFFF /**< Mask of reuse counter (alloc/free) */ |
|
43 |
||
44 |
#define KMEM_FLAG_REUSE PCILIB_KMEM_FLAG_REUSE /**< Try to reuse existing buffer with the same use & item */ |
|
45 |
#define KMEM_FLAG_EXCLUSIVE PCILIB_KMEM_FLAG_EXCLUSIVE /**< Allow only a single application accessing a specified use & item */ |
|
46 |
#define KMEM_FLAG_PERSISTENT PCILIB_KMEM_FLAG_PERSISTENT /**< Sets persistent mode */ |
|
47 |
#define KMEM_FLAG_HW PCILIB_KMEM_FLAG_HARDWARE /**< The buffer may be accessed by hardware, the hardware access will not occur any more if passed to _free function */ |
|
48 |
#define KMEM_FLAG_FORCE PCILIB_KMEM_FLAG_FORCE /**< Force memory cleanup even if references are present */ |
|
49 |
#define KMEM_FLAG_MASS PCILIB_KMEM_FLAG_MASS /**< Apply to all buffers of selected use */ |
|
50 |
#define KMEM_FLAG_TRY PCILIB_KMEM_FLAG_TRY /**< Do not allocate buffers, try to reuse and fail if not possible */ |
|
51 |
||
52 |
#define KMEM_FLAG_REUSED PCILIB_KMEM_FLAG_REUSE /**< Indicates if buffer with specified use & item was already allocated and reused */ |
|
53 |
#define KMEM_FLAG_REUSED_PERSISTENT PCILIB_KMEM_FLAG_PERSISTENT /**< Indicates that reused buffer was persistent before the call */ |
|
54 |
#define KMEM_FLAG_REUSED_HW PCILIB_KMEM_FLAG_HARDWARE /**< Indicates that reused buffer had a HW reference before the call */ |
|
55 |
||
56 |
/* Types */
|
|
57 |
||
58 |
typedef struct { |
|
59 |
unsigned long version; /**< pcilib version */ |
|
60 |
unsigned long interface; /**< driver interface version */ |
|
61 |
unsigned long ioctls; /**< number of supporterd ioctls */ |
|
62 |
unsigned long reserved[5]; /**< reserved for the future use */ |
|
63 |
} pcilib_driver_version_t; |
|
64 |
||
65 |
typedef struct { |
|
66 |
int iommu; /**< Specifies if IOMMU is enabled or disabled */ |
|
67 |
int mps; /**< PCIe maximum payload size */ |
|
68 |
int readrq; /**< PCIe read request size */ |
|
69 |
unsigned long dma_mask; /**< DMA mask */ |
|
70 |
} pcilib_device_state_t; |
|
71 |
||
72 |
typedef struct { |
|
73 |
unsigned short vendor_id; |
|
74 |
unsigned short device_id; |
|
75 |
unsigned short bus; |
|
76 |
unsigned short slot; |
|
77 |
unsigned short func; |
|
78 |
unsigned short devfn; |
|
79 |
unsigned char interrupt_pin; |
|
80 |
unsigned char interrupt_line; |
|
81 |
unsigned int irq; |
|
82 |
unsigned long bar_start[6]; |
|
83 |
unsigned long bar_length[6]; |
|
84 |
unsigned long bar_flags[6]; |
|
85 |
} pcilib_board_info_t; |
|
86 |
||
87 |
typedef struct { |
|
88 |
unsigned long type; |
|
89 |
unsigned long pa; |
|
90 |
unsigned long ba; |
|
91 |
unsigned long size; |
|
92 |
unsigned long align; |
|
93 |
unsigned long use; |
|
94 |
unsigned long item; |
|
95 |
int flags; |
|
96 |
int handle_id; |
|
97 |
} kmem_handle_t; |
|
98 |
||
99 |
typedef struct { |
|
100 |
unsigned long addr; |
|
101 |
unsigned long size; |
|
102 |
} umem_sgentry_t; |
|
103 |
||
104 |
typedef struct { |
|
105 |
int handle_id; |
|
106 |
int type; |
|
107 |
int nents; |
|
108 |
umem_sgentry_t *sg; |
|
109 |
} umem_sglist_t; |
|
110 |
||
111 |
typedef struct { |
|
112 |
unsigned long vma; |
|
113 |
unsigned long size; |
|
114 |
int handle_id; |
|
115 |
int dir; |
|
116 |
} umem_handle_t; |
|
117 |
||
118 |
typedef struct { |
|
119 |
kmem_handle_t handle; |
|
120 |
int dir; |
|
121 |
} kmem_sync_t; |
|
122 |
||
123 |
typedef struct { |
|
124 |
unsigned long count; |
|
125 |
unsigned long timeout; // microseconds |
|
126 |
unsigned int source; |
|
127 |
} interrupt_wait_t; |
|
128 |
||
129 |
typedef struct { |
|
130 |
int size; |
|
131 |
int addr; |
|
132 |
union { |
|
133 |
unsigned char byte; |
|
134 |
unsigned short word; |
|
135 |
unsigned int dword; /* not strict C, but if not can have problems */ |
|
136 |
} val; |
|
137 |
} pci_cfg_cmd; |
|
138 |
||
139 |
/* ioctl interface */
|
|
140 |
/* See documentation for a detailed usage explanation */
|
|
141 |
||
142 |
/*
|
|
143 |
* one of the problems of ioctl, is that requires a type definition.
|
|
144 |
* This type is only 8-bits wide, and half-documented in
|
|
145 |
* <linux-src>/Documentation/ioctl-number.txt.
|
|
146 |
* previous SHL -> 'S' definition, conflicts with several devices,
|
|
147 |
* so I changed it to be pci -> 'p', in the range 0xA0-BF
|
|
148 |
*/
|
|
149 |
#define PCIDRIVER_IOC_MAGIC 'p'
|
|
150 |
#define PCIDRIVER_IOC_BASE 0xA0
|
|
151 |
||
152 |
#define PCIDRIVER_IOC_MMAP_MODE _IO( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 0 )
|
|
153 |
#define PCIDRIVER_IOC_MMAP_AREA _IO( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 1 )
|
|
154 |
#define PCIDRIVER_IOC_KMEM_ALLOC _IOWR( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 2, kmem_handle_t * )
|
|
155 |
#define PCIDRIVER_IOC_KMEM_FREE _IOW ( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 3, kmem_handle_t * )
|
|
156 |
#define PCIDRIVER_IOC_KMEM_SYNC _IOWR( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 4, kmem_sync_t * )
|
|
157 |
#define PCIDRIVER_IOC_UMEM_SGMAP _IOWR( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 5, umem_handle_t * )
|
|
158 |
#define PCIDRIVER_IOC_UMEM_SGUNMAP _IOW( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 6, umem_handle_t * )
|
|
159 |
#define PCIDRIVER_IOC_UMEM_SGGET _IOWR( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 7, umem_sglist_t * )
|
|
160 |
#define PCIDRIVER_IOC_UMEM_SYNC _IOW( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 8, umem_handle_t * )
|
|
161 |
#define PCIDRIVER_IOC_WAITI _IO( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 9 )
|
|
162 |
||
163 |
/* And now, the methods to access the PCI configuration area */
|
|
164 |
#define PCIDRIVER_IOC_PCI_CFG_RD _IOWR( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 10, pci_cfg_cmd * )
|
|
165 |
#define PCIDRIVER_IOC_PCI_CFG_WR _IOWR( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 11, pci_cfg_cmd * )
|
|
166 |
#define PCIDRIVER_IOC_PCI_INFO _IOWR( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 12, pcilib_board_info_t * )
|
|
167 |
||
168 |
/* Clear interrupt queues */
|
|
169 |
#define PCIDRIVER_IOC_CLEAR_IOQ _IO( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 13 )
|
|
170 |
||
171 |
#define PCIDRIVER_IOC_VERSION _IOR( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 14, pcilib_driver_version_t * )
|
|
172 |
#define PCIDRIVER_IOC_DEVICE_STATE _IOR( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 15, pcilib_device_state_t * )
|
|
173 |
#define PCIDRIVER_IOC_DMA_MASK _IO( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 16)
|
|
174 |
#define PCIDRIVER_IOC_MPS _IO( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 17)
|
|
175 |
||
176 |
#define PCIDRIVER_IOC_MAX 17
|
|
177 |
||
178 |
#endif /* _PCIDRIVER_IOCTL_H */ |