1 | /*
|
---|
2 | * $ZEL$
|
---|
3 | */
|
---|
4 |
|
---|
5 | #include "test_3100.h"
|
---|
6 |
|
---|
7 | int
|
---|
8 | check_r_block(struct path* path, u_int32_t start, u_int32_t max)
|
---|
9 | {
|
---|
10 | int i, res, first, count, size;
|
---|
11 |
|
---|
12 | printf("check_r_block: max=0x%08x\n", max);
|
---|
13 |
|
---|
14 | for (i=0; i<max; i++) {
|
---|
15 | buf[i]=i;
|
---|
16 | }
|
---|
17 |
|
---|
18 | if (lseek(path->p, start, SEEK_SET)!=start) {
|
---|
19 | printf("\nlseek(%s, 0x%08x, SEEK_SET): %s\n",
|
---|
20 | path->name, start, strerror(errno));
|
---|
21 | return -1;
|
---|
22 | }
|
---|
23 |
|
---|
24 | for (i=0; i<max; i++) {
|
---|
25 | res=write(path->p, buf+i, 4);
|
---|
26 | if (res!=4) {
|
---|
27 | printf("\nwrite(%s, start+%d): %s\n", path->name, i, strerror(errno));
|
---|
28 | return -1;
|
---|
29 | }
|
---|
30 | }
|
---|
31 |
|
---|
32 | for (size=max; size<=max; size++) {
|
---|
33 | if (lseek(path->p, start, SEEK_SET)!=start) {
|
---|
34 | printf("\nlseek(%s, 0x%08x, SEEK_SET): %s\n",
|
---|
35 | path->name, start, strerror(errno));
|
---|
36 | return -1;
|
---|
37 | }
|
---|
38 | for (i=0; i<size; i++) {
|
---|
39 | buf[i]=~i;
|
---|
40 | }
|
---|
41 | res=read(path->p, buf, 4*size);
|
---|
42 | if (res!=4*size) {
|
---|
43 | u_int32_t err;
|
---|
44 | printf("\nread(%s, ..., 4*%d): ", path->name, size);
|
---|
45 | if (res&3) printf("res=%d\n", res);
|
---|
46 | if (res>=0) {
|
---|
47 | printf("res=%d (%4d)\n", res/4, size-res/4);
|
---|
48 | } else {
|
---|
49 | printf("%s\n", strerror(errno));
|
---|
50 | }
|
---|
51 | if (ioctl(path->p, SIS1100_LAST_ERROR, &err)<0) {
|
---|
52 | printf("\nioctl(%s, LAST_ERROR): %s\n",
|
---|
53 | path->name, strerror(errno));
|
---|
54 | } else {
|
---|
55 | if (err==0x211)
|
---|
56 | return 0;
|
---|
57 | else
|
---|
58 | printf("prot_err: 0x%x\n", err);
|
---|
59 | }
|
---|
60 | return -1;
|
---|
61 | }
|
---|
62 | first=1; count=0;
|
---|
63 | for (i=0; i<size; i++) {
|
---|
64 | if (buf[i]!=i) {
|
---|
65 | if (first) {
|
---|
66 | printf("\n%s: check_r_block (max=%d size=%d):\n",
|
---|
67 | path->name, max, size);
|
---|
68 | first=0;
|
---|
69 | }
|
---|
70 | printf("[%3d]: %08x --> %08x\n", i, i, buf[i]);
|
---|
71 | count++;
|
---|
72 | }
|
---|
73 | }
|
---|
74 | if (count) return -1;
|
---|
75 | }
|
---|
76 | return 0;
|
---|
77 | }
|
---|