writeword.c
912 Bytes
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
/*
* Simple app to test memory interface for writing words.
*/
#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>
int commtype=DG_VERILOG;
void main(int argc, char **argv) {
unsigned int vaddr, data;
if (argc == 3) {
vaddr = (int)strtoul (argv[1], (char **)NULL, 0);
data = (int)strtoul (argv[2], (char **)NULL, 0);
} else {
printf("Usage: writeword vaddr len data\n");
exit (1);
}
printf("vaddr 0x%x data 0x%x\n", vaddr, data);
if ( dgInitComm() ) {
fprintf(stderr,
"%s: unable to initialize communication with target system.\n",
argv[0]);
exit(1);
}
if ( dgWriteMem (vaddr, 4, (char *) (&data) ) ) {
fprintf(stderr,
"%s: unable to write target system memory.\n",
argv[0]);
}
exit(0);
}
void
errlog()
{
}