dmaWrite.c
2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <netinet/in.h>
#include <bstring.h>
#include <diag.h>
#include <dbg_comm.h>
extern dbg_comm_struct dbg_comm;
int commtype = DG_TINYMON_DMEM;
/*
* dmaWrite tests the ability of dgDmaWriteMem() to setup a DMA operation from
* ramrom to rdram.
*/
void main(int argc, char **argv) {
unsigned int ramromAddr, rdramAddr, len;
unsigned int ramromData, rdramData;
int i, j;
int ret_len;
char *buf;
if (argc == 4) {
ramromAddr = (int)strtoul (argv[1], (char **)NULL, 0);
rdramAddr = (int)strtoul (argv[2], (char **)NULL, 0);
len = (int)strtol (argv[3], (char **)NULL, 0);
} else {
printf("Usage: dmaWrite ramromAddr rdramAddr len, where len is a multiple of 4\n");
exit (1);
}
if (len %4) {
printf("Usage: dmaWrite ramromAddr rdramAddr len, where len is a multiple of 4\n");
exit (1);
}
printf("ramromAddr 0x%x rdramAddr 0x%x len %d\n",
ramromAddr, rdramAddr, len);
printf("dma write of %d bytes from ramromAddr 0x%x to rdramAddr 0x%x\n",
len, ramromAddr, rdramAddr);
if ( dgInitComm() ) {
fprintf(stderr,
"%s: unable to initialize communication with target system.\n",
argv[0]);
exit(1);
}
/*
* Initialize ramrom and rdram to known values.
*/
for (i = 0; i < len; i+=4) {
dgWriteWord( ramromAddr + i, i );
dgReadWord( ramromAddr + i, &ramromData);
if (ramromData != i) {
fprintf(stderr, "ERROR: (init readback): ramrom(0x%x): exp 0x%x, read 0x%x\n",
ramromAddr + i, i, ramromData);
} else {
fprintf(stderr, "INFO: (init readback): ramrom(0x%x): read 0x%x\n",
ramromAddr + i, i, ramromData);
}
dgWriteWord( rdramAddr + i, ~i );
dgReadWord( rdramAddr + i, &rdramData);
if (rdramData != ~i) {
fprintf(stderr, "ERROR: (init readback): rdram(0x%x): exp 0x%x, read 0x%x\n",
rdramAddr + i, ~i, rdramData);
} else {
fprintf(stderr, "INFO: (init readback): rdram(0x%x): read 0x%x\n",
rdramAddr + i, rdramData);
}
}
buf = malloc(len);
if ( dgDmaWriteMem(ramromAddr, rdramAddr, len) ) {
fprintf(stderr,
"%s: unable to setup requested dma operation on target system.\n",
argv[0]);
exit(1);
}
for (i = 0; i < len; i+=4) {
dgReadWord( ramromAddr + i, &ramromData);
dgReadWord( rdramAddr + i, &rdramData);
if (rdramData != ramromData) {
fprintf(stderr,
"ERROR: (dma readback): ramrom(0x%x) = 0x%x != rdram(0x%x) = 0x%x\n",
ramromAddr + i, ramromData,
rdramAddr + i, rdramData);
} else {
fprintf(stderr,
"INFO: (dma readback): ramrom(0x%x) = 0x%x == rdram(0x%x) = 0x%x\n",
ramromAddr + i, ramromData,
rdramAddr + i, rdramData);
}
}
exit(0);
}
void
errlog() {
}
char *ideTestName;