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

📄 spitest.c

📁 GM5621原代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
	$Workfile:   spitest.c  $
	$Revision:   1.6  $
	$Date:   Aug 09 2004 15:38:08  $
*/

//******************************************************************
//
//		Copyright (C) 2003.  GENESIS MICROCHIP INC.
// All rights reserved.  No part of this program may be reproduced
//
//	Genesis Microchip Inc., 165 Commerce Valley Dr. West
//		Thornhill, Ontario, Canada, L3T 7V8
//
//================================================================
//
// MODULE:      spitest.c
//				contains functions to verify spi cache 
//				intended users are Genesis AE's doing chip verification
//
//******************************************************************

#include <mem.h>
#include ".\inc\all.h"


#ifdef ENABLE_CACHE_APPSTEST

//
// prototypes of SPI access functions in IROM
//

BYTE far gmi_ReadSPIByte (void);
BYTE far gmi_WriteSPIByte (BYTE);

#define ENABLE_DUMP_CACHE //un-comment to dump cache tag after test1

#if defined ENABLE_DUMP_CACHE && defined PHOENIX
	void PrintCache(void);
#else
	#define PrintCache()
#endif

#define msg(a,b) gm_Print((const char far *)a,b)

#define eightNops() \
         asm nop;   \
         asm nop;   \
         asm nop;   \
         asm nop;   \
         asm nop;   \
         asm nop;   \
         asm nop;   \
         asm nop;   

#define fortyEightNops() \
			eightNops() \
			eightNops() \
			eightNops() \
			eightNops() \
			eightNops() \
			eightNops() 
  
#define procnops() \
			eightNops() \
			eightNops() \
			eightNops() \
			eightNops() \
			asm nop; \
         asm nop		         
 
//static WORD spiStatus; //used to monitor whether SPI was accessed during procedure
static WORD cacheMissed; // counts of missed cache (scaled by spi_status possition of 128)

//void  near  Test2(void);
//void 	near Test3(void);
//
// test of loop  380 bytes long
// expect first two iterations to miss. 3rd to 100th iteration should all run from cache.
// Test passes if cacheMissed is < 4*SPI_EXCH_FLAG.  Note, TO elimiate a jump within the loop 
//  to determine if the loop came from the cache we simply accumulate the value of SPI_EXCH_FLAG
//  The function calling nop380 can report the value of cacheMissed

#if defined ENABLE_DUMP_CACHE &&  defined PHOENIX
static void  PrintCache(void)
{
		WORD index;
      BYTE regsave;
      WORD * cacheptr = (WORD*)0XA9c0;
      regsave = gm_ReadRegByte(SPI_CACHE_CTRL);
      gm_ClearRegBitsByte(SPI_CACHE_CTRL,SPI_CACHE_EN);

		for (index = 0; index <32; index++)
      {
        		
     		gm_Print("cachemem 0x%x", *cacheptr++);
      }
      gm_Print("ROM_TEST_SIG_0 0x%x",gm_ReadRegByte(ROM_TEST_SIG_0 ));
     gm_Print("ROM_TEST_SIG_1 0x%x",gm_ReadRegByte(ROM_TEST_SIG_1 ));
     gm_Print("ROM_TEST_SIG_2 0x%x",gm_ReadRegByte(ROM_TEST_SIG_2 ));
      gm_WriteRegByte(SPI_CACHE_CTRL,regsave);
}
#endif

//
// following test contains a loop of 380 bytes.  Nops padded to make for loop
// exactly 400 
void test1(void)
{
      WORD index;
      for (index = 0; index < 100; index++)
      {
      	gm_SetRegBitsByte( INPUT_STATUS, SPI_EXCH_FLAG);
       	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
  			eightNops();
  			eightNops();
  			eightNops();
  			eightNops();
         asm nop;
         asm nop;
         asm nop;
  
      	cacheMissed += gm_ReadRegByte(INPUT_STATUS) & SPI_EXCH_FLAG;
  	   }
      PrintCache();
}
//
// 366 byte loop
//
void nop341(void)
{
      WORD index;
      for (index = 0; index < 100; index++)
      {
      	gm_SetRegBitsByte( INPUT_STATUS, SPI_EXCH_FLAG);
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
//			eightNops();
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;

      	cacheMissed += gm_ReadRegByte(INPUT_STATUS) & SPI_EXCH_FLAG;
 	   }
        PrintCache();
}

