Rev 46 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
19 | f9daq | 1 | #ifndef __PCIVME_DRV_H__ |
2 | #define __PCIVME_DRV_H__ |
||
3 | //------------------------------------------------------------------------- |
||
4 | // WINNT driver for PCIVME interface from ARW Elektronik, Germany --------- |
||
5 | // the main header file of the driver |
||
6 | // |
||
7 | // (c) 1999-2004 ARW Elektronik |
||
8 | // |
||
9 | // this source code is published under GPL (Open Source). You can use, redistrubute 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 | // $Log: pcivme_drv.h,v $ |
||
18 | // Revision 1.3 2004/07/24 07:07:26 klaus |
||
19 | // Update copyright to 2004 |
||
20 | // |
||
21 | // Revision 1.2 2003/11/15 19:12:50 klaus |
||
22 | // Update copyright to 2003 |
||
23 | // |
||
24 | // Revision 1.1.1.1 2003/11/14 23:16:33 klaus |
||
25 | // First put into repository |
||
26 | // |
||
27 | // Revision 1.5 2002/10/27 18:41:21 klaus |
||
28 | // changed driver version to 2.0 (not 'inf' version) |
||
29 | // |
||
30 | // Revision 1.4 2002/10/27 17:02:30 klaus |
||
31 | // File addressing bug > 2 Gbtye circumvent |
||
32 | // |
||
33 | // Revision 1.3 2002/10/27 16:17:48 klaus |
||
34 | // Typing bug fixed caused at log addition |
||
35 | // |
||
36 | // Revision 1.2 2002/10/27 16:11:02 klaus |
||
37 | // Added CVS log into header |
||
38 | // |
||
39 | // what who when |
||
40 | // started AR 15.06.1999 |
||
41 | // version 1.0 released AR 20.10.1ß99 |
||
42 | // version 1.2 released AR 25.11.2001 |
||
43 | // changed to VisualStudio 6.0 AR 30.09.2001 |
||
44 | // compiled with DDK 1/2001 AR 20.11.2001 |
||
45 | // removed alloc_text cause of WIN2000 problems AR 25.11.2001 |
||
46 | // version 1.3 released AR 25.11.2001 |
||
47 | // changed resource allocation caused by WIN2000 AR 08.06.2002 |
||
48 | // |
||
49 | |||
50 | //------------------------------------------------------------------------- |
||
51 | #define DRIVER_VERSION ((2 << 16) | 0) // the only place for version info |
||
52 | #define DRIVER_VARIANT 0 // mark customisation here |
||
53 | //------------------------------------------------------------------------- |
||
54 | |||
55 | //------------------------------------------------------------------------- |
||
56 | // precautions for debug compile |
||
57 | #define PCIVME_DEBUG |
||
58 | |||
59 | #ifndef PCIVME_DEBUG |
||
60 | #ifdef KdPrint() |
||
61 | #undef KdPrint() |
||
62 | #define KdPrint(x) |
||
63 | #endif |
||
64 | #endif |
||
65 | //------------------------------------------------------------------------- |
||
66 | |||
67 | //------------------------------------------------------------------------- |
||
68 | // INCLUDES |
||
69 | // |
||
70 | #define PCI_MAX_BUSES 4 // buses to search for pciada |
||
71 | |||
72 | #define PCIVME_MAX_PCIADA 4 // maximum of PCIADA to search for |
||
73 | #define PCIVME_MAX_VMEMM 16 // maximum number of VMEMMs |
||
74 | |||
75 | //------------------------------------------------------------------------- |
||
76 | // DEFINES |
||
77 | // |
||
78 | #define PCIVME_VENDOR_ID 0x10B5 |
||
79 | #define PCIVME_DEVICE_ID 0x9050 |
||
80 | #define PCIVME_SUBSYS_ID 0x1167 |
||
81 | #define PCIVME_SUBVEN_ID 0x9050 |
||
82 | |||
83 | #define LCR_SPACE 256 // space in bytes of LCR |
||
84 | #define IFR_SPACE 8192 // space in bytes of IFR |
||
85 | |||
86 | //------------------------------------------------------------------------- |
||
87 | // TYPEDEFS |
||
88 | // |
||
89 | typedef struct _FILE_OBJ |
||
90 | { |
||
91 | USHORT uwAssociatedVMEMM; // which VMEMM it belongs |
||
92 | UCHAR bAddressModifier; // this is the current modifier |
||
93 | UCHAR bAccessType; // this is the current access type (1,2,4) |
||
94 | UCHAR bIncrement; // set 0 if no increment of address |
||
95 | ULONG dwAddressMask; // mask for aligned transfers |
||
96 | ULONG dwAccessBase; |
||
97 | void (*fRead)(void *to, ULONG length, void *from); // resulting read |
||
98 | void (*fWrite)(void *to, ULONG length, void *from); // resulting write |
||
99 | |||
100 | BOOLEAN bQueueIrq; // queue interrupt vectors belonging to this |
||
101 | PVOID pIrqListHandle; // pointer to the irq FIFO |
||
102 | |||
103 | BOOLEAN bBusError; // marks current access as responsible |
||
104 | } FILE_OBJ, *PFILE_OBJ; |
||
105 | |||
106 | typedef struct |
||
107 | { |
||
108 | int Bus; // bus number of pciada |
||
109 | PCI_SLOT_NUMBER Slot; // slot + function number encoded |
||
110 | PCI_COMMON_CONFIG PCIDevice; // content of pcr |
||
111 | |||
112 | PHYSICAL_ADDRESS pvPhysLcr; // local config register |
||
113 | PHYSICAL_ADDRESS pvPhysIfr; // interface registers |
||
114 | PVOID pvVirtLcr; // virtual LCR space |
||
115 | PVOID pvVirtIfr; // virtual IFR space |
||
116 | |||
117 | KIRQL Irql; // virtual Irq level |
||
118 | ULONG Vector; // mapped system vector |
||
119 | KAFFINITY Affinity; // which processor uses this irq |
||
120 | |||
121 | PKINTERRUPT InterruptObject; // points to the associated irq obj |
||
122 | |||
123 | PUSHORT pwCntrl; // LCR Cntrl Offset @ LCR + 0x50 |
||
124 | PUSHORT pwIntCSR; // LCR IntCSR Offset @ LCR + 0x4C |
||
125 | |||
126 | ULONG dwLinkCount; // how often this interface is requested |
||
127 | BOOLEAN bConnected; // VMEMM is connected and powered |
||
128 | BOOLEAN bWordMode; // WordMode Jumper set |
||
129 | BOOLEAN bSysControl; // SystemController enabled |
||
130 | USHORT wModuleNumber; // Number (Jumper) of VMEMM |
||
131 | USHORT wFPGAVersion; // Revision of (VMEMM) FPGA |
||
132 | USHORT wModuleType; // Type of (VMEMM) module |
||
133 | |||
134 | PUSHORT pwCSR; // pointer to csr register |
||
135 | PUSHORT pwIRQStat; // pointer to irq status |
||
136 | PUCHAR pbVector; // pointer to vector read register |
||
137 | PULONG pdwVMEAdr; // pointer to VME adress register |
||
138 | PUCHAR pbModifier; // pointer to address modifier register |
||
139 | PVOID pvVME; // pointer into VME window |
||
140 | |||
141 | ULONG dwVMEPage; // current page to VME |
||
142 | UCHAR bModifier; // current Modifier |
||
143 | |||
144 | KSPIN_LOCK AccessLock; // a lock for Access to VMEMM registers |
||
145 | KSPIN_LOCK IrqListLock; // a lock to guard access to List |
||
146 | LIST_ENTRY IrqListList; // start of list of IRQ FIFOs |
||
147 | |||
148 | KDPC kDPCobj; // custom DPC object for irq tunneling |
||
149 | |||
150 | PBOOLEAN pbBusError; // points to the responsible party |
||
151 | |||
152 | int nInterruptHandlers; // counts the controlling interrupt handlers |
||
153 | } PCIADA; |
||
154 | |||
155 | typedef struct _DEVICE_EXT |
||
156 | { |
||
157 | PDEVICE_OBJECT DeviceObject; // points to myself |
||
41 | f9daq | 158 | PDEVICE_OBJECT LowerDeviceObject; |
19 | f9daq | 159 | PDRIVER_OBJECT driverObj; // points to my driver */ |
160 | PIRP actualIrp; // points to .. |
||
161 | |||
162 | KSPIN_LOCK IRPLock; // a lock to guard access to List |
||
163 | LIST_ENTRY IRPList; // List of queued IRPs |
||
164 | |||
165 | int nPCIADAs; // how many PCIADAs are found |
||
166 | |||
167 | PCIADA pciada[PCIVME_MAX_PCIADA]; // for each PCIADA a descriptor |
||
168 | |||
169 | PCIADA *vmemm[PCIVME_MAX_VMEMM]; // points to PCIADA to which it belongs |
||
170 | |||
171 | int nInitState; // tracks the state of initialisation |
||
46 | f9daq | 172 | PBUS_INTERFACE_STANDARD busInterface; |
41 | f9daq | 173 | } DEVICE_EXT, *PDEVICE_EXT; |
19 | f9daq | 174 | |
175 | typedef struct |
||
176 | { |
||
177 | LIST_ENTRY entry; // doubly linked list |
||
178 | PFILE_OBJ pFile_obj; // the owner |
||
179 | PVOID pIrqListHandle; // the irq FIFO of this owner |
||
180 | } FIFO_LIST; |
||
181 | |||
182 | // Prototypes to support following pragmas |
||
183 | NTSTATUS DriverEntry(PDRIVER_OBJECT driverObj, PUNICODE_STRING regPath); |
||
41 | f9daq | 184 | NTSTATUS HandleStartDevice(PDEVICE_OBJECT fdo, PIRP Irp); |
185 | NTSTATUS HandleStopDevice(PDEVICE_OBJECT fdo, PIRP Irp); |
||
186 | NTSTATUS DefaultPnpHandler(PDEVICE_OBJECT fdo, PIRP Irp); |
||
187 | NTSTATUS PCIVMEStartDevice(PDEVICE_OBJECT device_object, PIRP irp); |
||
188 | NTSTATUS PCIVMEAddDevice( PDRIVER_OBJECT driverObj, PDEVICE_OBJECT pdo); |
||
189 | NTSTATUS PCIVMEDispatchPnp(PDEVICE_OBJECT deviceObj, PIRP irp); |
||
19 | f9daq | 190 | NTSTATUS PCIVMEOpen(PDEVICE_OBJECT deviceObj, PIRP irp); |
191 | NTSTATUS PCIVMEClose(PDEVICE_OBJECT deviceObj, PIRP irp); |
||
192 | VOID PCIVMEUnload(PDRIVER_OBJECT driverObj); |
||
46 | f9daq | 193 | NTSTATUS QueryBusInterface(IN PDEVICE_OBJECT DeviceObject, OUT PBUS_INTERFACE_STANDARD BusInterface); |
19 | f9daq | 194 | NTSTATUS SearchDevices(PDEVICE_OBJECT device_Obj); |
195 | NTSTATUS PLX9050BugFix(PDEVICE_OBJECT device_Obj); |
||
41 | f9daq | 196 | NTSTATUS PCIVMEExtractResources(PCIADA *pciada, PIRP irp); |
197 | NTSTATUS PCIVMEReserveResources(PDEVICE_OBJECT device_Obj, PIRP irp); |
||
19 | f9daq | 198 | NTSTATUS PCIVMEFreeResources(PDEVICE_OBJECT device_Obj); |
41 | f9daq | 199 | NTSTATUS PCIVMETranslateBusAddresses(PDEVICE_OBJECT device_Obj, PIRP irp); |
19 | f9daq | 200 | NTSTATUS PCIVMETranslateInterrupt(PDEVICE_OBJECT device_Obj); |
201 | NTSTATUS PCIVMEMapIOspace(PDEVICE_OBJECT device_object); |
||
202 | VOID PCIVMESoftInit(PDEVICE_OBJECT device_Obj); |
||
203 | PBOOLEAN ExchangePointer(PBOOLEAN *current, PBOOLEAN next); |
||
204 | |||
205 | /* release all this procedures after init of the driver */ |
||
206 | #if 0 // WIN2000 change versus WINNT? |
||
207 | #ifdef ALLOC_PRAGMA |
||
208 | #pragma alloc_text (init, DriverEntry) |
||
41 | f9daq | 209 | #pragma alloc_text (page, PCIVMEStartDevice) |
210 | #pragma alloc_text (page, PCIVMEAddDevice) |
||
46 | f9daq | 211 | #pragma alloc_text (page, QueryBusInterface) |
41 | f9daq | 212 | #pragma alloc_text (page, SearchDevices) |
213 | #pragma alloc_text (page, PLX9050BugFix) |
||
214 | #pragma alloc_text (page, PCIVMEExtractResources) |
||
215 | #pragma alloc_text (page, PCIVMEReserveResources) |
||
216 | #pragma alloc_text (page, PCIVMETranslateBusAddresses) |
||
217 | #pragma alloc_text (page, PCIVMETranslateInterrupt) |
||
218 | #pragma alloc_text (page, PCIVMEMapIOspace) |
||
219 | #pragma alloc_text (page, PCIVMESoftInit) |
||
19 | f9daq | 220 | #endif |
221 | |||
222 | /* put all this procedures in the paged memory-pool, all called at passiv Level */ |
||
223 | #ifdef ALLOC_PRAGMA |
||
41 | f9daq | 224 | #pragma alloc_text (page, HandleStartDevice) |
225 | #pragma alloc_text (page, HandleStopDevice) |
||
19 | f9daq | 226 | #pragma alloc_text (page, PCIVMEOpen) |
227 | #pragma alloc_text (page, PCIVMEClose) |
||
228 | #pragma alloc_text (page, PCIVMEUnload) |
||
229 | #pragma alloc_text (page, PCIVMEFreeResources) |
||
41 | f9daq | 230 | #pragma alloc_text (page, PCIVMEDispatchPnp) |
231 | #pragma alloc_text (page, DefaultPnpHandler) |
||
19 | f9daq | 232 | #endif |
233 | #endif // WIN2000 change versus WINNT? |
||
234 | |||
235 | #endif // __PCIVME_DRV_H__ |
||
236 |