⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parse.c

📁 详细介绍了一篇关于pci开发的接口芯片
💻 C
📖 第 1 页 / 共 2 页
字号:

static int useage( CHAR *exefile )
{
	int i;

	printf( 	"\n"
				"Useage:  <file1> <file2> <file3> {options} \n"
				"         file1/2/3 must be in order.\n"
			  	"         file1 is nvram boot image file captured by autoexec.bat\n"
			  	"         file2 is desired boot nvram image file\n"
			  	"         file3 is control chip nvram image file (for IDs)\n"
			  	"         The following options may be in any order, preceded by \"\\\":\n\n"
			);

	for ( i = 0; options[i].optstr != NULL; i++ )
	{
		if ( options[i].description == NULL )  continue;
		if ( stricmp(options[i].description, "BREAK") == 0 )
		{
			printf( "For more options, " );
			if ( pcontinue() == ESC ) return 1;		// "press key..."
			continue;
		}
		printf( "%8s  %s\n", options[i].optstr, options[i].description );
	}

	strip( text, exefile );	// dummy if want to use later
	return 1;
}

static int errexit( CHAR *string )
{
	printf( string );
	printf( errstring );
	return FALSE;
}


static CHAR *strip( CHAR *string, CHAR *stripped )
/*  strip off leading "\" from path stuff so only base filename
	remains.

	Entry:	string - input string
			stripped - output string
	Return:	stripped (pointerto the stripped stuff)
*/
{
	int status;
	char name[MAXFILE], ext[MAXEXT];

	status = fnsplit( string, NULL, NULL, name, ext);
	strcpy( stripped, name );
	if ( status & EXTENSION ) 
		strcat( stripped, ext );	// ext includes the dot "."

	return text;
}


static void enverr( void )
{
	fprintf( stderr, ENVSTR );
	exit(1);
}


static void checkenv( void )
{
	CHAR *verp, *dqp, *mdp, *ptp, *clockp, *pclockp, *aclockp;

	if ( (verp = getenv("VERSION5920")) == NULL )  enverr();
	if ( (dqp = getenv("DQMODE")) == NULL )  enverr();
	if ( (mdp = getenv("MDMODE")) == NULL )  enverr();
	if ( (ptp = getenv("PTMODE")) == NULL )  enverr();
	if ( (clockp = getenv("CLOCK")) == NULL )  enverr();
	if ( (pclockp = getenv("CLOCK_RATE_P")) == NULL )  enverr();
	if ( (aclockp = getenv("CLOCK_RATE_A")) == NULL )  enverr();


	if ( stricmp("16", dqp) == 0 )  dqmode_32 = FALSE;
	else if ( stricmp("32", dqp) == 0 )  dqmode_32 = TRUE;
	else enverr();

	if ( stricmp("OUT", mdp) == 0 ) mdmode_in = FALSE;
	else if ( stricmp("IN", mdp) == 0 ) mdmode_in = TRUE;
	else enverr();

	if ( stricmp("PASSIVE", ptp) == 0 ) ptmode_active = FALSE;
	else if ( stricmp("ACTIVE", ptp) == 0 ) ptmode_active = TRUE;
	else enverr();

	if ( stricmp("SYNC", clockp) == 0 ) sync_clock = TRUE;
	else if ( stricmp("ASYNC", clockp) == 0 ) sync_clock = FALSE;
	else enverr();

	sscanf( pclockp, "%x", &clock_rate_pci );
	sscanf( aclockp, "%x", &clock_rate_addon );
	sscanf( verp, "%x", &version_uut );

}

static int cmdline_pin_defaults( void )
/*
	Set up mode based on request. Verify that we could change the 
	values.

	Entry:	dqmode32 TRUE if want 32-bit mode
			mdmode_in TRUE if want MD always inputs
			ptmode_active TRUE if want active mode
	Return:	TRUE if OK, else FALSE and errstring
*/
{
	int failed = FALSE;

	if ( dqmode_32 )
	{
		bclr_control_reg( CTRL_DQMODE );	// set 32-bit mode
		if ( addon_width_16() )
			failed = TRUE;
	}
	else
	{
		bset_control_reg( CTRL_DQMODE );	// set 16-bit mode
		if ( !addon_width_16() )
			failed = TRUE;
	}

	if ( failed )
	{
		strcat( errstring, "Unable to modify DQMODE.\n" );
		return FALSE;
	}


	if ( mdmode_in )
	{
		bset_control_reg( CTRL_MDMODE );	// set as MD as inputs
		if ( !( read_status_register() & STAT_MDMODE ) )
			failed = TRUE;
	}
	else
	{
		bclr_control_reg( CTRL_MDMODE );	// set as MD as outputs
		if ( read_status_register() & STAT_MDMODE )
			failed = TRUE;
	}
	if ( failed )
	{
		strcat( errstring, "Unable to modify MDMODE.\n" );
		return FALSE;
	}


	if ( ptmode_active )
	{
		bclr_control_reg( CTRL_PTMODE );		// set active mode
		if ( read_status_register() & STAT_PTMODE )
			failed = TRUE;
	}
	else
	{
		bset_control_reg( CTRL_PTMODE );		// set passive mode
		if ( !(read_status_register() & STAT_PTMODE ) )
			failed = TRUE;
	}
	if ( failed )
	{
		strcat( errstring, "Unable to modify PTMODE.\n" );
		return FALSE;
	}

	return TRUE;
}

