hc
2024-08-16 62c46c9150c4afde7e5b25436263fddf79d66f0b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef _PG_DRV_H
#define _PG_DRV_H
 
#define BYTE    __u8
#define WORD    __u16
#define DWORD    __u32
#define DWORD64    __u64
#define BOOLEAN    int
typedef void *    PVOID;
typedef BYTE *    PBYTE;
typedef WORD *    PWORD;
typedef DWORD *    PDWORD;
 
#ifndef TRUE
   #define TRUE    1
   #define FALSE    0
#endif
 
#define PRINT_LEVEL                    KERN_NOTICE
 
#ifdef DEBUG
#define DebugPrint(fmt,args...)                printk(PRINT_LEVEL "[RTNICPG]" fmt "\n",## args)
#define DbgFunPrint(fmt,args...)            printk(PRINT_LEVEL "[RTNICPG]" "%s %i: " fmt "\n",__FUNCTION__,__LINE__,## args)
#else
#define DebugPrint(fmt,args...)                //printk(PRINT_LEVEL fmt "\n",## args)
#define DbgFunPrint(fmt,args...)            //printk(PRINT_LEVEL "%s %i: " fmt "\n",__FUNCTION__,__LINE__,## args)
#endif
 
/*******************************************************************************
*******************************************************************************/
#define Writel(Address,Data)            writel(Data,(void *)(Address))
#define Readl(Address)                readl((void *)(Address))
#define Writew(Address,Data)            writew(Data,(void *)(Address))
#define Readw(Address)                readw((void *)(Address))
#define Writeb(Address,Data)            writeb(Data,(void *)(Address))
#define Readb(Address)                readb((void *)(Address))
 
#define MODULENAME                "pgtool"
#define MAX_DEV_NUM                10
#define MAX_IO_SIZE                0x100
 
typedef struct _DEV_INFO_
{
   dev_t                    devno;
   bool                    bUsed;
}DEV_INFO,*PDEV_INFO;
 
typedef struct _PG_DEV_
{
   struct cdev                cdev;
   struct pci_dev                *pdev;
   unsigned long                base_phyaddr;
   unsigned int                offset;
   unsigned int                deviceID;
   atomic_t                count;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
   struct semaphore            dev_sem;
#else
   struct mutex                dev_mutex;
#endif
   unsigned int                index;
}PGDEV,*PPGDEV;
 
typedef struct _PCI_CONFIG_RW_
{
   union
   {
       unsigned char    byte;
       unsigned short    word;
       unsigned int    dword;
   };
   unsigned int        bRead:1;
   unsigned int        size:7;
   unsigned int        addr:8;
   unsigned int        reserve:16;
}PCI_CONFIG_RW,*PPCI_CONFIG_RW;
 
#define RTL_IOC_MAGIC                    0x95
 
#define IOC_PCI_CONFIG                    _IOWR(RTL_IOC_MAGIC, 0, PCI_CONFIG_RW)
#define IOC_IOMEM_OFFSET                _IOR(RTL_IOC_MAGIC, 1, unsigned int)
#define IOC_DEV_FUN                    _IOR(RTL_IOC_MAGIC, 2, unsigned int)
 
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
#define __devinit
#define __devexit
#define __devexit_p(func)   func
#endif
 
#endif // end of #ifndef _PG_DRV_H