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

📄 taskmain.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
字号:
/*******************************************************************************
 *
 *      file name : main.c
 *
 *	Copyright (C) SEIKO EPSON CORP. 2001
 *
 *	This file implement PDA CELLULAR SYSTEM TASK
 *
 *              Revision History
 *
 *              2001/05/23  Leon Zhong 	Start
 *				2001/10/9	Pessia		New taskmain()
 ********************************************************************************/
#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 "pen.h"

#include "FAL.h"

#include "systsk.h"
#include "taskdsp.h"
#include "sysusr.h"
#include "lmalloc.h"
#include "systmr.h"
#include "nucleus.h"
#include "stdio.h"					//041115 wuer

DWORD idle_stk[ STACK_SIZE*10];
DWORD sys_stk[ STACK_SIZE*4 ];
DWORD tmr_stk[STACK_SIZE];

DWORD fs_test_stk[STACK_SIZE];				//041115 wuer

extern void hardware_ini(void);
extern void fs_parameter_init(void);
extern void AsixTaskInit( void );

extern DWORD	mp3_server_stk[];
extern void Mp3Server(void);

/*
 *	for idle times test
 */
int Ttimes;
volatile int Itimes= 0;
int Iflags;
extern void DGB_Close_Disk(void); 
extern STATUS NU_Close_Disk(CHAR *path);

/************************************************************************
* FUNCTION                                                              
*                                                                       
*       FsTestServer(void)                                                   
*                                                                       
* DESCRIPTION                                                           
*                                                                       
*       This function test ASIX OS filesys 	
*                                                                       
* AUTHOR                                                                
*                                                                       
*      wuer
*                                                                       
* INPUTS                                                                
*  
*		NONE
*                                                                       
* OUTPUTS                                                               
*                                                                       
*       	NONE
*              
*************************************************************************/