void nop343(void)
{
      WORD index;
      for (index = 0; index < 100; index++)
      {
      	gm_SetRegBitsByte( INPUT_STATUS, SPI_EXCH_FLAG);
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
//			eightNops();
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;

      	cacheMissed += gm_ReadRegByte(INPUT_STATUS) & SPI_EXCH_FLAG;
 	   }
      PrintCache();
}
void nop344(void)
{
      WORD index;
      for (index = 0; index < 100; index++)
      {
      	gm_SetRegBitsByte( INPUT_STATUS, SPI_EXCH_FLAG);
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
//			eightNops();
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
      	cacheMissed += gm_ReadRegByte(INPUT_STATUS) & SPI_EXCH_FLAG;
 	   }
        PrintCache();
}
#if   1
void nop345(void)
{
      WORD index;
      for (index = 0; index < 100; index++)
      {
      	gm_SetRegBitsByte( INPUT_STATUS, SPI_EXCH_FLAG);
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
//			eightNops();
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop ;
         asm nop;
         asm nop;
      	cacheMissed += gm_ReadRegByte(INPUT_STATUS) & SPI_EXCH_FLAG;
 	   }
        PrintCache();
}
void nop346(void)
{
      WORD index;
      for (index = 0; index < 100; index++)
      {
      	gm_SetRegBitsByte( INPUT_STATUS, SPI_EXCH_FLAG);
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
//			eightNops();
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop ;
         asm nop;
         asm nop;
         asm nop;
      	cacheMissed += gm_ReadRegByte(INPUT_STATUS) & SPI_EXCH_FLAG;
 	   }
        PrintCache();
}

void nop347(void)
{
      WORD index;
      for (index = 0; index < 100; index++)
      {
      	gm_SetRegBitsByte( INPUT_STATUS, SPI_EXCH_FLAG);
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
//			eightNops();
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;

      	cacheMissed += gm_ReadRegByte(INPUT_STATUS) & SPI_EXCH_FLAG;
 	   }
        PrintCache();
}
#endif
void nop342(void)
{
      WORD index;
      for (index = 0; index < 100; index++)
      {
      	gm_SetRegBitsByte( INPUT_STATUS, SPI_EXCH_FLAG);
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
      	fortyEightNops();
//			eightNops();
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;
         asm nop;

      	cacheMissed += gm_ReadRegByte(INPUT_STATUS) & SPI_EXCH_FLAG;
 	   }
        PrintCache();
}





//
// test of execution of different procedure.  Main procedure and 6 sub procedures
// should each take less than 52 bytes.  Check SPI_EXCH_FLAG to determine if 
//  spi was accessed during during any procedure.  This flag will be set after first
//  time proc was set.  There should be a gap between each procedure.
//

void	near Proc1(void)
{
	procnops();
}
void	 ProcPad1(void)
{
	procnops();
}
void	near Proc2(void)
{
	procnops();
}
void	 ProcPad2(void)
{
	procnops();
}
void	near Proc3(void)
{
	procnops();
}
void	 ProcPad3(void)
{
	procnops();
}
void near 	Proc4(void)
{
	procnops();
}
void	 ProcPad4(void)
{
	procnops();
}
void	near Proc5(void)
{
	procnops();
}
void 	ProcPad5(void)
{
	procnops();
}
void	near Proc6(void)
{
	procnops();
}
void 	 near ProcPad6(void)
{
	procnops();
}

void (near *proclist[])(void)  = 
{
	Proc1, Proc2, Proc3, Proc4, Proc5, Proc6,
   Proc1, Proc2, Proc3, Proc4, Proc5, Proc6,

⌨️ 快捷键说明

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