wrapper_bufdma.c
3.56 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
/*************************************************************************
*
* File: tstsim.c
*
* $Header: /root/leakn64/depot/rf/sw/bbplayer/iosim/src/pi_test/wrapper_bufdma.c,v 1.1 2003/01/01 00:14:44 apatti Exp $
*
*/
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include "../iomap.h"
#include "../iotest.h"
#include "../sim.h"
#include "../simipc.h"
/***********************************************************************
* Extern definitions
*/
extern TstCmd TstCmdTbl[];
extern void IoTestAll(char *flashInitFileName);
/***********************************************************************
* Macro definitions
*/
#define TEST_CMD_FILE "all.tst"
#define OPTARG "d:l:f:knh"
/***********************************************************************
* Global definitions
*/
int IpcFd = -1;
unsigned long Dflags;
char *CmdFile = TEST_CMD_FILE;
FILE *LogFp, *CmdFp;
int ConfigRdramV = 0;
int NumberStallCycles = 0;
/***********************************************************************
* Local static definitions
*/
static FILE *dumpFp = NULL;
static void usage(void);
static void convertTst2C(char *);
main(int argc, char **argv)
{
int c, testId, killsim=0, verify=1;
char *file,flashInitFileName[1024];
FILE *fp = NULL;
extern char *optarg;
extern int optind, opterr, optopt;
optind = 1;
Dflags = 0;
LogFp = stdout;
while ((c = getopt(argc, argv, OPTARG)) != EOF) {
switch (c) {
case 'd': { /* Debug flag */
Dflags = strtoul(optarg, NULL, 16);
printf("Debug flag=0x%08x\n", Dflags);
break;
}
case 'l': { /* Log file */
file = optarg;
printf("Log file = %s\n", file);
if ((fp = fopen(file, "w+")) == NULL) {
printf("Unable to open log: %s\n",
file);
}
else
LogFp = fp;
break;
}
case 'f': { /* flash initialization file */
strcpy(flashInitFileName,optarg);
break;
}
case 'k': { /* kill simulator on exit */
killsim=1;
break;
}
case 'n': { /* no verification of dma */
verify=0;
break;
}
case 'h': { /* Help */
usage();
exit(0);
}
default:
break;
}
} /* while */
ExceptionHandlerInit();
IpcInit(NULL);
FindServer();
IoTestBufDma(flashInitFileName,verify);
if (fp)
fclose(fp);
if (IpcFd != -1)
IpcClose(IpcFd);
/* exit simulator */
if(killsim)
IoCmd(REQ_QUIT, 0);
exit(0);
}
static void
usage(void)
{
printf("Usage: pi_functest \n");
printf(" -l <log_file>\n");
printf(" -f <flash_init_file>\n");
printf(" Currently must be named <sim_path>/External_File.txt,\n");
printf(" where <sim_path> is the directory from where sim.ipc\n");
printf(" is run.\n");
printf(" -d <debug_flags in hex>\n");
printf(" NOTE: DLOG | DSTATUS | DERROR always on\n");
printf(" -k\n");
printf(" Use this option to kill the simulator on exit\n");
printf(" -n\n");
printf(" No verification of dma result\n");
}