Subversion Repositories f9daq

Rev

Rev 23 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23 f9daq 1
#ifndef __PCICC32_DRV_H__
2
#define __PCICC32_DRV_H__
3
//-------------------------------------------------------------------------
4
// WINNT driver for PCICC32 interface from ARW Elektronik, Germany ---------
5
// the main header file of the driver
6
//
7
// (c) 1999 ARW Elektronik
8
//
9
// this source code is published under GPL (Open Source). You can use, redistribute and 
10
// modify it unless this header   is not modified or deleted. No warranty is given that 
11
// this software will work like expected.
12
// This product is not authorized for use as critical component in life support systems
13
// wihout the express written approval of ARW Elektronik Germany.
14
//
15
// Please announce changes and hints to ARW Elektronik
16
//
17
// what                                            who          when
18
// started                                         AR           10.03.2000
19
// dwIrqStatus added, version 2                    AR           24.02.2001
20
// with AUTOREAD, version 2.01                     AR           17.03.2001
21
// with support for LCR_READ, version 2.02         AR           31.03.2001
22
// changed to VisualStudio 6.0                     AR           30.09.2001
23
// compiled with DDK 1/2001                        AR           20.11.2001
24
// removed alloc_text cause of WIN2000 problems    AR           25.11.2001
25
// version 2.7 released                            AR           25.11.2001
26
// version 2.8 still experimental                  AR           26.05.2002
27
// version 2.16 eliminates PLXBUG in WIN2000       AR           05.06.2002
28
// version 2.17 added KeSynchronizeExecution       AR           16.06.2002
29
// version 2.18 improved snchronisation            AR           18.06.2002
30
//
31
 
32
//-------------------------------------------------------------------------
33
#define DRIVER_VERSION ((2 << 16) | 18) // the only place for version info
34
#define DRIVER_VARIANT 0                // mark customisation here
35
//-------------------------------------------------------------------------
36
 
37
//-------------------------------------------------------------------------
38
// precautions for debug compile
39
#define PCICC32_DEBUG
40
 
41
#ifndef PCICC32_DEBUG
42
#ifdef  KdPrint
43
#undef  KdPrint
44
#define KdPrint(x) /* x */
45
#endif
46
#endif
47
//-------------------------------------------------------------------------
48
 
49
//-------------------------------------------------------------------------
50
// INCLUDES
51
//
52
#define PCI_MAX_BUSES     4   // buses to search for pciada
53
 
54
#define PCICC32_MAX_PCIADA 4  // maximum of PCIADA to search for  
55
#define PCICC32_MAX_CC32  16  // maximum number of CC32 modules connected
56
 
57
//-------------------------------------------------------------------------
58
// DEFINES
59
//
60
#define PCICC32_VENDOR_ID  0x10B5  
61
#define PCICC32_DEVICE_ID  0x2258
62
#define PCICC32_SUBSYS_ID  0x2258
63
#define PCICC32_SUBVEN_ID  0x9050
64
 
65
#define LCR_SPACE         256    // space in bytes of LCR
66
#define IFR_SPACE         32768  // space in bytes of IFR
67
 
68
//----------------------------------------------------------------------------------------
69
// macros for simple address calculation
70
//
71
#define _WORD_NAF(base, n, a, f)  ((USHORT *)((ULONG)base + (n << 10) + (a << 6) + ((f & 0xf) << 2)))
72
#define _DWORD_NAF(base, n, a, f) ((ULONG  *)((ULONG)base + (n << 10) + (a << 6) + ((f & 0xf) << 2)))
73
 
74
//-------------------------------------------------------------------------
75
// TYPEDEFS
76
//
77
typedef struct _FILE_OBJ
78
{
79
        USHORT uwAssociatedCC32;                   // which CC32 number it belongs
80
        USHORT wAccessType;                // WORD or LONGWORD
81
        USHORT wBlockTransfer;             // != 0 for block transfer
82
        void   (*fRead)(void *to,  void *from); // resulting read
83
        void   (*fWrite)(void *to, void *from); // resulting write
84
        PIRP              blockingIrp;     // if != 0 then a blocking IRP is waiting
85
} FILE_OBJ, *PFILE_OBJ;
86
 
