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

📄 bios.c

📁 arm学习报告
💻 C
字号:
/*  * Compex BIOS for SAMSUNG S3C4510B v1.20 * modified by duyunhai(duyunhai@hotmailc.com) for "ARM study report 003" * bios-dyh v1.5 */#include "types.h"#include "bios.h"#include "board.h"#include "console.h"#include "utils.h"#include "gunzip.h"extern const unsigned long _rom_base;extern const unsigned long system_table_offset;extern const unsigned char sysinit_data[];extern const unsigned char biosapi_data[];extern const unsigned char tftp_data[];extern const unsigned char uart_rec_data[];int sys_init(struct system_table_struct *system_table, unsigned long rom_base, unsigned long dram_base){	typedef int (SYSINIT)(struct system_table_struct *, unsigned long, unsigned long);	SYSINIT *sys_init_ptr;	memcpy((char *)SRAM_BASE, sysinit_data, 1024 * 3);	sys_init_ptr = (SYSINIT *)SRAM_BASE;	sys_init_ptr(system_table, rom_base, dram_base);	return 0;}int biosapi_init(void){	unsigned char *inbuf;	unsigned long insize;	unsigned char *outbuf;	unsigned long outsize;	struct biosapi_init_struct init_param;	BIOSCALL *fp;	inbuf = (unsigned char *)biosapi_data;	outbuf = (unsigned char *)BIOS_API_ADDR;	insize = 0x7fffffff;	outsize = 0x7fffffff;	gunzip(inbuf, &insize, outbuf, &outsize);	init_param.rom_base = _rom_base;	init_param.dram_base = DRAM_BASE;	init_param.system_table_offset = system_table_offset;	fp = (BIOSCALL *)outbuf;	return (*fp)(0, (unsigned long)&init_param);  // Init BIOS call}int uart_receive(){		typedef int (UART_REC)(void);	UART_REC *uart_rec_ptr;		memcpy((char *)UART_REC_ADDR, uart_rec_data, 1024 * 5);		uart_rec_ptr= (UART_REC *)UART_REC_ADDR;		(*uart_rec_ptr)();		return 0;}int load_tftp(unsigned long mode, unsigned long param){	typedef int (TFTP)(unsigned long, unsigned long, unsigned long);	unsigned char *inbuf;	unsigned long insize;	unsigned char *outbuf;	unsigned long outsize;	unsigned long ip;	TFTP *tftp_ptr;	inbuf = (unsigned char *)tftp_data;	outbuf = (unsigned char *)TFTP_ADDR;	insize = 0x7fffffff;	outsize = 0x7fffffff;	gunzip(inbuf, &insize, outbuf, &outsize);	tftp_ptr = (TFTP *)TFTP_ADDR;	ip = bios_tftp_ipaddr();	tftp_ptr(ip, mode, param);	return 0;}int main_menu(struct system_table_struct *system_table){	int list[] = {		BOOT_LOAD_FIRMWARE,		BOOT_LOAD_PROGRAM,		BOOT_BIOS_SETUP,		BOOT_LOAD_UART0,		//bios-dyh modified		BOOT_UPDATE_BIOS,		BOOT_UPDATE_SYSPARAMETERS,		BOOT_UPDATE_PARTITIONTABLE,		BOOT_UPDATE_PARTITION,		BOOT_UPDATE_FIRMWARE,		};	int select;	int ch;	int sh;			printf("Main Menu For bios-dyh \r\n\r\n");	printf("1 - Run uClinux \r\n");	printf("2 - Load uClinux image to sdram by tftp and Run \r\n");	printf("3 - Burn uClinux image to flash \r\n");	printf("4 - Update BIOS!!! \r\n");	printf("5 - Load image to sdram from uart0 and run (Low Speed!!!)\r\n");	printf("\r\n");	printf("Please Select: ");		while (1) {		sh = getch();		if (sh >= '1' && sh <= '5') {					if (sh=='1')				ch='1';			if (sh=='2')				ch='2';			if (sh=='3')				ch='9';			if (sh=='4')				ch='5';			if (sh=='5')				ch='4';					putch(sh);			select = list[ch - '1'];			break;		}	}	printf("\r\n\r\n");	return select;}int menu(struct system_table_struct *system_table){	int select, partition_num = 0;	unsigned long input_data;	unsigned long i;	unsigned long linux_origin=0x01010000;	while (1) {		select = main_menu(system_table);		if (select == BOOT_LOAD_FIRMWARE) {			for(i=0;i<1024*1024*2;i++)			{				*(volatile unsigned char*)(0x8000+i)=*(volatile unsigned char*)(linux_origin+i);			}			asm(    "	                        ldr     r14, =0x00008000;	                        mov     PC, r14; "	                );			break;		}				switch (select) {		case BOOT_LOAD_PROGRAM:			load_tftp(select, partition_num);			break;				case BOOT_UPDATE_FIRMWARE: 	                printf("Sorry,this function is not complement!\r\n\n\n");			break;				case BOOT_UPDATE_BIOS: 			printf("Sorry,this function is not complement!\r\n\n\n");			break;									case BOOT_LOAD_UART0:						uart_receive();                        break;				default:			break;		}	}	return select;}/* *  Main BIOS functions */unsigned char *bios_main(void){	struct system_table_struct *system_table;	unsigned long startup_mode;	int i, ch;	system_table = (struct system_table_struct *)(_rom_base + system_table_offset);	sys_init(system_table, _rom_base, DRAM_BASE);	console_init();	printf("\r\n\r\n");	printf("Compex BIOS for SAMSUNG S3C4510B v1.20 (build 0801)\r\n\r\n");	printf("modified by duyunhai for 'ARM study report 003'\r\n");	biosapi_init();	printf("\r\n");	startup_mode = bios_startup_mode();	if (startup_mode == BOOT_MENU) {		startup_mode = menu(system_table);	}	return (unsigned char *)_rom_base;   //return to head.S with _rom_base in r0}

⌨️ 快捷键说明

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