audiotest.c
7.09 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
/*====================================================================
* audiotest.c
*
* Audio performance monitoring tool
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: audiotest.c,v $
$Revision: 1.1.1.1 $
$Date: 2002/05/02 03:27:08 $
*---------------------------------------------------------------------*/
#include <ultralog.h>
#include <ramrom.h>
#include <sched.h>
#include "audiotest.h"
#include "misc.h"
#include "seqpTest.h"
extern test_cntrl Test0;
extern test_cntrl Test1;
extern test_cntrl Test2;
extern test_cntrl Test3;
extern test_cntrl Test4;
extern test_cntrl Test5;
extern test_cntrl seqpTest;
extern test_cntrl OsAiTest;
extern test_cntrl synScriptTest;
test_cntrl *tests[] = {
&OsAiTest, /* hardware bug test */
&Test0,
&Test1,
&Test2, /* synth monkey */
&Test3, /* priority test */
&Test4, /* sndplayer monkey */
&Test5, /* engine rev test */
&synScriptTest, /* synth special case tests */
&seqpTest, /* seqplayer special case tests and monkey */
NULL
};
/**** Stack for boot code. Space can be reused after 1st thread starts ****/
u64 bootStack[STACKSIZE/8];
/**** threads used by this file ****/
static OSThread gameThread;
static OSThread initThread;
static OSThread rmonThread;
/**** Stacks for the threads ****/
static u64 gameThreadStack[STACKSIZE/8];
static u64 initThreadStack[STACKSIZE/8];
static u64 rmonStack[RMON_STACKSIZE/8];
/**** function prototypes for private functions in this file ****/
static void gameproc(void *);
static void initproc(char *);
/**** message queues and message buffers used by PI manager ****/
static OSMesg PiMessages[DMA_QUEUE_SIZE];
static OSMesgQueue PiMessageQ;
/**** message queues and message buffers used by romCopy ****/
OSMesgQueue dmaMessageQ;
OSMesg dmaMessageBuf[MAX_MESGS];
/**** message queues and message buffers used by grafix processes ****/
OSMesgQueue gfxFrameMsgQ;
OSMesg gfxFrameMsgBuf[MAX_MESGS];
/**** Some globals ****/
OSScClient gfxClient;
GFXInfo gInfo[2];
u32 gTestDone;
/**** Scheduler globals ****/
OSSched sc;
u64 scheduleStack[OS_SC_STACKSIZE/8];
static void initGame(void);
OSPiHandle *handler;
boot(void *arg)
{
int i;
u32 *argp;
u32 argbuf[16];
osInitialize();
handler = osCartRomInit();
argp = (u32 *)RAMROM_APP_WRITE_ADDR;
for (i=0; i<sizeof(argbuf)/4; i++, argp++)
osEPiReadIo(handler, (u32)argp, &argbuf[i]); /* Assume no DMA */
parse_args((char *)argbuf);
osCreateThread(&initThread, 1, (void(*)(void *))initproc, arg,
(void *)(initThreadStack+STACKSIZE/8), (OSPri)INIT_PRIORITY);
osStartThread(&initThread);
}
static void
initproc(char *argv)
{
/**** Start PI Mgr for access to cartridge ****/
osCreatePiManager((OSPri) OS_PRIORITY_PIMGR, &PiMessageQ, PiMessages,
DMA_QUEUE_SIZE);
/**** Start rmonThread so you can do printf's ****/
osCreateThread(&rmonThread, 0, rmonMain, (void *)0,
(void *)(rmonStack+RMON_STACKSIZE/8),
(OSPri) OS_PRIORITY_RMON );
osStartThread(&rmonThread);
/**** Create the game thread and start it up ****/
osCreateThread(&gameThread, 6, gameproc, argv,
gameThreadStack+STACKSIZE/8, (OSPri)GAME_PRIORITY);
osStartThread(&gameThread);
/**** Set the thread to be the idle thread ****/
osSetThreadPri(0, IDLE_PRIORITY);
for(;;);
}
/************************************************************
*
* A continual loop, primarily used for servicing the starts
* of graphic tasks and controller reads. If InitTest starts
* an audio manager, tests can be serviced by voice handler,
* otherwise they are called by the test's retrace proc.
*
************************************************************/
static void
gameproc(void *argv)
{
u8 displaybuffer = 0;
u8 drawbuffer = 0;
u8 pendingGFX = 0;
u8 cntrlReadNeeded = TRUE;
GFXMsg *msg;
GFXInfo *gfxp;
u32 testNum = 0,subTestNum;
test_cntrl *test;
initGame();
test = tests[testNum];
while( test != NULL )
{
for( subTestNum = 0; subTestNum < test->numSubTests ; subTestNum++)
{
(*(test->InitTest))(subTestNum);
gTestDone = FALSE;
while (gTestDone == FALSE)
{
osRecvMesg(&gfxFrameMsgQ, (OSMesg *)&msg, OS_MESG_BLOCK);
switch (msg->gen.type)
{
case (OS_SC_RETRACE_MSG):
if(test->retraceProc)
(*(test->retraceProc))(test->retraceData);
if (pendingGFX < 2) /* don't do if already have 2 tasks */
{
createGfxTask(&gInfo[drawbuffer]);
pendingGFX++;
drawbuffer ^= 1; /* switch drawbuffer */
}
if (cntrlReadNeeded)
{
osContStartReadData(&gfxFrameMsgQ);
cntrlReadNeeded = FALSE;
}
break;
case (OS_SC_DONE_MSG):
gfxp = &gInfo[displaybuffer];
displaybuffer ^= 1; /* switch the displaybuffer */
pendingGFX--; /* decrement number of pending tasks */
break;
case SCHED_CONTROLLER_MSG:
UpdateController(test);
cntrlReadNeeded = TRUE; /* might want to reset this somewhere else */
break;
default:
break;
}
}
(*(test->StopTest))(subTestNum);
PRINTF("Test %d, SubTest %d completed\n",testNum,subTestNum);
}
PRINTF("Test %d completed\n",testNum);
testNum++;
test = tests[testNum];
}
}
void initGame(void)
{
/**** set up a couple message q's ****/
osCreateMesgQueue(&dmaMessageQ, dmaMessageBuf, MAX_MESGS);
osCreateMesgQueue(&gfxFrameMsgQ, gfxFrameMsgBuf, MAX_MESGS);
/**** Initialize the RCP task scheduler ****/
osCreateScheduler(&sc, (void *)(scheduleStack + OS_SC_STACKSIZE/8),
SCHEDULER_PRIORITY, OS_VI_NTSC_LAN1, NUM_FIELDS);
/**** Add ourselves to the scheduler to receive retrace messages ****/
osScAddClient(&sc, &gfxClient, &gfxFrameMsgQ);
/**** Call the initialization routines ****/
initGFX();
initCntrl();
}
void TestDone(void)
{
gTestDone = TRUE;
}