📄 main.c
字号:
#include <config.h>#include <stdio.h>#include <time.h>#include <string.h>#include <command.h>#include <setup.h>#include <version.h>#define u16(x) (volatile unsigned *)(x)#define u32(x) (volatile unsigned *)(x)//#define GPSR0 *(volatile unsigned long *)(0x40e00018)//#define GPCR0 *(volatile unsigned long *)(0x40e00024)#define PWMCR0 *(volatile unsigned long *)(0x40b00000)#define PWMDCR0 *(volatile unsigned long *)(0x40b00004)#define PWMPCR0 *(volatile unsigned long *)(0x40b00008)#define LED8 (*(volatile unsigned short *)(0x10500000))extern void pxafb_disable(void);extern bool eth_init(void);extern bool uart_init(void);extern bool config_init(void);extern bool iflash_init(void);extern void DisplayMenu(void);extern void command_run(char *cCmd);extern void set_filename(void);extern void set_delaytime(void);extern void set_default(void);extern void tftp_Image(char *cImage);extern void filename_init(void);#include <board/xsbase270.h>int main(void){ int count; bool autoboot=true; //Audio, Rs232, LCD enable (*(volatile unsigned short *)(0x0a000000)) |= (1<<9)|(1<<6)|(1<<15); LED8 = 0xff; uart_init(); time_init(); config_init(); printf("\033[H\033[J\n"); // clear screen. printf(" Welcome to use %s Bootloader for XSBase270 board\n", PACKAGE); printf(" Copyright (C) 2002-2006 51Board Co,. Ltd.\n"); printf(" Support : http://www.51Board.com\n"); printf(" Version : %s\n", VERSION); iflash_init(); PWMPCR0 = 0xff; PWMDCR0 = (0x4ff>>2); //let eth CS is ok (*(volatile unsigned long *)(0x4800000c)) = _MSC1_ED; eth_init(); printf(" autoboot in progress, press any key to stop.\n"); count = setup->delay * 1000; printf(" Boot delay %d seconds ", setup->delay); autoboot = true; if (count == 0) { count = 500; do { if (getc() != -1){ autoboot=false; break; } --count; mdelay(1); }while (count); } else { do { if (getc() != -1){ autoboot=false; break; } if (!(--count%1000)) putc('.'); mdelay(1); }while (count); } putc('\n'); __asm__("mov r0, #3; mcr p14,0,r0,c6,c0,0"); if (autoboot){ printf(" autoboot started.\n"); autoboot_mode(); } printf(" autoboot aborted.\n"); //follows add by Chapter Jan 21th, 2006 bool bExit = false; while(!bExit) { DisplayMenu(); int iNum; bool bSelect = false; do { iNum = getc(); if ((iNum >= 48 && iNum <= 57) || iNum == 97 || iNum == 98 || iNum == 99) { printf("%c\n", iNum); bSelect = true; } } while (!bSelect); switch(iNum) { case 48: //ComanndLine mode command_mode(); break; case 49: //View current configuration command_run("set"); break; case 50: //Bootp command_run("bootp"); break; case 51: //Download default Kernel(zImage270) tftp_Image("kernel"); break; case 53: //Download default Filesystem(rootfs270.img) tftp_Image("filesystem"); break; case 52: //Flash Kernel command_run("flash kernel"); break; case 54: //Flash Filesystem command_run("flash root"); break; case 55: //boot System bExit = true; command_run("boot"); break; case 56: //Reboot System bExit = true; command_run("reboot"); break; case 57: //Reset to factory default configuration set_default(); break; case 97: //Set default Kernel name and Filesystem name set_filename(); break; case 98: //Set boot delay time set_delaytime(); break; case 99: //Help(to get a list of commands) command_run("help"); break; default: break; } } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -