reg.c
1.94 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
#include <sys/types.h>
#ifdef __sgi__
#include <sys/sbd.h>
#endif
#include <sys/stat.h>
#include <sys/mman.h>
#ifdef __sgi__
#include <sys/sema.h>
#endif
#include <netinet/in.h>
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <getopt.h>
#include "diag.h"
#include "dbg_comm.h"
int
dgReg(struct diagcomm *pcomm)
{
int c;
static unsigned int address, data;
int no_args = 1;
extern char *optarg;
extern int optind;
while ((c = getopt(pGlobalComm->argc, pGlobalComm->argv, "ia:d:rwv:p:g"))!=EOF) {
switch(c) {
case 'i':
if (dgInitComm()) return 1;
no_args = 0;
break;
case 'a':
address = atoi(optarg);
no_args = 0;
break;
case 'd':
data = atoi(optarg);
no_args = 0;
break;
case 'r':
if (dgInitialize) {
if (dgInitComm()) return 1;
}
dgReadWord(address, &data);
printf("read address = 0x%08x, data = 0x%08x\n", address, data);
no_args = 0;
break;
case 'w':
if (dgInitialize) {
if (dgInitComm()) return 1;
}
dgWriteWord(address, data);
printf("write address = 0x%08x, data = 0x%08x\n", address, data);
no_args = 0;
break;
case 'v':
dgEnableVideo(address, atoi(optarg));
break;
case 'p':
address = 0x80000000;
data = atoi(optarg);
if (dgInitialize) {
if (dgInitComm()) return 1;
}
dgWriteWord(address, data);
printf("write address = 0x%08x, data = 0x%08x\n", address, data);
no_args = 0;
break;
case 'g':
address = 0x80000000;
if (dgInitialize) {
if (dgInitComm()) return 1;
}
dgReadWord(address, &data);
printf("read address = 0x%08x, data = 0x%08x\n", address, data);
no_args = 0;
break;
default:
return(0);
break;
}
}
if (no_args) {
printf("address = 0x%08x, data = 0x%08x\n", address, data);
}
return(0);
}