iotestebus.c 1.62 KB

/*************************************************************************
 *
 *  File: iotestebus.c
 *
 *  This file contains the routines to the E-bus data path through the MI
 *
 *  $Header: /root/leakn64/depot/rf/sw/n64os20l/iosim/src/iotestebus.c,v 1.2 2002/05/30 05:52:50 whs Exp $
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include "trace.h"
#include "iomap.h"
#include "iotest.h"

#ifndef __sgi__
	#ifndef u_int
		typedef unsigned int u_int;
	#endif 
#endif 

/***********************************************************************
 * Routines
 */

int
EbusTestPgRw(int a1, int a2, int a3, int a4)
{
	u_int data, ret;
	unsigned int address;
	int i, j, k;

	for (i = 0; i < 1/*RDRAM_MAX_COUNT*/; i++) {
	    for (j = 0; j < 1/*BANKS_PER_RDRAM*/; j++) {
		address = i * (BANKS_PER_RDRAM * RDRAM_BANK_SIZE)
			+ j * RDRAM_BANK_SIZE;
		for (k = 0; k < (2 * RDRAM_PAGE_SIZE)/sizeof(u_int); k++) {
		    data = (i << 3) | (j << 2) | (k & 0x3);
		    IO_WRITE(address, data);
		    address = address + sizeof(u_int);
		}  /* for */
	    }  /* for */
	}  /* for */

	for (i = 0; i < 1/*RDRAM_MAX_COUNT*/; i++) {
	    for (j = 0; j < 1/*BANKS_PER_RDRAM*/; j++) {
		address = i * (BANKS_PER_RDRAM * RDRAM_BANK_SIZE)
			+ j * RDRAM_BANK_SIZE;
		for (k = 0; k < (2 * RDRAM_PAGE_SIZE)/sizeof(u_int); k++) {
		    data = (i << 3) | (j << 2) | (k & 0x3);
		    ret = IO_READ(address);
		    if (data != ret) {
			errorCount++;
			_TRACE(DERROR, LOG_ERROR(data, ret));
		    }  /* if */
		    address = address + sizeof(u_int);
		}  /* for */
	    }  /* for */
	}  /* for */

	errorTotal += errorCount;

	return((errorCount == 0) ? 0 : -1);

}  /* EbusTestPgRw */