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

📄 bloader.c

📁 Boot code for ADM5120 with serial console for Edimax router.
💻 C
字号:
/*****************************************************************************;;   (C) Unpublished Work of ADMtek Incorporated.  All Rights Reserved.;;       THIS WORK IS AN UNPUBLISHED WORK AND CONTAINS CONFIDENTIAL,;       PROPRIETARY AND TRADESECRET INFORMATION OF ADMTEK INCORPORATED.;       ACCESS TO THIS WORK IS RESTRICTED TO (I) ADMTEK EMPLOYEES WHO HAVE A;       NEED TO KNOW TO PERFORM TASKS WITHIN THE SCOPE OF THEIR ASSIGNMENTS;       AND (II) ENTITIES OTHER THAN ADMTEK WHO HAVE ENTERED INTO APPROPRIATE;       LICENSE AGREEMENTS.  NO PART OF THIS WORK MAY BE USED, PRACTICED,;       PERFORMED, COPIED, DISTRIBUTED, REVISED, MODIFIED, TRANSLATED,;       ABBRIDGED, CONDENSED, EXPANDED, COLLECTED, COMPILED, LINKED, RECAST,;       TRANSFORMED OR ADAPTED WITHOUT THE PRIOR WRITTEN CONSENT OF ADMTEK.;       ANY USE OR EXPLOITATION OF THIS WORK WITHOUT AUTHORIZATION COULD;       SUBJECT THE PERPERTRATOR TO CRIMINAL AND CIVIL LIABILITY.;;------------------------------------------------------------------------------;;    Project : Common platform;    Creator :;    File    : loader.C;    Abstract: ;;Modification History:; ;;*****************************************************************************/#include <mips4kc.h>#include <adm5120.h>#include <hw_profile.h>#include <ctype.h>#ifdef	NOR_FLASH#include <mx29lv160.h>#include <mx29lv320.h>#include <flash.h>#else#include <nand.h>#endif#include <bconfig.h>#include <uartdrv.h>#include <if_5120.h>#include <linuxld.h>#include <banner.h>#include <param.h>#include <bsp_cfg.h>#define LOADER_BACK_DOOR_TIME   3#define LOADER_BACK_DOOR_HINT   (' ')#define LOADER_BACK_DOOR_COUNT  3#define LOADER_START_HINT       '@'char hexdigit[] = "0123456789abcdef";char bt_name[] = "\r\nADM0000 Boot:";// Already defined in memlib.c (DE)// void *_heap_h;extern void _icache_sync_all(void);/* * This routine prints the main menu  */static void print_menu(){	buart_print("\n\r"				"\n\rLoader Menu"				"\n\r==================================" "\n\r [1] Xmodem Download" "\n\r [2] TFTP Client Download" "\n\r [3] Print Boot Params" "\n\r [4] Set Boot Params" "\n\r [5] Update bootloader" "\n\r [6] Exit\n" "\n\rPlease enter your number:");}/* * This routine is the C entry pointer of the loader  */void c_entry(void){	int type;	register int i;	register int c;	unsigned long tick1, tick2;	void (*funcptr) (int);	int countdown = 3;	/* initialize uart, timer and flash */	buart_init();	//init mem space	memlib_init();	//init Timer        	InitTimer();#ifdef NOR_FLASH#if (HWPF_5120_SMEM0_BANK_SIZE == 0x200000)	mx29lv160_init();#endif#if (HWPF_5120_SMEM0_BANK_SIZE == 0x400000)	mx29lv320_init();	ADM5120_SW_REG(Mem_control_REG) |= 0x050000;#endif	flash_init();#endif	//print '@' at the very beginning	i = ADM5120_SW_REG(CODE_REG) & CODE_ID_MASK;	bt_name[5] = hexdigit[(i >> 12) & 0xf];	bt_name[6] = hexdigit[(i >> 8) & 0xf];	bt_name[7] = hexdigit[(i >> 4) & 0xf];	bt_name[8] = hexdigit[i & 0xf];	buart_print(bt_name);	buart_print("\n\r\n\r");	buart_print("\n\rCopyright 2002-2004  Infineon-ADMtek, Inc.");	buart_print("\n\rCPU: ADM");	buart_print(CPU_NO);	buart_put('-');	buart_print(CPU_CLOCK);	buart_print("\n\rSDRAM: ");	buart_print(SDRAM_SIZE);	buart_print("\n\rFlash: ");	buart_print(FLASH_TYPE);	buart_put('-');	buart_print(FLASH_SIZE);	buart_print("\n\rBoot System: ");	buart_print(BOOT_SYSTEM);	buart_print("\n\rLoader Version: ");	buart_print(LOADER_VERSION);	buart_print("\n\rCreation Date: ");	buart_print(CREATE_DATE);	buart_print("\n\r\n\rPress <space> key tree times to enter boot menu..");	buart_print("\n\r");	/* wait 3 second for back door */	buart_put(countdown + '0');	tick1 = UpTime();	for (i = 0; i < 3;) {		tick2 = UpTime();		if ((tick2 - tick1) >= 200) {			countdown--;			if (countdown < 0)				break;			buart_put('\r');			buart_put(countdown + '0');			tick1 = UpTime();		}		c = buart_get(0);		switch (c) {			case -1:				break;			case LOADER_BACK_DOOR_HINT:				if (++i == LOADER_BACK_DOOR_COUNT)					goto main_menu;				break;			default:				i = 0;				break;		}	}	/* boot Linux kernel */	boot_linux();	/* go back door */  main_menu:	// Read the Network configuration data.	if (boot_param_init() != 0) {		buart_print("\n\rRead bsp error.");		panic();	}	// Init Switch.	if (if5120_init() != 0) {		buart_print("\n\rSwitch init false.");		panic();	}	// Init networks for TFTP.	tftp_init();	//Bootloader Function Start.	while (1) {		print_menu();		c = (int) buart_getchar();		buart_put((char) c);		switch (c) {			case '1':				xmodem_download();				break;			case '2':				tftp_client_menu();				break;			case '3':				PrintBspParam();				break;			case '4':				set_boot_param();				break;			case '5':				update_bootloader();				break;			case '6':				boot_linux();				break;			default:				break;		}	}}

⌨️ 快捷键说明

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