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

📄 bios.c

📁 如果想自制一个自己的BOOTLOADER
💻 C
字号:
#include "def.h"
#include "addr.h"
#include "lib.h"
#include "slib.h"
#include "mmu.h"
#include "timer.h"



void NandLoadRun(void);

extern U32 downloadAddress, downloadFileSize;
static EnvParams Env;
U32	Console_Uart = 0;
U32	Console_Baud = 115200;
char boot_params[256];

static void AutoBoot(void)
{
	
	if(Env.Os_Auto_Flag==1)
		NandLoadRun();
	
	rGPBDAT ^= 1<<5;
}

/******************************************************************************
【功能说明】系统主函数
******************************************************************************/
int Main(U32 RstStat)
{
	int i;
	
	SetClockDivider(0, 1);
	SetSysFclk(FCLK_96M);		//to save power, use 48M
	
	Port_Init();
	Isr_Init();

	Uart_Init(0, Console_Baud);
	Uart_Select(Console_Uart);	
	
			
	MMU_Init();	//MMU should be reconfigured or turned off for the debugger, 
		
	//enable GPIO,UART0,PWM TIMER,NAND FLASH module clock
	EnableModuleClock(CLOCK_ALL);	

	puts("The Main function is called!\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");
	}	
		
	rMISCCR &= ~(0x3007);		//USB port0,1 = normal, D0~D31 pull-up enable

    
	
	
	
	puts("************************************\n");
	puts("*  Welcome study ARM & Linux      *\n");
	puts("************************************\n");

	Env.Os_Auto_Flag=1;
	AutoBoot();
	
	
	printf("Env.Os_Auto_Flag=%x\n",Env.Os_Auto_Flag);
	
	if(rBWSCON&6)
	{
		printf( "Not supported NorFlash found!!!\n" ) ;	
	}
	else 
		puts("NAND Flash Boot\n");
	
	
	while(1)
	{
		printf("Go to the while(1) loop!\n");
		
	}

}

⌨️ 快捷键说明

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