/*
//#define TSIZE (3*1024*1024+32)
U32	TSIZE;
UINT8 *surbuff = NULL;
UINT8 *dstbuff = NULL;
char g_testfname[256];

U32 Freespace = 0x0;

void FsTestServer(void)				//041115 wuer 
{
	U32	status;
	FAL_FILE fd;
	int lenth, count;
	U32 fnamecount = 0; 
	int cyclenb = 0;   
	FAL_DIR  statobj;
	U32 freeneed= 0x0L;

	//U32 FILESIZEP[]={10032,343534,3232,25322C8}
	printf("Start test now!\n");

	FsTest_Allnamesdisp();
	FsTest_Freespacedisp();
	
	while(1)
	{
		freeneed = 0x0L;
			
		TSIZE = (U32)rand() % 0x300000;
		printf("------TSIZE is 0x%x\n",TSIZE);
		FsTest_FreespaceClean();

		surbuff = (UINT8 *)SysLmalloc(TSIZE);
		if(surbuff == NULL) 
		{
			printf("malloc surbuff failed*****************\n"); 
			goto NEXTROUND;
		}
		dstbuff = (UINT8 *)SysLmalloc(TSIZE);
		if(dstbuff == NULL)
		{
			printf("malloc dstbuff failed\n");
			SysLfree(surbuff);
			surbuff = NULL;
			goto NEXTROUND;
			////return;
		}

		HA_DMA_DATADEFINE(surbuff, TSIZE );
		
		cyclenb = cyclenb%2000;
		//get file name according to the given num
		sprintf(g_testfname,"c:\\tt%d.txt", cyclenb);

		
		fd = FAL_Open(g_testfname, PO_RDWR|PO_CREAT, FAL_IWRITE|FAL_IREAD);
		printf("----OPEN fd[%d]\n", fd);
		if((fd & 0xffff0000) != 0x0)
		{
			printf("FAL_Open %s  Faileed!\n",g_testfname);
			freeneed = 0x1L;
			goto NEXTROUND;
			////break;
		}
		
		lenth = FAL_Fwrite(surbuff, TSIZE, fd);
		printf("----WRITE len[%d] rlen[%d]\n", TSIZE, lenth);
		if(lenth == 0)
		{
			printf("FAL_Fwrite %s  Faileed!\n",g_testfname);
			printf("Maybe the disk is full.\n");
			FAL_Fclose(fd, 0);
			printf("----CLOSE fd[%d]\n", fd);
			freeneed = 0x1L;
			goto NEXTROUND;
			////break;
		}	
	
		FAL_Fclose(fd, 0);
		printf("----CLOSE fd[%d]\n", fd);
		
		
		fd = FAL_Open(g_testfname, PO_RDWR|PO_CREAT, FAL_IWRITE|FAL_IREAD);
		lenth = FAL_Fread(dstbuff, TSIZE, fd);
		printf("----READ len[%d] rlen[%d]\n", TSIZE, lenth);
		if(lenth != TSIZE)
		{
			printf("FAL_Fread %s  Faileed!\n",g_testfname);
			FAL_Fclose(fd, 0);
			printf("----CLOSE fd[%d]\n", fd);
			freeneed = 0x1L;
			goto NEXTROUND;
			////break;
		}
		FAL_Fclose(fd, 0);
		printf("----CLOSE fd[%d]\n", fd);

		status = FsTest_Check2Memory(surbuff, dstbuff, TSIZE);
		if(status != YES)
			printf("Not the same context!!!\n");

				
		freeneed = 0x1L;

NEXTROUND:
		if((freeneed & 0x1) == 0x1)
		{
			if(surbuff)
				SysLfree(surbuff);
			if(dstbuff)
				SysLfree(dstbuff);
			surbuff = NULL;
			dstbuff = NULL;
		}

		printf("NO.%d test is done!\n",cyclenb);
		cyclenb++;

	}

	printf("TEST is ternimated and the cyclenb is %d\n",cyclenb);

	FsTest_Freespacedisp();
	FsTest_Allnamesdisp();
	
	NU_Close_Disk("C:");
	while(1);

}

*/
void rtc_reset(void)
{
	*(RP)(0x10002004) = 0x00;	// clear second bit //小时、分钟、秒寄存器
	*(RP)(0x1000200c) = 0X00;	// enable rtc // 控制寄存器
	*(RP)(0x10002008) = 0x00;	// no interrupt occur // 中断使能寄存器
	//*(RP)(0x10002014) = 		// in order to clear int bit as if int happen// 中断状态寄存器
	*(RP)(0x10002018) = 0x400;	// 采样周期寄存器
}

U32	TSIZE;
UINT8 *surbuff = NULL;
UINT8 *dstbuff = NULL;
char g_testfname[256];

U32 Freespace = 0x0;