static int c_break( void )
{
	exit_program = TRUE;
	return 1;				// keep going for now
}

static void	set_passthru_defaults( void )
{
	int region;

	for ( region = MIN_PT_REGION; region <= MAX_PT_REGION; region++ )
	{
		if ( region_is_sram(region) )
			region_set_waits( region, cmdline_sram_wait );
		else
			region_set_waits( region, cmdline_fifo_wait );

		region_set_prefetch_size( region, prefetch & 3 );
		if ( wfifo )
			region_write_fifo_enable( region );
		else
			region_write_fifo_disable( region );
	}

	if ( priority ) bset_control_reg( CTRL_PRIORITY );
	else bclr_control_reg( CTRL_PRIORITY );
}


static int ask( CHAR *str )
{
	str[0] = str[0];				// dummy to make compiler not warn
	cmdline_ask = FALSE; 
	return TRUE;
}

static int exiterr( CHAR *str )
{
	str[0] = str[0];				// dummy to make compiler not warn
	cmdline_exit_on_error = FALSE; 
	return TRUE;
}

static int wfifof( CHAR *str )
{
	str[0] = str[0];				// dummy to make compiler not warn
	wfifo = TRUE;
	return TRUE;
}


// NOTE - the optional IDs are not normally
// They were added as debug when the board was failing
static int vendorid( CHAR *str )
{
	cmdline_vendor  = TRUE;
    sscanf( &str[0], "%x", &chip_uut.vendor_id );
	return TRUE;
}

static int did( CHAR *str )
{
	cmdline_device  = TRUE;
    sscanf( &str[0], "%x", &chip_uut.device_id );
	return TRUE;
}

static int svid( CHAR *str )
{
	cmdline_subsys_vendor_id  = TRUE;
    sscanf( &str[0], "%x", &chip_uut.subsys_vendor_id );
	return TRUE;
}

static int sid( CHAR *str )
{
	cmdline_subsys_id  = TRUE;
	sscanf( &str[0], "%x", &chip_uut.subsys_id );
	return TRUE;
}

static int loop( CHAR *str )
{
    if  ( str[0] == '\0' ) 
      	cmdline_loop = 0x7FFF;
    else
     	sscanf( &str[0], "%x", &cmdline_loop );
	return TRUE;
}

static int onetest( CHAR *str )
{
	cmdline_ask = FALSE; 
    sscanf( &str[0], "%x", &cmdline_only );
	cmdline_only++;		// 0 is inactive, so test# is +1
	return TRUE;
}

static int pause( CHAR *str )
{		   
	str[0] = str[0];				// dummy to make compiler not warn
	cmdline_pause_on_error = FALSE; 
	return TRUE;
}

static int quiet( CHAR *str )
{
	str[0] = str[0];				// dummy to make compiler not warn
	cmdline_quiet = TRUE; 
	return TRUE;
}

static int prefetchf( CHAR *str )
{
    sscanf( &str[0], "%x", &prefetch);
	return TRUE;
}

static int skip( CHAR *str )
{
	int testnum;

    sscanf( &str[0], "%x", &testnum);	// skip a test
	skiptest[testnum] = TRUE;
	return TRUE;
}

static int type( CHAR *str )
{
    sscanf( &str[0], "%x", &cmdline_type );
	return TRUE;
}

static int priorityf( CHAR *str )
{
	str[0] = str[0];				// dummy to make compiler not warn
	priority = TRUE;
	return TRUE;
}

static int sramwait( CHAR *str )
{
    sscanf( &str[0], "%x", &cmdline_sram_wait);
	return TRUE;
}

static int fifowait( CHAR *str )
{
    sscanf( &str[0], "%x", &cmdline_fifo_wait);
	return TRUE;
}

static int usehpf( CHAR *str )
{
	str[0] = str[0];				// dummy to make compiler not warn
	use_hp = FALSE;
	return TRUE;
}

static int help( CHAR *str )
{
	str[0] = str[0];				// dummy to make compiler not warn
	return TRUE;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -