uji.c
7.55 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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
/**************************************************************************
* *
* Copyright (C) 1995, 1996 Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
*************************************************************************/
#include <ultra64.h>
#include "gng.h"
extern void playSubway(void);
/*
* File: uji.c
* Creator: scott@sgi.com
* Purpose: Ported code, from uji_diags.c, for tests that require
* the Zaru jig.
*/
static u8 controllerdata[] = {
0x00,
0x55,
0xaa,
0xff,
0x01,
0x02,
0x04,
0x08,
0x10,
0x20,
0x40,
0x80,
};
/*
* Check the power, ground, and other signal bits.
* These are scattered around in the zaru address space
*/
int
VoltageTest()
{
int retvalue = GNG_TEST_SUCCESS; /* assume success */
u8 data;
if (!zaruexists) /* Assume everything is OK if no Zaru */
return GNG_TEST_SUCCESS;
/* First check the Power line register (0x1800) */
data = ZaruGetPowerCheck();
/*
* check that only the bits that should be on are on
* and that only those bits are on.
*/
if (data ^ (ZARU_V2 | ZARU_V3 | ZARU_V4 | ZARU_GND1CHK | ZARU_GND2CHK))
retvalue = GNG_TEST_FAILURE;
data = ZaruGetMisc();
if ( (data & ZARU_MISC_5VCHKCON) == 0)
retvalue = GNG_TEST_FAILURE;
ZaruSetExpCommand(ZARU_EXP_CMD_GND);
data = ZaruGetExpHigh();
/*
* check that only the bits that should be on are on
* and that only those bits are on.
* XXXX - also checking SEC1, SEC2, CCLK & CSYNC
*/
if (data ^ (ZARU_SEC1 | ZARU_SEC2 | ZARU_CCLK | ZARU_CSYNC))
retvalue = GNG_TEST_FAILURE;
data = ZaruGetExpLow();
/*
* check that only the bits that should be on are on
* and that only those bits are on.
*/
if (data)
retvalue = GNG_TEST_FAILURE;
ZaruSetExpCommand(ZARU_EXP_CMD_VOLT);
data = ZaruGetExpLow();
data &= (ZARU_12V1 | ZARU_3V0 | ZARU_3V1 | ZARU_3V2); /* some bits unused!!! */
/*
* check that only the bits that should be on are on
* and that only those bits are on.
*/
if (data ^ (ZARU_12V1 | ZARU_3V0 | ZARU_3V1 | ZARU_3V2))
retvalue = GNG_TEST_FAILURE;
return retvalue;
}
/*
* Check that the reset time is in acceptable range
*/
int
ResetTimeTest()
{
int resettime;
if (!zaruexists) /* Assume everything is OK if no Zaru */
return GNG_TEST_SUCCESS;
resettime = ZaruGetResetTime();
if (resettime >= ZARU_RESET_LOW && resettime <= ZARU_RRESET_HIGH)
return GNG_TEST_SUCCESS;
else
return GNG_TEST_FAILURE;
}
/*
* Test Joy ports 2, 3, and 4
* There is only one switch register. You cannot write different
* data values to 2, 3, and 4 and then expect those values to be
* read back. Only the data from the last write is available.
*/
int
ControllerTest()
{
u16 buttons;
u8 select;
int i, j;
char message[256];
if (!zaruexists) /* Assume everything is OK if no Zaru */
return GNG_TEST_SUCCESS;
gng_report(
"Controller test:\nPlease wiggle (shake)\ncontroller inputs\nduring test.\n\nPress yellow button\nto continue...",
0, GNG_INHIBIT_PRINT, 0);
/*
* Play an alert noise to indicate to the user that they need to press
* the button.
*/
playSubway();
while (ZaruGetNextTestButton() == 0) {
/*
* test joy ports 2, 3, and 4.
*/
for (i = 2; i < 5; i++) {
switch (i) {
case 2:
select = ZARU_JOY_SELECT_2;
break;
case 3:
select = ZARU_JOY_SELECT_3;
break;
case 4:
select = ZARU_JOY_SELECT_4;
break;
default:
sprintf(message, "Controller test:\nillegal controller index %d", i);
gng_report(message, 0, GNG_INHIBIT_PRINT, 120);
break;
}
ZaruSetJoySelect(select);
for (j = 0; j < sizeof(controllerdata)/sizeof(u8); j++) {
ZaruSetJoyButtons(controllerdata[j]);
if (ZaruButtonCheck(controllerdata[j], ZaruReadControllerButton(i-1))
== GNG_TEST_FAILURE) {
sprintf(message, "Controller test:\ncontroller %d no good", i);
gng_report(message, 1, GNG_PASS_FAIL_BIT, 0);
/*
* Not reached.
*/
return GNG_TEST_FAILURE;
}
}
}
}
return GNG_TEST_SUCCESS;
}
/*
* New functions from uji "checker" program
*/
/*
* Import globals from ../testDriver/main.c:
*/
extern OSMesgQueue dmaMessageQ, rspMessageQ, rdpMessageQ, retraceMessageQ;
extern OSMesg dmaMessageBuf, rspMessageBuf, rdpMessageBuf,
retraceMessageBuf;
extern OSMesg dummyMessage;
extern OSIoMesg dmaIOMessageBuf;
extern char *staticSegment;
#define AD16BUSTEST 0x12345678
/*
* Symbols generated by "makerom" to tell us where the static segment is
* in ROM.
*/
extern char _staticSegmentRomStart[], _staticSegmentRomEnd[];
char ssnRWchk(void){
volatile u32* ptr0;
int itmp0,itmp1;
volatile unsigned long ltmp0;
ZaruSetADBusCheck(ZARU_ON, 1);
/*
* Perform 4 reads to AD16 address space
* (these will be counted by the Zaru)
*/
ptr0=(u32*)(PHYS_TO_K1(AD16BUSTEST));
osInvalDCache((void *)ptr0, 4);
ltmp0=*(ptr0++);
osInvalDCache((void *)ptr0, 4);
ptr0=(u32*)(PHYS_TO_K1(AD16BUSTEST));
ltmp0=*(ptr0++);
ZaruSetExpCommand(ZARU_EXP_CMD_RW_COUNTS);
ZaruSetADBusCheck(ZARU_OFF, 0);
ZaruSetADBusCheck(ZARU_ON, 1);
/*
* Perform 8 writes to AD16 using DMA (to avoid dcache problems)
* (these will be counted by the Zaru)
*/
osPiStartDma(&dmaIOMessageBuf,OS_MESG_PRI_NORMAL,OS_WRITE,
(u32)_staticSegmentRomStart,staticSegment,0x10,&dmaMessageQ);
(void)osRecvMesg(&dmaMessageQ,&dummyMessage,OS_MESG_BLOCK);
ZaruSetExpCommand(ZARU_EXP_CMD_RW_COUNTS);
ZaruSetADBusCheck(ZARU_OFF, 0);
itmp0 = ZaruReadReg(REG_3000);
return(0x84^itmp0);
}
/*
* Return values from ssnRWchk
*/
#define MASK_READ 0x000f
#define MASK_WRITE 0x00f0
int chk50PReadWrite( ) {
char state = 0;
char message[256];
if (!zaruexists) /* Assume everything is OK if no Zaru */
return GNG_TEST_SUCCESS;
state = ssnRWchk(); /* ^[$B:{Ln$5$s$N%W%m%0%i%`$+$i8!::7k2L$rF@$k^[(B
*/
if (state) {
sprintf(message,
"AD16 BUS RW ERROR:\nexpected 0x0\nread 0x%x\n",
state);
gng_report(message, 1, GNG_PASS_FAIL_BIT, 0);
return GNG_TEST_FAILURE;
} else {
return GNG_TEST_SUCCESS;
}
}
#define AD16_TEST_ADDRESS 0x12345678
/*
* Check that we are properly generating AD16 addresses on the bottom connector.
*/
int
AD16_LatchedAddressTest()
{
unsigned int *latchedAddress;
char message[256];
if (!zaruexists) /* Assume everything is OK if no Zaru */
return GNG_TEST_SUCCESS;
latchedAddress = ZaruGetAD16Address((unsigned int *)AD16_TEST_ADDRESS);
if (latchedAddress == (unsigned int *)AD16_TEST_ADDRESS) {
return GNG_TEST_SUCCESS;
} else {
sprintf(message,
"AD16 BUS ADDRESS LATCH ERROR:\nexpected 0x%x\nread 0x%x\n",
AD16_TEST_ADDRESS, latchedAddress);
gng_report(message, 1, GNG_INHIBIT_PRINT, 1200);
return GNG_TEST_FAILURE;
}
}