inp001.c 3.55 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 simpleTest(void);
static void checkResetValues(void);
static void incrementWritePointer(void);
static void checkRequest(void);
static void doFILLRECT(vector_t *vp);
static void doNOOP(vector_t *vp, int);
static void printTrailingCycles(void);

int
main(int argc, char *argv[])
{
	printHeader();
	resetFifo();
	initFifo();
	resetFifo();
	incrementWritePointer();
	resetFifo();
	checkRequest();
	printTrailingCycles();
}

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

	printf("# Supply data, verify read/write pointers increment and wraps\n");

	bzero(vp, sizeof(*vp));

	vp->reset_l = 1;

	for (i = 0; i < 66; i++) {
		doNOOP(vp, 1);
	}
}

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


	bzero(vp, sizeof(*vp));
	vp->reset_l = 1;

	printf("# Verify cs_xbus_request goes low when (r < 32) && (w < 32)\n");

	doFILLRECT(vp);
	doFILLRECT(vp);

	printf("# Verify cs_xbus_request goes high when fifo empties\n");

	for (i = 0; i < 22; i++)
		doNOOP(vp, 1);

	vp->xbus_cs_valid = 0;
	vp->data64 = 0;

	for (i = 0; i < 37; i++)
		printVector(vp, 1);

	printf("# Verify cs_xbus_request goes low when (r < 32) && (w >= 32)\n");
	doFILLRECT(vp);
	doFILLRECT(vp);

	printf("# Verify cs_xbus_request goes high when fifo empties\n");

	for (i = 0; i < 22; i++)
		doNOOP(vp, 1);

	vp->xbus_cs_valid = 0;
	vp->data64 = 0;

	for (i = 0; i < 37; i++)
		printVector(vp, 1);
	printf("# Verify cs_xbus_request goes low when (r >= 32) && (w < 32)\n");

	doFILLRECT(vp);
	doFILLRECT(vp);

	printf("# Verify cs_xbus_request goes high when fifo empties\n");

	for (i = 0; i < 22; i++)
		doNOOP(vp, 1);

	vp->xbus_cs_valid = 0;
	vp->data64 = 0;

	for (i = 0; i < 37; i++)
		printVector(vp, 1);

	printf("# Verify cs_xbus_request goes low when (r < 32) && (w >= 32)\n");
	doFILLRECT(vp);
	doFILLRECT(vp);

	printf("# Verify cs_xbus_request goes high when fifo empties\n");

	for (i = 0; i < 22; i++)
		doNOOP(vp, 1);

	vp->xbus_cs_valid = 0;
	vp->data64 = 0;

	for (i = 0; i < 37; i++)
		printVector(vp, 1);

}

static void
doFILLRECT(vector_t *vp)
{
	printf("#  FILLRECT\n");

	vp->xbus_cs_valid = 1;
	vp->gfillr.cmd = G_FILLRECT;
	vp->gfillr.x0 = 100;
	vp->gfillr.y0 = 150;
	vp->gfillr.pad	= 0;
	vp->gfillr.x1 = 200;
	vp->gfillr.y1 = 250;
	printVector(vp, 1);
}

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

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

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);
}