rsp_regr_common.c
6.63 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#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 <rcp.h>
#include <rsp.h>
/* From $ROOT/usr/include/ide, which is installed from PR/diags/include */
#include "diag.h"
#include "dbg_comm.h"
#define DMEM_R1 0x04000f84
#define RSP_TEST_BASE 001
#define RDRAM_SCRATCH_BASE 0x00100000
void mem_init(FILE *file_p, unsigned int start_addr);
int rsp_regrInit();
int rsp_regrDo(TEST_REF *test_ref);
extern int NumFailures = 0;
extern int failed_tests[512];
int rsp_regr(TestRefs)
TEST_REF TestRefs[];
{
int c;
int i;
while ((c = getopt(pGlobalComm->argc, pGlobalComm->argv, "hdet:")) != EOF) {
switch(c) {
case 'h':
dgListSubTests(TestRefs);
return;
case 'd':
printmask = 0xff;
errlog(INFO, "Test will be run in debug mode.");
break;
case 'e':
exitmask = 0x0;
errlog(INFO, "Test will not terminate on errors.");
break;
case 't':
pGlobalComm->entryNum = -atoi(optarg);
errlog(INFO, "Running test %d only.", pGlobalComm->entryNum);
break;
default:
printf("weird option character %c = 0x%x\n", c, c);
break;
}
}
/*
* IDE will call our one-time initialization function rsp_regrInit(),
* then invoke rsp_regrDo() for as many tests as we've put into the
* global test array "TestRefs", declared at the top of this module.
*/
diaginit(TestRefs, rsp_regrInit, rsp_regrDo);
if (NumFailures) {
for (i=1; i<512; i++) {
if (failed_tests[i]) {
errlog(INFO_END, "Test %d: %s failed.", i, TestRefs[i-1].name);
}
}
errlog(ERR_SEVERE, "... test %s FAILED, %d failures.",
ideTestName, NumFailures);
} else {
errlog(INFO_END, "... test %s PASSED", ideTestName);
}
}
int rsp_regrInit()
{
int i;
errlog(INFO, "Starting test %s ... ", ideTestName);
for (i=0; i<512; i++) {failed_tests[i] = 0;}
NumFailures = 0;
dgInitComm();
return(0);
}
int rsp_regrDo(TEST_REF *test_ref)
{
int rc;
errlog(INFO, " %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, "--- subtest %s PASSED", test_ref->name);
else {
errlog(ERR_SEVERE, "--- subtest %s FAILED", test_ref->name);
failed_tests[test_ref->num] = 1;
}
return(NumFailures);
}
void
mem_init(FILE *file_p, unsigned int start_addr)
{
unsigned int data;
int cont = 1;
int c;
while (cont==1) {
cont = fscanf(file_p, "%x", &data);
if (cont==1) {
if ((start_addr & 0xff) == 0)
errlog(DEBUG, "Loading Mem[%x] with %x", start_addr, data);
dgWriteWord(start_addr, data);
}
start_addr +=4;
/* scan to end of line */
while (c != '\n' && c != EOF) {
c = fgetc(file_p);
}
}
}
void
unhalt_and_go()
{
dgWriteWord(0x04080000, 0x00000000); /* Initialize PC */
dgWriteWord(0x04040010, 0x00000005); /* Clear break and halt */
}
int
generic_rsp_regression (const char *file_name)
{
int done = 0;
unsigned int status;
unsigned int r1_contents;
unsigned int pc;
char dmem_file[100];
char imem_file[100];
FILE *file_i;
FILE *file_d;
char ifile[100];
char dfile[100];
sprintf(imem_file, "%s.ihex", file_name);
sprintf(dmem_file, "%s.dhex", file_name);
if (! dgFindFile(ifile, "/PR/diags/rsp", imem_file)) {
if (! dgFindFile(ifile, "/usr/diags/data/rsp",imem_file)){
errlog(ERR_SEVERE,"Could not find file %s",imem_file);}}
if (! dgFindFile(dfile, "/PR/diags/rsp", dmem_file)) {
if (! dgFindFile(dfile, "/usr/diags/data/rsp",dmem_file)){
errlog(ERR_SEVERE,"Could not find file %s",dmem_file);}}
if ((file_i = fopen(ifile, "r")) == NULL) {
errlog(ERR_SEVERE, "could not open file %s", imem_file);
return 1;
}
if ((file_d = fopen(dfile, "r")) == NULL) {
errlog(ERR_SEVERE, "could not open file %s", dmem_file);
return 1;
}
dgWriteWord(DMEM_R1, 0x000c1ea7); /* Clear DMem R1 contents */
mem_init(file_i, RSP_IMEM_BASE);
mem_init(file_d, RSP_DMEM_BASE);
fclose(file_i);
fclose(file_d);
unhalt_and_go();
while (!done) {
dgReadWord(0x04040010, &status); /* Check break status */
done = status & 0x2;
}
dgReadWord(DMEM_R1, &r1_contents);
errlog(DEBUG, "R1 contents:%x", r1_contents);
dgReadWord(0x04080000, &pc);
errlog(DEBUG, "PC::%x", pc);
return((r1_contents != 0x0000feed) && (r1_contents != 0xfeed0000));
}
int
generic_rsp_dma_regression (const char *file_name)
{
int done = 0;
unsigned int status;
unsigned int r1_contents;
unsigned int pc;
char dmem_file[100];
char imem_file[100];
FILE *file_i;
FILE *file_d;
FILE *file_r;
char ifile[100];
char dfile[100];
char rfile[100];
errlog(DEBUG, "dgRdramFree: %x", dgRdramFree);
sprintf(imem_file, "%s.ihex", file_name);
sprintf(dmem_file, "%s.dhex", file_name);
if (! dgFindFile(ifile, "/PR/diags/rsp", imem_file)) {
if (! dgFindFile(ifile, "/usr/diags/data/rsp",imem_file)){
errlog(ERR_SEVERE,"Could not find file %s",imem_file);}}
if (! dgFindFile(dfile, "/PR/diags/rsp", dmem_file)) {
if (! dgFindFile(dfile, "/usr/diags/data/rsp",dmem_file)){
errlog(ERR_SEVERE,"Could not find file %s",dmem_file);}}
if (! dgFindFile(rfile, "/PR/diags/rsp", "dmatests/rdram.rhex")) {
if (! dgFindFile(rfile, "/usr/diags/data/rsp","dmatests/rdram.rhex")){
errlog(ERR_SEVERE,"Could not find file dmatests/rdram.rhex");}}
if ((file_i = fopen(ifile, "r")) == NULL) {
errlog(ERR_SEVERE, "could not open file %s", imem_file);
return 1;
}
if ((file_d = fopen(dfile, "r")) == NULL) {
errlog(ERR_SEVERE, "could not open file %s", dmem_file);
return 1;
}
if ((file_r = fopen(rfile, "r")) == NULL) {
errlog(ERR_SEVERE, "could not open file dmatests/rdram.rhex");
return 1;
}
mem_init(file_i, RSP_IMEM_BASE);
mem_init(file_d, RSP_DMEM_BASE);
mem_init(file_r, RDRAM_SCRATCH_BASE);
fclose(file_i);
fclose(file_d);
fclose(file_r);
unhalt_and_go();
while (!done) {
dgReadWord(0x04040010, &status); /* Check break status */
done = status & 0x2;
}
dgReadWord(DMEM_R1, &r1_contents);
errlog(DEBUG, "R1 contents:%x", r1_contents);
dgReadWord(0x04080000, &pc);
errlog(DEBUG, "PC::%x", pc);
return((r1_contents != 0x0000feed) && (r1_contents != 0xfeed0000));
}