inp000.c 5.29 KB
/**************************************************************************
 *                                                                        *
 *               Copyright (C) 1994, Silicon Graphics, Inc.               *
 *                                                                        *
 *  These coded instructions, statements, and computer programs  contain  *
 *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
 *  are protected by Federal copyright  law.  They  may not be disclosed  *
 *  to  third  parties  or copied or duplicated in any form, in whole or  *
 *  in part, without the prior written consent of Silicon Graphics, Inc.  *
 *                                                                        *
 *************************************************************************/

#include <bstring.h>
#include <stdio.h>
#include <mbi.h>	/* from software-land */

#include "inp.h"

static void checkResetRegs(void (*)(void), char *s);
static void dirtyShfState(void);
static void dirtyFullSyncState(void);
static void dirtyTileSyncState(void);
static void dirtyPipeSyncState(void);
static void dirtyLoadSyncState(void);
static void printTrailingCycles(void);

int
main(int argc, char *argv[])
{
	printHeader();
	resetFifo();
	checkResetRegs(dirtyShfState, "wr_adrs, read_adrs, cs_xbus_req");
	checkResetRegs(dirtyFullSyncState, "full_sync_state");
	checkResetRegs(dirtyTileSyncState, "tile_sync_state");
	checkResetRegs(dirtyPipeSyncState, "pipe_sync_state");
	checkResetRegs(dirtyLoadSyncState, "load_sync_state");
	printTrailingCycles();
}

static void
checkResetRegs(void (*dirtyFunc)(void), char *s)
{
	int i, j, k, l, m;
	vector_t v;
	vector_t *vp = &v;

	printf("# Verify %s after reset\n", s);

	bzero(vp, sizeof(*vp));

	for (i = 0; i < 2; i++) {
	    for (j = 0; j < 2; j++) {
		for (k = 0; k < 2; k++) {
		    for (l = 0; l < 2; l++) {
			for (m = 0; m < 2; m++) {

			    dirtyFunc();

			    printf("#  reset\n");

			    /*
			     * Last two vectors coinciding with reset can't
			     * set valid bit since C-sim  doesn't (and
			     * can't easily) simulate asynchronous reset
			     */
			    vp->data[0] = (G_NOOP << 24);
			    vp->data[1] = 0x0;

			    vp->reset_l = 1;
	                    printVector(vp, 0);

			    vp->reset_l = 0;
			    printVector(vp, 0);

	   		    vp->xbus_cs_valid = 1 - vp->xbus_cs_valid;
			}
			vp->ew_cs_busy = 1 - vp->ew_cs_busy;
		    }
		    vp->rel_sync_tile = 1 - vp->rel_sync_tile;
		}
		vp->rel_sync_pipe = 1 - vp->rel_sync_pipe;
	    }
	    vp->rel_sync_full = 1 - vp->rel_sync_full;
	}
}

static void
doNOOP(vector_t *vp)
{
	printf("#  NOOP\n");

	vp->data[0] = (G_NOOP << 24);
	vp->data[1] = 0x0;
	printVector(vp, 1);
}

static void
doTEXRECT(vector_t *vp)
{
	printf("#  TEXRECT\n");

	vp->gtexr.cmd = G_TEXRECT;
	vp->gtexr.xl = 100;
	vp->gtexr.yl = 150;
	vp->gtexr.tile = 2;
	vp->gtexr.xh = 200;
	vp->gtexr.yh = 250;
	printVector(vp, 1);

	vp->data[0] = 0xaabbccdd;
	vp->data[1] = 0x00640064;
	printVector(vp, 1);
}

static void
doTEXRECTFLIP(vector_t *vp)
{
	printf("#  TEXRECTFLIP\n");

	vp->xbus_cs_valid = 1;
	vp->rel_sync_tile = vp->rel_sync_pipe = vp->rel_sync_full = 0;

	vp->gtexr.cmd = G_TEXRECTFLIP;
	vp->gtexr.xl = 100;
	vp->gtexr.yl = 50;
	vp->gtexr.tile = 2;
	vp->gtexr.xh = 200;
	vp->gtexr.yh = 150;
	printVector(vp, 1);

	vp->data[0] = 0xaabbccdd;
	vp->data[1] = 0x00640064;
	printVector(vp, 1);
}

static void
doFULLSYNC(vector_t *vp)
{
	printf("#  FULLSYNC\n");

	vp->data[0] = (G_RDPFULLSYNC << 24);
	vp->data[1] = 0x0;
	printVector(vp, 1);
}
	
static void
doTILESYNC(vector_t *vp)
{
	printf("#  TILESYNC\n");

	vp->data[0] = (G_RDPTILESYNC << 24);
	vp->data[1] = 0x0;
	printVector(vp, 1);
}
	
static void
doPIPESYNC(vector_t *vp)
{
	printf("#  PIPESYNC\n");

	vp->data[0] = (G_RDPPIPESYNC << 24);
	vp->data[1] = 0x0;
	printVector(vp, 1);
}

static void
doLOADSYNC(vector_t *vp)
{
	printf("#  LOADSYNC\n");

	vp->data[0] = (G_RDPLOADSYNC << 24);
	vp->data[1] = 0x0;
	printVector(vp, 1);
}

static void
dirtyShfState(void)
{
	int i, j, k, l, m;
	vector_t v;
	vector_t *vp = &v;

	bzero(vp, sizeof(*vp));

	printf("#  dirty registers\n");
	vp->reset_l = 1;
	vp->xbus_cs_valid = 1;

	/* bump up read and write pointers */
	doNOOP(vp);

	/* bump up shf_state */

	doTEXRECT(vp);
	doTEXRECT(vp);
}

static void
dirtyFullSyncState(void)
{
	int i, j, k, l, m;
	vector_t v;
	vector_t *vp = &v;

	bzero(vp, sizeof(*vp));

	vp->reset_l = 1;
	vp->xbus_cs_valid = 1;

	/* bump up full_sync_state */

	doFULLSYNC(vp);

	doNOOP(vp);
}

static void
dirtyTileSyncState(void)
{
	int i, j, k, l, m;
	vector_t v;
	vector_t *vp = &v;

	bzero(vp, sizeof(*vp));

	vp->reset_l = 1;
	vp->xbus_cs_valid = 1;

	/* bump up tile_sync_state */

	doTILESYNC(vp);
}

static void
dirtyPipeSyncState(void)
{
	int i, j, k, l, m;
	vector_t v;
	vector_t *vp = &v;

	bzero(vp, sizeof(*vp));

	vp->reset_l = 1;
	vp->xbus_cs_valid = 1;

	/* bump up pipe_sync_state */

	doPIPESYNC(vp);
}

static void
dirtyLoadSyncState(void)
{
	int i, j, k, l, m;
	vector_t v;
	vector_t *vp = &v;

	bzero(vp, sizeof(*vp));

	vp->reset_l = 1;
	vp->xbus_cs_valid = 1;

	/* bump up load_sync_state */

	doLOADSYNC(vp);
}

static void
printTrailingCycles(void)
{
	int i;
	vector_t v;
	vector_t *vp = &v;

	printf("#  Trailing cycles\n");

	bzero(vp, sizeof(*vp));

	vp->reset_l = 1;

	for (i = 0; i < 3; i++)
		printVector(vp, 0);
}