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 | #include <signal.h>
|
---|
11 |
|
---|
12 | #include "dev/pci/sis1100_var.h"
|
---|
13 |
|
---|
14 | int p;
|
---|
15 |
|
---|
16 | /* das sind die CAEN-Module, die ich zufaellig habe, beliebig durcheinander-
|
---|
17 | gewuerfelt und vervielfacht */
|
---|
18 | struct sis1100_pipelist list[]={
|
---|
19 | {0x03010000, 0x09, 0x100fc, 0},
|
---|
20 | {0x0c010000, 0x09, 0x200fa, 0},
|
---|
21 | {0x03010000, 0x09, 0x200fc, 0},
|
---|
22 | {0x0c010000, 0x09, 0x200fe, 0},
|
---|
23 | {0x0c010000, 0x09, 0x300fa, 0},
|
---|
24 | {0x0c010000, 0x09, 0x100fa, 0},
|
---|
25 | {0x03010000, 0x09, 0x300fc, 0},
|
---|
26 | {0x0c010000, 0x09, 0x100fe, 0},
|
---|
27 | {0x0c010000, 0x09, 0x300fe, 0},
|
---|
28 | {0x0c010000, 0x09, 0x400fa, 0},
|
---|
29 | {0x03010000, 0x09, 0x400fc, 0},
|
---|
30 | {0x0c010000, 0x09, 0x400fe, 0},
|
---|
31 | {0x0c010000, 0x09, 0x500fa, 0},
|
---|
32 | {0x03010000, 0x09, 0x500fc, 0},
|
---|
33 | {0x03010000, 0x09, 0x100fc, 0},
|
---|
34 | {0x0c010000, 0x09, 0x200fa, 0},
|
---|
35 | {0x03010000, 0x09, 0x200fc, 0},
|
---|
36 | {0x0c010000, 0x09, 0x200fe, 0},
|
---|
37 | {0x0c010000, 0x09, 0x300fa, 0},
|
---|
38 | {0x0c010000, 0x09, 0x100fa, 0},
|
---|
39 | {0x03010000, 0x09, 0x300fc, 0},
|
---|
40 | {0x0c010000, 0x09, 0x100fe, 0},
|
---|
41 | {0x0c010000, 0x09, 0x300fe, 0},
|
---|
42 | {0x0c010000, 0x09, 0x400fa, 0},
|
---|
43 | {0x03010000, 0x09, 0x100fc, 0},
|
---|
44 | {0x0c010000, 0x09, 0x200fa, 0},
|
---|
45 | {0x03010000, 0x09, 0x200fc, 0},
|
---|
46 | {0x0c010000, 0x09, 0x200fe, 0},
|
---|
47 | {0x03010000, 0x09, 0x100fc, 0},
|
---|
48 | {0x0c010000, 0x09, 0x200fa, 0},
|
---|
49 | {0x03010000, 0x09, 0x200fc, 0},
|
---|
50 | {0x0c010000, 0x09, 0x200fe, 0},
|
---|
51 | {0x0c010000, 0x09, 0x300fa, 0},
|
---|
52 | {0x0c010000, 0x09, 0x100fa, 0},
|
---|
53 | {0x03010000, 0x09, 0x300fc, 0},
|
---|
54 | {0x0c010000, 0x09, 0x100fe, 0},
|
---|
55 | {0x0c010000, 0x09, 0x300fe, 0},
|
---|
56 | {0x0c010000, 0x09, 0x400fa, 0},
|
---|
57 | {0x03010000, 0x09, 0x400fc, 0},
|
---|
58 | {0x0c010000, 0x09, 0x400fe, 0},
|
---|
59 | {0x0c010000, 0x09, 0x500fa, 0},
|
---|
60 | {0x03010000, 0x09, 0x500fc, 0},
|
---|
61 | {0x03010000, 0x09, 0x100fc, 0},
|
---|
62 | {0x0c010000, 0x09, 0x200fa, 0},
|
---|
63 | {0x03010000, 0x09, 0x200fc, 0},
|
---|
64 | {0x0c010000, 0x09, 0x200fe, 0},
|
---|
65 | {0x0c010000, 0x09, 0x300fa, 0},
|
---|
66 | {0x0c010000, 0x09, 0x100fa, 0},
|
---|
67 | {0x03010000, 0x09, 0x300fc, 0},
|
---|
68 | {0x0c010000, 0x09, 0x100fe, 0},
|
---|
69 | {0x0c010000, 0x09, 0x300fe, 0},
|
---|
70 | {0x0c010000, 0x09, 0x400fa, 0},
|
---|
71 | {0x0c010000, 0x09, 0x300fa, 0},
|
---|
72 | {0x0c010000, 0x09, 0x100fa, 0},
|
---|
73 | {0x03010000, 0x09, 0x300fc, 0},
|
---|
74 | {0x0c010000, 0x09, 0x100fe, 0},
|
---|
75 | {0x0c010000, 0x09, 0x300fe, 0},
|
---|
76 | {0x0c010000, 0x09, 0x400fa, 0},
|
---|
77 | {0x03010000, 0x09, 0x400fc, 0},
|
---|
78 | {0x0c010000, 0x09, 0x400fe, 0},
|
---|
79 | {0x0c010000, 0x09, 0x500fa, 0},
|
---|
80 | {0x03010000, 0x09, 0x500fc, 0},
|
---|
81 | {0x03010000, 0x09, 0x100fc, 0},
|
---|
82 | {0x0c010000, 0x09, 0x200fa, 0},
|
---|
83 | {0x03010000, 0x09, 0x200fc, 0},
|
---|
84 | {0x0c010000, 0x09, 0x200fe, 0},
|
---|
85 | {0x0c010000, 0x09, 0x300fa, 0},
|
---|
86 | {0x0c010000, 0x09, 0x100fa, 0},
|
---|
87 | {0x03010000, 0x09, 0x300fc, 0},
|
---|
88 | {0x0c010000, 0x09, 0x100fe, 0},
|
---|
89 | {0x0c010000, 0x09, 0x300fe, 0},
|
---|
90 | {0x0c010000, 0x09, 0x400fa, 0},
|
---|
91 | {0x03010000, 0x09, 0x400fc, 0},
|
---|
92 | {0x0c010000, 0x09, 0x400fe, 0},
|
---|
93 | {0x0c010000, 0x09, 0x500fa, 0},
|
---|
94 | {0x03010000, 0x09, 0x500fc, 0},
|
---|
95 | {0x03010000, 0x09, 0x100fc, 0},
|
---|
96 | {0x0c010000, 0x09, 0x200fa, 0},
|
---|
97 | {0x03010000, 0x09, 0x200fc, 0},
|
---|
98 | {0x0c010000, 0x09, 0x200fe, 0},
|
---|
99 | {0x0c010000, 0x09, 0x300fa, 0},
|
---|
100 | {0x0c010000, 0x09, 0x100fa, 0},
|
---|
101 | {0x03010000, 0x09, 0x300fc, 0},
|
---|
102 | {0x0c010000, 0x09, 0x100fe, 0},
|
---|
103 | {0x0c010000, 0x09, 0x300fe, 0},
|
---|
104 | {0x0c010000, 0x09, 0x400fa, 0},
|
---|
105 | {0x03010000, 0x09, 0x400fc, 0},
|
---|
106 | {0x0c010000, 0x09, 0x400fe, 0},
|
---|
107 | {0x0c010000, 0x09, 0x500fa, 0},
|
---|
108 | {0x03010000, 0x09, 0x500fc, 0},
|
---|
109 | {0x03010000, 0x09, 0x300fc, 0},
|
---|
110 | {0x0c010000, 0x09, 0x100fe, 0},
|
---|
111 | {0x0c010000, 0x09, 0x300fe, 0},
|
---|
112 | {0x0c010000, 0x09, 0x400fa, 0},
|
---|
113 | {0x03010000, 0x09, 0x400fc, 0},
|
---|
114 | {0x0c010000, 0x09, 0x400fe, 0},
|
---|
115 | {0x0c010000, 0x09, 0x500fa, 0},
|
---|
116 | {0x03010000, 0x09, 0x500fc, 0},
|
---|
117 | {0x03010000, 0x09, 0x100fc, 0},
|
---|
118 | {0x0c010000, 0x09, 0x200fa, 0},
|
---|
119 | {0x03010000, 0x09, 0x200fc, 0},
|
---|
120 | {0x0c010000, 0x09, 0x200fe, 0},
|
---|
121 | {0x0c010000, 0x09, 0x300fa, 0},
|
---|
122 | {0x0c010000, 0x09, 0x100fa, 0},
|
---|
123 | {0x03010000, 0x09, 0x300fc, 0},
|
---|
124 | {0x0c010000, 0x09, 0x100fe, 0},
|
---|
125 | {0x0c010000, 0x09, 0x300fe, 0},
|
---|
126 | {0x0c010000, 0x09, 0x400fa, 0},
|
---|
127 | {0x03010000, 0x09, 0x400fc, 0},
|
---|
128 | {0x0c010000, 0x09, 0x400fe, 0},
|
---|
129 | {0x0c010000, 0x09, 0x500fa, 0},
|
---|
130 | {0x03010000, 0x09, 0x500fc, 0},
|
---|
131 | {0x0c010000, 0x09, 0x500fe, 0}
|
---|
132 | };
|
---|
133 |
|
---|
134 |
|
---|
135 | static int pipeline_read(int p, struct sis1100_pipelist* list, int listlen,
|
---|
136 | u_int32_t* data, int seq)
|
---|
137 | {
|
---|
138 | struct sis1100_pipe pipe;
|
---|
139 |
|
---|
140 | pipe.num=listlen;
|
---|
141 | pipe.list=list;
|
---|
142 | pipe.data=data;
|
---|
143 |
|
---|
144 | if (ioctl(p, SIS1100_PIPE, &pipe)<0) {
|
---|
145 | printf("ioctl(SIS1100_PIPE): %s\n", strerror(errno));
|
---|
146 | return -1;
|
---|
147 | }
|
---|
148 | if (pipe.error) printf("error=0x%x\n", pipe.error);
|
---|
149 | return 0;
|
---|
150 | }
|
---|
151 |
|
---|
152 | volatile int stop=0;
|
---|
153 |
|
---|
154 | static void hand(int sig)
|
---|
155 | {
|
---|
156 | printf("signal %d\n", sig);
|
---|
157 | stop=1;
|
---|
158 | }
|
---|
159 |
|
---|
160 | int main(int argc, char* argv[])
|
---|
161 | {
|
---|
162 | int num, loopcount, reqcount, i, j, *data;
|
---|
163 | int* comp, comp_valid, dot;
|
---|
164 | struct sigaction act;
|
---|
165 |
|
---|
166 | if (argc<4)
|
---|
167 | {
|
---|
168 | fprintf(stderr, "usage: %s path reqcount loopcount\n", argv[0]);
|
---|
169 | return 1;
|
---|
170 | }
|
---|
171 | if ((p=open(argv[1], O_RDWR, 0))<0) {
|
---|
172 | perror("open");
|
---|
173 | return 1;
|
---|
174 | }
|
---|
175 |
|
---|
176 | reqcount=atoi(argv[2]);
|
---|
177 | loopcount=atoi(argv[3]);
|
---|
178 |
|
---|
179 | act.sa_handler=hand;
|
---|
180 | sigemptyset(&act.sa_mask);
|
---|
181 | act.sa_flags=0;
|
---|
182 | sigaction(SIGINT, &act, 0);
|
---|
183 | sigaction(SIGQUIT, &act, 0);
|
---|
184 |
|
---|
185 | num=sizeof(list)/sizeof(struct sis1100_pipelist);
|
---|
186 | if (reqcount<num) num=reqcount;
|
---|
187 | printf("listlen=%d; loopcount=%d\n", num, loopcount);
|
---|
188 |
|
---|
189 | data=(u_int32_t*)malloc(num*sizeof(u_int32_t));
|
---|
190 | comp=(u_int32_t*)malloc(num*sizeof(u_int32_t));
|
---|
191 | comp_valid=0;
|
---|
192 |
|
---|
193 | if (!data) {
|
---|
194 | printf("malloc: %s\n", strerror(errno));
|
---|
195 | return 1;
|
---|
196 | }
|
---|
197 | for (i=0; i<num; i++) data[i]=0x12345678; /* just for test */
|
---|
198 | dot=10000/num;
|
---|
199 | for (j=0; j<loopcount; j++) {
|
---|
200 | if (stop || (pipeline_read(p, list, num, data, j)<0)) goto raus;
|
---|
201 | if (comp_valid) {
|
---|
202 | for (i=0; i<num; i++) {
|
---|
203 | if (comp[i]!=data[i]) printf("[%d] %08x-->%08x\n",
|
---|
204 | i, comp[i], data[i]);
|
---|
205 | }
|
---|
206 | } else {
|
---|
207 | for (i=0; i<num; i++) comp[i]=data[i];
|
---|
208 | comp_valid=1;
|
---|
209 | }
|
---|
210 | if ((j%dot)==0) {printf("."); fflush(stdout);}
|
---|
211 | }
|
---|
212 | raus:
|
---|
213 | printf("tranferred %d words\n", j*num);
|
---|
214 | for (i=0; i<num; i++)
|
---|
215 | printf("[%2d] %x: %08x\n", i, list[i].addr, data[i]&0xffff);
|
---|
216 | close(p);
|
---|
217 | return 0;
|
---|
218 | }
|
---|