Rev 23 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 23 | Rev 176 | ||
|---|---|---|---|
| 1 | //------------------------------------------------------------------------- |
1 | //------------------------------------------------------------------------- |
| 2 | // WINNT driver for PCICC32 interface from ARW Elektronik, Germany -------- |
2 | // WINNT driver for PCICC32 interface from ARW Elektronik, Germany -------- |
| 3 | // all around recognition and basic services of VMEMM |
3 | // all around recognition and basic services of VMEMM |
| 4 | // |
4 | // |
| 5 | // (c) 2000-2002 ARW Elektronik |
5 | // (c) 2000-2002 ARW Elektronik |
| 6 | // |
6 | // |
| 7 | // this source code is published under GPL (Open Source). You can use, redistrubute and |
7 | // this source code is published under GPL (Open Source). You can use, redistrubute and |
| 8 | // modify it unless this header is not modified or deleted. No warranty is given that |
8 | // modify it unless this header is not modified or deleted. No warranty is given that |
| 9 | // this software will work like expected. |
9 | // this software will work like expected. |
| 10 | // This product is not authorized for use as critical component in life support systems |
10 | // This product is not authorized for use as critical component in life support systems |
| 11 | // wihout the express written approval of ARW Elektronik Germany. |
11 | // wihout the express written approval of ARW Elektronik Germany. |
| 12 | // |
12 | // |
| 13 | // Please announce changes and hints to ARW Elektronik |
13 | // Please announce changes and hints to ARW Elektronik |
| 14 | // |
14 | // |
| 15 | // what who when |
15 | // what who when |
| 16 | // started from pcivme_v.c AR 02.07.2000 |
16 | // started from pcivme_v.c AR 02.07.2000 |
| 17 | // changed making procedure (only VCC > 6.0) AR 30.05.2002 |
17 | // changed making procedure (only VCC > 6.0) AR 30.05.2002 |
| 18 | // |
18 | // |
| 19 | 19 | ||
| 20 | //------------------------------------------------------------------------- |
20 | //------------------------------------------------------------------------- |
| 21 | // INCLUDES |
21 | // INCLUDES |
| 22 | // |
22 | // |
| 23 | #include <ntddk.h> |
23 | #include <ntddk.h> |
| 24 | #include <pcicc32_drv.h> |
24 | #include <pcicc32_drv.h> |
| 25 | #include <pcicc32_v.h> |
25 | #include <pcicc32_v.h> |
| 26 | #include <pcicc32_local.h> // all around the pciada interface |
26 | #include <pcicc32_local.h> // all around the pciada interface |
| 27 | 27 | ||
| 28 | #ifndef WORD // don't touch include files of WIN95 driver |
28 | #ifndef WORD // don't touch include files of WIN95 driver |
| 29 | #define WORD USHORT |
29 | #define WORD USHORT |
| 30 | #endif |
30 | #endif |
| 31 | 31 | ||
| 32 | #ifndef DWORD |
32 | #ifndef DWORD |
| 33 | #define DWORD ULONG |
33 | #define DWORD ULONG |
| 34 | #endif |
34 | #endif |
| 35 | 35 | ||
| 36 | //------------------------------------------------------------------------ |
36 | //------------------------------------------------------------------------ |
| 37 | // PROTOTYPES |
37 | // PROTOTYPES |
| 38 | // |
38 | // |
| 39 | 39 | ||
| 40 | //------------------------------------------------------------------------ |
40 | //------------------------------------------------------------------------ |
| 41 | // GLOBALS |
41 | // GLOBALS |
| 42 | // |
42 | // |
| 43 | 43 | ||
| 44 | //------------------------------------------------------------------------ |
44 | //------------------------------------------------------------------------ |
| 45 | // FUNCTIONS |
45 | // FUNCTIONS |
| 46 | // |
46 | // |
| 47 | 47 | ||
| 48 | //------------------------------------------------------------------------ |
48 | //------------------------------------------------------------------------ |
| 49 | // test connection to VMEMM devices without disturbing anything |
49 | // test connection to VMEMM devices without disturbing anything |
| 50 | // |
50 | // |
| 51 | //--------------------------------------------------------------------- |
51 | //--------------------------------------------------------------------- |
| 52 | // checks a connection with a small test pattern |
52 | // checks a connection with a small test pattern |
| 53 | // |
53 | // |
| 54 | NTSTATUS TestConnection(PCIADA *pciada) |
54 | NTSTATUS TestConnection(PCIADA *pciada) |
| 55 | { |
55 | { |
| 56 | USHORT *pwADRH = (USHORT *)_WORD_NAF(pciada->pvVirtIfr, 30, 1, 0); |
56 | USHORT *pwADRH = (USHORT *)_WORD_NAF(pciada->pvVirtIfr, 30, 1, 0); |
| 57 | USHORT *pwADRL = (USHORT *)_WORD_NAF(pciada->pvVirtIfr, 30, 0, 0); |
57 | USHORT *pwADRL = (USHORT *)_WORD_NAF(pciada->pvVirtIfr, 30, 0, 0); |
| 58 | int i; |
58 | int i; |
| 59 | USHORT wRet; |
59 | USHORT wRet; |
| 60 | USHORT wADRHContent; |
60 | USHORT wADRHContent; |
| 61 | USHORT wADRLContent; |
61 | USHORT wADRLContent; |
| 62 | 62 | ||
| 63 | 63 | ||
| 64 | KdPrint(("TestConnection()\n")); |
64 | KdPrint(("TestConnection()\n")); |
| 65 | 65 | ||
| 66 | wADRHContent = READ_REGISTER_USHORT(pwADRH); // save previous content |
66 | wADRHContent = READ_REGISTER_USHORT(pwADRH); // save previous content |
| 67 | wADRLContent = READ_REGISTER_USHORT(pwADRL); |
67 | wADRLContent = READ_REGISTER_USHORT(pwADRL); |
| 68 | 68 | ||
| 69 | for (i = 0; i < 10000; i++) |
69 | for (i = 0; i < 10000; i++) |
| 70 | { |
70 | { |
| 71 | WRITE_REGISTER_USHORT(pwADRH, 0x5555); |
71 | WRITE_REGISTER_USHORT(pwADRH, 0x5555); |
| 72 | WRITE_REGISTER_USHORT(pwADRL, 0xAAAA); |
72 | WRITE_REGISTER_USHORT(pwADRL, 0xAAAA); |
| 73 | wRet = READ_REGISTER_USHORT(pwADRH); |
73 | wRet = READ_REGISTER_USHORT(pwADRH); |
| 74 | if (wRet != 0x5555) return STATUS_UNSUCCESSFUL; |
74 | if (wRet != 0x5555) return STATUS_UNSUCCESSFUL; |
| 75 | 75 | ||
| 76 | WRITE_REGISTER_USHORT(pwADRH, 0xAAAA); |
76 | WRITE_REGISTER_USHORT(pwADRH, 0xAAAA); |
| 77 | WRITE_REGISTER_USHORT(pwADRL, 0x5555); |
77 | WRITE_REGISTER_USHORT(pwADRL, 0x5555); |
| 78 | wRet = READ_REGISTER_USHORT(pwADRH); |
78 | wRet = READ_REGISTER_USHORT(pwADRH); |
| 79 | if (wRet != 0xAAAA) return STATUS_UNSUCCESSFUL; |
79 | if (wRet != 0xAAAA) return STATUS_UNSUCCESSFUL; |
| 80 | 80 | ||
| 81 | WRITE_REGISTER_USHORT(pwADRH, 0x0000); |
81 | WRITE_REGISTER_USHORT(pwADRH, 0x0000); |
| 82 | WRITE_REGISTER_USHORT(pwADRL, 0xFFFF); |
82 | WRITE_REGISTER_USHORT(pwADRL, 0xFFFF); |
| 83 | wRet = READ_REGISTER_USHORT(pwADRH); |
83 | wRet = READ_REGISTER_USHORT(pwADRH); |
| 84 | if (wRet != 0x0000) return STATUS_UNSUCCESSFUL; |
84 | if (wRet != 0x0000) return STATUS_UNSUCCESSFUL; |
| 85 | 85 | ||
| 86 | WRITE_REGISTER_USHORT(pwADRH, 0xFFFF); |
86 | WRITE_REGISTER_USHORT(pwADRH, 0xFFFF); |
| 87 | WRITE_REGISTER_USHORT(pwADRL, 0x0000); |
87 | WRITE_REGISTER_USHORT(pwADRL, 0x0000); |
| 88 | wRet = READ_REGISTER_USHORT(pwADRH); |
88 | wRet = READ_REGISTER_USHORT(pwADRH); |
| 89 | if (wRet != 0xFFFF) return STATUS_UNSUCCESSFUL; |
89 | if (wRet != 0xFFFF) return STATUS_UNSUCCESSFUL; |
| 90 | } |
90 | } |
| 91 | 91 | ||
| 92 | WRITE_REGISTER_USHORT(pwADRH, wADRHContent); // restore previous content |
92 | WRITE_REGISTER_USHORT(pwADRH, wADRHContent); // restore previous content |
| 93 | WRITE_REGISTER_USHORT(pwADRL, wADRLContent); |
93 | WRITE_REGISTER_USHORT(pwADRL, wADRLContent); |
| 94 | 94 | ||
| 95 | KdPrint(("TestConnection() OK.\n")); |
95 | KdPrint(("TestConnection() OK.\n")); |
| 96 | 96 | ||
| 97 | return STATUS_SUCCESS; |
97 | return STATUS_SUCCESS; |
| 98 | } |
98 | } |
| 99 | 99 | ||
| 100 | //------------------------------------------------------------------------ |
100 | //------------------------------------------------------------------------ |
| 101 | // scan VMEMM devices without disturbing anything |
101 | // scan VMEMM devices without disturbing anything |
| 102 | // |
102 | // |
| 103 | NTSTATUS PCICC32ScanCC32(PDEVICE_OBJECT deviceObj) |
103 | NTSTATUS PCICC32ScanCC32(PDEVICE_OBJECT deviceObj) |
| 104 | { |
104 | { |
| 105 | int i; |
105 | int i; |
| 106 | int nPCIADAs = ((DEVICE_EXT*)(deviceObj->DeviceExtension))->nPCIADAs; |
106 | int nPCIADAs = ((DEVICE_EXT*)(deviceObj->DeviceExtension))->nPCIADAs; |
| 107 | PCIADA *pciada; |
107 | PCIADA *pciada; |
| 108 | USHORT wCntrl; |
108 | USHORT wCntrl; |
| 109 | USHORT wIntCSR; |
109 | USHORT wIntCSR; |
| 110 | USHORT wModuleStatus; |
110 | USHORT wModuleStatus; |
| 111 | 111 | ||
| 112 | KdPrint(("PCICC32ScanCC32(nPCIADAs = %d)\n", nPCIADAs)); |
112 | KdPrint(("PCICC32ScanCC32(nPCIADAs = %d)\n", nPCIADAs)); |
| 113 | 113 | ||
| 114 | for (i = 0; i < nPCIADAs; i++) |
114 | for (i = 0; i < nPCIADAs; i++) |
| 115 | { |
115 | { |
| 116 | pciada = &((DEVICE_EXT*)(deviceObj->DeviceExtension))->pciada[i]; |
116 | pciada = &((DEVICE_EXT*)(deviceObj->DeviceExtension))->pciada[i]; |
| 117 | 117 | ||
| 118 | wCntrl = READ_REGISTER_USHORT(pciada->pwCntrl); // save it for later use |
118 | wCntrl = READ_REGISTER_USHORT(pciada->pwCntrl); // save it for later use |
| 119 | wIntCSR = READ_REGISTER_USHORT(pciada->pwIntCSR); |
119 | wIntCSR = READ_REGISTER_USHORT(pciada->pwIntCSR); |
| 120 | 120 | ||
| 121 | KdPrint(("wCntrl = 0x%04x, wIntCSR = 0x%04x\n", wCntrl, wIntCSR)); |
121 | KdPrint(("wCntrl = 0x%04x, wIntCSR = 0x%04x\n", wCntrl, wIntCSR)); |
| 122 | 122 | ||
| 123 | WRITE_REGISTER_USHORT(pciada->pwCntrl, INHIBIT_CC32); // switch off before open |
123 | WRITE_REGISTER_USHORT(pciada->pwCntrl, INHIBIT_CC32); // switch off before open |
| 124 | WRITE_REGISTER_USHORT(pciada->pwIntCSR, DISABLE_PCIADA_IRQS); |
124 | WRITE_REGISTER_USHORT(pciada->pwIntCSR, DISABLE_PCIADA_IRQS); |
| 125 | WRITE_REGISTER_USHORT(pciada->pwCntrl, RELEASE_CC32); // open it for test |
125 | WRITE_REGISTER_USHORT(pciada->pwCntrl, RELEASE_CC32); // open it for test |
| 126 | 126 | ||
| 127 | if (wCntrl & 0x0800) |
127 | if (wCntrl & 0x0800) |
| 128 | { |
128 | { |
| 129 | if (TestConnection(pciada) == STATUS_SUCCESS) |
129 | if (TestConnection(pciada) == STATUS_SUCCESS) |
| 130 | { |
130 | { |
| 131 | wModuleStatus = READ_REGISTER_USHORT(pciada->pvVirtIfr); |
131 | wModuleStatus = READ_REGISTER_USHORT(pciada->pvVirtIfr); |
| 132 | 132 | ||
| 133 | pciada->bConnected = TRUE; |
133 | pciada->bConnected = TRUE; |
| 134 | 134 | ||
| 135 | // interpret the content |
135 | // interpret the content |
| 136 | pciada->wModuleNumber = (wModuleStatus & MASK_MODNR) >> 4; |
136 | pciada->wModuleNumber = (wModuleStatus & MASK_MODNR) >> 4; |
| 137 | pciada->wFPGAVersion = (wModuleStatus & MASK_FPGA) >> 8; |
137 | pciada->wFPGAVersion = (wModuleStatus & MASK_FPGA) >> 8; |
| 138 | pciada->wModuleType = (wModuleStatus & MASK_MODTYPE) >> 12; |
138 | pciada->wModuleType = (wModuleStatus & MASK_MODTYPE) >> 12; |
| 139 | 139 | ||
| 140 | KdPrint(("PCIADA %d <-> CC32 %d\n", i, pciada->wModuleNumber)); |
140 | KdPrint(("PCIADA %d <-> CC32 %d\n", i, pciada->wModuleNumber)); |
| 141 | } |
141 | } |
| 142 | else |
142 | else |
| 143 | pciada->wModuleNumber = 0xFFFF; // not recognized, take it out |
143 | pciada->wModuleNumber = 0xFFFF; // not recognized, take it out |
| 144 | } |
144 | } |
| 145 | else |
145 | else |
| 146 | pciada->wModuleNumber = 0xFFFF; // not recognized, take it out |
146 | pciada->wModuleNumber = 0xFFFF; // not recognized, take it out |
| 147 | 147 | ||
| 148 | if (pciada->wModuleNumber != 0xFFFF) |
148 | if (pciada->wModuleNumber != 0xFFFF) |
| 149 | WRITE_REGISTER_USHORT(pciada->pwCntrl, wCntrl); // restore state |
149 | WRITE_REGISTER_USHORT(pciada->pwCntrl, wCntrl); // restore state |
| 150 | else |
150 | else |
| 151 | WRITE_REGISTER_USHORT(pciada->pwCntrl, INHIBIT_CC32); |
151 | WRITE_REGISTER_USHORT(pciada->pwCntrl, INHIBIT_CC32); |
| 152 | 152 | ||
| 153 | WRITE_REGISTER_USHORT(pciada->pwIntCSR, wIntCSR); // restore interrupt masks |
153 | WRITE_REGISTER_USHORT(pciada->pwIntCSR, wIntCSR); // restore interrupt masks |
| 154 | } |
154 | } |
| 155 | 155 | ||
| 156 | return STATUS_SUCCESS; |
156 | return STATUS_SUCCESS; |
| 157 | } |
157 | } |
| 158 | 158 | ||
| 159 | 159 | ||
| 160 | //------------------------------------------------------------------------ |
160 | //------------------------------------------------------------------------ |
| 161 | // deinit all PCIADAs in a passive state |
161 | // deinit all PCIADAs in a passive state |
| 162 | // |
162 | // |
| 163 | NTSTATUS PCICC32DeInitPCIADAs(PDEVICE_OBJECT deviceObj) |
163 | NTSTATUS PCICC32DeInitPCIADAs(PDEVICE_OBJECT deviceObj) |
| 164 | { |
164 | { |
| 165 | int i; |
165 | int i; |
| 166 | DEVICE_EXT *pDevExt = (DEVICE_EXT*)deviceObj->DeviceExtension; |
166 | DEVICE_EXT *pDevExt = (DEVICE_EXT*)deviceObj->DeviceExtension; |
| 167 | int nPCIADAs = pDevExt->nPCIADAs; |
167 | int nPCIADAs = pDevExt->nPCIADAs; |
| 168 | PCIADA *pciada; |
168 | PCIADA *pciada; |
| 169 | 169 | ||
| 170 | KdPrint(("PCICC32DeInitPCIADAs()\n")); |
170 | KdPrint(("PCICC32DeInitPCIADAs()\n")); |
| 171 | 171 | ||
| 172 | // dis connect the interrupts to service routines |
172 | // dis connect the interrupts to service routines |
| 173 | for (i = 0; i < nPCIADAs; i++) |
173 | for (i = 0; i < nPCIADAs; i++) |
| 174 | { |
174 | { |
| 175 | pciada = &pDevExt->pciada[i]; |
175 | pciada = &pDevExt->pciada[i]; |
| 176 | 176 | ||
| 177 | WRITE_REGISTER_USHORT(pciada->pwCntrl, INHIBIT_CC32); |
177 | WRITE_REGISTER_USHORT(pciada->pwCntrl, INHIBIT_CC32); |
| 178 | // this is the same as globalInterruptDisable(pciada); |
178 | // this is the same as globalInterruptDisable(pciada); |
| 179 | WRITE_REGISTER_USHORT(pciada->pwIntCSR, DISABLE_PCIADA_IRQS); |
179 | WRITE_REGISTER_USHORT(pciada->pwIntCSR, DISABLE_PCIADA_IRQS); |
| 180 | } |
180 | } |
| 181 | 181 | ||
| 182 | return STATUS_SUCCESS; |
182 | return STATUS_SUCCESS; |
| 183 | } |
183 | } |
| 184 | 184 | ||
| 185 | //------------------------------------------------------------------------ |
185 | //------------------------------------------------------------------------ |
| 186 | // switches pciada on or off |
186 | // switches pciada on or off |
| 187 | // |
187 | // |
| 188 | void enableCC32(PCIADA *pciada) |
188 | void enableCC32(PCIADA *pciada) |
| 189 | { |
189 | { |
| 190 | WRITE_REGISTER_USHORT(pciada->pwCntrl, RELEASE_CC32); |
190 | WRITE_REGISTER_USHORT(pciada->pwCntrl, RELEASE_CC32); |
| 191 | } |
191 | } |
| 192 | 192 | ||
| 193 | void disableCC32(PCIADA *pciada) |
193 | void disableCC32(PCIADA *pciada) |
| 194 | { |
194 | { |
| 195 | WRITE_REGISTER_USHORT(pciada->pwCntrl, INHIBIT_CC32); |
195 | WRITE_REGISTER_USHORT(pciada->pwCntrl, INHIBIT_CC32); |
| 196 | } |
196 | } |
| 197 | 197 | ||