randmain.c
4.97 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
/*************************************************************************
*
* File: main.c
*
* This file contains the main routine for the I/O random test.
*
* $Header: /root/leakn64/depot/rf/sw/n64os20l/iosim/src/randmain.c,v 1.2 2002/05/30 05:52:50 whs Exp $
*
*/
#ifdef __sgi__
#include <sys/cachectl.h>
#endif
#include <sys/mman.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#ifdef __sgi__
#include <libelf.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include "sim.h"
#include "simipc.h"
#define OPTARG "CRad:i:f:l:m:n:o:c:r:s:t:h:?"
/*
* Forward declarations
*/
static void usage(void);
/*
* External references
*/
extern void SyncInit(void);
extern void IoInit(void);
extern int IoRandInit(char *);
extern int IoRandTest(char *);
extern void ShutdownServer(void);
extern unsigned int LoopCount;
extern unsigned int MinRunCount;
extern unsigned int TestSeed;
extern unsigned int CompareEnabled;
extern unsigned int RoundRobinEnabled;
extern unsigned int RandomRobinEnabled;
extern unsigned int Ai441Enabled;
extern unsigned int RdramSize;
extern char IpcName[];
/*
* Global variables
*/
int IpcFd = -1;
unsigned long Dflags;
char *CmdFile;
char *LogFile;
FILE *LogFp, *CmdFp;
int ConfigRdramV = 0;
char *Server = NULL;
int NumberStallCycles = 0;
/*
* Local variables
*/
static char *ipcName = NULL;
static char *testRange = "0-14"; /* Default test range: 0-14 */
/*
* Main
*/
main(int argc, char **argv)
{
int c, ret;
FILE *fp = NULL;
struct descriptor d;
time_t t;
char *s;
extern char *optarg;
extern int optind, opterr, optopt;
optind = 1;
Dflags = 0;
LogFp = stderr;
while ((c = getopt(argc, argv, OPTARG)) != EOF) {
switch (c) {
case 'C': { /* Turn off DMA compare */
printf("DMA compare is disabled!\n");
CompareEnabled = 0;
break;
}
case 'R': { /* Turn on round robin scheduling */
printf("Round-robin scheduling is enabled!\n");
RoundRobinEnabled = 1;
break;
}
case 'a': { /* Turn on audio to run at 44.1 KHz */
printf("Audio at 44.1 KHz is enabled!\n");
Ai441Enabled = 1;
break;
}
case 'd': { /* Debug */
Dflags = strtoul(optarg, NULL, 16);
printf("Debug flag=0x%08x\n", Dflags);
break;
}
case 'i': { /* Iteration */
LoopCount = atoi(optarg);
printf("Minimum iteration=%d\n", LoopCount);
break;
}
case 'l': { /* Log file */
LogFile = optarg;
printf("Log file = %s\n", LogFile);
if ((fp = fopen(LogFile, "w+")) == NULL) {
printf("Unable to open log: %s\n",
LogFile);
}
else
LogFp = fp;
break;
}
case 'm': { /* Memory size = 4,6 */
ret = atoi(optarg);
switch (ret) {
case 4:
case 6:
RdramSize = ret;
break;
default:
RdramSize = 4;
break;
}
break;
}
case 'n': { /* IPC name */
ipcName = optarg;
break;
}
case 'o': { /* Random test 'ovule' */
TestSeed = atoi(optarg);
break;
}
case 'c': { /* Config RDRAM */
printf("Config RDRAM using verilog\n");
ConfigRdramV = 1;
break;
}
case 'r': { /* Run count */
MinRunCount = atoi(optarg);
printf("Minimum thread run count=%d\n",
MinRunCount);
break;
}
case 's': { /* Automatically exec simv.ipc */
Server = optarg;
break;
}
case 't': { /* Test range */
testRange = optarg;
printf("Test range=%s\n", testRange);
break;
}
case 'h': /* Help */
case '?': {
usage();
exit(0);
}
default:
break;
}
} /* while */
SyncInit();
IpcInit(ipcName);
printf("Using IPC name '%s' ...\n", IpcName);
if (Server == NULL) {
Server = getenv("SIMV");
if ((Server != NULL) && (*Server == '\0'))
Server = NULL;
}
if (Server != NULL)
ExecServer(Server);
FindServer();
ExceptionHandlerInit();
IoInit();
t = time(NULL);
s = asctime(localtime(&t));
fprintf(LogFp, "\n=======> IO random test begins at\t%s\n", s);
IoRandInit(testRange);
if (IoRandTest(testRange) < 0)
printf("ERROR: Unable to perform random IO testing!\n");
t = time(NULL);
s = asctime(localtime(&t));
fprintf(LogFp, "\n=======> IO random test ends at\t%s\n", s);
ShutdownServer();
if (fp)
fclose(fp);
if (Server != NULL)
WaitServer();
exit(0);
}
static void
usage(void)
{
printf("Usage: iorand \n");
printf(" -C (Turn off data comparison for most DMA tests)\n");
printf(" -R (Turn on round-robin scheduling)\n");
printf(" -a (Turn audio to run at 44.1 KHz)\n");
printf(" -n <ipc name>\n");
printf(" -d <debug_flags in hex>\n");
printf(" -i <iteration>\n");
printf(" -m <memory size>\n");
printf(" -r <thread run count>\n");
printf(" -t <test range>\n");
printf(" -l <log_file>\n");
printf(" -s <simv ... >\n");
printf(" -h <help - this message>\n");
}