rdpDump.c
3.46 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#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 <sys/u64driver.h>
#include <diag.h>
#include <dbg_comm.h>
#define RDP_DUMP_TEST_BASE 10
static int rdpDump(TEST_REF *test_ref);
/*
* Create an array of tests, each of which corresponds to a separate menu
* item callable from the master ide menu.
*/
static TEST_REF TestRefs[] = {
{"Dump of important RDP registers", RDP_DUMP_TEST_BASE+0, rdpDump},
{"",0,0}
};
static char *addr, *mask, *count;
static int NumFailures = 0;
static int rdpDump_Init();
static int rdpDump_Do(TEST_REF *test_ref);
/*
* diagnostic entry point:
*
* Each separately invokable ide diagnostic command corresponds to an
* independent ".c" module; the entry point herein must match
* the test name as specified in the commoncmd.awk script. These command
* names correspond to the names you see from the ide menu.
*/
int
dgRdpDumpEntry()
{
int c, testNum;
int i;
for (i = 0; i < pGlobalComm->argc; i++) {
printf("argv[%d] = %s\n", i, pGlobalComm->argv[i]);
}
/*
* Sample of how to parse command line args received from ide
*/
while ((c = getopt(pGlobalComm->argc, pGlobalComm->argv, "ht:")) != EOF) {
switch(c) {
case 'h':
/*
* Print out the available subtests, then return without
* invoking any subtests (which is done by calling diaginit()).
*/
dgListSubTests(TestRefs);
return(0);
break;
case 't':
testNum = atoi(optarg);
pGlobalComm->entryNum = -(testNum);
break;
default:
printf("weird option character %c = 0x%x\n", c, c);
while (1);
break;
}
}
return;
/*
* IDE will call our one-time initialization function rdpDump_Init(),
* then invoke rdpDump_Do() for as many tests as we've put into the
* global test array "TestRefs", declared at the top of this module.
*/
diaginit(TestRefs, rdpDump_Init, rdpDump_Do);
if (NumFailures) {
errlog(INFO_END, "... test %s FAILED, %d failures.",
ideTestName, NumFailures);
} else {
errlog(INFO_END, "... test %s PASSED", ideTestName);
}
}
static int rdpDump_Init()
{
char *env;
errlog(INFO_START, "Starting test %s ... ", ideTestName);
NumFailures = 0;
/*
* Setup the diagnostic communication link to the target system.
*/
if ( dgInitComm() ) {
errlog(ERR_SEVERE,
"Unable to initialize communication with target system.\n");
pGlobalComm->entryNum = -1;
}
return(0);
}
static int rdpDump_Do(TEST_REF *test_ref)
{
int rc;
errlog(INFO_START, "%s: starting subtest %s (%d) ...",
ideTestName, test_ref->name, test_ref->num);
/*
* Invoke the actual test from the "TEST_REF" array statically declared
* as a global within this test module.
*/
if (rc = test_ref->fnc(test_ref)) NumFailures++;
if (rc == 0) {
errlog(INFO_END, "... PASSED");
} else {
errlog(INFO_END, "... FAILED");
}
return(NumFailures);
}
/*
* Return value: number of errors encountered. "Zero" indicates success.
*/
int
rdpDump(TEST_REF *test_ref)
{
int i;
unsigned int revision1, revision;
dgReadWord(0x04300004, &revision1);
for (i = 0; i < 10000000; i++) {
dgReadWord(0x04300004, &revision);
if (revision != revision1)
errlog(INFO, "ulp!\n");
}
return(0);
}