source: drsdaq/VME/struck/sis3100_vme_calls.c@ 23

Last change on this file since 23 was 22, checked in by ogrimm, 16 years ago
First commit of drsdaq program
File size: 22.3 KB
Line 
1
2
3/*===========================================================================*/
4/* */
5/* File: sis3100_vme_calls.c */
6/* */
7/* OS: LINUX (Kernel >= 2.4.18 */
8/* */
9/* Description: */
10/* */
11/* Version: 1.2 */
12/* */
13/* */
14/* Generated: 18.12.01 */
15/* Modified: 05.11.03 */
16/* Modified: 21.06.04 */
17/* */
18/* Author: TH */
19/* */
20/* Last Change: Installation */
21/*---------------------------------------------------------------------------*/
22/* SIS GmbH */
23/* Harksheider Str. 102A */
24/* 22399 Hamburg */
25/* */
26/* http://www.struck.de */
27/* */
28/*===========================================================================*/
29
30#define _GNU_SOURCE
31#include <stdio.h>
32#include <errno.h>
33#include <string.h>
34#include <sys/types.h>
35#include <unistd.h>
36#include <stdlib.h>
37#include <fcntl.h>
38#include <sys/ioctl.h>
39
40
41#include "sis1100_var.h"
42
43
44#include "sis3100_vme_calls.h"
45
46
47
48
49
50
51
52
53
54/**********************/
55/* */
56/* VME SYSReset */
57/* */
58/**********************/
59
60int vmesysreset(int p)
61{
62 if (s3100_control_write(p, 0x100 /*offset*/, 0x2 /*data*/) != 0x0) return -1 ;
63 usleep(500000); /* 500ms (min. 200ms) */
64 if (s3100_control_write(p, 0x100 /*offset*/, 0x20000 /*data*/) != 0x0) return -1 ;
65 return 0 ;
66}
67
68/********************************/
69/* */
70/* VME Read IRQ Ackn. Cycle */
71/* */
72/********************************/
73
74/* VME Read IRQ Ackn. Cycles */
75
76int vme_IACK_D8_read(int p, u_int32_t vme_irq_level, u_int8_t* vme_data )
77{
78struct sis1100_vme_req req;
79
80 req.size=1; /* driver does not change any field except data */
81 req.am=0x4000; /* */
82 req.addr= (vme_irq_level << 1) + 1;
83 if (ioctl(p, SIS3100_VME_READ, &req)<0) return -1 ;
84 if (req.error) return req.error ;
85 *vme_data = req.data;
86 return 0 ;
87
88}
89
90
91
92
93
94
95
96
97/*****************/
98/* */
99/* VME A16 */
100/* */
101/*****************/
102
103/* VME A16 Read Cycles */
104
105int vme_A16D8_read(int p, u_int32_t vme_adr, u_int8_t* vme_data )
106{
107struct sis1100_vme_req req;
108
109 req.size=1; /* driver does not change any field except data */
110 req.am=0x29; /* */
111 req.addr= vme_adr;
112 if (ioctl(p, SIS3100_VME_READ, &req)<0) return -1; /* NEW */
113 if (req.error) return req.error ;
114 *vme_data = req.data;
115 return 0 ;
116
117}
118
119
120int vme_A16D16_read(int p, u_int32_t vme_adr, u_int16_t* vme_data )
121{
122struct sis1100_vme_req req;
123
124 req.size=2; /* driver does not change any field except data */
125 req.am=0x29; /* "" */
126 req.addr= vme_adr;
127 if (ioctl(p, SIS3100_VME_READ, &req)<0) return -1; /* NEW */
128 if (req.error) return req.error ;
129 *vme_data = req.data;
130 return 0 ;
131}
132
133
134
135int vme_A16D32_read(int p, u_int32_t vme_adr, u_int32_t* vme_data )
136{
137struct sis1100_vme_req req;
138
139 req.size=4; /* driver does not change any field except data */
140 req.am=0x29; /* "" */
141 req.addr= vme_adr;
142 if (ioctl(p, SIS3100_VME_READ, &req)<0) return -1; /* NEW */
143 if (req.error) return req.error ;
144 *vme_data = req.data;
145 return 0 ;
146}
147
148
149/* VME A16 Write Cycles */
150
151int vme_A16D8_write(int p, u_int32_t vme_adr, u_int8_t vme_data )
152{
153struct sis1100_vme_req req;
154 req.size=1;
155 req.am=0x29;
156 req.addr= vme_adr;
157 req.data= (u_int32_t)vme_data;
158 if (ioctl(p, SIS3100_VME_WRITE, &req)<0) return -1; /* NEW */
159 if (req.error) return req.error ;
160 return 0 ;
161}
162
163int vme_A16D16_write(int p, u_int32_t vme_adr, u_int16_t vme_data )
164{
165struct sis1100_vme_req req;
166 req.size=2;
167 req.am=0x29;
168 req.addr= vme_adr;
169 req.data= (u_int32_t)vme_data;
170 if (ioctl(p, SIS3100_VME_WRITE, &req)<0) return -1; /* NEW */
171 if (req.error) return req.error ;
172 return 0 ;
173}
174
175
176
177int vme_A16D32_write(int p, u_int32_t vme_adr, u_int32_t vme_data )
178{
179struct sis1100_vme_req req;
180 req.size=4;
181 req.am=0x29;
182 req.addr= vme_adr;
183 req.data= vme_data;
184 if (ioctl(p, SIS3100_VME_WRITE, &req)<0) return -1; /* NEW */
185 if (req.error) return req.error ;
186 return 0 ;
187}
188
189
190
191
192
193
194/*****************/
195/* */
196/* VME A24 */
197/* */
198/*****************/
199
200/* VME A24 Read Cycles */
201
202int vme_A24D8_read(int p, u_int32_t vme_adr, u_int8_t* vme_data )
203{
204struct sis1100_vme_req req;
205
206 req.size=1; /* driver does not change any field except data */
207 req.am=0x39; /* */
208 req.addr= vme_adr;
209 if (ioctl(p, SIS3100_VME_READ, &req)<0) return -1; /* NEW */
210 if (req.error) return req.error ;
211 *vme_data = req.data;
212 return 0 ;
213}
214
215
216int vme_A24D16_read(int p, u_int32_t vme_adr, u_int16_t* vme_data )
217{
218struct sis1100_vme_req req;
219
220 req.size=2; /* driver does not change any field except data */
221 req.am=0x39; /* "" */
222 req.addr= vme_adr;
223 if (ioctl(p, SIS3100_VME_READ, &req)<0) return -1; /* NEW */
224 if (req.error) return req.error ;
225 *vme_data = req.data;
226 return 0 ;
227}
228
229
230
231int vme_A24D32_read(int p, u_int32_t vme_adr, u_int32_t* vme_data )
232{
233struct sis1100_vme_req req;
234
235 req.size=4; /* driver does not change any field except data */
236 req.am=0x39; /* "" */
237 req.addr= vme_adr;
238 if (ioctl(p, SIS3100_VME_READ, &req)<0) return -1; /* NEW */
239 if (req.error) return req.error ;
240 *vme_data = req.data;
241 return 0 ;
242}
243
244
245
246
247int vme_A24DMA_D32_read(int p, u_int32_t vme_adr, u_int32_t* vme_data,
248 u_int32_t req_num_of_lwords, u_int32_t* got_num_of_lwords)
249{
250struct sis1100_vme_block_req block_req;
251
252 block_req.num=req_num_of_lwords ; /* */
253 block_req.fifo=0;
254 block_req.size=4;
255 block_req.am=0x39;
256 block_req.addr=vme_adr ;
257 block_req.data = (u_int8_t*)vme_data ;
258
259 if (ioctl(p, SIS3100_VME_BLOCK_READ, &block_req)<0) return -1 ; /* NEW */
260 *got_num_of_lwords = block_req.num;
261 return block_req.error ; /* NEW */
262}
263
264
265int vme_A24BLT32_read(int p, u_int32_t vme_adr, u_int32_t* vme_data,
266 u_int32_t req_num_of_lwords, u_int32_t* got_num_of_lwords)
267{
268struct sis1100_vme_block_req block_req;
269
270 block_req.num=req_num_of_lwords ; /* */
271 block_req.fifo=0;
272 block_req.size=4;
273 block_req.am=0x3b;
274 block_req.addr=vme_adr ;
275 block_req.data = (u_int8_t*)vme_data ;
276 if (ioctl(p, SIS3100_VME_BLOCK_READ, &block_req)<0) return -1 ; /* NEW */
277 *got_num_of_lwords = block_req.num;
278 return block_req.error ; /* NEW */
279}
280
281
282
283int vme_A24MBLT64_read(int p, u_int32_t vme_adr, u_int32_t* vme_data,
284 u_int32_t req_num_of_lwords, u_int32_t* got_num_of_lwords)
285{
286struct sis1100_vme_block_req block_req;
287
288 block_req.num=req_num_of_lwords ; /* */
289 block_req.fifo=0;
290 block_req.size=4;
291 block_req.am=0x38;
292 block_req.addr=vme_adr ;
293 block_req.data = (u_int8_t*)vme_data ;
294 if (ioctl(p, SIS3100_VME_BLOCK_READ, &block_req)<0) return -1 ; /* NEW */
295 *got_num_of_lwords = block_req.num;
296 return block_req.error ; /* NEW */
297}
298
299
300
301int vme_A24BLT32FIFO_read(int p, u_int32_t vme_adr, u_int32_t* vme_data,
302 u_int32_t req_num_of_lwords, u_int32_t* got_num_of_lwords)
303{
304struct sis1100_vme_block_req block_req;
305
306 block_req.num=req_num_of_lwords ; /* */
307 block_req.fifo=1;
308 block_req.size=4;
309 block_req.am=0x3b;
310 block_req.addr=vme_adr ;
311 block_req.data = (u_int8_t*)vme_data ;
312 if (ioctl(p, SIS3100_VME_BLOCK_READ, &block_req)<0) return -1 ; /* NEW */
313 *got_num_of_lwords = block_req.num;
314 return block_req.error ; /* NEW */
315}
316
317
318
319int vme_A24MBLT64FIFO_read(int p, u_int32_t vme_adr, u_int32_t* vme_data,
320 u_int32_t req_num_of_lwords, u_int32_t* got_num_of_lwords)
321{
322struct sis1100_vme_block_req block_req;
323
324 block_req.num=req_num_of_lwords ; /* */
325 block_req.fifo=1;
326 block_req.size=4;
327 block_req.am=0x38;
328 block_req.addr=vme_adr ;
329 block_req.data = (u_int8_t*)vme_data ;
330 if (ioctl(p, SIS3100_VME_BLOCK_READ, &block_req)<0) return -1 ; /* NEW */
331 *got_num_of_lwords = block_req.num;
332 return block_req.error ; /* NEW */
333}
334
335
336
337
338
339
340
341/* VME A24 Write Cycles */
342
343int vme_A24D8_write(int p, u_int32_t vme_adr, u_int8_t vme_data )
344{
345struct sis1100_vme_req req;
346 req.size=1;
347 req.am=0x39;
348 req.addr= vme_adr;
349 req.data= (u_int32_t)vme_data;
350 if (ioctl(p, SIS3100_VME_WRITE, &req)<0) return -1; /* NEW */
351 if (req.error) return req.error ;
352 return 0 ;
353}
354
355int vme_A24D16_write(int p, u_int32_t vme_adr, u_int16_t vme_data )
356{
357struct sis1100_vme_req req;
358 req.size=2;
359 req.am=0x39;
360 req.addr= vme_adr;
361 req.data= (u_int32_t)vme_data;
362 if (ioctl(p, SIS3100_VME_WRITE, &req)<0) return -1; /* NEW */
363 if (req.error) return req.error ;
364 return 0 ;
365}
366
367
368
369int vme_A24D32_write(int p, u_int32_t vme_adr, u_int32_t vme_data )
370{
371struct sis1100_vme_req req;
372 req.size=4;
373 req.am=0x39;
374 req.addr= vme_adr;
375 req.data= vme_data;
376 if (ioctl(p, SIS3100_VME_WRITE, &req)<0) return -1; /* NEW */
377 if (req.error) return req.error ;
378 return 0 ;
379}
380
381
382
383int vme_A24DMA_D32_write(int p, u_int32_t vme_adr, u_int32_t* vme_data,
384 u_int32_t req_num_of_lwords, u_int32_t* put_num_of_lwords)
385{
386struct sis1100_vme_block_req block_req;
387
388 block_req.num=req_num_of_lwords ; /* */
389 block_req.fifo=0;
390 block_req.size=4;
391 block_req.am=0x39;
392 block_req.addr=vme_adr ;
393 block_req.data = (u_int8_t*)vme_data ;
394 if (ioctl(p, SIS3100_VME_BLOCK_WRITE, &block_req)<0) return -1 ; /* NEW */
395 *put_num_of_lwords = block_req.num;
396 return block_req.error ; /* NEW */
397}
398
399
400int vme_A24BLT32_write(int p, u_int32_t vme_adr, u_int32_t* vme_data,
401 u_int32_t req_num_of_lwords, u_int32_t* put_num_of_lwords)
402{
403struct sis1100_vme_block_req block_req;
404
405 block_req.num=req_num_of_lwords ; /* */
406 block_req.fifo=0;
407 block_req.size=4;
408 block_req.am=0x3b;
409 block_req.addr=vme_adr ;
410 block_req.data = (u_int8_t*)vme_data ;
411 if (ioctl(p, SIS3100_VME_BLOCK_WRITE, &block_req)<0) return -1 ; /* NEW */
412 *put_num_of_lwords = block_req.num;
413 return block_req.error ; /* NEW */
414}
415
416
417int vme_A24MBLT64_write(int p, u_int32_t vme_adr, u_int32_t* vme_data,
418 u_int32_t req_num_of_lwords, u_int32_t* put_num_of_lwords)
419{
420struct sis1100_vme_block_req block_req;
421
422 block_req.num=req_num_of_lwords ; /* */
423 block_req.fifo=0;
424 block_req.size=4;
425 block_req.am=0x38;
426 block_req.addr=vme_adr ;
427 block_req.data = (u_int8_t*)vme_data ;
428 if (ioctl(p, SIS3100_VME_BLOCK_WRITE, &block_req)<0) return -1 ; /* NEW */
429 *put_num_of_lwords = block_req.num;
430 return block_req.error ; /* NEW */
431}
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459/*****************/
460/* */
461/* VME A32 */
462/* */
463/*****************/
464
465
466/* VME A32 Read Cycles */
467
468int vme_A32D8_read(int p, u_int32_t vme_adr, u_int8_t* vme_data )
469{
470struct sis1100_vme_req req;
471
472 req.size=1; /* driver does not change any field except data */
473 req.am=0x9; /* */
474 req.addr= vme_adr;
475 if (ioctl(p, SIS3100_VME_READ, &req)<0) return -1; /* NEW */
476 if (req.error) return req.error ;
477 *vme_data = req.data;
478 return 0 ;
479}
480
481
482int vme_A32D16_read(int p, u_int32_t vme_adr, u_int16_t* vme_data )
483{
484struct sis1100_vme_req req;
485
486 req.size=2; /* driver does not change any field except data */
487 req.am=0x9; /* "" */
488 req.addr= vme_adr;
489 if (ioctl(p, SIS3100_VME_READ, &req)<0) return -1; /* NEW */
490 if (req.error) return req.error ;
491 *vme_data = req.data;
492 return 0 ;
493}
494
495
496
497int vme_A32D32_read(int p, u_int32_t vme_adr, u_int32_t* vme_data )
498{
499struct sis1100_vme_req req;
500
501 req.size=4; /* driver does not change any field except data */
502 req.am=0x9; /* "" */
503 req.addr= vme_adr;
504 if (ioctl(p, SIS3100_VME_READ, &req)<0) return -1; /* NEW */
505 if (req.error) return req.error ;
506 *vme_data = req.data; /* NEW */
507 return 0 ;
508}
509
510
511
512
513
514
515
516int vme_A32DMA_D32_read(int p, u_int32_t vme_adr, u_int32_t* vme_data,
517 u_int32_t req_num_of_lwords, u_int32_t* got_num_of_lwords)
518{
519struct sis1100_vme_block_req block_req;
520
521 block_req.num=req_num_of_lwords ; /* */
522 block_req.fifo=0;
523 block_req.size=4;
524 block_req.am=0x9;
525 block_req.addr=vme_adr ;
526 block_req.data = (u_int8_t*)vme_data ;
527
528 if (ioctl(p, SIS3100_VME_BLOCK_READ, &block_req)<0) return -1 ; /* NEW */
529 *got_num_of_lwords = block_req.num;
530 return block_req.error ; /* NEW */
531}
532
533
534
535
536
537
538int vme_A32BLT32_read(int p, u_int32_t vme_adr, u_int32_t* vme_data,
539 u_int32_t req_num_of_lwords, u_int32_t* got_num_of_lwords)
540{
541struct sis1100_vme_block_req block_req;
542
543 block_req.num=req_num_of_lwords ; /* */
544 block_req.fifo=0;
545 block_req.size=4;
546 block_req.am=0xb;
547 block_req.addr=vme_adr ;
548 block_req.data = (u_int8_t*)vme_data ;
549
550 if (ioctl(p, SIS3100_VME_BLOCK_READ, &block_req)<0) return -1 ; /* NEW */
551 *got_num_of_lwords = block_req.num;
552 return block_req.error ; /* NEW */
553}
554
555
556
557int vme_A32MBLT64_read(int p, u_int32_t vme_adr, u_int32_t* vme_data,
558 u_int32_t req_num_of_lwords, u_int32_t* got_num_of_lwords)
559{
560struct sis1100_vme_block_req block_req;
561
562 block_req.num=req_num_of_lwords ; /* */
563 block_req.fifo=0;
564 block_req.size=4;
565 block_req.am=0x8;
566 block_req.addr=vme_adr ;
567 block_req.data = (u_int8_t*)vme_data ;
568 if (ioctl(p, SIS3100_VME_BLOCK_READ, &block_req)<0) return -1 ; /* NEW */
569 *got_num_of_lwords = block_req.num;
570 return block_req.error ; /* NEW */
571}
572
573
574
575int vme_A32_2EVME_read(int p, u_int32_t vme_adr, u_int32_t* vme_data,
576 u_int32_t req_num_of_lwords, u_int32_t* got_num_of_lwords)
577{
578struct sis1100_vme_block_req block_req;
579
580 block_req.num=req_num_of_lwords ; /* */
581 block_req.fifo=0;
582 block_req.size=4;
583 block_req.am=0x20;
584 block_req.addr=vme_adr ;
585 block_req.data = (u_int8_t*)vme_data ;
586 if (ioctl(p, SIS3100_VME_BLOCK_READ, &block_req)<0) return -1 ; /* NEW */
587 *got_num_of_lwords = block_req.num;
588 return block_req.error ; /* NEW */
589}
590
591
592
593
594
595
596int vme_A32DMA_D32FIFO_read(int p, u_int32_t vme_adr, u_int32_t* vme_data,
597 u_int32_t req_num_of_lwords, u_int32_t* got_num_of_lwords)
598{
599struct sis1100_vme_block_req block_req;
600
601 block_req.num=req_num_of_lwords ; /* */
602 block_req.fifo=1;
603 block_req.size=4;
604 block_req.am=0x9;
605 block_req.addr=vme_adr ;
606 block_req.data = (u_int8_t*)vme_data ;
607 if (ioctl(p, SIS3100_VME_BLOCK_READ, &block_req)<0) return -1 ; /* NEW */
608 *got_num_of_lwords = block_req.num;
609 return block_req.error ; /* NEW */
610}
611
612
613
614
615
616int vme_A32BLT32FIFO_read(int p, u_int32_t vme_adr, u_int32_t* vme_data,
617 u_int32_t req_num_of_lwords, u_int32_t* got_num_of_lwords)
618{
619struct sis1100_vme_block_req block_req;
620
621 block_req.num=req_num_of_lwords ; /* */
622 block_req.fifo=1;
623 block_req.size=4;
624 block_req.am=0xb;
625 block_req.addr=vme_adr ;
626 block_req.data = (u_int8_t*)vme_data ;
627 if (ioctl(p, SIS3100_VME_BLOCK_READ, &block_req)<0) return -1 ; /* NEW */
628 *got_num_of_lwords = block_req.num;
629 return block_req.error ; /* NEW */
630}
631
632
633
634int vme_A32MBLT64FIFO_read(int p, u_int32_t vme_adr, u_int32_t* vme_data,
635 u_int32_t req_num_of_lwords, u_int32_t* got_num_of_lwords)
636{
637struct sis1100_vme_block_req block_req;
638
639 block_req.num=req_num_of_lwords ; /* */
640 block_req.fifo=1;
641 block_req.size=4;
642 block_req.am=0x8;
643 block_req.addr=vme_adr ;
644 block_req.data = (u_int8_t*)vme_data ;
645 if (ioctl(p, SIS3100_VME_BLOCK_READ, &block_req)<0) return -1 ; /* NEW */
646 *got_num_of_lwords = block_req.num;
647 return block_req.error ; /* NEW */
648}
649
650
651int vme_A32_2EVMEFIFO_read(int p, u_int32_t vme_adr, u_int32_t* vme_data,
652 u_int32_t req_num_of_lwords, u_int32_t* got_num_of_lwords)
653{
654struct sis1100_vme_block_req block_req;
655
656 block_req.num=req_num_of_lwords ; /* */
657 block_req.fifo=1;
658 block_req.size=4;
659 block_req.am=0x20;
660 block_req.addr=vme_adr ;
661 block_req.data = (u_int8_t*)vme_data ;
662 if (ioctl(p, SIS3100_VME_BLOCK_READ, &block_req)<0) return -1 ; /* NEW */
663 *got_num_of_lwords = block_req.num;
664 return block_req.error ; /* NEW */
665}
666
667
668
669
670
671
672
673
674
675
676
677/* VME A32 Write Cycles */
678
679int vme_A32D8_write(int p, u_int32_t vme_adr, u_int8_t vme_data )
680{
681struct sis1100_vme_req req;
682 req.size=1;
683 req.am=0x9;
684 req.addr= vme_adr;
685 req.data= (u_int32_t)vme_data;
686 if (ioctl(p, SIS3100_VME_WRITE, &req)<0) return -1; /* NEW */
687 if (req.error) return req.error ;
688 return 0 ;
689}
690
691int vme_A32D16_write(int p, u_int32_t vme_adr, u_int16_t vme_data )
692{
693struct sis1100_vme_req req;
694 req.size=2;
695 req.am=0x9;
696 req.addr= vme_adr;
697 req.data= (u_int32_t)vme_data;
698 if (ioctl(p, SIS3100_VME_WRITE, &req)<0) return -1; /* NEW */
699 if (req.error) return req.error ;
700 return 0 ;
701}
702
703
704
705int vme_A32D32_write(int p, u_int32_t vme_adr, u_int32_t vme_data )
706{
707struct sis1100_vme_req req;
708 req.size=4;
709 req.am=0x9;
710 req.addr= vme_adr;
711 req.data= vme_data;
712 if (ioctl(p, SIS3100_VME_WRITE, &req)<0) return -1; /* NEW */
713 if (req.error) return req.error ;
714 return 0 ;
715}
716
717
718
719int vme_A32DMA_D32_write(int p, u_int32_t vme_adr, u_int32_t* vme_data,
720 u_int32_t req_num_of_lwords, u_int32_t* put_num_of_lwords)
721{
722struct sis1100_vme_block_req block_req;
723
724 block_req.num=req_num_of_lwords ; /* */
725 block_req.fifo=0;
726 block_req.size=4;
727 block_req.am=0x9;
728 block_req.addr=vme_adr ;
729 block_req.data = (u_int8_t*)vme_data ;
730 if (ioctl(p, SIS3100_VME_BLOCK_WRITE, &block_req)<0) return -1 ; /* NEW */
731 *put_num_of_lwords = block_req.num;
732 return block_req.error ; /* NEW */
733}
734
735int vme_A32BLT32_write(int p, u_int32_t vme_adr, u_int32_t* vme_data,
736 u_int32_t req_num_of_lwords, u_int32_t* put_num_of_lwords)
737{
738struct sis1100_vme_block_req block_req;
739
740 block_req.num=req_num_of_lwords ; /* */
741 block_req.fifo=0;
742 block_req.size=4;
743 block_req.am=0xb;
744 block_req.addr=vme_adr ;
745 block_req.data = (u_int8_t*)vme_data ;
746
747 if (ioctl(p, SIS3100_VME_BLOCK_WRITE, &block_req)<0) return -1 ; /* NEW */
748 *put_num_of_lwords = block_req.num;
749 return block_req.error ; /* NEW */
750}
751
752
753int vme_A32MBLT64_write(int p, u_int32_t vme_adr, u_int32_t* vme_data,
754 u_int32_t req_num_of_lwords, u_int32_t* put_num_of_lwords)
755{
756struct sis1100_vme_block_req block_req;
757
758 block_req.num=req_num_of_lwords ; /* */
759 block_req.fifo=0;
760 block_req.size=4;
761 block_req.am=0x8;
762 block_req.addr=vme_adr ;
763 block_req.data = (u_int8_t*)vme_data ;
764 if (ioctl(p, SIS3100_VME_BLOCK_WRITE, &block_req)<0) return -1 ; /* NEW */
765 *put_num_of_lwords = block_req.num;
766 return block_req.error ; /* NEW */
767}
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784/***********************/
785/* */
786/* s3100_control */
787/* */
788/***********************/
789
790
791int s3100_control_read(int p, int offset, u_int32_t* data)
792{
793struct sis1100_ctrl_reg reg;
794int error ;
795 reg.offset = offset;
796 error = (ioctl(p, SIS1100_CTRL_READ, &reg)<0) ;
797 *data = reg.val;
798 return error ;
799}
800
801
802
803int s3100_control_write(int p, int offset, u_int32_t data)
804{
805struct sis1100_ctrl_reg reg;
806int error ;
807 reg.offset = offset;
808 reg.val = data;
809 error = (ioctl(p, SIS1100_CTRL_WRITE, &reg)<0) ;
810 return error ;
811}
812
813
814
815
816
817
818
819
820
821
822/***********************/
823/* */
824/* s3100_sharc */
825/* */
826/***********************/
827
828
829int s3100_sharc_write(int p_sharc_desc, u_int32_t byte_adr, u_int32_t* ptr_data, u_int32_t num_of_lwords )
830{
831int return_code ;
832
833 lseek(p_sharc_desc, byte_adr, SEEK_SET); /* must be longword aligned */
834 return_code=write(p_sharc_desc, ptr_data, num_of_lwords*4);
835
836
837/* return_code = length ? */
838/*
839res=write(p_sharc_desc, data, 4);
840 if (res<0) {
841 printf("write(0x%08lx, 0x%x): %s\n", offset, data, strerror(errno));
842 exit(1);
843 }
844 if (res!=4) {
845 printf("write(0x%08lx, 0x%x): res=%d\n", offset, data, res);
846 exit(1);
847 }
848*/
849
850 return return_code ;
851}
852
853
854
855
856
857
858int s3100_sharc_read(int p_sharc_desc, u_int32_t byte_adr, u_int32_t* ptr_data, u_int32_t num_of_lwords )
859{
860int return_code ;
861
862
863 lseek(p_sharc_desc, byte_adr, SEEK_SET); /* must be longword aligned */
864 return_code=read(p_sharc_desc, ptr_data, num_of_lwords*4);
865
866 return return_code ;
867}
868
869
870
871
872
873/***********************/
874/* */
875/* s3100_sdram */
876/* */
877/***********************/
878
879
880int s3100_sdram_write(int p_sdram_desc, u_int32_t byte_adr, u_int32_t* ptr_data, u_int32_t num_of_lwords )
881{
882int return_code ;
883
884
885 lseek(p_sdram_desc, byte_adr, SEEK_SET); /* must be longword aligned */
886 return_code=write(p_sdram_desc, ptr_data, num_of_lwords*4);
887
888/* return_code = length ? */
889/*
890res=write(p, &data, 4);
891 if (res<0) {
892 printf("write(0x%08lx, 0x%x): %s\n", offset, data, strerror(errno));
893 exit(1);
894 }
895 if (res!=4) {
896 printf("write(0x%08lx, 0x%x): res=%d\n", offset, data, res);
897 exit(1);
898 }
899*/
900
901 return return_code ;
902}
903
904
905
906
907
908
909int s3100_sdram_read(int p_sdram_desc, u_int32_t byte_adr, u_int32_t* ptr_data, u_int32_t num_of_lwords )
910{
911int return_code ;
912
913
914 lseek(p_sdram_desc, byte_adr, SEEK_SET); /* must be longword aligned */
915 return_code=read(p_sdram_desc, ptr_data, num_of_lwords*4);
916
917
918 return return_code ;
919}
Note: See TracBrowser for help on using the repository browser.