uji.c
4.22 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
/**************************************************************************
* *
* 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"
/*
* 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;
#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;
#ifndef _FINALROM
if (!zaruexists) /* Assume everything is OK if no Zaru */
return GNG_TEST_SUCCESS;
#endif
/*
* test joy ports 2, 3, and 4. Remember that a Fortran progammer
* labled the connectors.
*/
for (i = 1; i< 4; i++) {
switch (i) {
case 1:
select = ZARU_JOY_SELECT_2;
break;
case 2:
select = ZARU_JOY_SELECT_3;
break;
case 3:
select = ZARU_JOY_SELECT_4;
break;
}
ZaruSetJoySelect(select);
for (j = 0; j < sizeof(controllerdata)/sizeof(u8); j++) {
ZaruSetJoyButtons(controllerdata[j]);
if (ZaruButtonCheck(controllerdata[j], ZaruReadControllerButton(i))
== GNG_TEST_FAILURE) {
return GNG_TEST_FAILURE;
}
}
}
return GNG_TEST_SUCCESS;
}