parse.c 1.31 KB

/*---------------------------------------------------------------------*
        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++;
    }
}