1 | /********************************************************************
|
---|
2 |
|
---|
3 | Name: sis3100.c
|
---|
4 | Created by: Stefan Ritt
|
---|
5 |
|
---|
6 | Contents: Midas VME standard (MVMESTD) layer for SIS 3100/1100
|
---|
7 | VME controller using sis1100w.lib
|
---|
8 |
|
---|
9 | $Id: sis3100.c 3783 2007-07-30 16:03:49Z ritt@PSI.CH $
|
---|
10 |
|
---|
11 | \********************************************************************/
|
---|
12 |
|
---|
13 | #ifdef __linux__
|
---|
14 | #ifndef OS_LINUX
|
---|
15 | #define OS_LINUX
|
---|
16 | #endif
|
---|
17 | #endif
|
---|
18 | #ifdef _MSC_VER
|
---|
19 | #define OS_WINNT
|
---|
20 | #endif
|
---|
21 |
|
---|
22 | #ifdef OS_WINNT
|
---|
23 |
|
---|
24 | #define PLX_9054
|
---|
25 | #define PCI_CODE
|
---|
26 | #define LITTLE_ENDIAN
|
---|
27 |
|
---|
28 | #include <stdio.h>
|
---|
29 | #include <string.h>
|
---|
30 | #include "PlxApi.h"
|
---|
31 | #include "sis1100w.h" // Header file for sis1100w.dll
|
---|
32 | #include "sis3100_vme_calls.h"
|
---|
33 |
|
---|
34 | #endif // OS_WINNT
|
---|
35 |
|
---|
36 | #ifdef OS_LINUX
|
---|
37 |
|
---|
38 | #define _GNU_SOURCE
|
---|
39 | #include <stdio.h>
|
---|
40 | #include <errno.h>
|
---|
41 | #include <string.h>
|
---|
42 | #include <sys/types.h>
|
---|
43 | #include <unistd.h>
|
---|
44 | #include <stdlib.h>
|
---|
45 | #include <fcntl.h>
|
---|
46 | #include <sys/ioctl.h>
|
---|
47 |
|
---|
48 | #include "sis3100_vme_calls.h"
|
---|
49 |
|
---|
50 | #endif // OS_LINUX
|
---|
51 |
|
---|
52 | #include "mvmestd.h"
|
---|
53 |
|
---|
54 | /*------------------------------------------------------------------*/
|
---|
55 |
|
---|
56 | int mvme_open(MVME_INTERFACE **vme, int idx)
|
---|
57 | {
|
---|
58 | *vme = (MVME_INTERFACE *) malloc(sizeof(MVME_INTERFACE));
|
---|
59 | if (*vme == NULL)
|
---|
60 | return MVME_NO_MEM;
|
---|
61 |
|
---|
62 | memset(*vme, 0, sizeof(MVME_INTERFACE));
|
---|
63 |
|
---|
64 | #ifdef OS_WINNT
|
---|
65 | {
|
---|
66 | int n_sis3100;
|
---|
67 |
|
---|
68 | sis1100w_Find_No_Of_sis1100(&n_sis3100);
|
---|
69 | if (idx >= n_sis3100)
|
---|
70 | return MVME_NO_INTERFACE;
|
---|
71 |
|
---|
72 | (*vme)->info = malloc(sizeof(struct SIS1100_Device_Struct));
|
---|
73 | if ((*vme)->info == NULL)
|
---|
74 | return MVME_NO_MEM;
|
---|
75 |
|
---|
76 | if (sis1100w_Get_Handle_And_Open(idx+1, (struct SIS1100_Device_Struct *) (*vme)->info) != 0)
|
---|
77 | return MVME_NO_INTERFACE;
|
---|
78 |
|
---|
79 | if (sis1100w_Init((struct SIS1100_Device_Struct *) (*vme)->info, 0) != 0)
|
---|
80 | return MVME_NO_INTERFACE;
|
---|
81 |
|
---|
82 | if (sis1100w_Init_sis3100((struct SIS1100_Device_Struct *) (*vme)->info, 0) != 0)
|
---|
83 | return MVME_NO_CRATE;
|
---|
84 | }
|
---|
85 | #endif // OS_WINNT
|
---|
86 |
|
---|
87 | #ifdef OS_LINUX
|
---|
88 | {
|
---|
89 | char str[256];
|
---|
90 |
|
---|
91 | /* open VME */
|
---|
92 | if (idx == 0)
|
---|
93 | strcpy(str, "/tmp/sis1100");
|
---|
94 | else
|
---|
95 | sprintf(str, "/tmp/sis1100_%d", idx+1);
|
---|
96 |
|
---|
97 | (*vme)->handle = open(str, O_RDWR, 0);
|
---|
98 | if ((*vme)->handle < 0)
|
---|
99 | return MVME_NO_INTERFACE;
|
---|
100 | }
|
---|
101 | #endif
|
---|
102 |
|
---|
103 | /* default values */
|
---|
104 | (*vme)->am = MVME_AM_DEFAULT;
|
---|
105 | (*vme)->dmode = MVME_DMODE_D32;
|
---|
106 | (*vme)->blt_mode = MVME_BLT_NONE;
|
---|
107 | (*vme)->table = NULL; // not used
|
---|
108 |
|
---|
109 | return MVME_SUCCESS;
|
---|
110 | }
|
---|
111 |
|
---|
112 | /*------------------------------------------------------------------*/
|
---|
113 |
|
---|
114 | int mvme_close(MVME_INTERFACE *vme)
|
---|
115 | {
|
---|
116 | #ifdef OS_WINNT
|
---|
117 | sis1100w_Close((struct SIS1100_Device_Struct *) vme->info);
|
---|
118 | free(vme->info);
|
---|
119 | #endif
|
---|
120 |
|
---|
121 | #ifdef OS_LINUX
|
---|
122 | close(vme->handle);
|
---|
123 | #endif
|
---|
124 |
|
---|
125 | return MVME_SUCCESS;
|
---|
126 | }
|
---|
127 |
|
---|
128 | /*------------------------------------------------------------------*/
|
---|
129 |
|
---|
130 | int mvme_sysreset(MVME_INTERFACE *vme)
|
---|
131 | {
|
---|
132 | #ifdef OS_WINNT
|
---|
133 | sis1100w_VmeSysreset((struct SIS1100_Device_Struct *) vme->info);
|
---|
134 | #endif
|
---|
135 | #ifdef OS_LINUX
|
---|
136 | vmesysreset(vme->handle);
|
---|
137 | #endif
|
---|
138 | return MVME_SUCCESS;
|
---|
139 | }
|
---|
140 |
|
---|
141 | /*------------------------------------------------------------------*/
|
---|
142 |
|
---|
143 | int mvme_write(MVME_INTERFACE *vme, mvme_addr_t vme_addr, void *src, mvme_size_t n_bytes)
|
---|
144 | {
|
---|
145 | mvme_size_t n;
|
---|
146 | DWORD status=0, data;
|
---|
147 | #ifdef OS_WINNT
|
---|
148 | struct SIS1100_Device_Struct *hvme;
|
---|
149 | hvme = (struct SIS1100_Device_Struct *) vme->info;
|
---|
150 | #else
|
---|
151 | int hvme;
|
---|
152 | hvme = vme->handle;
|
---|
153 | #endif
|
---|
154 |
|
---|
155 | if (n_bytes <= 4) {
|
---|
156 | data = n = 0;
|
---|
157 | memcpy(&data, src, n_bytes);
|
---|
158 |
|
---|
159 | /* A32 */
|
---|
160 | if (vme->am >= 0x08 && vme->am <= 0x0F) {
|
---|
161 | if (vme->dmode == MVME_DMODE_D8)
|
---|
162 | status = vme_A32D8_write(hvme, (u_int32_t) vme_addr, (u_int8_t) data);
|
---|
163 | else if (vme->dmode == MVME_DMODE_D16)
|
---|
164 | status = vme_A32D16_write(hvme, (u_int32_t) vme_addr, (u_int16_t) data);
|
---|
165 | else if (vme->dmode == MVME_DMODE_D32)
|
---|
166 | status = vme_A32D32_write(hvme, (u_int32_t) vme_addr, (u_int32_t) data);
|
---|
167 | }
|
---|
168 |
|
---|
169 | /* A16 */
|
---|
170 | else if (vme->am >= 0x29 && vme->am <= 0x2D) {
|
---|
171 | if (vme->dmode == MVME_DMODE_D8)
|
---|
172 | status = vme_A16D8_write(hvme, (u_int32_t) vme_addr, (u_int8_t) data);
|
---|
173 | else if (vme->dmode == MVME_DMODE_D16)
|
---|
174 | status = vme_A16D16_write(hvme, (u_int32_t) vme_addr, (u_int16_t) data);
|
---|
175 | else if (vme->dmode == MVME_DMODE_D32)
|
---|
176 | status = vme_A16D32_write(hvme, (u_int32_t) vme_addr, (u_int32_t) data);
|
---|
177 | }
|
---|
178 |
|
---|
179 | /* A24 */
|
---|
180 | else if (vme->am >= 0x38 && vme->am <= 0x3F) {
|
---|
181 | if (vme->dmode == MVME_DMODE_D8)
|
---|
182 | status = vme_A24D8_write(hvme, (u_int32_t) vme_addr, (u_int8_t) data);
|
---|
183 | else if (vme->am >= 0x38 && vme->am <= 0x3F && vme->dmode == MVME_DMODE_D16)
|
---|
184 | status = vme_A24D16_write(hvme, (u_int32_t) vme_addr, (u_int16_t) data);
|
---|
185 | else if (vme->am >= 0x38 && vme->am <= 0x3F && vme->dmode == MVME_DMODE_D32)
|
---|
186 | status = vme_A24D32_write(hvme, (u_int32_t) vme_addr, (u_int32_t) data);
|
---|
187 | }
|
---|
188 |
|
---|
189 | if (status == 0)
|
---|
190 | n = n_bytes;
|
---|
191 | else
|
---|
192 | n = 0;
|
---|
193 | } else {
|
---|
194 |
|
---|
195 | /* A32 */
|
---|
196 | if (vme->am >= 0x08 && vme->am <= 0x0f) {
|
---|
197 | if (vme->blt_mode == MVME_BLT_NONE)
|
---|
198 | status = vme_A32DMA_D32_write(hvme, (u_int32_t) vme_addr, (u_int32_t*) src, (u_int32_t) n_bytes/4, (u_int32_t*)&n);
|
---|
199 | else if (vme->blt_mode == MVME_BLT_BLT32)
|
---|
200 | status = vme_A32BLT32_write(hvme, (u_int32_t) vme_addr, (u_int32_t*) src, (u_int32_t) n_bytes/4, (u_int32_t*)&n);
|
---|
201 | else if (vme->blt_mode == MVME_BLT_MBLT64)
|
---|
202 | status = vme_A32MBLT64_write(hvme, (u_int32_t) vme_addr, (u_int32_t*) src, (u_int32_t) n_bytes/4, (u_int32_t*)&n);
|
---|
203 | }
|
---|
204 |
|
---|
205 | /* A24 */
|
---|
206 | else if (vme->am >= 0x38 && vme->am <= 0x3f) {
|
---|
207 | if (vme->blt_mode == MVME_BLT_BLT32)
|
---|
208 | status = vme_A24BLT32_write(hvme, (u_int32_t) vme_addr, (u_int32_t*) src, (u_int32_t) n_bytes/4, (u_int32_t*)&n);
|
---|
209 | else if (vme->blt_mode == MVME_BLT_MBLT64)
|
---|
210 | status = vme_A24MBLT64_write(hvme, (u_int32_t) vme_addr, (u_int32_t*) src, (u_int32_t) n_bytes/4, (u_int32_t*)&n);
|
---|
211 | }
|
---|
212 |
|
---|
213 | else
|
---|
214 | n = 0;
|
---|
215 |
|
---|
216 | n = n*4;
|
---|
217 | }
|
---|
218 |
|
---|
219 | return n;
|
---|
220 | }
|
---|
221 |
|
---|
222 | /*------------------------------------------------------------------*/
|
---|
223 |
|
---|
224 | int mvme_write_value(MVME_INTERFACE *vme, mvme_addr_t vme_addr, unsigned int value)
|
---|
225 | {
|
---|
226 | mvme_size_t n;
|
---|
227 | DWORD status=0;
|
---|
228 | #ifdef OS_WINNT
|
---|
229 | struct SIS1100_Device_Struct *hvme;
|
---|
230 | hvme = (struct SIS1100_Device_Struct *) vme->info;
|
---|
231 | #else
|
---|
232 | int hvme;
|
---|
233 | hvme = vme->handle;
|
---|
234 | #endif
|
---|
235 |
|
---|
236 | if (vme->dmode == MVME_DMODE_D8)
|
---|
237 | n = 1;
|
---|
238 | else if (vme->dmode == MVME_DMODE_D16)
|
---|
239 | n = 2;
|
---|
240 | else
|
---|
241 | n = 4;
|
---|
242 |
|
---|
243 | /* A16 */
|
---|
244 | if (vme->am >= 0x29 && vme->am <= 0x2D) {
|
---|
245 | if (vme->dmode == MVME_DMODE_D8)
|
---|
246 | status = vme_A16D8_write(hvme, (u_int32_t) vme_addr, (u_int8_t) value);
|
---|
247 | else if (vme->dmode == MVME_DMODE_D16)
|
---|
248 | status = vme_A16D16_write(hvme, (u_int32_t) vme_addr, (u_int16_t) value);
|
---|
249 | else if (vme->dmode == MVME_DMODE_D32)
|
---|
250 | status = vme_A16D32_write(hvme, (u_int32_t) vme_addr, (u_int32_t) value);
|
---|
251 | }
|
---|
252 |
|
---|
253 | /* A24 */
|
---|
254 | else if (vme->am >= 0x38 && vme->am <= 0x3F) {
|
---|
255 | if (vme->dmode == MVME_DMODE_D8)
|
---|
256 | status = vme_A24D8_write(hvme, (u_int32_t) vme_addr, (u_int8_t) value);
|
---|
257 | else if (vme->dmode == MVME_DMODE_D16)
|
---|
258 | status = vme_A24D16_write(hvme, (u_int32_t) vme_addr, (u_int16_t) value);
|
---|
259 | else if (vme->dmode == MVME_DMODE_D32)
|
---|
260 | status = vme_A24D32_write(hvme, (u_int32_t) vme_addr, (u_int32_t) value);
|
---|
261 | }
|
---|
262 |
|
---|
263 | /* A32 */
|
---|
264 | else if (vme->am >= 0x08 && vme->am <= 0x0F) {
|
---|
265 | if (vme->dmode == MVME_DMODE_D8)
|
---|
266 | status = vme_A32D8_write(hvme, (u_int32_t) vme_addr, (u_int8_t) value);
|
---|
267 | else if (vme->dmode == MVME_DMODE_D16)
|
---|
268 | status = vme_A32D16_write(hvme, (u_int32_t) vme_addr, (u_int16_t) value);
|
---|
269 | else if (vme->dmode == MVME_DMODE_D32)
|
---|
270 | status = vme_A32D32_write(hvme, (u_int32_t) vme_addr, (u_int32_t) value);
|
---|
271 | }
|
---|
272 |
|
---|
273 | if (status != 0)
|
---|
274 | n = 0;
|
---|
275 |
|
---|
276 | return n;
|
---|
277 | }
|
---|
278 |
|
---|
279 | /*------------------------------------------------------------------*/
|
---|
280 |
|
---|
281 | int mvme_read(MVME_INTERFACE *vme, void *dst, mvme_addr_t vme_addr, mvme_size_t n_bytes)
|
---|
282 | {
|
---|
283 | mvme_size_t i, n;
|
---|
284 | DWORD data;
|
---|
285 | WORD data16;
|
---|
286 | int status=0;
|
---|
287 | #ifdef OS_WINNT
|
---|
288 | struct SIS1100_Device_Struct *hvme;
|
---|
289 | hvme = (struct SIS1100_Device_Struct *) vme->info;
|
---|
290 | #else
|
---|
291 | int hvme;
|
---|
292 | hvme = vme->handle;
|
---|
293 | #endif
|
---|
294 |
|
---|
295 | if (n_bytes <= 4) {
|
---|
296 | data = 0;
|
---|
297 |
|
---|
298 | /* A32 */
|
---|
299 | if (vme->am >= 0x08 && vme->am <= 0x0F) {
|
---|
300 | if (vme->dmode == MVME_DMODE_D8)
|
---|
301 | status = vme_A32D8_read(hvme, (u_int32_t) vme_addr, (u_int8_t *) &data);
|
---|
302 | else if (vme->dmode == MVME_DMODE_D16) {
|
---|
303 | status = vme_A32D16_read(hvme, (u_int32_t) vme_addr, (u_int16_t *) &data16);
|
---|
304 | data = (DWORD)data16;
|
---|
305 | } else if (vme->dmode == MVME_DMODE_D32)
|
---|
306 | status = vme_A32D32_read(hvme, (u_int32_t) vme_addr, (u_int32_t *) &data);
|
---|
307 | }
|
---|
308 |
|
---|
309 | /* A16 */
|
---|
310 | else if (vme->am >= 0x29 && vme->am <= 0x2D) {
|
---|
311 | if (vme->dmode == MVME_DMODE_D8)
|
---|
312 | status = vme_A16D8_read(hvme, (u_int32_t) vme_addr, (u_int8_t *) &data);
|
---|
313 | else if (vme->dmode == MVME_DMODE_D16) {
|
---|
314 | status = vme_A16D16_read(hvme, (u_int32_t) vme_addr, (u_int16_t *) &data16);
|
---|
315 | data = (DWORD)data16;
|
---|
316 | } else if (vme->dmode == MVME_DMODE_D32)
|
---|
317 | status = vme_A16D32_read(hvme, (u_int32_t) vme_addr, (u_int32_t *) &data);
|
---|
318 | }
|
---|
319 |
|
---|
320 | /* A24 */
|
---|
321 | else if (vme->am >= 0x38 && vme->am <= 0x3F) {
|
---|
322 | if (vme->dmode == MVME_DMODE_D8)
|
---|
323 | status = vme_A24D8_read(hvme, (u_int32_t) vme_addr, (u_int8_t *) &data);
|
---|
324 | else if (vme->dmode == MVME_DMODE_D16) {
|
---|
325 | status = vme_A24D16_read(hvme, (u_int32_t) vme_addr, (u_int16_t *) &data16);
|
---|
326 | data = (DWORD)data16;
|
---|
327 | } else if (vme->dmode == MVME_DMODE_D32)
|
---|
328 | status = vme_A24D32_read(hvme, (u_int32_t) vme_addr, (u_int32_t *) &data);
|
---|
329 | }
|
---|
330 |
|
---|
331 | memcpy(dst, &data, n_bytes);
|
---|
332 | if (status == 0)
|
---|
333 | n = n_bytes;
|
---|
334 | else
|
---|
335 | n = 0;
|
---|
336 |
|
---|
337 | } else {
|
---|
338 |
|
---|
339 | n = 0;
|
---|
340 |
|
---|
341 | /* A32 */
|
---|
342 | if (vme->am >= 0x08 && vme->am <= 0x0F) {
|
---|
343 | if (vme->blt_mode == MVME_BLT_NONE)
|
---|
344 | status = vme_A32DMA_D32_read(hvme, (u_int32_t) vme_addr, (u_int32_t*) dst, (u_int32_t) n_bytes/4, (u_int32_t*)&n);
|
---|
345 | else if (vme->blt_mode == MVME_BLT_BLT32)
|
---|
346 | status = vme_A32BLT32_read(hvme, (u_int32_t) vme_addr, (u_int32_t*) dst, (u_int32_t) n_bytes/4, (u_int32_t*)&n);
|
---|
347 | else if (vme->blt_mode == MVME_BLT_BLT32FIFO)
|
---|
348 | status = vme_A32BLT32FIFO_read(hvme, (u_int32_t) vme_addr, (u_int32_t*) dst, (u_int32_t) n_bytes/4, (u_int32_t*)&n);
|
---|
349 | else if (vme->blt_mode == MVME_BLT_MBLT64)
|
---|
350 | status = vme_A32MBLT64_read(hvme, (u_int32_t) vme_addr, (u_int32_t*) dst, (u_int32_t) n_bytes/4, (u_int32_t*)&n);
|
---|
351 | else if (vme->blt_mode == MVME_BLT_MBLT64FIFO)
|
---|
352 | status = vme_A32MBLT64FIFO_read(hvme, (u_int32_t) vme_addr, (u_int32_t*) dst, (u_int32_t) n_bytes/4, (u_int32_t*)&n);
|
---|
353 | else if (vme->blt_mode == MVME_BLT_2EVME)
|
---|
354 | status = vme_A32_2EVME_read(hvme, (u_int32_t) vme_addr, (u_int32_t*) dst, (u_int32_t) n_bytes/4, (u_int32_t*)&n);
|
---|
355 | else if (vme->blt_mode == MVME_BLT_2EVMEFIFO)
|
---|
356 | status = vme_A32_2EVMEFIFO_read(hvme, (u_int32_t) vme_addr, (u_int32_t*) dst, (u_int32_t) n_bytes/4, (u_int32_t*)&n);
|
---|
357 | }
|
---|
358 |
|
---|
359 | /* A24 */
|
---|
360 | else if (vme->am >= 0x38 && vme->am <= 0x3F) {
|
---|
361 | if (vme->blt_mode == MVME_BLT_BLT32)
|
---|
362 | status = vme_A24BLT32_read(hvme, (u_int32_t) vme_addr, (u_int32_t*) dst, (u_int32_t) n_bytes/4, (u_int32_t*)&n);
|
---|
363 | else if (vme->blt_mode == MVME_BLT_BLT32FIFO)
|
---|
364 | status = vme_A24BLT32FIFO_read(hvme, (u_int32_t) vme_addr, (u_int32_t*) dst, (u_int32_t) n_bytes/4, (u_int32_t*)&n);
|
---|
365 | else if (vme->blt_mode == MVME_BLT_MBLT64)
|
---|
366 | status = vme_A24MBLT64_read(hvme, (u_int32_t) vme_addr, (u_int32_t*) dst, (u_int32_t) n_bytes/4, (u_int32_t*)&n);
|
---|
367 | else if (vme->blt_mode == MVME_BLT_MBLT64FIFO)
|
---|
368 | status = vme_A24MBLT64FIFO_read(hvme, (u_int32_t) vme_addr, (u_int32_t*) dst, (u_int32_t) n_bytes/4, (u_int32_t*)&n);
|
---|
369 | }
|
---|
370 |
|
---|
371 | /* A16 */
|
---|
372 | else if (vme->am >= 0x29 && vme->am <= 0x2D) {
|
---|
373 | if (vme->dmode == MVME_DMODE_D8)
|
---|
374 | for (i=0 ; i<n_bytes ; i++)
|
---|
375 | status = vme_A16D8_read(hvme, (u_int32_t) vme_addr, ((u_int8_t *) dst)+i);
|
---|
376 | else if (vme->dmode == MVME_DMODE_D16)
|
---|
377 | for (i=0 ; i<n_bytes/2 ; i++)
|
---|
378 | status = vme_A16D16_read(hvme, (u_int32_t) vme_addr, ((u_int16_t *) dst)+i);
|
---|
379 | else if (vme->dmode == MVME_DMODE_D32)
|
---|
380 | for (i=0 ; i<n_bytes/4 ; i++)
|
---|
381 | status = vme_A16D32_read(hvme, (u_int32_t) vme_addr, ((u_int32_t *) dst)+i);
|
---|
382 | }
|
---|
383 |
|
---|
384 | else
|
---|
385 | status = 1;
|
---|
386 |
|
---|
387 | n = n*4;
|
---|
388 | }
|
---|
389 |
|
---|
390 | return n;
|
---|
391 | }
|
---|
392 |
|
---|
393 | /*------------------------------------------------------------------*/
|
---|
394 |
|
---|
395 | unsigned int mvme_read_value(MVME_INTERFACE *vme, mvme_addr_t vme_addr)
|
---|
396 | {
|
---|
397 | unsigned int data;
|
---|
398 | WORD data16;
|
---|
399 | int status;
|
---|
400 | #ifdef OS_WINNT
|
---|
401 | struct SIS1100_Device_Struct *hvme;
|
---|
402 | hvme = (struct SIS1100_Device_Struct *) vme->info;
|
---|
403 | #else
|
---|
404 | int hvme;
|
---|
405 | hvme = vme->handle;
|
---|
406 | #endif
|
---|
407 |
|
---|
408 | data = 0;
|
---|
409 |
|
---|
410 | /* A16 */
|
---|
411 | if (vme->am >= 0x29 && vme->am <= 0x2D) {
|
---|
412 | if (vme->dmode == MVME_DMODE_D8)
|
---|
413 | status = vme_A16D8_read(hvme, (u_int32_t) vme_addr, (u_int8_t *) &data);
|
---|
414 | else if (vme->dmode == MVME_DMODE_D16) {
|
---|
415 | status = vme_A16D16_read(hvme, (u_int32_t) vme_addr, (u_int16_t *) &data16);
|
---|
416 | data = (DWORD)data16;
|
---|
417 | } else if (vme->dmode == MVME_DMODE_D32)
|
---|
418 | status = vme_A16D32_read(hvme, (u_int32_t) vme_addr, (u_int32_t *) &data);
|
---|
419 | }
|
---|
420 |
|
---|
421 | /* A24 */
|
---|
422 | else if (vme->am >= 0x38 && vme->am <= 0x3F) {
|
---|
423 | if (vme->dmode == MVME_DMODE_D8)
|
---|
424 | status = vme_A24D8_read(hvme, (u_int32_t) vme_addr, (u_int8_t *) &data);
|
---|
425 | else if (vme->dmode == MVME_DMODE_D16) {
|
---|
426 | status = vme_A24D16_read(hvme, (u_int32_t) vme_addr, (u_int16_t *) &data16);
|
---|
427 | data = (DWORD)data16;
|
---|
428 | } else if (vme->dmode == MVME_DMODE_D32)
|
---|
429 | status = vme_A24D32_read(hvme, (u_int32_t) vme_addr, (u_int32_t *) &data);
|
---|
430 | }
|
---|
431 |
|
---|
432 | /* A32 */
|
---|
433 | else if (vme->am >= 0x08 && vme->am <= 0x0F) {
|
---|
434 | if (vme->dmode == MVME_DMODE_D8)
|
---|
435 | status = vme_A32D8_read(hvme, (u_int32_t) vme_addr, (u_int8_t *) &data);
|
---|
436 | else if (vme->dmode == MVME_DMODE_D16) {
|
---|
437 | status = vme_A32D16_read(hvme, (u_int32_t) vme_addr, (u_int16_t *) &data16);
|
---|
438 | data = (DWORD)data16;
|
---|
439 | } else if (vme->dmode == MVME_DMODE_D32)
|
---|
440 | status = vme_A32D32_read(hvme, (u_int32_t) vme_addr, (u_int32_t *) &data);
|
---|
441 | }
|
---|
442 |
|
---|
443 | return data;
|
---|
444 | }
|
---|
445 |
|
---|
446 | /*------------------------------------------------------------------*/
|
---|
447 |
|
---|
448 | int mvme_set_am(MVME_INTERFACE *vme, int am)
|
---|
449 | {
|
---|
450 | vme->am = am;
|
---|
451 | return MVME_SUCCESS;
|
---|
452 | }
|
---|
453 |
|
---|
454 | /*------------------------------------------------------------------*/
|
---|
455 |
|
---|
456 | int mvme_get_am(MVME_INTERFACE *vme, int *am)
|
---|
457 | {
|
---|
458 | *am = vme->am;
|
---|
459 | return MVME_SUCCESS;
|
---|
460 | }
|
---|
461 |
|
---|
462 | /*------------------------------------------------------------------*/
|
---|
463 |
|
---|
464 | int mvme_set_dmode(MVME_INTERFACE *vme, int dmode)
|
---|
465 | {
|
---|
466 | vme->dmode = dmode;
|
---|
467 | return MVME_SUCCESS;
|
---|
468 | }
|
---|
469 |
|
---|
470 | /*------------------------------------------------------------------*/
|
---|
471 |
|
---|
472 | int mvme_get_dmode(MVME_INTERFACE *vme, int *dmode)
|
---|
473 | {
|
---|
474 | *dmode = vme->dmode;
|
---|
475 | return MVME_SUCCESS;
|
---|
476 | }
|
---|
477 |
|
---|
478 | /*------------------------------------------------------------------*/
|
---|
479 |
|
---|
480 | int mvme_set_blt(MVME_INTERFACE *vme, int mode)
|
---|
481 | {
|
---|
482 | vme->blt_mode = mode;
|
---|
483 | return MVME_SUCCESS;
|
---|
484 | }
|
---|
485 |
|
---|
486 | /*------------------------------------------------------------------*/
|
---|
487 |
|
---|
488 | int mvme_get_blt(MVME_INTERFACE *vme, int *mode)
|
---|
489 | {
|
---|
490 | *mode = vme->blt_mode;
|
---|
491 | return MVME_SUCCESS;
|
---|
492 | }
|
---|