/alps/pcitool

To get this branch, use:
bzr branch http://darksoft.org/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to driver/common.h

  • Committer: Suren A. Chilingaryan
  • Date: 2011-02-13 02:07:11 UTC
  • Revision ID: csa@dside.dyndns.org-20110213020711-y9bjh3n4ke6p4t4n
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _PCIDRIVER_COMMON_H
 
2
#define _PCIDRIVER_COMMON_H
 
3
 
 
4
/*************************************************************************/
 
5
/* Private data types and structures */
 
6
 
 
7
/* Define an entry in the kmem list (this list is per device) */
 
8
/* This list keeps references to the allocated kernel buffers */
 
9
typedef struct {
 
10
        int id;
 
11
        struct list_head list;
 
12
        dma_addr_t dma_handle;
 
13
        unsigned long cpua;
 
14
        unsigned long size;
 
15
        struct class_device_attribute sysfs_attr;       /* initialized when adding the entry */
 
16
} pcidriver_kmem_entry_t;
 
17
 
 
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 */
 
20
typedef struct {
 
21
        int id;
 
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;
 
29
 
 
30
/* Hold the driver private data */
 
31
typedef struct  {
 
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 */
 
38
 
 
39
#ifdef ENABLE_IRQ
 
40
        int irq_enabled;                                        /* Non-zero if IRQ is enabled */
 
41
        int irq_count;                                          /* Just an IRQ counter */
 
42
 
 
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 */
 
48
 
 
49
#endif
 
50
        
 
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 */
 
54
 
 
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 */
 
58
 
 
59
        
 
60
} pcidriver_privdata_t;
 
61
 
 
62
/* Identifies the mpRACE-1 boards */
 
63
#define MPRACE1_VENDOR_ID 0x10b5
 
64
#define MPRACE1_DEVICE_ID 0x9656
 
65
 
 
66
/* Identifies the PCI-X Test boards */
 
67
#define PCIXTEST_VENDOR_ID 0x10dc
 
68
#define PCIXTEST_DEVICE_ID 0x0156
 
69
 
 
70
/* Identifies the PCIe-PLDA Test board */
 
71
#define PCIEPLDA_VENDOR_ID 0x1556
 
72
#define PCIEPLDA_DEVICE_ID 0x1100
 
73
 
 
74
/* Identifies the PCIe-ABB Test board */
 
75
#define PCIEABB_VENDOR_ID 0x10dc
 
76
#define PCIEABB_DEVICE_ID 0x0153
 
77
 
 
78
/* Identifies the PCI-X PROGRAPE4 */
 
79
#define PCIXPG4_VENDOR_ID 0x1679
 
80
#define PCIXPG4_DEVICE_ID 0x0001
 
81
 
 
82
/* Identifies the PCI-64 PROGRAPE4 */
 
83
#define PCI64PG4_VENDOR_ID 0x1679
 
84
#define PCI64PG4_DEVICE_ID 0x0005
 
85
 
 
86
/* Identifies the PCI-E Xilinx ML605 */
 
87
#define PCIE_XILINX_VENDOR_ID 0x10ee
 
88
#define PCIE_ML605_DEVICE_ID 0x04a0
 
89
 
 
90
/*************************************************************************/
 
91
/* Some nice defines that make code more readable */
 
92
/* This is to print nice info in the log */
 
93
 
 
94
#ifdef DEBUG
 
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)
 
101
#else
 
102
 #define mod_info( args... ) \
 
103
    do { printk( KERN_INFO "%s: ", MODNAME );\
 
104
    printk( args ); } while(0)
 
105
 #define mod_info_dbg( args... ) 
 
106
#endif
 
107
 
 
108
#define mod_crit( args... ) \
 
109
    do { printk( KERN_CRIT "%s: ", MODNAME );\
 
110
    printk( args ); } while(0)
 
111
 
 
112
#define MIN(a, b) ((a) < (b) ? (a) : (b))
 
113
 
 
114
#endif