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

📄 tftpmain.c.bak

📁 自己编写移植的基于s3c44b0的bootloader源代码
💻 BAK
字号:
/****************************************************************
 *		ARMSYS7 S3C44B0X developer's notes						*  
 ****************************************************************

 1. 2005.5.17::
 
 ***************************************************************/

#include "..\inc\config.h"
#include "..\inc\utils.h"
#include "..\inc\board.h"
#include "..\inc\tftp\skbuff.h"
#include "..\inc\tftp\eth.h"
#include "..\inc\tftp\ip.h"
#include "..\inc\tftp\udp.h"
#include "..\inc\tftp\arp.h"
#include "..\myfution\myfution.h"
#include "..\exint\eint.h"


#ifdef	TFTP_DOWNLOAD_SUPPORT
#define MP3_PLAY_ADDRESS 0xc008000
char TftpLoadEnd;
char TftpPutBegin;
char TftpPutMark;
extern int dataLen;
struct tftphdr *tftpHdrMp3;
static char musicChange=0;
static int musicLen=0;

int net_handle(void)
{
	struct sk_buff *skb;
	struct ethhdr *eth_hdr;		
	
	skb = alloc_skb(ETH_FRAME_LEN);

	if (eth_rcv(skb) != -1) 
	{

		eth_hdr = (struct ethhdr *)(skb->data);					
		skb_pull(skb, ETH_HLEN);

		if (ntohs(eth_hdr->h_proto) == ETH_P_ARP)
			arp_rcv_packet(skb);

		else if(ntohs(eth_hdr->h_proto) == ETH_P_IP)						
		 	ip_rcv_packet(skb);
	 	
	}

	free_skb(skb);

	return 0;
}

//#include "params.h"

void tftp_main(U32 addr, U32 give_ip)
{
	unsigned char eth_addr[ETH_ALEN];
	unsigned char *s = (unsigned char *)&give_ip;
	int i=0;	
	
	printf("Mini TFTP Server 1.1 (IP : %d.%d.%d.%d PORT: %d)\n", s[3], s[2], s[1], s[0], TFTP);		
	printf("Example: tftp -i %d.%d.%d.%d put filename at the host PC\n", s[3], s[2], s[1], s[0]);
	puts("Press ESC key to exit\n");

	eth_init();
	if(eth_lnk_stat())
		return;
		
	eth_get_addr(eth_addr);		
//	arp_init();
	ip_init(give_ip);
	udp_init();
		
	arp_add_entry(eth_addr, give_ip);	

	TftpLoadEnd  = 0;
	TftpPutMark  = 0;
	TftpPutBegin = 0;
	Mp3Reset();
	Mp3SelectData();
	SoftDelay100ns(1);
	Mp3DeselectControl();
	SoftDelay100ns(1);
	while ((getkey()!=ESC_KEY)&&!TftpLoadEnd&&(i<=165))                //最大传送长度不超过180 ,MP3修改
	{		
		 
		net_handle();/*
		while(TftpPutBegin==0)
		{
		int DataCount=0,i,j;
		unsigned char *MP3Buf;
		MP3Buf=(unsigned char *)(0xc008000);  
		//   NandLoadMusic();
		for(i=0;i<32;i++)
		{
		         SPIPutChar(*MP3Buf);
		         MP3Buf++;
		         SoftDelay100ns(1);
		         while (MP3_DREQ_IN == 0);  
		}
		DataCount++;
		if(DataCount==16000)                    //播放500K数据
		{
			DataCount=0;
			MP3Buf=(unsigned char *)(0xc008000);
			printf("\nmusic play over\n");	
				
		}
		*/
//		}
		if(TftpPutBegin) 
		{
			puts("Starting the TFTP download...\n");
			TftpPutBegin = 0;
		}
		if(TftpPutMark) 
		{
			//putch('.');
			printf("%3d,",i++);
			TftpPutMark = 0;
			if((i%10)==0)
				printf("\n");	
			
		}
	}
}

