1 | #define _GNU_SOURCE
|
---|
2 | #include <stdio.h>
|
---|
3 | #include <errno.h>
|
---|
4 | #include <string.h>
|
---|
5 | #include <sys/types.h>
|
---|
6 | #include <unistd.h>
|
---|
7 | #include <fcntl.h>
|
---|
8 | #include <sys/mman.h>
|
---|
9 | #include <sys/ioctl.h>
|
---|
10 |
|
---|
11 | #include "dev/pci/sis1100_var.h"
|
---|
12 |
|
---|
13 | int p;
|
---|
14 |
|
---|
15 | /****************************************************************************/
|
---|
16 | static void printerror(struct sis1100_vme_req* req, int _errno, int write)
|
---|
17 | {
|
---|
18 | if (write)
|
---|
19 | printf("vme write 0x%08x to 0x%08x", req->data, req->addr);
|
---|
20 | else
|
---|
21 | printf("vme read 0x%08x", req->addr);
|
---|
22 |
|
---|
23 | printf(": %s", strerror(_errno));
|
---|
24 | if (_errno==EIO) printf("; protocoll error 0x%x", req->error);
|
---|
25 | printf("\n");
|
---|
26 | }
|
---|
27 | /****************************************************************************/
|
---|
28 | int main(int argc, char* argv[])
|
---|
29 | {
|
---|
30 | int i;
|
---|
31 | struct sis1100_vme_req req;
|
---|
32 | u_int32_t base;
|
---|
33 |
|
---|
34 | if (argc<2)
|
---|
35 | {
|
---|
36 | fprintf(stderr, "usage: %s path\n", argv[0]);
|
---|
37 | return 1;
|
---|
38 | }
|
---|
39 | if ((p=open(argv[1], O_RDWR, 0))<0) return 1;
|
---|
40 |
|
---|
41 | req.size=2; /* driver does not change any field except data */
|
---|
42 | req.am=0x9; /* "" */
|
---|
43 |
|
---|
44 | printf("search for CAEN-Modules:\n");
|
---|
45 | for (i=0, base=0; i<10; i++, base+=0x10000) {
|
---|
46 | req.addr=base+0xfa;
|
---|
47 | if (ioctl(p, SIS3100_VME_READ, &req)<0) {
|
---|
48 | printerror(&req, errno, 0);
|
---|
49 | } else {
|
---|
50 | printf("data=0x%08x\n", req.data);
|
---|
51 | if (req.data==0xfaf5) { /* CAEN-Module */
|
---|
52 | u_int16_t type, serial;
|
---|
53 | req.addr=base+0xfc;
|
---|
54 | if (ioctl(p, SIS3100_VME_READ, &req)<0) {
|
---|
55 | printerror(&req, errno, 0); return 1;
|
---|
56 | }
|
---|
57 | type=req.data;
|
---|
58 | req.addr=base+0xfe;
|
---|
59 | if (ioctl(p, SIS3100_VME_READ, &req)<0) {
|
---|
60 | printerror(&req, errno, 0); return 1;
|
---|
61 | }
|
---|
62 | serial=req.data;
|
---|
63 | printf("at 0x%x: type=0x%x; serial=%d\n", base, type, serial&0xfff);
|
---|
64 | }
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|
68 | close(p);
|
---|
69 | return 0;
|
---|
70 | }
|
---|