testDriver.c.euc
12.6 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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
/***************************************************************************
NUS検査プログラム順序検査プログラムとそのた小物検査プログラム
*************************************************************************/
/***************************************************************************
改訂履歴 和田
96/10 コントローラ検査関数ContTestから不要なV−Sync待ちを省く
************************************************************************/
#include <ultra64.h>
#include "testDriver.h"
#include "gng.h"
extern void ssn(void);
extern int controllerSlot;
Test_t testList[] = {
/* debug */
{ 0,&(intr1test) ,"Cartridge Interrupt" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexINT },
{ 0,&(ContTest) ,"Controller test" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexCONT },
{ 0,&(rdramTest) ,"RDRAM memory" ,GNG_PASS_FAIL_BIT , PASS_MESSAGE_RETRACE_COUNT,IndexRDRAM },
{ 0,&(clocktest) ,"62.5MHz Clock" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexCLOCK },
#if 0
{ 0,&(intr1test) ,"Cartridge Interrupt" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexINT },
#endif
{ 0,&(pifCheck) ,"PIF controller" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexPIF },
{ 0,&(chk50PExtjoy) ,"EXTJOY controller check" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexEXTJOY},
{ 0,&(chk50PReadWrite),"AD16 BUS RW cycle count" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexRW },
{ 0,&(AD16_LatchTest1),"AD16 BUS address latch1" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexLATCH1},
{ 0,&(AD16_LatchTest2),"AD16 BUS address latch2" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexLATCH2},
{ 0,&(piAllTest) ,"PI RW DMA/PIO,INT" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexPIO },
{ 0,&(rsp) ,"RSP Diagnostic Tests" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexRSP },
{ 0,&(dlDriver) ,"RDP Display List Checksum" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexRDP },
{ 0,&(nmitest_phase1) ,"Reset Switch" ,GNG_PASS_FAIL_BIT | GNG_NMI_TEST_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexRESET },
{ 0,&(WaveOutput) ,"Wave Output" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexWAVE },
{ 1,&(music44100) ,"Music with 44100Hz" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,Index441 },
{ 1,&(music32000) ,"Music with 32000Hz" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,Index320 },
{ 1,&(music22050) ,"Music with 22050Hz" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,Index220 },
{ 1,&(RunViTests) ,"Video Patterns" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexVIDEO },
{ 0,&(CpuTest) ,"R4300 CPU Test" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexCPU },
{ 0,&(Jumptime) ,"Dummy jump" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexJUMP },
{ 0,NULL ,"end of tests" ,GNG_PASS_FAIL_BIT | GNG_FINAL_TEST_BIT, PASS_MESSAGE_RETRACE_COUNT,255},
};
int Jumptime(){
return GNG_TEST_SUCCESS;
}
int WaveOutput(){
char message[256];
int length;
volatile u32 *ptr;
short s0;
length=ZaruReadReg2(REG_SNDLENGTH);
if(length==0) length=ZARU_SNDLENGTHDEFAULT;
ZaruWriteReg2(REG_AUDIO,ZARU_SINWAVE); /* sasano added */
sprintf(message,"When press yellow button,\nOutput sin wave\n");
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
audioTest(ZARU_SINWAVE,length);
ptr=(u32*)(PHYS_TO_K1(0x1f000000));
s0=*(ptr);
ZaruWriteReg2(REG_THRU ,s0>>8);
ZaruWriteReg2(REG_THRU2,s0%0x100);
ZaruWriteReg2(REG_AUDIO,ZARU_SAWWAVE); /* sasano added */
sprintf(message,"When press yellow button,\nOutput saw wave\n");
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
audioTest(ZARU_SAWWAVE,length);
ZaruWriteReg2(REG_AUDIO,ZARU_TRIWAVE); /* sasano added */
sprintf(message,"When press yellow button,\nOutput triangle wave\n");
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
audioTest(ZARU_TRIWAVE,length);
ZaruWriteReg2(REG_AUDIO,ZARU_RCTWAVE); /* sasano added */
sprintf(message,"When press yellow button,\nOutput rectangle wave\n");
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
audioTest(ZARU_RCTWAVE,length);
ZaruWriteReg2(REG_AUDIO,ZARU_ONLYL); /* sasano added */
sprintf(message,"When press yellow button,\nOutput sin wave\nonly Left channel");
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
audioTest(ZARU_ONLYL,length);
ZaruWriteReg2(REG_AUDIO,ZARU_ONLYR); /* sasano added */
sprintf(message,"When press yellow button,\nOutput sin wave\nonly Right channel");
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
audioTest(ZARU_ONLYR,length);
return GNG_TEST_SUCCESS;
}
void presstonext(){
char message[80];
sprintf(message,"When press yellow button,\nGo next test.");
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
ZaruWaitForNextTestButton();
}
/**************************************************************************
現在接続されているジョイチャンネルを取得
************************************************************************/
int ZaruGetCurrentChannel( void ){
int i;
u8 data[16];
ZaruReadAllControllerButton( data );
/* 現在接続されているジョイチャンネルを検索 */
for( i=0 ; i<4; i+=1 ){
if( ( data[i*4]&0x80 )== 0 ) return i;
}
return 0xffff; /* 接続なし */
}
int ContTest(){
int i,j=0;
u16 ikey1[MAXCONTROLLERS],ikey2[MAXCONTROLLERS];
char message[256];
u8 command; /* 検査器側からの命令 */
u8 data[16]; /* コントローラの状態保存用配列 */
u16 *Data16b; /* データ切出用にデータ形式の変換 */
int ch; /* 検査で使用するチャンネル */
/* 検査画面表示 */
gng_report( "Controller test:\nPlease wiggle (shake)\ncontroller inputs\nduring test.\n\nPress yellow button\nto continue...",
0, GNG_INHIBIT_PRINT, 0);
/* 検査ループ */
while(1){
j++;
/* コントローラ読取許可待ち */
while( 1 ){
/* ジョイチャンネル接続状況読取(接続なし=0xffff) */
ch = ZaruGetCurrentChannel();
/* 接続先からコントローラ読取リクエストを受け取る */
if ( ch != 0xffff ){
/* コントローラが接続されているとき */
command=ZaruReadReg4( REG_CONTLOOP, ch );
if ( (command &0x80)== 0 )break;
}
}
/* 検査終了判定 */
if( command == ZARU_CONTLOOPEXIT ) break;
/* 全チャンネルのコントローラデータ読み出し */
ZaruReadAllControllerButton( data );
/* データを検査器側に転送 */
switch( ch ){
case 0: ZaruWriteReg4(REG_CONTRESULT0,16,data,0); break;
case 1: ZaruWriteReg4(REG_CONTRESULT1,16,data,1); break;
case 2: ZaruWriteReg4(REG_CONTRESULT2,16,data,2); break;
case 3: ZaruWriteReg4(REG_CONTRESULT3,16,data,3); break;
default: break;
}
/* 画面表示用にデータ形式の変換をおこなう */
Data16b = (u16 *)data; /* データ切出用にデータ形式の変換 */
for( i=0 ; i<4 ; i++ ){
ikey1[i]=*Data16b; Data16b++;
ikey2[i]=*Data16b; Data16b++;
}
/* 画面表示 */
sprintf(message,"Controller Status %d\n\n 1P:%04x %04x\n 2P:%04x %04x\n 3P:%04x %04x\n 4P:%04x %04x",j,ikey1[0],ikey2[0],ikey1[1],ikey2[1],ikey1[2],ikey2[2],ikey1[3],ikey2[3]);
gng_report(message,1,GNG_INHIBIT_PRINT,1);
/* コントローラ読取ポートのシンク */
while ( ZaruReadReg4( REG_CONTLOOP, ch )&ZARU_CONTNOWRITE == 0 );
}
return GNG_TEST_SUCCESS;
}
int DummyTest(){
char message[80];
gngstatus *pstatus;
int rdramDiagStatus,rdramDiagErrors;
u32 rdramDiagSasano,rdramDiagExpect,rdramDiagReaddt;
pstatus = (gngstatus *)osAppNMIBuffer;
rdramDiagStatus = pstatus->rdram_diag_status;
rdramDiagErrors = pstatus->rdram_diag_errors;
rdramDiagSasano = pstatus->rdram_diag_sasano;
rdramDiagExpect = pstatus->rdram_diag_expect;
rdramDiagReaddt = pstatus->rdram_diag_readdt;
sprintf(message,"Dummy\nStatus=%x\nErrors=%x\nSasano=%x\nExpect=%x\nReaddt=%x",rdramDiagStatus,rdramDiagErrors,rdramDiagSasano,rdramDiagExpect,rdramDiagReaddt);
while(ZaruReadReg2(REG_PAUSE)==ZARU_PAUSE){
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
}
(void)osRecvMesg(&retraceMessageQ, NULL, OS_MESG_BLOCK);
return GNG_TEST_SUCCESS;
}
void testLoop(int index) {
char message[256];
Test_t *pTest;
int errCount;
u8 directtest;
int i,j;
/* RunViTests();*/
pTest = &(testList[index]);
while (pTest->pTestFunction != NULL) {
do {
if (ZaruReadReg2(REG_DIRECTENBL)!=ZARU_DIRECTDSBL) {
i=ZaruReadReg2(REG_DIRECTTEST);
j=0;
while(1){
pTest = &(testList[j]);
if ((pTest->testNumber) == i) {
index=j;
break;
}
j++;
if ((pTest->testNumber)==0xff) {
while(1) {gng_report("Error index number.\nHalted.",1,GNG_INHIBIT_PRINT,1);}
}
}
pTest = &(testList[index]);
ZaruWriteReg2(REG_DIRECTENBL,ZARU_DIRECTDSBL);
}
/* write pTest->testNumber to the LED panel on the ZARU test jig */
ZaruSetMemA(pTest->testNumber);
/* Always print the test message before the test starts. We'll re-print the message with PASS/FAIL reporting afterwards, if the test requested it. */
gng_report(pTest->gngMessageText, 1, GNG_INHIBIT_PRINT, 1);
if (pTest->presswait == 1) ZaruWaitForNextTestButton();
sprintf(message,"%s\nworking...",pTest->gngMessageText);
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
} while (ZaruReadReg2(REG_DIRECTENBL) != ZARU_DIRECTDSBL);
/* Run the test. */
errCount = (*pTest->pTestFunction)();
/* If test does need PASS/FAIL reporting, do so now. */
if (pTest->testFlags & GNG_PASS_FAIL_BIT) gng_report(pTest->gngMessageText, errCount, pTest->testFlags, pTest->retraceCount);
pTest = &(testList[++index]);
if (ZaruReadReg2(REG_DIRECTENBL)!=ZARU_DIRECTDSBL) {
i=ZaruReadReg2(REG_DIRECTTEST);
j=0;
while(1){
pTest = &(testList[j]);
if ((pTest->testNumber) == i) {
index=j;
break;
}
j++;
if ((pTest->testNumber)==0xff) {
while(1) {gng_report("Error index number.\nHalted.",1,GNG_INHIBIT_PRINT,1);}
}
}
pTest = &(testList[index]);
ZaruWriteReg2(REG_DIRECTENBL,ZARU_DIRECTDSBL);
}
}
sprintf(message,"Go/No-go testing complete.\n%s\n",NOWTIME);
gng_report(message, 0, GNG_PASS_FAIL_BIT | GNG_FINAL_TEST_BIT, 0);
ZaruWriteReg2(REG_ALLEND,0x80);
}
void testDriver(int nmiEntryFlag) {
Test_t *pTest;
int i;
gngstatus *pstatus;
int rdramDiagStatus,rdramDiagErrors;
char message[80];
char data[6];
if (nmiEntryFlag == FALSE) {
/* Iterate through the tests; optionally do a gng_report with their status upon completion. */
pstatus = (gngstatus *)osAppNMIBuffer;
pstatus->rdram_diag_status=0;
/* SetVersionNumber */
sprintf(message,NOWTIME);
data[0]=((message[0]-'0')<<4)+(message[1]-'0');
data[1]=((message[3]-'0')<<4)+(message[4]-'0');
data[2]=((message[6]-'0')<<4)+(message[7]-'0');
data[3]=((message[9]-'0')<<4)+(message[10]-'0');
data[4]=((message[12]-'0')<<4)+(message[13]-'0');
data[5]=((message[15]-'0')<<4)+(message[16]-'0');
ZaruWriteReg3(REG_VERSION,6,data);
testLoop(0);
} else {
/* Find the NMI test by examining the testFlags field, then print a gng_report() as per the testFlags, retraceCount fields. Then, iterate through the rest of the test sequence. */
ZaruWriteReg2(REG_RESET,ZARU_AFTERRESET); /* sasano added */
i = 0;
pTest = &(testList[i]);
while ( (pTest->pTestFunction != NULL) && (pTest->testFlags & GNG_NMI_TEST_BIT) == 0 ) pTest = &(testList[++i]);
/* We should be pointing at the NMI test now. Skip past it & continue. */
testLoop(++i);
}
}