87
typedef struct
88
{
89
        int               Bus;             // bus number of pciada
90
        PCI_SLOT_NUMBER   Slot;            // slot + function number encoded
91
        PCI_COMMON_CONFIG PCIDevice;       // content of pcr, only for direct HW related functions
92
 
93
    PHYSICAL_ADDRESS  pvPhysLcr;       // local config register, unmapped and mapped
94
        PHYSICAL_ADDRESS  pvPhysIfr;       // interface registers, unmapped and mapped
95
        PVOID             pvVirtLcr;       // virtual LCR space
96
        PVOID             pvVirtIfr;       // virtual IFR space
97
 
98
        PKINTERRUPT       InterruptObject; // points to the associated interrupt obj
99
        KIRQL                     Irql;                    // virtual Irq level, unmapped and mapped
100
        ULONG                     Vector;              // mapped system vector, unmapped and mapped
101
        KAFFINITY                 Affinity;        // which processor uses this irq, unmapped and mapped
102
 
103
        PUSHORT           pwCntrl;         // LCR Cntrl Offset @ LCR + 0x50
104
        PUSHORT           pwIntCSR;        // LCR IntCSR Offset @ LCR + 0x4C
105
 
106
        ULONG                     dwLinkCount;     // how often this interface is requested
107
    BOOLEAN                       bConnected;      // CC32 is connected and powered
108
        USHORT                    wModuleNumber;   // Number (Jumper) of CC32
109
        USHORT                    wFPGAVersion;    // Revision of (CC32) FPGA
110
        USHORT                    wModuleType;     // Type of (CC32) module
111
 
112
        KDPC              kDPCobj;         // custom DPC object for irq tunneling
113
 
114
        ULONG             dwIrqStatus;     // the last unrequested status of a interrupt
115
        PIRP              *pBlockingIrp;   // points to File or == NULL when no blocking in progress 
116
 
117
        FILE_OBJ          *pIrqControlFile; // this file controls the global enable / disable IRQ
118
} PCIADA;
119
 
120
typedef struct _DEVICE_EXT
121
{
122
        PDEVICE_OBJECT DeviceObject;       // points to myself and carries the pointer to DriverObject
123
        PIRP actualIrp;                                    // points to .. 
124
 
125
        int    nPCIADAs;                   // how many PCIADAs are found
126
 
127
        PCIADA pciada[PCICC32_MAX_PCIADA]; // for each PCIADA a descriptor 
128
 
129
        PCIADA *cc32[PCICC32_MAX_CC32];    // points to PCIADA to which it belongs
130
 
131
        int    nInitState;                 // tracks the state of initialisation
132
} DEVICE_EXT;
133
 
134
 
135
// Prototypes to support following pragmas
136
NTSTATUS DriverEntry(PDRIVER_OBJECT driverObj, PUNICODE_STRING regPath);
137
NTSTATUS PCICC32Open(PDEVICE_OBJECT deviceObj, PIRP irp);
138
NTSTATUS PCICC32Close(PDEVICE_OBJECT deviceObj, PIRP irp);
139
VOID     PCICC32Unload(PDRIVER_OBJECT driverObj);
140
NTSTATUS SearchDevices(PDEVICE_OBJECT device_Obj);
141
NTSTATUS PLX9050BugFix(PDEVICE_OBJECT deviceObj);
142
NTSTATUS PCICC32ReserveResources(PDEVICE_OBJECT device_Obj);
143
NTSTATUS PCICC32ExtractResources(PCIADA *pciada, PCM_RESOURCE_LIST pList);
144
NTSTATUS PCICC32FreeResources(PDEVICE_OBJECT device_Obj);
145
NTSTATUS PCICC32TranslateBusAddress(PDEVICE_OBJECT device_Obj);
146
NTSTATUS PCICC32MapIOspace(PDEVICE_OBJECT device_object);
147
VOID     PCICC32SoftInit(PDEVICE_OBJECT device_Obj);
148
NTSTATUS InitializeCustomDPCObjects(PDEVICE_OBJECT device_object);
149
 
150
/* release all this procedures after init of the driver */
151
#ifdef ALLOC_PRAGMA
152
#pragma alloc_text (init, DriverEntry)
153
#pragma alloc_text (init, SearchDevices)
154
#pragma alloc_text (init, PLX9050BugFix)
155
#pragma alloc_text (init, PCICC32ReserveResources)
156
#pragma alloc_text (init, PCICC32ExtractResources)
157
#pragma alloc_text (init, PCICC32TranslateBusAddress)
158
#pragma alloc_text (init, PCICC32MapIOspace)
159
#pragma alloc_text (init, PCICC32SoftInit) 
160
#pragma alloc_text (init, InitializeCustomDPCObjects) 
161
#endif
162
 
163
/* put all this procedures in the paged memory-pool, all called at passiv Level */
164
#ifdef ALLOC_PRAGMA
165
#pragma alloc_text (page, PCICC32Open)
166
#pragma alloc_text (page, PCICC32Close)
167
#pragma alloc_text (page, PCICC32Unload)
168
#pragma alloc_text (page, PCICC32FreeResources)
169
#endif
170
 
171
#endif // __PCICC32_DRV_H__
172