int main(int argc, char *argv[]) { #if defined(_WIN32) || defined(__CYGWIN__) const char * port = "COM1"; #else const char * port = "/dev/ttyS11"; #endif int fcnt; char * fnam[64]; extern char *optarg; /* getopt */ extern int optind; /* getopt */ int c; /* the program name start just after the last slash */ if ((progname = (char *)strrchr(argv[0], '/')) == NULL) progname = argv[0]; else progname++; /* parse the command line options */ while ((c = getopt(argc, argv, "dvhp:")) > 0) { switch (c) { case 'v': show_version(); return 0; case 'h': show_usage(); return 1; case 'p': port = optarg; break; default: parse_err(optarg); return 2; } } if (optind < argc) { fcnt = 0; do { fnam[fcnt++] = argv[optind]; optind++; } while (optind < argc); return ymodem_send(port, fcnt, fnam); } return ymodem_recv(port); }
void down_kernel(void) { void (*theKernel)(int zero, int arch, unsigned int params); printf("download linux kernel through ymodem\n\r"); char *addr = (char *)0x21000000; ymodem_recv(addr); /* 设置启动参数 */ printf("Set boot params\n\r"); init_taglist(); /* 跳转执行*/ printf("Boot kernel...\n\r"); theKernel = (void (*)(int, int, unsigned int))0x21000040;/* Linux 内核入口地址 */ theKernel(0, 3466, 0x22000000); /* 第一个参数是0,第二个参数是机器码,第三个参数是启动参数地址 */ }