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

📄 2410bios.c

📁 s3c2410 bios程序 可引导wince linux vxworks
💻 C
字号:
#include "def.h"
#include "2410addr.h"
#include "2410lib.h"
#include "2410slib.h"
#include "mmu.h"
#include "uart.h"
#include "timer.h"
#include "PowerManage.h"

void call_linux(U32 a0, U32 a1, U32 a2);
void UsbMain(void);
void comdownload(void);
void NandWrite(void);
void NandLoadRun(int);
void NandInputRun(void);
void NandErase(void);

extern U32 downloadAddress, downloadFileSize;
static EnvParams Env;
U32	Console_Uart = 0;
U32	Console_Baud = 115200;
char boot_params[256] = {"noinitrd root=/dev/bon/3 init=/linuxrc console=ttyS0"};

static short DsAutoBoot;

volatile int PwrKeyChkEnd;

//*****************************************************************************
static __inline int RtcAlmWake(void)
{	
	return ((rBCDHOUR==rALMHOUR)&&(rBCDMIN==rALMMIN));
}


/****************** by chang *****************************/
static void Set_Auto_Run(void)
{
	printf("Please Select Auto Boot OS: ,1:linux 2:wince 3: ucos-ii\n");
	Env.Os_Auto_Flag=getch()-'0';
	printf("%x\n",Env.Os_Auto_Flag);
	NFSaveParams((char *)&Env);
}
/***************** by chang *****************************/
struct {
	void (*fun)(void);
	char *tip;
}CmdTip[] = {
				{UsbMain, "USB download file"},
				{comdownload, "Uart download file"},
				{NandWrite, "Write Nand flash with download file"},
				{NandInputRun, "Load OS from Nand flash and run"},
				{NandErase, "Erase Nand flash regions"},
				{Set_Auto_Run,"Set AutoBoot parameter"},
				//{EnterPowerOff, "Test Power off"},
				{0, 0}						
			};

static int Auto_Run=0;	
//*****************************************************************************
static void AutoBoot(U32 i)
{
	static int cnt = 10;		//5s
	if(!--cnt) {
		ReleaseBiosTimerEvent(i);
		if((!DsAutoBoot)&&(Env.Os_Auto_Flag==1))Auto_Run=1;
		if((!DsAutoBoot)&&(Env.Os_Auto_Flag==2))Auto_Run=2;
		if((!DsAutoBoot)&&(Env.Os_Auto_Flag==3))Auto_Run=3;		
	}
}

void NandInputRun()
{
	char choice;
	
	puts("\nSelect The OS You Want to Run: 1. Linux,  2. Wince,  3. ucos-ii\n");	

	choice = getch() - '0';

	NandLoadRun((int)choice);
}	
		
	
/******************************************************************************
【功能说明】系统主函数
******************************************************************************/
int Main(U32 RstStat)
{
	int i;
	U8 idx;
	
	SetClockDivider(1, 1);
	SetSysFclk(FCLK_202_8M);		//use 202.8M
	
	Port_Init();
	Isr_Init();

	Uart_Init(0, Console_Baud);
	Uart_Select(Console_Uart);	
	
	//bank0 modified to RO_START
	MMU_Init();	//MMU should be reconfigured or turned off for the debugger, 
	//After downloading, MMU should be turned off for the MMU based program,such as WinCE.	
	
	//enable GPIO,UART0,PWM TIMER,NAND FLASH module clock
	EnableModuleClock(CLOCK_ALL);	

	Delay( 0 ) ;

	putch('\n');

	PwrKeyChkInit();
	
	if(RstStat&1) {
		puts("Power on reset\n");
	}
	if(RstStat&4) {
		puts("Watchdog reset\n");
	}
	if(RstStat&2) {
		puts("Power-off reset\n");
		if(RtcAlmWake()) {
			puts("Alarm wake up\n");
			printf("RTC hr : %d, min : %d\nALM hr : %d, min : %d\n", rBCDHOUR, rBCDMIN, rALMHOUR, rALMMIN);
		} else if( PwrKeyWake() ) {			
			PwrKeyChkEnd = 1;
			RequestBiosTimerEvent(1, PwrKeyChk);	//reload value = 1, 10ms*1 = 10ms
			while(PwrKeyChkEnd>0);
			if(PwrKeyChkEnd!=0)
				EnterPowerOff();
			puts("Power key wake up\n");
		}
	}	
		
	rMISCCR &= ~(0x3007);		//USB port0,1 = normal, D0~D31 pull-up enable

	
	RequestBiosTimerEvent(30, LedFlash);	//when request, auto open bios timer
		
	RequestBiosTimerEvent(1, AutoBoot);	//reload value = 50, 10ms*50 = 500ms
	NFSearchParams((char *)&Env);
	printf("Env.Os_Auto_Flag=%x\n",Env.Os_Auto_Flag);
	
	puts("************************************\n");
	puts("*                                  *\n");
	puts("*     S3C2410 Cyclone Board BIOS   *\n");
	puts("*     Http://www.trulyboy.com      *\n");
	puts("*                                  *\n");
	puts("************************************\n");
	
	puts("NAND Flash Boot\n");
	
	
	while(1)
	{
		idx=0;
		puts("\nPlease select function : \n");	
		for(i=0; CmdTip[i].fun!=0; i++)
			printf("%d : %s\n", i, CmdTip[i].tip);
		while(!idx)
		{
			if(Auto_Run && !DsAutoBoot)
				NandLoadRun(Auto_Run);
			Delay(10);
			idx=getkey();
		}
		DsAutoBoot = 1;	//when get a key press, disable auto boot
		idx -= '0';
		printf("You have input %x\n",idx);
		if(idx<i)
			(*CmdTip[idx].fun)();
	}
}

⌨️ 快捷键说明

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