uji.c
8.45 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
#include <ultra64.h>
#include "gng.h"
extern void playSubway(void);
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;
#ifndef _FINALROM
if (!zaruexists) /* Assume everything is OK if no Zaru */
return GNG_TEST_SUCCESS;
#endif
/* 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;
#ifndef _FINALROM
if (!zaruexists) /* Assume everything is OK if no Zaru */
return GNG_TEST_SUCCESS;
#endif
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];
#ifndef _FINALROM
if (!zaruexists) /* Assume everything is OK if no Zaru */
return GNG_TEST_SUCCESS;
#endif
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);
osPiStartDma(&dmaIOMessageBuf,OS_MESG_PRI_NORMAL,OS_WRITE,
(u32)_staticSegmentRomStart,staticSegment,0x10,&dmaMessageQ);
(void)osRecvMesg(&dmaMessageQ,&dummyMessage,OS_MESG_BLOCK);
/* 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) */
ZaruSetExpCommand(ZARU_EXP_CMD_RW_COUNTS);
ZaruSetADBusCheck(ZARU_OFF, 0);
itmp0 = ZaruReadReg(REG_3000);
return(0x84^itmp0);
#if 0
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);
#endif
}
/* Return values from ssnRWchk */
#define MASK_READ 0x000f
#define MASK_WRITE 0x00f0
int chk50PReadWrite( ) {
char state = 0;
char message[256];
#ifndef _FINALROM
if (!zaruexists) /* Assume everything is OK if no Zaru */
return GNG_TEST_SUCCESS;
#endif
sprintf(message,"When push yellow button\nAD16BUS RW ACCESS");
gng_report(message, 1, GNG_INHIBIT_PRINT, 0);
ZaruWriteReg2(REG_RW50P,ZARU_RW50PSTART); /* sasano added */
ZaruWaitForNextTestButton();
/* while(ZaruGetNextTestButton()==0){}*/
state = ssnRWchk();
ZaruWriteReg2(REG_RW50P,ZARU_RW50PEND); /* sasano added */
return GNG_TEST_SUCCESS; /* sasano added */
#if 0
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;
}
#endif
}
/* Check that we are properly generating AD16 addresses on the bottom connector*/
int AD16_LatchTest(u32 testadd) {
volatile u32* ptr;
short i0,i1,i2,i3;
char message[256];
int i;
sprintf(message,"Address latched test\n(%x)\nPress yello button\n to continue",testadd);
gng_report(message, 1, GNG_INHIBIT_PRINT, 0);
ZaruWriteReg2(REG_LATCH,ZARU_LATCHSTART); /* sasano added */
ZaruWaitForNextTestButton();
ptr=(u32*)(PHYS_TO_K1(testadd));
i0=*(ptr);
ZaruWriteReg2(REG_LATCH,ZARU_LATCHEND); /* sasano added */
sprintf(message,"Address latched test finished.\n(%x)\nPress yello button\n to continue",testadd);
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
return GNG_TEST_SUCCESS;
}
int AD16_LatchTest1(){
return(AD16_LatchTest((ZaruReadReg2(REG_LATCHADD3)<<24)
+(ZaruReadReg2(REG_LATCHADD2)<<16)
+(ZaruReadReg2(REG_LATCHADD1)<< 8)
+(ZaruReadReg2(REG_LATCHADD0))));
}
int AD16_LatchTest2(){
return(AD16_LatchTest((ZaruReadReg2(REG_LATCHADD7)<<24)
+(ZaruReadReg2(REG_LATCHADD6)<<16)
+(ZaruReadReg2(REG_LATCHADD5)<< 8)
+(ZaruReadReg2(REG_LATCHADD4))));
}