parse.c
1.31 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
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: parse.c,v $
$Revision: 1.1.1.1 $
$Date: 2002/05/02 03:27:21 $
*---------------------------------------------------------------------*/
#include "rgtest.h"
#include <ramrom.h>
/*
* globals set by the boot arguments
*/
int verbose = 0;
OSPiHandle *handler;
void
parse(void)
{
u32 *argp;
u32 argbuf[16];
int argc = 1, i;
char *arglist[32], **argv = arglist; /* max 32 args */
char *c, *ptr;
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 */
}
/* re-organize argstring to be like main(argv,argc) */
ptr = (char *)argbuf;
while (*ptr != '\0') {
while (*ptr != '\0' && (*ptr == ' ')) {
*ptr = '\0';
ptr++;
}
if (*ptr != '\0')
arglist[argc++] = ptr;
while (*ptr != '\0' && (*ptr != ' ')) {
ptr++;
}
}
/* process the arguments: */
while ((argc > 1) && (argv[1][0] == '-')) {
switch(argv[1][1]) {
case 'v':
verbose = 1;
break;
default:
break;
}
argc--;
argv++;
}
}