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

📄 fstest.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
字号:
/*******************************************************************************
 *
 *      file name : fstest.c
 *
 *	Copyright (C) ASIC SEU  2004
 *
 *	This file contain some functions used by fstest. 
 *
 *      Revision History
 *
 *              2004/11/15  wuer    tart
 *				
 ********************************************************************************/
#include <string.h>
#include "m68328.h"
#include "ros33.h"
#include "sysusr.h"
#include "hw.h"			//GFD
#include "hardware.h"	//GFD
#include "internal.h"	//GFD for test dispatch
#include "systsk.h"
#include "cdevice.h"

#include "hardware_reg.h"
#include "HA_typedef.h"

#include "plus/nucleus.h"

#include "net/inc/nu_net.h"
#include "FAL.h"

#include "systsk.h"
#include "taskdsp.h"
#include "sysusr.h"
#include "lmalloc.h"
#include "systmr.h"

#include "stdio.h"					//041115 wuer


			
//extern char  g_testfname[256];
extern U32 Freespace;


/************************************************************************
* FUNCTION                                                              
*                                                                       
*       FsTest_Allnamesdisp(void)                                                   
*                                                                       
* DESCRIPTION                                                           
*                                                                       
*       This function printf all files in nand flash  	
*                                                                       
* AUTHOR                                                                
*                                                                       
*      wuer
*                                                                       
* INPUTS                                                                
*  
*		NONE
*                                                                       
* OUTPUTS                                                               
*                                                                       
*       	NONE
*              
*************************************************************************/
void FsTest_Allnamesdisp(void)
{
	FAL_DIR  statobj;

	printf("Below is the table of files in Nand Flash:\n");
	printf("File name    Size Time     Other atrributions   \n");
	if (NU_Get_First(&statobj, "*.*") == NU_SUCCESS)
	{
		while(1)
		{
			printf("%s",statobj.sfname);
			if( statobj.fext[0] != ' ' )
				printf(".%s ", statobj.fext );
			else
				printf(" ");
			if( statobj.fattribute & ADIRENT)
			{
				printf(" <DIR>");
			}
			else if (statobj.fattribute & AVOLUME)
			{
				printf(" <VOL>");
			}
			else
			{
				printf("%6d", statobj.fsize );
			}
			printf(" %d-%d-%d %d:%d:%d ",
			((statobj.fupdate >> 9 ) & 0x007f) + 1980,
			((statobj.fupdate >> 5 ) & 0x000f),
			(statobj.fupdate & 0x001f),
			((statobj.fuptime >> 11 ) & 0x001f ),
			((statobj.fuptime >> 5 ) & 0x003f ),
			((statobj.fuptime << 1 ) & 0x003f ));
			printf(" %s\n",statobj.lfname );
			if (FAL_Find_Next(&statobj,0) != NU_SUCCESS) {
				NU_Done(&statobj);
			break;
			}

		}

	}
	printf("\n");
	printf("This is the end of table of files in Nand Flash:\n\n");
}


/************************************************************************
* FUNCTION                                                              
*                                                                       
*       FsTest_Freespacedisp(void)                                                   
*                                                                       
* DESCRIPTION                                                           
*                                                                       
*       This function printf bytes of Freespace room 
*                                                                       
* AUTHOR                                                                
*                                                                       
*      wuer
*                                                                       
* INPUTS                                                                
*  
*		NONE
*                                                                       
* OUTPUTS                                                               
*                                                                       
*       	NONE
*              
*************************************************************************/
void FsTest_Freespacedisp(void)
{
	Freespace = FAL_Disk_Space();
	printf("The free space of MMC is 0x%x!\n\n", Freespace);
}



/************************************************************************
* FUNCTION                                                              
*                                                                       
*        FsTest_Check2Memory(U32 suradd, U32 taradd, U32 num)                                                   
*                                                                       
* DESCRIPTION                                                           
*                                                                       
*       This function check 2 memory is the same or not
*                                                                       
* AUTHOR                                                                
*                                                                       
*      wuer
*                                                                       
* INPUTS                                                                
*  
*		easy to see
*                                                                       
* OUTPUTS                                                               
*                                                                       
*     0    --success
*     -1  --fail         
*************************************************************************/
U32 FsTest_Check2Memory(U32 add1, U32 add2, U32 num)
{
	U32 i;
	U32 errorbyte = 0x0L;
	
	for(i=0; i<num; i++)
	{
		if(  ( *(RP8) (add1 + i)) !=  *(RP8)(add2 + i))
		{
			printf("Compare error:\n");
			printf("adr:src=0x%08x, dst=0x%08x\n",(add1 + i), (add2 + i));
			printf("val:src=0x%08x, dst=0x%08x\n ",( *(RP8) (add1 + i)), (*(RP8)(add2 + i)));
			printf("adr offset=0x%08x\n\n", i);
			errorbyte++;
		}
	}

	printf("Compare result: wrong=%04d bytes in %d bytes file\n ",errorbyte,num);
	if(errorbyte)  return NO;
		else return YES;
}

/************************************************************************
* FUNCTION                                                              
*                                                                       
*        FsTest_FreespaceClean(void)                                                   
*                                                                       
* DESCRIPTION                                                           
*                                                                       
*       This function checks Free space and Clean out some room for creat new file
*             by remove some file randomly                                                          
* AUTHOR                                                                
*                                                                       
*      wuer
*                                                                       
* INPUTS                                                                
*  
*	void
*                                                                       
* OUTPUTS                                                               
*                                                                       
*     NONE 
*************************************************************************/
extern U32 TSIZE;
void FsTest_FreespaceClean(void)
{
	int filenum = 0,delfilename = 0;
	char tempfname[20];
	FAL_DIR  statobj;
	
	while(FAL_Disk_Space() < 5*TSIZE)
	{
		
		filenum = (int)((rand()) % 2000);
		//filenum = (int)((int)(rand()) % 200);
		sprintf(tempfname,"c:\\tt%d.txt", filenum++);
		if(FAL_Remove(tempfname) ==  NU_SUCCESS)
		{
			printf("---------remove a file name %s\n",tempfname);
			delfilename++;
		}
		/*
		if(filenum >= 2000) 
		{	
			printf("filename >= 2000\n");
			//break;
		}
		*/
		//else printf("Can not remove a file name %s\n",tempfname);
		
	}

	if ( delfilename )
	printf(" -------------removed files number is %d,and free space is 0x%x\n",delfilename,FAL_Disk_Space());
	
}


/*
while(cyclenb++ < 11)
	{
		sprintf(g_testfname,"d:\\tt%d.txt", cyclenb);
		if (NU_Get_First(&statobj, g_testfname) == NU_SUCCESS)
		{
			if(FAL_Remove(g_testfname) !=  NU_SUCCESS)  
			printf("Can not remove a file name %s\n",g_testfname);
					
		}
		else printf("Can not find a file name %s\n",g_testfname);
	}	

*/


⌨️ 快捷键说明

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