dbg-dump.c
1022 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
48
49
50
51
52
53
54
55
56
57
58
59
60
/* dbg-dump.c v1 Frank Berndt
* debug board sram dump;
* :set tabstop=4
*/
#include <sys/file.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <linux/parport.h>
#include "dbp.h"
/*
* main entry;
*/
int
main(int argc, char **argv)
{
int ret, p, n;
char *msg;
u_char ctrl;
u_short rbuf[16];
/*
* open the parallel port;
* configure the fpga;
*/
ret = dbp_open(dbp_TinyMon, 0);
/*
* reset the semaphores;
*/
dbp_cr(1);
ret = dbp_ctrl(0, &ctrl);
printf("host ctrl 0x%x, ret %d\n", ctrl, ret);
/*
* dump entire sram;
*/
for(p = 0; p < 2048; p += 32) {
ret = dbp_set_rptr(p); /* set rptr */
msg = "read ctrl";
if(ret < 0)
break;
ret = dbp_read_data(rbuf, sizeof(rbuf));
msg = "read data";
if(ret <= 0)
break;
for(n = 0; n < 16; n += 4) {
printf("%04d 0x%04x 0x%04x 0x%04x 0x%04x\n",
p + n*2, rbuf[n+0], rbuf[n+1], rbuf[n+2], rbuf[n+3]);
}
}
if(ret <= 0)
printf("%s: %s: %s\n", argv[0], msg, strerror(errno));
dbp_close();
exit(1);
}