rdram.c 2.5 KB
 /* This test consists of two parts. The first part is for stressing both the in- */
 /* ternal and external address buses of RDRAMs. Then we check if there is any    */
 /* short circuit between bits in the second part.                                */
 /* The meaning of the argument is:                                               */
 /*   0: Test from 0x0000_0000 to 0x002f_ffff                                     */
 /*   1: Test from 0x0030_0000 to 0x003f_ffff                                     */
 /*   2: Test from 0x0030_0000 to 0x005f_ffff                                     */
 /*   3: Test from 0x0030_0000 to 0x007f_ffff                                     */
 /* This routine is ensured *ONLY* for argument 1.                                */

#include <ultra64.h>
#include <assert.h>
#include "main.h"

extern 	u32 checkShort(u32 *, u32 *);
extern	u32 stressInternalAddressBus(u32 *, u32 *);
extern  u32 stressExternalBus(u32);

u32 rdramCheck(u32 test_flag)
{
  u32 error_cnt=0;
  u32 *begadr, *endadr;
  
/* Both begadr and endadr should be on the word boundary */
  switch(test_flag)
  {
  case 0:			/* test from 0x0000_0000 to 0x002f_ffff */
    begadr = (u32 *)OS_PHYSICAL_TO_K1(START_ADDRESS0);
    endadr = (u32 *)OS_PHYSICAL_TO_K1(END_ADDRESS0);
    break;
  case 1:			/* test from 0x0030_0000 to 0x003f_ffff (for 4M test) */
    begadr = (u32 *)OS_PHYSICAL_TO_K1(START_ADDRESS1);
    endadr = (u32 *)OS_PHYSICAL_TO_K1(END_ADDRESS1);
    break;
  case 2:			/* test from 0x0030_0000 to 0x005f_ffff (for 6M test) */
    begadr = (u32 *)OS_PHYSICAL_TO_K1(START_ADDRESS2);
    endadr = (u32 *)OS_PHYSICAL_TO_K1(END_ADDRESS2);
    break;
  case 3:			/* test from 0x0030_0000 to 0x007f_ffff (for 8M test) */
    begadr = (u32 *)OS_PHYSICAL_TO_K1(START_ADDRESS3);
    endadr = (u32 *)OS_PHYSICAL_TO_K1(END_ADDRESS3);
    break;
  }
  
  begadr = (u32 *)((u32)begadr & ~(0x3));
  endadr = ((u32)endadr & 0x3)? (u32 *)(((u32)endadr & ~(0x3)) + 0x4) : endadr;
  
#ifdef DEBUG
  SOAKPRINTF("beg -- %04x end -- %04x\n", begadr, endadr);
#endif

/* First part. Stress the buses of RDRAMS. */
#ifdef DEBUG
  SOAKPRINTF("First Part\n");
#endif  

  error_cnt += stressInternalAddressBus(begadr, endadr);
  error_cnt += stressExternalBus(10);
  
/* Second part. Is there any short between bits? */
#ifdef DEBUG
  SOAKPRINTF("Second Part\n");
#endif  
  error_cnt += checkShort(begadr, endadr);

#ifdef DEBUG
  if(error_cnt)
    SOAKPRINTF("Rdram test ---- FAIL\n");
  else
    SOAKPRINTF("Rdram test ---- PASS\n");
#endif

  return error_cnt;
}