📄 bootmenu.c
字号:
/***************************************** Copyright (c) 2002-2005 Sigma Designs, Inc. All Rights Reserved Proprietary and Confidential *****************************************//* This file is part of the EM86XX boot loader *//* * bootmenu.c * * process loader menu loop * * by Ho Lee 12/10/2002 */#include "config.h"#include "bootmenu.h"#include "uart.h"#include "io.h"#include "hardware.h"#include "irqs.h"#include "em86xxapi.h"#include "boot.h"#include "romfs.h"#include "bootconfig.h"#include "net.h"#include "net_ipv4.h"#include "util.h"#include "vsprintf.h"#include "system.h"#include "kunzip.h"#include "sflash.h"#include "flash.h"#include "pciem86xx.h"#include "pcifpga.h"#include "ide.h"#include "atapi.h"#include "timer.h"#include "memcfg.h"#ifdef CONFIG_ENABLE_FIP#include "fip.h"extern const char *fiptext;int downloading = 0;#endifextern unsigned long dram0_size;extern memcfg_t *memcfg_ptr;//// external function prototypes//// from main.cint build_kernel_param_tag(void);// from uucodec.cint serial_uudecode(unsigned char *buf, int maxlen);// // function prototypes//int bootmenu(void);int bootmenu_command(char *_str);int bootmenu_help(int argc, char *argv[]);int bootmenu_dump(int argc, char *argv[]);int bootmenu_boot(int argc, char *argv[]);int bootmenu_config(int argc, char *argv[]);int bootmenu_download(int argc, char *argv[]);int bootmenu_flash(int argc, char *argv[]);int bootmenu_ide_checkdrive(char *str, int flag, int exist);int bootmenu_ide_checkblock(char *str, int ispart, int exist, int drive);int bootmenu_ide(int argc, char *argv[]);#ifdef CONFIG_ARCH_TANGO15int bootmenu_mac(int argc, char *argv[]);#endifint bootmenu_info(int argc, char *argv[]);int bootmenu_mem(int argc, char *argv[]);int bootmenu_memcmp(int argc, char *argv[]);int bootmenu_memcpy(int argc, char *argv[]);int bootmenu_net(int argc, char *argv[]);int bootmenu_net_up(int force);int bootmenu_pci(int argc, char *argv[]);int bootmenu_sflash(int argc, char *argv[]);int bootmenu_test(int argc, char *argv[]);void flash_erase_usr(void);void dump_memory(void *memptr, unsigned int addr, int num, int unit);//// Constant messages//static const char *recv_msg = "Received %d(0x%x) bytes @ 0x%08x\n";static const char *unzip_msg = "Unzipping to 0x%08x\n";static const char *jmp_msg = "Jump directly to 0x%08x\n";static const char *nofile_msg = "Specify file to download\n";#ifdef CONFIG_ENABLE_FLASHstatic const char *dl_ram_msg = "Download %s to RAM first\n";#endif#ifdef CONFIG_ENABLE_FULLFUNCTIONstatic const char *flashw_msg = "Specify address and data to be written\n";#endif#ifdef CONFIG_ENABLE_IRQHANDLERconst char *irqhandler_init_msg = "Initializing IRQ handler @ 0x%08lx.\n";#endif//// command table//#ifndef CONFIG_DISABLE_HELP_MSGSstatic char s_help_help_brief[] = " help : shows list of commands\n" " help <command> : help on command\n";static char s_help_help[] = "";static char s_help_boot_brief[] = " boot <target> : boots kernel\n";static char s_help_boot[] = " rom : loads kernel from ROMFS in ROM and boots\n"#ifdef CONFIG_ENABLE_CRYPTO " romcrypt : loads encrypted kernel from ROMFS in ROM and boots\n"#endif#ifdef CONFIG_ENABLE_IDE " ide : looks for the bootable image in IDE devices and boots\n" " ide <drive> <part> [subpart] : loads kernel or romfs from IDE device and boots\n" " cd : loads kernel or romfs from CDROM and boots\n"#ifdef CONFIG_ENABLE_CRYPTO " cdcrypt : looks for the encrypted bootable image in CD (ATAPI) device and boots\n"#endif#endif#ifdef CONFIG_ENABLE_NETWORK " net : loads kernel via network and boots\n"#ifdef CONFIG_ENABLE_CRYPTO " netcrypt : loads encrypted kernel via network and boots\n"#endif#endif#ifdef CONFIG_ENABLE_FULLFUNCTION " romfs : loads kernel from ROMFS in RAM and boots\n"#endif " kernel : boots kernel directly on RAM\n" " initrd : boots kernel with separate initrd on RAM\n" " boot : boots downloaded bootloader (TESTLOADERONRAM=y)\n" " <addr> : jumps to specified address\n" ;static char s_help_config_brief[] = " config <conf> [options] : configures boot loader\n";static char s_help_config[] = " cmd <command line string> : Kernel command line string\n"" clock [speed] : CPU clock configuration\n"" valid speed range : 100 - 200 MHz\n"" serial [baudrate] : UART configuration\n"" valid baud rate : 9600, 19200, 38400 (def), 57600, 115200 (fast)\n"#ifdef CONFIG_ENABLE_NETWORK" net : network configuration\n"" file : download filename setting\n"#endif" cache/icache/dcache [on|off] : Enables or disables internal caches\n";static char s_help_download_brief[] = " download <media> <target> [gz] [address] [size] : downloads image via various media\n";static char s_help_download[] = " <media> : serial / ram / romfs"#ifdef CONFIG_ENABLE_NETWORK" / net "#endif#ifdef CONFIG_ENABLE_USERPREF#ifdef CONFIG_ENABLE_VSYNCPARAM" / flash "#endif#endif"\n"" <target> : boot / romfs / initrd / kernel / kernelfs / binary / instfile "#ifdef CONFIG_ENABLE_2NDBOOT"/ 2ndboot "#endif#ifdef CONFIG_ENABLE_IRQHANDLER"/ irqhandler "#endif#ifdef CONFIG_ENABLE_BITMAPS"/ bitmap "#endif#ifdef CONFIG_ENABLE_UCODES"/ ucode "#endif#ifdef CONFIG_ENABLE_USERPREF"/ userpref "#endif#ifdef CONFIG_ENABLE_VSYNCPARAM"/ vsyncparam "#endif#ifdef CONFIG_ENABLE_DVI"/ dvi "#endif"/ <addr>\n"" boot : boot loader (loader.bin)\n"#ifdef CONFIG_ENABLE_2NDBOOT " 2ndboot : secondary boot loader (2ndloader.bin)\n"#endif#ifdef CONFIG_ENABLE_USERPREF " userpref : user preference image (userpref.bin)\n"#endif#ifdef CONFIG_ENABLE_VSYNCPARAM " vsyncparam : display parameters structure\n"#endif#ifdef CONFIG_ENABLE_DVI " dvi : I2C commands to send to silicon image before displaying splashscreen\n"#endif#ifdef CONFIG_ENABLE_IRQHANDLER " irqhandler : irqhandler image (irqhandler.bin)\n"#endif#ifdef CONFIG_ENABLE_BITMAPS " bitmap : bitmap image (bitmap.bin)\n"#endif#ifdef CONFIG_ENABLE_UCODES " ucode : microcode image (ucode.bin)\n"#endif " romfs : rom filesystem (romfs.bin)\n" " initrd : initial ramdisk (initrd.bin)\n" " kernel : kernel (linux.bin)\n" " kernelfs : kernel with separate filesystem (linux.bin)\n" " binary : any binary (address needs to be provided)\n" " instfile : installable file\n" " [gz] option : allows gzipped image. not used with 'ram' media\n" " [address] : valid with 'ram' media only\n" " [size] : valid with 'ram' media only\n" ;static char s_help_dump_brief[] = " dump [option] [addr] [len] : dumps memory area\n";static char s_help_dump[] = " [option] : -l (4 bytes), -w (2 bytes), -b (1 byte)\n" ;#ifdef CONFIG_ENABLE_FLASHstatic char s_help_flash_brief[] = " flash <command> [args...] : flash commands\n";static char s_help_flash[] = " probe [addr] : probe flash\n" " list : show flash chip information\n" " boot : write boot loader image on RAM into FLASH\n"#ifdef CONFIG_ENABLE_2NDBOOT " 2ndboot : write secondary boot loader image on RAM into FLASH\n"#endif#ifdef CONFIG_ENABLE_USERPREF " userpref : write user preference image on RAM into FLASH\n"#endif " romfs : write ROMFS image on RAM into FLASH\n"#ifdef ENABLE_ENCRYPTED_OPT_ROM " romfscrypt[1-4] : write additional encrypted ROMFS image on RAM into FLASH\n"#endif#ifdef ENABLE_SIGNED_OPT_ROM " romfssign[1-4] : write additional signed ROMFS image on RAM into FLASH\n"#endif#ifdef CONFIG_ENABLE_FULLFUNCTION " erase <addr> [len] : erase one or more sectors of flash memory\n" " eraseall : erase all flash memory\n" " writeb <addr> <data> : write one byte of data into specified address\n" " writew <addr> <data> : write one word of data into specified even address\n" " write <to> <from> <len> : write block of data into specified address\n"#endif ;#endif#ifdef CONFIG_ENABLE_IDEstatic char s_help_ide_brief[] = " ide <cmd> [args...] : IDE commands\n";static char s_help_ide[] = " probe <drive> : probes drive (0/1)\n" " probeall : probes all drives\n" " eject <drive> [open] : opens or closes CD-ROM tray\n" " kernel <drive> <partition> [subpart] [addr] [length] : writes kernel image into IDE device\n" " romfs <drive> <partition> [subpart] [addr] [length] : writes romfs image into IDE device\n"#ifdef CONFIG_ENABLE_FULLFUNCTION " partition <drive> : shows partition table information\n" " read <drive> <block> : reads one sector\n" " readdma <drive> <block> : reads one sector by DMA\n" " readblock <addr> <drive> <block> <len> : reads blocks from IDE device\n" " writeblock <addr> <drive> <block> <len> : writes blocks to IDE device\n" " readpart <addr> <drive> <partition> <len> : reads block from specified partition in IDE device\n" " writepart <addr> <drive> <partition> <len> : writes blocks to specified partition in IDE device\n" " sense <drive> : shows CD-ROM sense information\n" " perf [<total-blocks> <blocks per transfer>] : performance test\n"#endif ;#endifstatic char s_help_info_brief[] = " info <class> : shows information on specified class\n";static char s_help_info[] = " edge : shows edge detector registers\n" " irq : shows interrupt controller registers\n" " fiq : shows fast interrupt controller registers\n" " sflash : shows serial flash controller registers\n" " pb : shows peripheral bus registers\n" " gpio : shows GPIO status\n"#ifdef CONFIG_ENABLE_FULLFUNCTION " romfs : shows the file list in ROMFS in ROM\n"#endif "" ;#ifdef CONFIG_ARCH_TANGO15static char s_help_mac_brief[] = " mac <op> [args] : reads/writes mac address to EEPROM\n";static char s_help_mac[] = " read : reads six bytes of addr\n" " write <addr1>..<addr6>: reads six bytes of addr\n"#ifdef CONFIG_ENABLE_FULLFUNCTION " dump : dump 256 bytes of EEPROM memory\n" " subwrite <subaddr> <len> <data1> <data2>..: write <len> bytes of data to <subaddr>\n"#endif ;#endifstatic char s_help_mem_brief[] = " mem <op> [args] : reads from or writes to memory\n";static char s_help_mem[] = " rb <addr> : reads one byte of data\n" " rw <addr> : reads two bytes of data\n" " rl <addr> : reads four bytes of data\n" " wb <addr> <data> : writes one byte of data\n" " ww <addr> <data> : writes two bytes of data\n" " wl <addr> <data> : writes four bytes of data\n" " sum <addr> <size> : gives the sum of size bytes from addr\n" #ifdef CONFIG_ENABLE_FULLFUNCTION " findb/findw/findl <data> <from> <to> : finds 32-bits data in the specified area\n" " clear : clears memory. must reboot after clearing memory\n"#endif ;#ifdef CONFIG_ENABLE_FULLFUNCTIONstatic char s_help_memcmp_brief[] = " memcmp <addr1> <addr2> [len] : compares memory region\n";static char s_help_memcmp[] = "";static char s_help_memcpy_brief[] = " memcpy <to> <from> [len] : copies memory region\n";static char s_help_memcpy[] = "";#endif#ifdef CONFIG_ENABLE_NETWORKstatic char s_help_net_brief[] = " net <command> [args...] : network commands\n";static char s_help_net[] = " config : shows current network configuration\n" " up : enables networking\n" " down : disables networking\n" " arp : shows entire ARP table\n" " arp <IP addr> : gets the hardware address of specified host\n" " ping <IP addr> : sends an ICMP echo message to specified host\n" " dhcp : requests DHCP\n" " status : shows network device status\n"#ifdef CONFIG_ENABLE_FULLFUNCTION " tftp <IP addr> <filename> : downloads specified file from specified server\n"#ifdef CONFIG_ENABLE_NETWORK_DNS " dns <hostname> : resolves IP address from host name\n"#endif " dump : dumps ethernet RX buffer contents\n"#endif ;#endif#ifdef CONFIG_ENABLE_PCIstatic char s_help_pci_brief[] = " pci <command> [args...] : PCI operation\n";static char s_help_pci[] = " info : shows information about PCI host controller\n" " scan : scans entire PCI bus for PCI devices\n" " select <idsel> : selects specified device as current device\n"#ifdef CONFIG_ENABLE_FULLFUNCTION " config <idsel> : configures PCI device and enable device\n" " dump <idsel> : shows device information located @ specified slot\n" " inl <addr> : Read 4 bytes from PCI I/O space\n" " readl <addr> : Read 4 bytes from PCI memory space\n"#endif ;#ifdef CONFIG_ENABLE_PCIHOST_FPGAstatic char s_help_ppci_brief[] = " ppci <command> [args...] : PCI operation\n";#endif#endif#ifdef CONFIG_ENABLE_SFLASHstatic char s_help_sflash_brief[] = " sflash <command> [args...] : sflash operation\n";static char s_help_sflash[] = " probe : probes serial flash\n" " force : specifies serial flash model\n" " forcelist : shows supported serial flash models\n" " boot : writes downloaded bootloader image into serial flash\n"#ifdef CONFIG_ENABLE_FULLFUNCTION " erase <addr> <len> : erases one or more sectors of serial flash memory\n" " eraseall : erases all serial flash memory\n" " writeb <addr> <data> : writes one byte of data into specified address\n" " write <to> <from> <len> : writes block of data into specified address\n"#endif ;#endif#elsestatic const char *no_help_msg = "Help is not available.\n";#endif /* !CONFIG_DISABLE_HELP_MSGS */#ifndef CONFIG_DISABLE_HELP_MSGSstatic struct { char *cmd; // command string
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -