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

📄 bootmenu.c

📁 1. 8623L平台
💻 C
📖 第 1 页 / 共 5 页
字号:
                        for (i = 0; asklist[i].title != NULL; ++i) {                if (g_bootconfig.protocol != BOOTNET_STATIC && !asklist[i].common)                    continue;                while (1) {                    // if the class of IP address has changed                     // or the current netmask value is invalid,                    // validate the netmask as default                    if (i == 1) {                        if (netmask == INADDR_ANY || netmask == INADDR_BROADCAST ||                            (ipaddr != newipaddr && class != newclass && ipv4_ipaddr_valid(newipaddr))) {                            g_bootconfig.netmask = ipv4_get_default_netmask(newipaddr);                        }                    }                    addr = htonl(*asklist[i].addr);                    cp = (unsigned char *) &addr;                                        // Get the string                    uart_printf("  %s : (%d.%d.%d.%d) ",                         asklist[i].title,                        cp[0], cp[1], cp[2], cp[3]);                    uart_gets(str, sizeof str, 0);                    if ((trim(str))[0] == 0)                        break;                    // Parse the string                    if (parse_netaddr(str, cp, 4) == 0) {                        addr = ntohl(addr);                        // if IP address class has changed, adjust netmask                        if (i == 0) {                            if (!ipv4_ipaddr_valid(addr))                                continue;                            newipaddr = addr;                            newclass = ipv4_get_ipaddr_class(newipaddr);                        }                        *asklist[i].addr = addr;                        break;                    }                }            }        }    } #endif    else if (strcmp(argv[1], "file") == 0) {        struct {            char *title;            unsigned char *value;        } asklist[] = {            { "boot loader", g_bootconfig.loader_filename },#ifdef CONFIG_ENABLE_2NDBOOT            { "2ndboot loader", g_bootconfig.scnd_loader_filename },#endif#ifdef CONFIG_ENABLE_USERPREF            { "user preference", g_bootconfig.userpref_filename },#endif#ifdef CONFIG_ENABLE_VSYNCPARAM            { "VSYNC parameters structure", g_bootconfig.vsyncparam_filename },#endif#ifdef CONFIG_ENABLE_DVI            { "I2C commands to control silicon image", g_bootconfig.dvi_filename },#endif            { "ROM filesystem", g_bootconfig.romfs_filename },            { "Kernel", g_bootconfig.kernel_filename },            { "KernelFS", g_bootconfig.kernelfs_filename },            { "initrd image", g_bootconfig.initrd_filename },            { "Binary", g_bootconfig.misc_filename },            { "Installable file", g_bootconfig.inst_filename },#ifdef CONFIG_ENABLE_IRQHANDLER            { "IRQ handler", g_bootconfig.irqhandler_filename },#endif#ifdef CONFIG_ENABLE_BITMAPS            { "Bitmap", g_bootconfig.bitmap_filename },#endif#ifdef CONFIG_ENABLE_UCODES            { "uCode", g_bootconfig.ucode_filename },#endif            { NULL, NULL },        };        int i;        unsigned char str[BOOTCONFIG_PATHLEN];                for (i = 0; asklist[i].title != NULL; ++i) {            uart_printf("  %s filename : (%s) ", asklist[i].title, asklist[i].value);            uart_gets(str, sizeof str, 0);            if ((trim(str))[0] != 0)                strcpy(asklist[i].value, str);        }    }     else if (strcmp(argv[1], "cache") == 0 || strcmp(argv[1], "dcache") == 0 || strcmp(argv[1], "icache") == 0 || strcmp(argv[1], "data") == 0 || strcmp(argv[1], "writeback") == 0) {        unsigned int icache = -1, dcache = -1, writeback = -1;        if (argv[1][0] == 'c')            icache = dcache = writeback = 1;        else if (argv[1][0] == 'd') {            if (argv[1][1] == 'c')                dcache = writeback = 1;            else                dcache = 1;        } else if (argv[1][0] == 'w')            writeback = 1;        else             icache = 1;                    if (strcmp(argv[2], "on") == 0) {#ifndef CONFIG_ENABLE_CACHE            uart_puts("Cache is disabled by default\n");#else            em86xx_enable_cache(icache, dcache, writeback);            uart_puts("Caches are enabled\n");#endif        } else if (strcmp(argv[2], "off") == 0) {#ifndef CONFIG_ENABLE_CACHE            uart_puts("Cache is disabled by default\n");#else            if (icache == 1)                icache = 0;            if (dcache == 1)                dcache = 0;            if (writeback == 1)                writeback = 0;            em86xx_enable_cache(icache, dcache, writeback);            uart_puts("Caches are disabled\n");#endif        }        #if 0        else if (strcmp(argv[2], "test") == 0) {            if (strcmp(argv[1], "dcache"))                 uart_puts("not implemented.\n");            else  {                if (dcache_test())                    uart_puts("D-CACHE test failed\n");                else                    uart_puts("D-CACHE test OK\n");            }            return 0;        }        else if (strcmp(argv[2], "bist") == 0) {            if (strcmp(argv[1], "cache") == 0) {                unsigned int res = 0;                if ((res = em86xx_cache_bist()) == 0)                    uart_puts("I/D-CACHE BIST OK\n");                else {                    if (res & 1)                        uart_puts("I-CACHE BIST failed\n");                    if (res & 2)                        uart_puts("D-CACHE BIST failed\n");                }            }            return 0;        }#endif        em86xx_get_cache_state(&icache, &dcache, &writeback);        uart_puts("Cache status : \n");        uart_printf("  I-CACHE = %s\n", icache ? "on" : "off");        uart_printf("  D-CACHE = %s\n", dcache ? "on" : "off");        uart_printf("  Writeback CACHE = %s\n", writeback ? "on" : "off");    } else         uart_puts("Unknown configuration\n");    return 0;}int bootmenu_download(int argc, char *argv[]){    static unsigned int addr = 0;    int target = DOWNLOAD_NONE;    char *filename = NULL;    unsigned int checksum = 0;#ifdef CONFIG_ENABLE_IRQHANDLER//    unsigned int flags = 0;#endif    if (argc == 1) {#ifndef CONFIG_DISABLE_HELP_MSGS        uart_puts(s_help_download_brief);        uart_puts(s_help_download);#else        uart_puts(no_help_msg);#endif        goto download_out;    }    if (argc == 2) {        uart_puts("Specify target to download\n");	goto download_out;    } else {        static struct {            int target;            char *name;        } s_targetlist[] = {            { DOWNLOAD_BOOT, "boot" },#ifdef CONFIG_ENABLE_2NDBOOT            { DOWNLOAD_2NDBOOT, "2ndboot" },#endif            { DOWNLOAD_ROMFS, "romfs" },#ifdef CONFIG_ENABLE_ROMFS2            { DOWNLOAD_ROMFS2, "romfs2" },#endif            { DOWNLOAD_INITRD, "initrd" },            { DOWNLOAD_KERNEL, "kernel" },            { DOWNLOAD_KERNELFS, "kernelfs" },	    { DOWNLOAD_MISC, "binary" },	    { DOWNLOAD_INSTFILE, "instfile" },#ifdef CONFIG_ENABLE_IRQHANDLER	    { DOWNLOAD_IRQHANDLER, "irqhandler" },#endif#ifdef CONFIG_ENABLE_BITMAPS	    { DOWNLOAD_BITMAP, "bitmap" },#endif#ifdef CONFIG_ENABLE_UCODES	    { DOWNLOAD_UCODE, "ucode" },#endif#ifdef CONFIG_ENABLE_USERPREF	    { DOWNLOAD_USERPREF, "userpref" },#endif#ifdef CONFIG_ENABLE_VSYNCPARAM	    { DOWNLOAD_VSYNCPARAM, "vsyncparam" },#endif#ifdef CONFIG_ENABLE_DVI	    { DOWNLOAD_DVI, "dvi" },#endif            { DOWNLOAD_NONE, NULL },        };        int i;        for (i = 0; s_targetlist[i].target != DOWNLOAD_NONE; ++i) {            if (strcmp(argv[2], s_targetlist[i].name) == 0) {                target = s_targetlist[i].target;                addr = g_download_info[target].addr;                filename = g_download_info[target].filename;                break;            }        }        if (target == DOWNLOAD_NONE) {            uart_puts("Invalid target\n");	    goto download_out;        } else if (target == DOWNLOAD_MISC) {	    if (strncmp(argv[3], "0x", 2) == 0) {		addr = atoi(argv[3]);	    }	}#ifdef CONFIG_ENABLE_IRQHANDLER	else if (target == DOWNLOAD_IRQHANDLER) {	    if (g_download_info[target].download != 0) {		uart_puts("IRQ handler existed.\n");		goto download_out;	    }	}#endif#ifdef CONFIG_ENABLE_UCODES	else if (target == DOWNLOAD_UCODE) {	    if (g_download_info[target].download != 0) {		uart_puts("ucode downloaded already.\n");		goto download_out;	    }	}#endif#ifdef CONFIG_ENABLE_BITMAPS	else if (target == DOWNLOAD_BITMAP) {	    if (g_download_info[target].download != 0) {		uart_puts("bitmap downloaded already.\n");		goto download_out;	    }	}#endif#ifdef CONFIG_ENABLE_USERPREF	else if (target == DOWNLOAD_USERPREF) {	    if (g_download_info[target].download != 0) {		uart_puts("userpref downloaded already.\n");		goto download_out;	    }	}#endif#ifdef CONFIG_ENABLE_VSYNCPARAM	else if (target == DOWNLOAD_VSYNCPARAM) {	    if (g_download_info[target].download != 0) {		uart_puts("vsyncparam downloaded already.\n");		goto download_out;	    }	}#endif#ifdef CONFIG_ENABLE_DVI	else if (target == DOWNLOAD_DVI) {	    if (g_download_info[target].download != 0) {		uart_puts("dvi downloaded already.\n");		goto download_out;	    }	}#endif    }     if (strcmp(argv[1], "serial") == 0) {        int len, gzipped = 0;        unsigned int origaddr = addr;        if (argv[3] && strcmp(argv[3], "gz") == 0) {            gzipped = 1;            origaddr = addr;            addr = loadaddr_temp;        }#ifdef CONFIG_ENABLE_FIP        downloading = 1;#endif        uart_puts("Send uuencoded stream to serial port\n");        if ((len = serial_uudecode((unsigned char *) addr, 0)) >= 0) {            uart_printf(recv_msg, len, len, addr);            if (gzipped) {                uart_printf(unzip_msg, origaddr);                len = kunzip((char *) addr, (char *) origaddr, loadaddr_heap_unzip);            }            g_download_info[target].download = 1;            g_download_info[target].len = len;        }#ifdef CONFIG_ENABLE_FIP	downloading = 0;#endif    }#ifdef CONFIG_ENABLE_FULLFUNCTION    else if (strcmp(argv[1], "ram") == 0) {        if (argv[3] == NULL)             uart_puts("Specify address of the image\n");        else if (argv[4] == NULL)            uart_puts("Specify size of the image\n");        else {            unsigned int imgaddr, imgsize;            imgaddr = atoi(argv[3]);            imgsize = atoi(argv[4]);            memmove((void *) addr, (void *) imgaddr, imgsize);            g_download_info[target].download = 1;            g_download_info[target].len = imgsize;        }    }#endif    else if (strcmp(argv[1], "romfs") == 0) {        int len, gzipped = 0;        unsigned int origaddr = addr;	char buf[BOOTCONFIG_PATHLEN + 3];    unsigned int romfs_addr;        if (filename == NULL) {            uart_puts(nofile_msg);	    goto download_out;        } else if (argv[3] && strcmp(argv[3], "gz") == 0) {	    gzipped = 1;	    origaddr = addr;	    addr = loadaddr_temp;        } 	strcpy(buf, filename);	if (gzipped)	    strcat(buf, ".gz");#ifdef CONFIG_ENABLE_ROMFS2    romfs_addr = LOADER_FLASH_ROMFS2ADDR;	len = load_romfs_file(buf, addr, romfs_addr, romfs_addr + 0x00040000, 0);	if (len > 0) {       	    if (gzipped) {                uart_printf(unzip_msg, origaddr);                len = kunzip((char *) addr, (char *) origaddr, loadaddr_heap_unzip);            }       	    g_download_info[target].download = 1;            g_download_info[target].len = len;	} else {#endif    romfs_addr = LOADER_FLASH_ROMFSADDR;	len = load_romfs_file(buf, addr, romfs_addr, romfs_addr + 0x00040000, 0);	if (len > 0) {       	    if (gzipped) {                uart_printf(unzip_msg, origaddr);                len = kunzip((char *) addr, (char *) origaddr, loadaddr_heap_unzip);            }       	    g_download_info[target].download = 1;            g_download_info[target].len = len;	}#ifdef CONFIG_ENABLE_ROMFS2	}#endif    }#ifdef CONFIG_ENABLE_NETWORK    else if (strcmp(argv[1], "net") == 0) {        int len, gzipped = 0;        unsigned int origaddr = addr;	char buf[BOOTCONFIG_PATHLEN + 3];        if (argv[3]) {            if (strcmp(argv[3], "gz") == 0) {                gzipped = 1;                origaddr = addr;                addr = loadaddr_temp;            } else {		        filename = argv[3];                if (argv[4] && strcmp(argv[4], "gz") == 0) {                    gzipped = 1;                    origaddr = addr;                    addr = loadaddr_temp;                }            }        }        if (bootmenu_net_up(0) != 0)	    goto download_out;        if (!ipv4_ipaddr_valid(g_bootconfig.server)) {            uart_puts("Server address is invalid\n");	    goto download_out;        } else if (filename == NULL) {            uart_puts(nofile_msg);	    goto download_out;        }	strcpy(buf, filename);	if (gzipped)

⌨️ 快捷键说明

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