1
#ifndef _PCIDRIVER_COMMON_H
2
#define _PCIDRIVER_COMMON_H
4
/*************************************************************************/
5
/* Private data types and structures */
7
/* Define an entry in the kmem list (this list is per device) */
8
/* This list keeps references to the allocated kernel buffers */
11
struct list_head list;
12
dma_addr_t dma_handle;
15
struct class_device_attribute sysfs_attr; /* initialized when adding the entry */
16
} pcidriver_kmem_entry_t;
18
/* Define an entry in the umem list (this list is per device) */
19
/* This list keeps references to the SG lists for each mapped userspace region */
22
struct list_head list;
23
unsigned int nr_pages; /* number of pages for this user memeory area */
24
struct page **pages; /* list of pointers to the pages */
25
unsigned int nents; /* actual entries in the scatter/gatter list (NOT nents for the map function, but the result) */
26
struct scatterlist *sg; /* list of sg entries */
27
struct class_device_attribute sysfs_attr; /* initialized when adding the entry */
28
} pcidriver_umem_entry_t;
30
/* Hold the driver private data */
32
dev_t devno; /* device number (major and minor) */
33
struct pci_dev *pdev; /* PCI device */
34
struct class_device *class_dev; /* Class device */
35
struct cdev cdev; /* char device struct */
36
int mmap_mode; /* current mmap mode */
37
int mmap_area; /* current PCI mmap area */
40
int irq_enabled; /* Non-zero if IRQ is enabled */
41
int irq_count; /* Just an IRQ counter */
43
wait_queue_head_t irq_queues[ PCIDRIVER_INT_MAXSOURCES ];
44
/* One queue per interrupt source */
45
atomic_t irq_outstanding[ PCIDRIVER_INT_MAXSOURCES ];
46
/* Outstanding interrupts per queue */
47
volatile unsigned int *bars_kmapped[6]; /* PCI BARs mmapped in kernel space */
51
spinlock_t kmemlist_lock; /* Spinlock to lock kmem list operations */
52
struct list_head kmem_list; /* List of 'kmem_list_entry's associated with this device */
53
atomic_t kmem_count; /* id for next kmem entry */
55
spinlock_t umemlist_lock; /* Spinlock to lock umem list operations */
56
struct list_head umem_list; /* List of 'umem_list_entry's associated with this device */
57
atomic_t umem_count; /* id for next umem entry */
60
} pcidriver_privdata_t;
62
/* Identifies the mpRACE-1 boards */
63
#define MPRACE1_VENDOR_ID 0x10b5
64
#define MPRACE1_DEVICE_ID 0x9656
66
/* Identifies the PCI-X Test boards */
67
#define PCIXTEST_VENDOR_ID 0x10dc
68
#define PCIXTEST_DEVICE_ID 0x0156
70
/* Identifies the PCIe-PLDA Test board */
71
#define PCIEPLDA_VENDOR_ID 0x1556
72
#define PCIEPLDA_DEVICE_ID 0x1100
74
/* Identifies the PCIe-ABB Test board */
75
#define PCIEABB_VENDOR_ID 0x10dc
76
#define PCIEABB_DEVICE_ID 0x0153
78
/* Identifies the PCI-X PROGRAPE4 */
79
#define PCIXPG4_VENDOR_ID 0x1679
80
#define PCIXPG4_DEVICE_ID 0x0001
82
/* Identifies the PCI-64 PROGRAPE4 */
83
#define PCI64PG4_VENDOR_ID 0x1679
84
#define PCI64PG4_DEVICE_ID 0x0005
86
/* Identifies the PCI-E Xilinx ML605 */
87
#define PCIE_XILINX_VENDOR_ID 0x10ee
88
#define PCIE_ML605_DEVICE_ID 0x04a0
90
/*************************************************************************/
91
/* Some nice defines that make code more readable */
92
/* This is to print nice info in the log */
95
#define mod_info( args... ) \
96
do { printk( KERN_INFO "%s - %s : ", MODNAME , __FUNCTION__ );\
97
printk( args ); } while(0)
98
#define mod_info_dbg( args... ) \
99
do { printk( KERN_INFO "%s - %s : ", MODNAME , __FUNCTION__ );\
100
printk( args ); } while(0)
102
#define mod_info( args... ) \
103
do { printk( KERN_INFO "%s: ", MODNAME );\
104
printk( args ); } while(0)
105
#define mod_info_dbg( args... )
108
#define mod_crit( args... ) \
109
do { printk( KERN_CRIT "%s: ", MODNAME );\
110
printk( args ); } while(0)
112
#define MIN(a, b) ((a) < (b) ? (a) : (b))