void FsTestServer(void)				//041115 wuer 
{
	U32	status;
	FAL_FILE fd;
	int lenth, count;
	U32 fnamecount = 0; 
	int cyclenb = 0;   
	FAL_DIR  statobj;
	U32 freeneed= 0x0L;

	
	U32 sumsize = 0x0;
	U32 sumwrtime = 0x0;
	U32 sumrdtime = 0x0;
	U32 m;
	
	count = 10;
	while(count > 0)
	{
		freeneed = 0x0L;
		cyclenb = cyclenb%2000;
		sprintf(g_testfname,"b:\\tt%d.txt", cyclenb);		
		TSIZE = (U32)rand() % 0x300000;

		sumsize +=TSIZE;

		
		printf("------TSIZE is 0x%x\n",TSIZE);
		FsTest_FreespaceClean();


		rtc_reset();
		surbuff = (UINT8 *)SysLmalloc(TSIZE);
		if(surbuff == NULL) 
		{
			printf("malloc surbuff failed*****************\n"); 
			goto NEXTROUND;
		}
		dstbuff = (UINT8 *)SysLmalloc(TSIZE);
		if(dstbuff == NULL)
		{
			printf("malloc dstbuff failed\n");
			SysLfree(surbuff);
			surbuff = NULL;
			goto NEXTROUND;
		}

		memset(surbuff, 0xf0, TSIZE);
		
		fd = FAL_Open(g_testfname, PO_RDWR|PO_CREAT, FAL_IWRITE|FAL_IREAD);
		//printf("----OPEN fd[%d]\n", fd);
		if((fd & 0xffff0000) != 0x0)
		{
			printf("FAL_Open %s  Faileed!\n",g_testfname);
			freeneed = 0x1L;
			goto NEXTROUND;
			////break;
		}
		
		lenth = FAL_Fwrite(surbuff, TSIZE, fd);
		//printf("----WRITE len[%d] rlen[%d]\n", TSIZE, lenth);
		if(lenth == 0)
		{
			printf("FAL_Fwrite %s  Faileed!\n",g_testfname);
			printf("Maybe the disk is full.\n");
			FAL_Fclose(fd, 0);
			printf("----CLOSE fd[%d]\n", fd);
			freeneed = 0x1L;
			goto NEXTROUND;
			////break;
		}	
	
		FAL_Fclose(fd, 0);
		//printf("----CLOSE fd[%d]\n", fd);


		m = *(RP)(0x10002004)&0x3F;
		////printf("wr time of 0x%x is: %d\n",TSIZE,m);
		if(m==0)  m=0x1;
		printf("write speed= %d KB\n",(TSIZE/m)>>10);
		sumwrtime += m; 





		rtc_reset();
		fd = FAL_Open(g_testfname, PO_RDWR|PO_CREAT, FAL_IWRITE|FAL_IREAD);
		lenth = FAL_Fread(dstbuff, TSIZE, fd);
		//printf("----READ len[%d] rlen[%d]\n", TSIZE, lenth);
		if(lenth != TSIZE)
		{
			printf("FAL_Fread %s  Faileed!\n",g_testfname);
			FAL_Fclose(fd, 0);
			printf("----CLOSE fd[%d]\n", fd);
			freeneed = 0x1L;
			goto NEXTROUND;
			////break;
		}
		FAL_Fclose(fd, 0);
		///printf("----CLOSE fd[%d]\n", fd);


		m = *(RP)(0x10002004)&0x3F;
		////printf("rd time of 0x%x is: %d\n",TSIZE,m);
		if(m==0)  m=0x1;
		printf("read speed= %d KB\n",(TSIZE/m)>>10);
		sumrdtime += m; 
		

		status = FsTest_Check2Memory(surbuff, dstbuff, TSIZE);
		if(status != YES)
			printf("Not the same context!!!\n");

				
		freeneed = 0x1L;

NEXTROUND:
		if((freeneed & 0x1) == 0x1)
		{
			if(surbuff)
				SysLfree(surbuff);
			if(dstbuff)
				SysLfree(dstbuff);
			surbuff = NULL;
			dstbuff = NULL;
		}

		printf("NO.%d test is done!\n",cyclenb);
		cyclenb++;
		count--;
	}

	printf("TEST is ternimated and the cyclenb is %d\n",cyclenb);


	printf("-----------write size is %d and the sum wr time is %d\n",sumsize,sumwrtime);
	printf("--------write speed  is %08d\n",(sumsize/sumwrtime));
	printf("-----------read size is 0x%x and the sum rd time is %d\n",sumsize,sumrdtime);
	printf("--------read speed  is %08d\n",(sumsize/sumrdtime));
	
	FsTest_Freespacedisp();
	FsTest_Allnamesdisp();
	
	//NU_Close_Disk("d:");
	while(1);

}


int tk = 0;

