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

📄 dmc_test.c

📁 s3c6400 ADS下官方测试程序
💻 C
字号:
/**************************************************************************************
* 
*	Project Name : S3C6400 Validation
*
*	Copyright 2006 by Samsung Electronics, Inc.
*	All rights reserved.
*
*	Project Description :
*		This software is only for validating functions of the S3C6400.
*		Anybody can use this software without our permission.
*  
*--------------------------------------------------------------------------------------
* 
*	File Name : DMC_test.c
*  
*	File Description : This file implements the functons for DRAM controller test.
*
*	Author : Wonjoon Jang
*	Dept. : AP Development Team
*	Created Date : 2007/02/10
*	Version : 0.1 
* 
*	History
*	- Created(wonjoon.jang 2007/02/10)
*  
**************************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#include "def.h"
#include "option.h"
#include "library.h"
#include "sfr6400.h"
#include "system.h"
#include "sysc.h"
#include "dma.h"
#include "intc.h"
#include "timer.h"

#include "dmc.h"

static DMAC oDmact0;
extern volatile int g_DmaDone;

void DMC_Test(void);


// Temp. function
void MemoryDump0( u32 *DumpAddress, u32 line)
{
	u32 i,j;
	
	for(i=0;i<line;i++) {
		printf("%08x : ",(u32)DumpAddress);
		for(j=0;j<8;j++) {
			printf("%08x ",*DumpAddress++);
		}
		putchar('\n');
	}
	putchar('\n');
}


void Mem_dump0 (void)
{

	int ch;
	
	
	 while(1)
    {
    	printf("dump address, '-1' to Exit \n");
    	//ch = Uart_getc();
    	ch = GetIntNum();
    		if(ch==-1)
    	{
    		break;
    	}
    	else
    	{
    	    	
    	MemoryDump0( ((u32 *)(ch)), 40);
    	}

    }

}






//////////
// Function Name : DMC0_Test
// Function Description : DMC0 Init & Access Test
// Input : 	None
// Output :	None 
// Version : v0.1
static void DMC0_Test(void)
{
	u32 i, check_size, uDMC1_TestAddr, uDMC0_TestAddr;
	u32 uerror = 0;

    check_size			= 0x100000;
    uDMC1_TestAddr	= _DRAM_BaseAddress + 0x1000000;
    uDMC0_TestAddr  	= _DRAM0_BaseAddress+ 0x1000000;
		
	
	
	DMC_Init(0, eALLEN,   eDIS_AutoPD , 0 );


	printf("DMC0 Initialized \n");

	
     	
    for(i=uDMC1_TestAddr;i<(uDMC1_TestAddr+check_size);i+=4)
    	*((unsigned int *)i)=i^0x55555555;
    	//*((unsigned int *)i)=0x55555555;
    
    
   

	Copy(uDMC1_TestAddr, uDMC0_TestAddr,check_size );
           

 	
    for(i=0;i<(0+check_size);i+=4)
    {
    	if(*((unsigned int *)(uDMC0_TestAddr+i))!=((uDMC1_TestAddr+i)^0x55555555))
    //	if(*((unsigned int *)i)!=(0x55555555))
    	{
    	    printf("Mem Error:0x%x=0x%x(%x)\n",(uDMC0_TestAddr+i),*((unsigned int *)(uDMC0_TestAddr+i)),(uDMC1_TestAddr+i)^0x55555555);
    	    uerror++;
    	}
    	if(uerror>20)
	    break;
    }
    if(uerror)
    	printf("DMC0 Access test:FAILED\n"); 
    else 
    	printf("DMC0 Access test:O.K.\n");	
	


}






void __irq Dma0Donet(void)
{
    	u32 uTime;
    	
  	DMACH_ClearIntPending(&oDmact0);
 	//rDMAC0IntTCClear = 0xff;
 	uTime = StopTimer(0);
	printf ("uTime %d\n", uTime);
	g_DmaDone=1;
	g_DmaDone++;
	INTC_ClearVectAddr();
       //Write_VECTADDR(0x0);
}

void DRAM_Copy_Test(void)
{
	u32 uMode,uTime, uBurst;

	printf("Select Operating Mode: 0: Sync,   1: Async \n");
	uMode = GetIntNum();
	

	switch(uMode)
		{
			case 0:		// Sync Mode
			SYSC_ChangeSYSCLK_1(eAPLL532M, eAPLL266M, 0, 1, 3);
			SYSC_ChangeMode(eSYNC_MODE);
			SYSC_ChangeSYSCLK_1(eAPLL532M, eAPLL266M, 0, 1, 3);
			
			break;

			case 1:		//ASync Mode
			SYSC_ChangeMode(eASYNC_MODE);
			SYSC_ChangeSYSCLK_1(eAPLL532M, eAPLL266M, 0, 0, 3);
			break;
		}

	printf("....\n");
	UART_Getc();

	 StartTimer(0);
   
	 Copy(0x51000000, 0x52000000, 0x40000);	// 1M 

	 uTime = StopTimer(0);

	 printf("Word Copy Time: %d us \n", uTime);

	 StartTimer(1);
   
	 Copy16(0x52000000, 0x53000000, 0x80000);	// 1M 

	 uTime = StopTimer(1);

	 printf("HWord Copy Time: %d us \n", uTime);

	 StartTimer(2);
   
	 Copy8(0x53000000, 0x54000000, 0x100000);	// 1M 

	 uTime = StopTimer(2);

	printf("Byte Copy Time: %d us \n", uTime);

	printf("\nSelect Burst Size : 0:SINGLE, 1:BURST4, 2:BURST8, 3:BURST16, 4:BURST32, 5:BURST64, 6:BURST128, 7:BURST256	: ");
	uBurst=GetIntNum();

     	DMAC_InitCh(DMA0, DMA_ALL, &oDmact0);
	INTC_SetVectAddr(NUM_DMA0,  Dma0Donet);
	INTC_Enable(NUM_DMA0);
	 printf("Word Copy Time: ");
	// 1MB
	DMACH_Setup(DMA_A, 0x0, 0x51000000, 0, 0x52000000, 0, WORD, 0x40000, DEMAND, MEM, MEM, (BURST_MODE)uBurst, &oDmact0);
        // Enable DMA
        g_DmaDone=0;
       StartTimer(0);
	DMACH_Start(&oDmact0);

	while(g_DmaDone==0);								// Int.

	 //uTime = StopTimer(0);
	 printf("HWord Copy Time: ");
	 // 1MB
	DMACH_Setup(DMA_A, 0x0, 0x51000000, 0, 0x52000000, 0, HWORD, 0x80000, DEMAND, MEM, MEM, (BURST_MODE)uBurst, &oDmact0);
        // Enable DMA
        g_DmaDone=0;
       StartTimer(0);
	DMACH_Start(&oDmact0);
 
	while(g_DmaDone==0);		
 
	printf("BYTE Copy Time: ");
	 // 1MB
	DMACH_Setup(DMA_A, 0x0, 0x51000000, 0, 0x52000000, 0, BYTE, 0x100000, DEMAND, MEM, MEM, (BURST_MODE)uBurst, &oDmact0);
        // Enable DMA
        g_DmaDone=0;
       StartTimer(0);
	DMACH_Start(&oDmact0);
	while(g_DmaDone==0);		  
	
}


///////////////////////////////////////////////////////////////////////////////////
////////////////////                    DMA Main Test                  /////////////////////////// 
///////////////////////////////////////////////////////////////////////////////////

const testFuncMenu dmc_menu[] =
{
		0,                      		"Exit",
		Mem_dump0,			 	"Memory dump",
		DMC0_Test,		               	"Test DMC0",
		DRAM_Copy_Test,			"Copy...",
		0,0
};

void DMC_Test(void)
{
	u32 i;
	s32 uSel;

	printf("[DMC_Test]\n\n");
	

	while(1)
	{
		for (i=0; (u32)(dmc_menu[i].desc)!=0; i++)
			printf("%2d: %s\n", i, dmc_menu[i].desc);

		printf("\nSelect the function to test : ");
		uSel =GetIntNum();
		printf("\n");
		if(uSel == -1) 
			break;
		if (uSel==0)
			break;
		if (uSel>=0 && uSel<(sizeof(dmc_menu)/8-1))
			(dmc_menu[uSel].func) ();
	}
}	




⌨️ 快捷键说明

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