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

📄 comload.c

📁 优龙 ARM9 FS2410开发板的BIOS源程序!
💻 C
字号:
#include "def.h"
#include "2410addr.h"
#include "2410lib.h"

extern U32 downloadAddress, downloadFileSize;
static U8 *temp;

static void __irq Uart0RxInt(void)
{
    ClearSubPending(BIT_SUB_RXD0); //rSUBSRCPND = BIT_SUB_RXD0;          //Clear pending bit (Requested)
    ClearPending(BIT_UART0);

    *temp ++= RdURXH0(); 
}

void call_linux(U32 a0, U32 a1, U32 a2);

void comdownload(void)
{
	U32 size;
	U8 *buf;
	U16 checksum;
	
	puts("\nNow download file from uart0...\n");
	downloadAddress = _NONCACHE_STARTADDRESS;
	buf  = (U8 *)downloadAddress;
	temp = buf-4;		
	
	pISR_UART0 = (U32)Uart0RxInt;		//串口接收数据中断
	ClearSubPending(BIT_SUB_RXD0);
	ClearPending(BIT_UART0);
	EnableSubIrq(BIT_SUB_RXD0);
	EnableIrq(BIT_UART0);	

	while((U32)temp<(U32)buf)		
    {
        Led_Display(0);
        Delay(8000);
        Led_Display(15);
        Delay(8000);
    }							//接收文件长度,4 bytes	
	
	size  = *(U32 *)(buf-4);
	downloadFileSize = size-6;
    printf("Download File Size = %d\n", size);
	
	while(((U32)temp-(U32)buf)<(size-4))
	{		
		Led_Display(0);
        Delay(8000);
        Led_Display(15);
        Delay(8000);		
	}
	
	DisableSubIrq(BIT_SUB_RXD0);
	DisableIrq(BIT_UART0);
	
	checksum = 0;
	for(size=0; size<downloadFileSize; size++)
		checksum += buf[size];
	if(checksum!=(buf[size]|(buf[size+1]<<8))) {
		puts("Checksum fail!\n");
		return;
	}
	
	puts("Are you sure to run? [y/n]\n");
	while(1)
	{
		U8 key = getch();
		if(key=='n')
			return;
		if(key=='y')
			break;	
	}
	
	call_linux(0, 193, downloadAddress);
}

⌨️ 快捷键说明

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