/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to driver/pciDriver.h

  • Committer: Suren A. Chilingaryan
  • Date: 2016-03-02 18:37:30 UTC
  • Revision ID: csa@suren.me-20160302183730-nlrgi7h3yuizcizc
Restructure driver headers

Show diffs side-by-side

added added

removed removed

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