loadkernel.c

来自「LPC2200 bootloader , 包括两个应用程序区」· C语言 代码 · 共 78 行

C
78
字号
#include  "config.h"
#include <string.h>

extern unsigned const char linux[];
extern const char romfs[];  
extern void UART0_SendStr(uint8 const *str);


uint8 const SEND_STRING2[] = "Loading uClinux kernel...... \r\n";
uint8 const SEND_STRING3[] = "Loading kernel finished!\r\n";
uint8 const SEND_STRING4[] = "Loading file system......\r\n";
uint8 const SEND_STRING5[] = "Loading file system finished!\r\n";

 void loadkernel()
{  
	
	unsigned int i, j;
	unsigned char from, *to;
	unsigned char *temp;
	void 	(*fp)(void);

	to   = (unsigned char*)0x81008000;	
	temp = (unsigned char*)linux;	
	UART0_SendStr(SEND_STRING2);
	
	memcpy(to,linux, 1.3*1024*1024);
	/* move 2Mbyte=4*0.5Mword */
	/* linux kernel size is about 1.2M */
	/***
	for(i = 0; i < 0x12CCD8/2; i++){
	//0.4*(0x100000); i++){
//	for(i = 0; i < 0.15*(0x100000); i++){
		from = 0;
		for(j = 0; j < 2; j++){
			from |= ((*temp) << (8*j));
			temp++;	
		}
		*to = from;
		to++;		
	}	
	**/
		
	UART0_SendStr(SEND_STRING3);
		
/*	to   = (int*)0x81200000;	
//	to   = (int*)0x81100000;	
	temp = (char*)romfs;
	UART0_SendStr(SEND_STRING4);
	/* file system size is about 2.0M 
	for(i = 0; i < 0.3*(0x100000); i++){
//	for(i = 0; i < 0.1*(0x100000); i++){
		from = 0;
		for(j = 0; j < 4; j++){
			from |= ((*temp) << (8*j));
			temp++;	
		}
		*to = from;
		to++;		
	}	
	
*/
	to   = (unsigned char*)0x81700000;	
	temp = (unsigned char*)romfs;	

	
	memcpy(to,romfs,0.6*1024*1024);
	UART0_SendStr(SEND_STRING5);
	    
	fp = (void (*)(void))0x81008000;		
	(*fp)();  //give charge to kernel。
	

	
	return;	
}


⌨️ 快捷键说明

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