dev.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef _PCIDRIVER_DEV_H
  2. #define _PCIDRIVER_DEV_H
  3. typedef struct pcidriver_privdata_s pcidriver_privdata_t;
  4. #include "kmem.h"
  5. #include "umem.h"
  6. /* Hold the driver private data */
  7. struct pcidriver_privdata_s {
  8. int devid; /* the device id */
  9. dev_t devno; /* device number (major and minor) */
  10. struct pci_dev *pdev; /* PCI device */
  11. struct device *class_dev; /* Class device */
  12. struct cdev cdev; /* char device struct */
  13. int mmap_mode; /* current mmap mode */
  14. int mmap_area; /* current PCI mmap area */
  15. #ifdef ENABLE_IRQ
  16. int irq_enabled; /* Non-zero if IRQ is enabled */
  17. int irq_count; /* Just an IRQ counter */
  18. wait_queue_head_t irq_queues[ PCIDRIVER_INT_MAXSOURCES ]; /* One queue per interrupt source */
  19. atomic_t irq_outstanding[ PCIDRIVER_INT_MAXSOURCES ]; /* Outstanding interrupts per queue */
  20. volatile unsigned int *bars_kmapped[6]; /* PCI BARs mmapped in kernel space */
  21. #endif
  22. spinlock_t kmemlist_lock; /* Spinlock to lock kmem list operations */
  23. struct list_head kmem_list; /* List of 'kmem_list_entry's associated with this device */
  24. pcidriver_kmem_entry_t *kmem_last_sync; /* Last accessed kmem entry */
  25. atomic_t kmem_count; /* id for next kmem entry */
  26. int kmem_cur_id; /* Currently selected kmem buffer, for mmap */
  27. spinlock_t umemlist_lock; /* Spinlock to lock umem list operations */
  28. struct list_head umem_list; /* List of 'umem_list_entry's associated with this device */
  29. atomic_t umem_count; /* id for next umem entry */
  30. int msi_mode; /* Flag specifying if interrupt have been initialized in MSI mode */
  31. atomic_t refs; /* Reference counter */
  32. };
  33. const struct file_operations *pcidriver_get_fops(void);
  34. void pcidriver_module_get(pcidriver_privdata_t *privdata);
  35. void pcidriver_module_put(pcidriver_privdata_t *privdata);
  36. long pcidriver_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
  37. #endif /* _PCIDRIVER_DEV_H */