void tftp_music(U32 addr, U32 give_ip)
{
	unsigned char eth_addr[ETH_ALEN];
	unsigned char *s = (unsigned char *)&give_ip;
	int i=0;
	int DataCount=0,j;
	unsigned char *MP3Buf;
	int musicCount=0;
	unsigned char *MP3Buf2;
	MP3Buf=(unsigned char *)(0xc008000);
	MP3Buf2=(unsigned char *)(MP3_PLAY_ADDRESS);	
	
	printf("Mini TFTP Server 1.1 (IP : %d.%d.%d.%d PORT: %d)\n", s[3], s[2], s[1], s[0], TFTP);		
	printf("Example: tftp -i %d.%d.%d.%d put filename at the host PC\n", s[3], s[2], s[1], s[0]);
	puts("Press ESC key to exit\n");

	eth_init();
	if(eth_lnk_stat())
		return;
		
	eth_get_addr(eth_addr);		
//	arp_init();
	ip_init(give_ip);
	udp_init();
		
	arp_add_entry(eth_addr, give_ip);	

	TftpLoadEnd  = 0;
	TftpPutMark  = 0;
	TftpPutBegin = 0;
	Mp3Reset();
	Mp3SelectData();
	SoftDelay100ns(1);
	Mp3DeselectControl();
	SoftDelay100ns(1);
	while ((getkey()!=ESC_KEY))         //&&(i<=180))//&&!TftpLoadEnd&&(i<=165))                //最大传送长度不超过180 ,MP3修改
	{		
		 
		if((TftpLoadEnd))           //(i>165))
		{
		  	printf("Mini TFTP Server 1.1 (IP : %d.%d.%d.%d PORT: %d)\n", s[3], s[2], s[1], s[0], TFTP);		
			printf("Example: tftp -i %d.%d.%d.%d put filename at the host PC\n", s[3], s[2], s[1], s[0]);
			puts("Press ESC key to exit\n");
		
			eth_init();
			if(eth_lnk_stat())
				return;
				
			eth_get_addr(eth_addr);		
		//	arp_init();
			ip_init(give_ip);
			udp_init();
				
			arp_add_entry(eth_addr, give_ip);	
		
			TftpLoadEnd  = 0;
			TftpPutMark  = 0;
			TftpPutBegin = 0;
			i=0;
//			Mp3Reset();
//			Mp3SelectData();
//			SoftDelay100ns(1);
//			Mp3DeselectControl();
//			SoftDelay100ns(1);		
			
		}
		net_handle();
		if(TftpPutBegin) 
		{
                  TftpPutBegin=0;
                  musicChange=1;
                  musicCount=0;
                  MP3Buf2=(unsigned char *)(MP3_PLAY_ADDRESS);
                  
                  
		}
		if(musicChange==0)
		{
			
			  
			//   NandLoadMusic();
			for(j=0;j<32;j++)
			{
			         SPIPutChar(*MP3Buf);
			         MP3Buf++;
			         SoftDelay100ns(1);
			         while (MP3_DREQ_IN == 0);  
			}
			DataCount++;
			if(DataCount==16000)                    //播放500K数据
			{
				DataCount=0;
				MP3Buf=(unsigned char *)(0xc008000);
				printf("\nmusic play over\n");	
					
			}
		}
		else if(musicChange==1)   //&&((musicCount<(dataLen/128))))
		{
			
			  
			//   NandLoadMusic();
			for(j=0;j<128;j++)
			{
			         SPIPutChar(*MP3Buf2);
			         MP3Buf2++;
			         SoftDelay100ns(1);
			         while (MP3_DREQ_IN == 0);  
			}
			musicCount++;
			if(musicCount==(dataLen/128))
			{
				musicCount=0;
				printf("\nnew play\n");
				MP3Buf2=(unsigned char *)(MP3_PLAY_ADDRESS);
				for(j=0;j<10;j++)                           //MP3 修改  2008年2月21日
				{                                           //
					tftp_send_ack(tftp_hdr, 50000);     //
				}
				TftpLoadEnd=1;                               //播放完一首歌后,Tftp重起
			}
//			if(DataCount==16000)                    //播放500K数据
//			{
//				DataCount=0;
//				MP3Buf=(unsigned char *)(0xc008000);
//				printf("\nmusic play over\n");	
					
//			}
		}
		if(TftpPutBegin) 
		{
//			puts("Starting the TFTP download...\n");
//			TftpPutBegin = 0;
		}
		if(TftpPutMark) 
		{
			//putch('.');
			printf("%3d,",i++);
			TftpPutMark = 0;
			if((i%10)==0)
				printf("\n");	
			
		}
//		if(i>180)
//		{
//			printf("\nmusic is too long\n");
//		}
	}
	while(musicCount<(dataLen/128))
	{
			
			  
			//   NandLoadMusic();
			for(j=0;j<128;j++)
			{
			         SPIPutChar(*MP3Buf2);
			         MP3Buf2++;
			         SoftDelay100ns(1);
			         while (MP3_DREQ_IN == 0);  
			}
			musicCount++;
//			if(DataCount==16000)                    //播放500K数据
//			{
//				DataCount=0;
//				MP3Buf=(unsigned char *)(0xc008000);
//				printf("\nmusic play over\n");	
					
//			}
	}
//        dataLen=0;
}


#endif

⌨️ 快捷键说明

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