void idle_task( void )
{
	FAL_FILE fd;
	int *mpp = 0x31500000;
	int lenth, count;

	Ttimes=0;
	Itimes=0;
	
	if(tk != 0){
   		fd = FAL_Open("b:\\mbtt.mp3", PO_RDWR|PO_CREAT, FAL_IWRITE|FAL_IREAD);
		lenth = FAL_Fwrite(mpp, 3862763, fd);
		if( lenth!=3862763)
				printf("There is an error !!!!!");
		FAL_Fclose(fd, 0);
		NU_Close_Disk("b");
	}
	
	if(tk != 0){
   		fd = FAL_Open("b:\\ymhs.mp3", PO_RDWR|PO_CREAT, FAL_IWRITE|FAL_IREAD);
		lenth = FAL_Fwrite(mpp, 4675110, fd);
		if( lenth!=4695131)
				printf("There is an error !!!!!");
		FAL_Fclose(fd, 0);
		NU_Close_Disk("b");
	}
	
	if(tk != 0){
   		fd = FAL_Open("b:\\Dont cry.mp3", PO_RDWR|PO_CREAT, FAL_IWRITE|FAL_IREAD);
		lenth = FAL_Fwrite(mpp, 3421959, fd);
		if( lenth!=3421959)
				printf("There is an error !!!!!");
		FAL_Fclose(fd, 0);
		NU_Close_Disk("b");
	}
	
	if(tk != 0){
   		fd = FAL_Open("b:\\HERO.mp3", PO_RDWR|PO_CREAT, FAL_IWRITE|FAL_IREAD);
		lenth = FAL_Fwrite(mpp, 4098825, fd);
		if( lenth!=4098825)
				printf("There is an error !!!!!");
		FAL_Fclose(fd, 0);
		NU_Close_Disk("b");
	}
	

	//***********************************************************************
	if(tk != 0){
   		fd = FAL_Open("b:\\4jy.txt", PO_RDWR|PO_CREAT, FAL_IWRITE|FAL_IREAD);
		lenth = FAL_Fwrite(mpp, 563485, fd);
		if( lenth!=563485)
				printf("There is an error !!!!!");
		FAL_Fclose(fd, 0);

		fd = FAL_Open("b:\\6jy.txt", PO_RDWR|PO_CREAT, FAL_IWRITE|FAL_IREAD);
		lenth = FAL_Fwrite(mpp, 461784, fd);
		if( lenth!=461784)
				printf("There is an error !!!!!");
		FAL_Fclose(fd, 0);
		
		fd = FAL_Open("b:\\master.txt", PO_RDWR|PO_CREAT, FAL_IWRITE|FAL_IREAD);
		lenth = FAL_Fwrite(mpp, 748518, fd);
		if( lenth!=748518)
				printf("There is an error !!!!!");
		FAL_Fclose(fd, 0);

		NU_Close_Disk("b");
	}
	
	
	
	
	
	
	while(1) {
		
    	int i;
    	i++;
    }	

    
	return;
}


void  taskmain(void)
{
	sys_ini();
	
#ifdef GFD_ASIXOS
	hardware_ini();
	fs_parameter_init();
#endif

	/* initial gloable arrays */
	SysTcbTableInit();
	
	/* create system and service task */
	vcre_tsk( SYSTASK_ID, Systask, SYSTASK_PRI, (DWORD)&sys_stk[STACK_SIZE] );
       gSysTcbTbl[SYSTASK_ID-1].status = DORMANT;
	   
	vcre_tsk(IDLETASK_ID, idle_task, IDLETASK_PRI, (DWORD)&idle_stk[STACK_SIZE*10] );
       gSysTcbTbl[IDLETASK_ID-1].status = DORMANT;
	
	vcre_tsk( TIMERTASK_ID, timer_task, TIMERTASK_PRI, (DWORD)&tmr_stk[STACK_SIZE] );
	gSysTcbTbl[TIMERTASK_ID-1].status = DORMANT;


  
      
	/* create all application task and initial systcb table */
	AsixTaskInit();
		
 	sta_tsk(IDLETASK_ID, 0);    /* start idle task  */
 	gSysTcbTbl[IDLETASK_ID-1].status = RUNNING;
	
	sta_tsk(SYSTASK_ID, 0);		/* start system task  */
	gSysTcbTbl[SYSTASK_ID-1].status = RUNNING;

	
	sta_tsk(TIMERTASK_ID, 0);	/* start timer task  */
	gSysTcbTbl[TIMERTASK_ID-1].status = RUNNING;
	
	prints(0,"task schedule now!\n");
	
	sys_sta();	
}

⌨️ 快捷键说明

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