📄 bootmenu.c
字号:
" 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 int (*func)(int argc, char *argv[]); // return nonzero if it want to jumpt to kernel // argc : number of parameters // argv : parameter list char *helpbrief; // help message (brief) char *helpmsg; // help message (detail)} s_cmdtable[] = { { "help", bootmenu_help, s_help_help_brief, s_help_help }, { "boot", bootmenu_boot, s_help_boot_brief, s_help_boot }, { "config", bootmenu_config, s_help_config_brief, s_help_config }, { "download", bootmenu_download, s_help_download_brief, s_help_download }, { "dump", bootmenu_dump, s_help_dump_brief, s_help_dump },#ifdef CONFIG_BOOTMENU_BIST { "bist", bootmenu_bist, s_help_bist_brief, s_help_bist },#endif#ifdef CONFIG_ENABLE_FLASH { "flash", bootmenu_flash, s_help_flash_brief, s_help_flash },#endif#ifdef CONFIG_ENABLE_IDE { "ide", bootmenu_ide, s_help_ide_brief, s_help_ide },#endif { "info", bootmenu_info, s_help_info_brief, s_help_info},#ifdef CONFIG_ARCH_TANGO15#ifdef CONFIG_ENABLE_NETWORK_TANGO15 { "mac", bootmenu_mac, s_help_mac_brief, s_help_mac },#endif#endif { "mem", bootmenu_mem, s_help_mem_brief, s_help_mem },#ifdef CONFIG_ENABLE_FULLFUNCTION { "memcmp", bootmenu_memcmp, s_help_memcmp_brief, s_help_memcmp }, { "memcpy", bootmenu_memcpy, s_help_memcpy_brief, s_help_memcpy },#endif#ifdef CONFIG_ENABLE_NETWORK { "net", bootmenu_net, s_help_net_brief, s_help_net },#endif#ifdef CONFIG_ENABLE_PCI { "pci", bootmenu_pci, s_help_pci_brief, s_help_pci },#endif#ifdef CONFIG_ENABLE_PCIHOST_FPGA { "ppci", bootmenu_pci, s_help_ppci_brief, s_help_pci },#endif#ifdef CONFIG_ENABLE_SFLASH { "sflash", bootmenu_sflash, s_help_sflash_brief, s_help_sflash },#endif#ifdef CONFIG_ENABLE_FULLFUNCTION { "test", bootmenu_test, NULL, NULL },#endif { NULL, NULL, NULL, NULL },};#elsestatic struct { char *cmd; // command string int (*func)(int argc, char *argv[]); // return nonzero if it want to jumpt to kernel // argc : number of parameters // argv : parameter list} s_cmdtable[] = { { "help", bootmenu_help }, { "boot", bootmenu_boot }, { "config", bootmenu_config }, { "download", bootmenu_download }, { "dump", bootmenu_dump },#ifdef CONFIG_BOOTMENU_BIST { "bist", bootmenu_bist },#endif#ifdef CONFIG_ENABLE_FLASH { "flash", bootmenu_flash },#endif#ifdef CONFIG_ENABLE_IDE { "ide", bootmenu_ide }, #endif { "info", bootmenu_info }, #ifdef CONFIG_ARCH_TANGO15#ifdef CONFIG_ENABLE_NETWORK_TANGO15 { "mac", bootmenu_mac },#endif#endif { "mem", bootmenu_mem },#ifdef CONFIG_ENABLE_FULLFUNCTION { "memcmp", bootmenu_memcmp }, { "memcpy", bootmenu_memcpy },#endif#ifdef CONFIG_ENABLE_NETWORK { "net", bootmenu_net },#endif#ifdef CONFIG_ENABLE_PCI { "pci", bootmenu_pci },#endif#ifdef CONFIG_ENABLE_PCIHOST_FPGA { "ppci", bootmenu_pci },#endif#ifdef CONFIG_ENABLE_SFLASH { "sflash", bootmenu_sflash }, #endif#ifdef CONFIG_ENABLE_FULLFUNCTION { "test", bootmenu_test },#endif { NULL, NULL },};#endif /* !CONFIG_DISABLE_HELP_MSGS */struct { char *shortcut; char *cmd;} s_shortcuttable[] = { { "sdb", "download serial boot" },#ifdef CONFIG_ENABLE_2NDBOOT { "sdb2", "download serial 2ndboot" }, { "sdb2z", "download serial 2ndboot gz" },#endif { "sdbz", "download serial boot gz" }, { "sdk", "download serial kernel" }, { "sdkz", "download serial kernel gz" }, { "sdrz", "download serial romfs gz" }, { "ssfb", "config cache off;sflash boot;config cache on" }, { "scsf", "config serial fast" }, { "scsd", "config serial default" }, { NULL, NULL },};#ifdef CONFIG_BOOTMENU_BISTstatic const struct bist_entry { const unsigned int addr; const char *name; unsigned long mask;} bist_table[] = { { REG_BASE_audio_engine_0, "Audio Engine 0", 0 }, #ifdef CONFIG_ARCH_MAMBO { REG_BASE_audio_engine_1, "Audio Engine 1", 0 }, /* Only Mambo has it */#endif { REG_BASE_mpeg_engine_0, "MPEG Engine 0", 0 }, { REG_BASE_demux_engine, "Transport Demux Engine", 0 }, { REG_BASE_display_block, "Display Block", 0x30 /* Exclude graphic/vsync inputs as external clock needed */ }, { REG_BASE_host_interface, "Host Interface", 0 }, /* Host interface may be used for PFlash */ { REG_BASE_system_block, "System Block", 0 }, /* System block is used for clocks/pll */ { REG_BASE_cpu_block, "CPU Block", 0 }, /* CPU block is used to execute the code */ { REG_BASE_dram_controller_0, "DRAM Controller 0", 0 }, /* Cannot be BIST under bootmenu */#if defined(CONFIG_ARCH_MAMBO) && (DEFAULT_DRAM1_SIZE != 0) { REG_BASE_dram_controller_1, "DRAM Controller 1", 0 }, /* Only Mambo has DRAM1 */#endif// { REG_BASE_mpeg_engine_1, "MPEG Engine 1", 0 }, /* Not existed on Mambo/Tango */// { REG_BASE_dram_controller_2, "DRAM Controller 2", 0 }, /* Not existed */ { 0, NULL, 0 },};#define PBI_REGS 14#define DRAM_REGS 15#define BIST_TIMEOUT 1000 /* 1000ms */static int do_bist(const struct bist_entry *entry);#endif//// global variables// extern unsigned long loadaddr_romfs;extern unsigned long loadaddr_initrd;extern unsigned long loadaddr_kernel;extern unsigned long loadaddr_kernelfs;extern unsigned long loadaddr_temp;extern unsigned long loadaddr_boot;extern unsigned long loadaddr_heap_unzip;extern unsigned long loadaddr_heap_start;extern unsigned long loadaddr_heap_end;#ifdef CONFIG_ENABLE_2NDBOOTextern unsigned long loadaddr_2ndboot;#endif#ifdef CONFIG_ENABLE_IRQHANDLERextern unsigned long loadaddr_irqhandler;//int irqhandler_loaded = 0;#endif#ifdef CONFIG_ENABLE_BITMAPSextern unsigned long loadaddr_bitmap;#endif#ifdef CONFIG_ENABLE_UCODESextern unsigned long loadaddr_ucode;#endif#ifdef CONFIG_ENABLE_USERPREFextern unsigned long loadaddr_userpref;#endif#ifdef CONFIG_ENABLE_VSYNCPARAMextern unsigned long loadaddr_vsyncparam;#endif#ifdef CONFIG_ENABLE_DVIextern unsigned long loadaddr_dvi;#endifenum { DOWNLOAD_NONE, DOWNLOAD_BOOT, #ifdef CONFIG_ENABLE_2NDBOOTDOWNLOAD_2NDBOOT, #endifDOWNLOAD_ROMFS, #ifdef CONFIG_ENABLE_ROMFS2DOWNLOAD_ROMFS2, #endifDOWNLOAD_INITRD, DOWNLOAD_KERNEL, DOWNLOAD_KERNELFS, DOWNLOAD_MISC, DOWNLOAD_INSTFILE,#ifdef CONFIG_ENABLE_IRQHANDLERDOWNLOAD_IRQHANDLER,#endif#ifdef CONFIG_ENABLE_BITMAPSDOWNLOAD_BITMAP, #endif#ifdef CONFIG_ENABLE_UCODESDOWNLOAD_UCODE,#endif#ifdef CONFIG_ENABLE_USERPREFDOWNLOAD_USERPREF,#endif#ifdef CONFIG_ENABLE_VSYNCPARAMDOWNLOAD_VSYNCPARAM,#endif#ifdef CONFIG_ENABLE_DVIDOWNLOAD_DVI,#endifDOWNLOAD_MAX };static struct { int download; int len; unsigned int addr; unsigned char *filename;} g_download_info[DOWNLOAD_MAX] = { { 0, 0, 0, "" }, { 0, 0, 0, NULL },#ifdef CONFIG_ENABLE_2NDBOOT { 0, 0, 0, NULL },#endif { 0, 0, 0, NULL },#ifdef CONFIG_ENABLE_ROMFS2 { 0, 0, 0, NULL },#endif { 0, 0, 0, NULL }, { 0, 0, 0, NULL }, { 0, 0, 0, NULL }, { 0, 0, 0, NULL }, { 0, 0, 0, NULL },#ifdef CONFIG_ENABLE_IRQHANDLER { 0, 0, 0, NULL },#endif#ifdef CONFIG_ENABLE_BITMAPS { 0, 0, 0, NULL },#endif#ifdef CONFIG_ENABLE_UCODES { 0, 0, 0, NULL },#endif#ifdef CONFIG_ENABLE_USERPREF { 0, 0, 0, NULL },#endif#ifdef CONFIG_ENABLE_VSYNCPARAM { 0, 0, 0, NULL },#endif#ifdef CONFIG_ENABLE_DVI { 0, 0, 0, NULL },#endif};void download_init(void){ g_download_info[DOWNLOAD_BOOT].addr = loadaddr_boot; g_download_info[DOWNLOAD_ROMFS].addr = loadaddr_romfs;#ifdef CONFIG_ENABLE_ROMFS2 g_download_info[DOWNLOAD_ROMFS2].addr = loadaddr_romfs;#endif g_download_info[DOWNLOAD_INITRD].addr = loadaddr_initrd; g_download_info[DOWNLOAD_KERNEL].addr = loadaddr_kernel; g_download_info[DOWNLOAD_KERNELFS].addr = loadaddr_kernelfs; g_download_info[DOWNLOAD_MISC].addr = loadaddr_temp; g_download_info[DOWNLOAD_INSTFILE].addr = loadaddr_romfs; g_download_info[DOWNLOAD_MISC].filename = g_bootconfig.misc_filename; g_download_info[DOWNLOAD_INSTFILE].filename = g_bootconfig.inst_filename; g_download_info[DOWNLOAD_BOOT].filename = g_bootconfig.loader_filename; g_download_info[DOWNLOAD_ROMFS].filename = g_bootconfig.romfs_filename;#ifdef CONFIG_ENABLE_ROMFS2 g_download_info[DOWNLOAD_ROMFS2].filename = g_bootconfig.romfs_filename;#endif g_download_info[DOWNLOAD_KERNEL].filename = g_bootconfig.kernel_filename; g_download_info[DOWNLOAD_KERNELFS].filename = g_bootconfig.kernelfs_filename; g_download_info[DOWNLOAD_INITRD].filename = g_bootconfig.initrd_filename;#ifdef CONFIG_ENABLE_2NDBOOT g_download_info[DOWNLOAD_2NDBOOT].addr = loadaddr_2ndboot; g_download_info[DOWNLOAD_2NDBOOT].filename = g_bootconfig.scnd_loader_filename;#endif#ifdef CONFIG_ENABLE_IRQHANDLER g_download_info[DOWNLOAD_IRQHANDLER].addr = loadaddr_irqhandler; g_download_info[DOWNLOAD_IRQHANDLER].filename = g_bootconfig.irqhandler_filename;#endif#ifdef CONFIG_ENABLE_BITMAPS g_download_info[DOWNLOAD_BITMAP].addr = loadaddr_bitmap; g_download_info[DOWNLOAD_BITMAP].filename = g_bootconfig.bitmap_filename;#endif#ifdef CONFIG_ENABLE_UCODES g_download_info[DOWNLOAD_UCODE].addr = loadaddr_ucode; g_download_info[DOWNLOAD_UCODE].filename = g_bootconfig.ucode_filename;#endif#ifdef CONFIG_ENABLE_USERPREF g_download_info[DOWNLOAD_USERPREF].addr = loadaddr_userpref; g_download_info[DOWNLOAD_USERPREF].filename = g_bootconfig.userpref_filename;#endif#ifdef CONFIG_ENABLE_VSYNCPARAM g_download_info[DOWNLOAD_VSYNCPARAM].addr = loadaddr_vsyncparam; g_download_info[DOWNLOAD_VSYNCPARAM].filename = g_bootconfig.vsyncparam_filename;#endif#ifdef CONFIG_ENABLE_DVI g_download_info[DOWNLOAD_DVI].addr = loadaddr_dvi; g_download_info[DOWNLOAD_DVI].filename = g_bootconfig.dvi_filename;#endif}//// Main Menu Loop//int bootmenu(void){ int i; char str[256]; // initialize heap heap_init((void *)loadaddr_heap_start, loadaddr_heap_end - loadaddr_heap_start); download_init(); // detect peripherals and initialize them#ifdef CONFIG_ENABLE_SFLASH sflash_detect(0);#endif#ifdef CONFIG_ENABLE_FLASH // flash_probe(LOADER_FLASHBASE, 0, 0);#endif#ifdef CONFIG_ENABLE_IDE // ide_probe(0x03, 0);#endif#ifdef CONFIG_ENABLE_NETWORK // network#if defined(CONFIG_ENABLE_PCIHOST_EM86XX) pci_init(&g_pciem86xx_op, 1);#elif defined(CONFIG_ENABLE_PCIHOST_FPGA) pci_init(&g_pcifpga_op, 1);#endif net_init();#if 0 if (net_found() && g_bootconfig.protocol != BOOTNET_NONE) { em86xx_msleep(1500); // wait until device gets stable net_dev_up(); }#else /* Don't start network automatically */ if (net_found()) uart_puts("Use \"net up\" to enable network.\n");#endif#endif#ifdef CONFIG_ENABLE_FIP fip_init(); fip_write_text(0, fiptext = "MENU", FIP_CENTER);#endif uart_puts("\n"); // command loop for (;;) { // show prompt uart_puts(BOOTPROMPT); // get input from serial uart_getcmd(str); // process shortcut & batch for (i = 0; s_shortcuttable[i].shortcut; ++i) { if (strcmp(str, s_shortcuttable[i].shortcut) == 0) { char *cp = str, *cpend; strcpy(cp, s_shortcuttable[i].cmd); // strtok() function is used by bootmenu_command() // so this code does the parsing by itself. do { cpend = strchr(cp , ';'); if (cpend)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -