4 * @brief General driver definitions. For kernel space only.
6 * @author Yury GEORGIEVSKIY
12 * @version 1.0 ygeorige 27/06/2008 Creation date.
14 #ifndef _GENERAL_DRVR_HEADER_H_INCLUDE_
15 #define _GENERAL_DRVR_HEADER_H_INCLUDE_
17 /*! @name Handy size operators
19 * Tnks to Linux kernel src
27 #define MB (1024UL*KB)
31 #define GB (1024UL*MB)
35 #define B2KB(x) ((x) / 1024)
39 #define B2MB(x) (B2KB (B2KB (x)))
44 #define memzero(_buf, _len) memset(_buf, 0, _len)
47 #if defined (__linux__) && defined(__KERNEL__)
48 /* for Linux kernel only */
50 #include <linux/vmalloc.h>
51 #include <linux/pci.h> /* for pci interface */
52 #include <data_tables.h> /* for 'bar_rdwr_t' && 'bar_map_t' */
54 /*! @name PCI BAR offsets
57 //!< they are in linux/pci_regs.h:83
60 //!< Get bar number [0 - 5] from the BAR offset
61 #define PCI_BAR(_bar) ((_bar - PCI_BASE_ADDRESS_0) >> 2)
63 //!< BAR bitmask (bits [5 4 3 2 1 0])
64 #define PCI_BAR_BIT(_bar) (1<<PCI_BAR(_bar))
66 #define MEM_BOUND (128*KB) /**< in bytes! what to use kmalloc or vmalloc */
68 /*! @name drvr_utils.c functions
71 int map_bars(struct list_head
*, struct pci_dev
*, int, char*);
72 int unmap_bars(struct list_head
*, int);
73 bar_map_t
* get_bar_descr(struct list_head
*, int);
74 void bar_read(bar_map_t
*, bar_rdwr_t
*);
75 void bar_write(bar_map_t
*, bar_rdwr_t
*);
77 void _mmio_insb_shift(void __iomem
*, u8
*, int);
78 void _mmio_insw_shift(void __iomem
*, u16
*, int);
79 void _mmio_insl_shift(void __iomem
*, u32
*, int);
81 void _mmio_outsb_shift(void __iomem
*, const u8
*, int);
82 void _mmio_outsw_shift(void __iomem
*, const u16
*, int);
83 void _mmio_outsl_shift(void __iomem
*, const u32
*, int);
85 char* sysbrk(unsigned long);
86 void sysfree(char *, unsigned long);
90 /*! @name drvr_load_file.c functions
93 char* read_info_file(char*, int*);
96 //!< PCI device initialization on a run
98 * INIT_PCI_DEVICE - macro used to initialize a specific pci device
100 * @param ptr - <B>struct pci_device_id</B> to init.
101 * @param vend - the 16 bit PCI Vendor ID
102 * @parma dev - the 16 bit PCI Device ID
104 * This macro is used to initialize 'on a run' a <B>struct pci_device_id</B>
105 * that matches a specific device. The subvendor and subdevice fields will be
106 * set to @b PCI_ANY_ID.
108 #define INIT_PCI_DEVICE(ptr, vend, dev) \
110 (ptr)->vendor = (vend); \
111 (ptr)->device = (dev); \
112 (ptr)->subvendor = PCI_ANY_ID; \
113 (ptr)->subdevice = PCI_ANY_ID; \
116 #endif /* (__linux__) && defined(__KERNEL__) */
117 #endif /* _GENERAL_DRVR_HEADER_H_INCLUDE_ */