ulxmain.c
10.4 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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/*
* F i l e N a m e : U L X M A I N . C
*
****************************************************************************
* (C) CopyRight ALPS Electric Co., Ltd. 1996
****************************************************************************
* Version
*
* ver Date
* ---- --------
* 1.10 '97,03,10 Update version (3.31 -> 3.31a) add disk in switch test
* 1.10 '97,03,10 Update version ( -> 3.30)
* 1.03 '96.10.12 Update version (3.02 -> 3.02A).
* 1.02 '96.07.17 Add LIFE-TEST Menu.
* 1.01 '96.02.05 ベンチマーク測定メニューを追加
* 1.00 '95.12.20 Initial revision .
****************************************************************************
*/
/*===========================================*/
/* レオドライブ用テストソフトのメインルーチン */
/*===========================================*/
#include <ultra64.h>
#include "ulxlib.h"
#include "ulxutil.h"
#include "leodrive.h"
#define CONTINUE 0
#define ENABLE 1
#define DISABLE 0
u32 min_lba = LEO_LBA_MIN;
u32 max_lba = LEO_LBA_MAX;
u32 test_blk = 2;
u8 rnd_blk = DISABLE;
u8 rnd_data = DISABLE;
u8 tag_data = DISABLE;
u32 pass_count = CONTINUE;
u8 err_stop = ENABLE;
u8 disktype = 0;
u8 cmpflg = ENABLE;
u8 dispflg = ENABLE;
u8 notdisp = 0;
u32 err_count = 0;
void LeoulxMain( void *arg );
void bufhandle(void);
void init_display(void);
void MakeSystemData(void);
extern void commandtest( void ) ;
extern void rwtest( void ) ;
extern void bench_test( void );
extern void life_test( void );
/*********************************************************/
/* DEFINITION */
/*********************************************************/
OSMesgQueue serialMessageQ;
OSMesgQueue controllerMessageQ;
OSMesg serialMsgBuf;
OSMesg controllerMsgBuf;
OSContStatus statusdata[MAXCONTROLLERS];
OSContPad controllerdata[MAXCONTROLLERS];
char *staticSegment;
#define LEOULX_STACKSIZE 2048
OSThread leoulxThread;
u64 leoulxStack[LEOULX_STACKSIZE/sizeof(u64)];
extern union data_trans_form LEO_country_code;
extern u32 draw_string( char *);
extern s8 LEOfirmware_rev[];
const u8 *SC_NAME_SHORT[] =
{ "NO SENSE ",
"DRIVE NOT READY ",
"DIAG ERROR ",
"COMMAND PHASE ERR ",
"DATA PHASE ERR ",
"RTC FAILURE ",
"06 UNKNOWN ERR ",
"07 UNKNOWN ERR ",
"08 UNKNOWN ERR ",
"09 UNKNOWN ERR ",
"10 UNKNOWN ERR ",
"INCOMPATIBLE MEDIUM",
"12 UNKNOWN ERR ",
"13 UNKNOWN ERR ",
"14 UNKNOWN ERR ",
"15 UNKNOWN ERR ",
"16 UNKNOWN ERR ",
"17 UNKNOWN ERR ",
"18 UNKNOWN ERR ",
"19 UNKNOWN ERR ",
"20 UNKNOWN ERR ",
"NO SEEK COMP ",
"WRITE FAULT ",
"UNRECOVERD READ ERR",
"NO REFERENCE POS ",
"TRACK FOLLOWING ERR",
"26 UNKNOWN ERR ",
"27 UNKNOWN ERR ",
"28 UNKNOWN ERR ",
"29 UNKNOWN ERR ",
"30 UNKNOWN ERR ",
"INVALID CMD ",
"LBA OUT OF RANGE ",
"WRITE PROTECTED ",
"COMMAND TERMINATED ",
"QUEUE FULL ",
"ILLEGAL TIMER VALUE",
"37 UNKNOWN ERR ",
"38 UNKNOWN ERR ",
"39 UNKNOWN ERR ",
"40 UNKNOWN ERR ",
"COMMUNICATION ERR ",
"MEDIUM NOT PRESENT ",
"RESET OCCURRED ",
"44 UNKNOWN ERR ",
"45 UNKNOWN ERR ",
"46 UNKNOWN ERR ",
"MEDIUM CHANGED ",
"48 UNKNOWN ERR ",
"EJECTED ",
"50 UNKNOWN ERR ",
"EJECTED "
};
/*==========================================================*/
void start(void)
{
init_display();
osCreateThread(&leoulxThread,(OSId)7,LeoulxMain,(void*)0,
leoulxStack+LEOULX_STACKSIZE/sizeof(u64),(OSPri)40);
osStartThread(&leoulxThread);
while(1)osYieldThread();
}
void init_display(void)
{
osViModeTable[OS_VI_NTSC_LPN1].comRegs.hStart=
(((((osViModeTable[OS_VI_NTSC_LAN1].comRegs.hStart>>16)&0xffff)-24)%0xffff)<<16)|
(((((osViModeTable[OS_VI_NTSC_LAN1].comRegs.hStart>> 0)&0xffff)-24)%0xffff)<< 0);
osViModeTable[OS_VI_NTSC_LPN1].fldRegs[0].vStart=
(((((osViModeTable[OS_VI_NTSC_LAN1].fldRegs[0].vStart>>16)&0xffff)-6)%0xffff)<<16)|
(((((osViModeTable[OS_VI_NTSC_LAN1].fldRegs[0].vStart>> 0)&0xffff)-6)%0xffff)<< 0);
osViModeTable[OS_VI_NTSC_LPN1].fldRegs[1].vStart=
(((((osViModeTable[OS_VI_NTSC_LAN1].fldRegs[1].vStart>>16)&0xffff)-6)%0xffff)<<16)|
(((((osViModeTable[OS_VI_NTSC_LAN1].fldRegs[1].vStart>> 0)&0xffff)-6)%0xffff)<< 0);
osWritebackDCacheAll();
osViSetMode(&osViModeTable[OS_VI_NTSC_LAN1]);
*(u32*)PHYS_TO_K1(VI_H_VIDEO_REG)=0;
}
extern u16 key;
void LeoulxMain(void *arg)
{
u16 x_l=5, y_l=2, num=1;
u16 col_l=5;
u8 *left_d[10] = {"COMMAND TEST ",
"WRITE/READ TEST ",
"BENCHMARK TEST ",
"LIFE TEST ",
"VERSION ",
};
InitialRoutine();
beginulx:
#if 1 /* sw test */
SCode = 43;
for (;;){
u32 cnt,testmode;u8*modename[]={"READ","WRITE","READ/WAIT","WRITE/WAIT"};
ClrDisp();
ulxPrint0(0,0,CYAN,"DISK-IN SENSOR Test ");
for (testmode = 0;;)
{
ulxPrint1(1,2,GREEN,"Select Test Mode: %s ",modename[testmode]);
key = InCtrlData();
if ( key == CONT_START) break;
if ( key == CONT_B) break;
if ( key == CONT_A) testmode += 1;
if (testmode > 3) testmode = 0;
}
if ( key == CONT_B) break;
for (cnt = 0; ;cnt++)
{
switch (SCode)
{
case 43: /* reset */
ClrUAReset();
ReadCapa(1,0,0);
break;
case 47: /* medium change */
ReadDiskID(RDB);
ReadCapa(1,0,0);
default:;
}
switch (testmode)
{
case 0:
case 2:
ulxPrint2( 1,4,GREEN,"READ LBA=%u %u ",TAG09.start_lba,cnt);
ReadDrive(TAG09.start_lba,1,RDB);
break;
case 1:
case 3:
ulxPrint2( 1,4,GREEN,"WRITE LBA=%u %u ",TAG09.start_lba,cnt);
WriteDrive(TAG09.start_lba,1,RDB);
break;
}
ulxPrint1( 3,6,GREEN,"%02d ",SCode);
ulxPrint0( 6,6,GREEN,(u8*)SC_NAME_SHORT[SCode]);
key = InCtrlData();
switch (testmode)
{
case 2:
case 3:
for (;;)
{
TestUnit();
if (TAG03.test & LEO_TEST_UNIT_SS)
{
ulxPrint0( 1,8,GREEN,"TEST UNIT READY SLEEP ");
}
else if (TAG03.test & LEO_TEST_UNIT_RE)
ulxPrint0( 1,8,GREEN,"TEST UNIT READY STBY ");
else
ulxPrint0( 1,8,GREEN,"TEST UNIT READY ACTIV ");
ulxPrint1( 3,10,GREEN,"%02d ",SCode);
ulxPrint0( 6,10,GREEN,(u8*)SC_NAME_SHORT[SCode]);
key = InCtrlData();
switch (key)
{
case CONT_A:
case CONT_B:
case CONT_START:
break;
default:
continue;
}
break;
}
break;
}
if ( key == CONT_B) break;
}
ulxPrint0( 1,8,GREEN,"Hit any key ");
GetChr();
}
#endif /* end of sw test */
do
{
ClrDisp();
Disp_Ready(0, 0, CYAN);
sprintf( STR, "LEO TEST PROGRAM LEOULX Ver.3.31a" );
Disp_Fin();
ListDisp( x_l, y_l, col_l, left_d, 0, 0, 0, (void *)0, GREEN );
num = SelStr1( x_l, y_l, col_l, left_d, 1, GREEN );
switch( num )
{
case 1:
commandtest();
break;
case 2:
rwtest();
break;
case 3:
bench_test();
break;
case 4:
life_test();
break;
case 5:
ClrDisp();
Disp_Ready( 7, 8, YELLOW);
sprintf( STR, "VERSION : %s",LEOfirmware_rev );
Disp_Fin();
Disp_Ready( 7, 9, YELLOW);
if (LEO_country_code.u32_data == 0)
sprintf( STR, "COUNTRY CODE : DEVELOPER" );
else
sprintf( STR, "COUNTRY CODE : MASS PRO." );
Disp_Fin();
GetChr();
break;
case ESC:
goto beginulx;
default:
break;
}
} while( 1 );
ClrDisp();
}
void bufhandle( void )
{
u32 pattern=0;
u32 dwd;
u16 x_l=5, y_l=2, col_l=7, num=1;
u8 *left_d[9] = {"EDIT READ DATA BUFFER ",
"EDIT WRITE DATA BUFFER ",
"CMP. R/W DATA BUFFER ",
"SWAP R/W DATA BUFFER ",
"CLEAR R/W DATA BUFFER ",
"RND DATA PATTERN <WDB>",
"FILL DATA PATTERN <WDB>"
};
do
{
ClrDisp();
Disp_Ready(0, 0, CYAN);
sprintf( STR, "BUFFER EDIT MENU " );
Disp_Fin();
ListDisp( x_l, y_l, col_l, left_d, 0, 0, 0, (void *)0, GREEN );
num = SelStr1( x_l, y_l, col_l, left_d, 1, GREEN );
switch( num )
{
case 1:
EditBuf( RDB, "EDIT READ BUFFER" );
break;
case 2:
EditBuf( WDB, "EDIT WRITE BUFFER" );
break;
case 3:
CompBufDisp();
break;
case 4:
SwapBuf();
break;
case 5:
ClrBuf();
break;
case 6:
MakeRand( WDB, BUFSIZE );
break;
case 7:
pattern = InDig32( pattern, 10, 10, YELLOW );
for(dwd=0; dwd<(BUFSIZE/4); dwd++)
{
((u32 *)WDB)[dwd] = (u32)pattern;
}
break;
default:
break;
}
} while( num != ESC );
}