usbboot/src/cmd.c |
568 | 568 | " \t-e:\twith oob and ecc\n"; |
569 | 569 | |
570 | 570 | if (com_argc != 6) { |
571 | | printf(" not enough argument.\n"); |
| 571 | printf(" arguments count error.\n"); |
572 | 572 | printf("%s", help); |
573 | 573 | return 0; |
574 | 574 | } |
... | ... | |
578 | 578 | nand_in.start = atoi(com_argv[1]); |
579 | 579 | image_file = com_argv[2]; |
580 | 580 | nand_in.dev = atoi(com_argv[3]); |
| 581 | |
581 | 582 | (nand_in.cs_map)[atoi(com_argv[4])] = 1; |
582 | 583 | if (!strcmp(com_argv[5], "-e")) |
583 | 584 | nand_in.option = OOB_ECC; |
usbboot/src/command_line.c |
223 | 223 | |
224 | 224 | int command_interpret(char * com_buf) |
225 | 225 | { |
226 | | char *buf = com_buf; |
227 | | int k, L, i = 0, j = 0; |
228 | | |
229 | | L = (int)strlen(buf); |
230 | | buf[L]=' '; |
231 | | |
232 | | if (buf[0] == '\n') |
| 226 | if(com_buf[0] == '\n') |
233 | 227 | return 0; |
234 | 228 | |
235 | | for (k = 0; k <= L; k++) { |
236 | | if (*buf == ' ' || *buf == '\n') { |
237 | | while ( *(++buf) == ' ' ); |
238 | | com_argv[i][j] = '\0'; |
239 | | i++; |
240 | | if (i > MAX_ARGC) |
241 | | return COMMAND_NUM + 1; |
242 | | j = 0; |
243 | | continue; |
244 | | } else { |
245 | | com_argv[i][j] = *buf; |
246 | | j++; |
247 | | if (j > MAX_COMMAND_LENGTH) |
248 | | return COMMAND_NUM + 1; |
249 | | } |
250 | | buf++; |
251 | | } |
| 229 | com_argc = 0; |
| 230 | char *p = strtok(com_buf, "\n "); |
| 231 | strcpy(com_argv[com_argc++], p); |
| 232 | |
| 233 | while(p = strtok(NULL, "\n ")) |
| 234 | strcpy(com_argv[com_argc++], p); |
252 | 235 | |
253 | | com_argc = i; |
| 236 | int loop = 0; |
| 237 | for (loop = 1; loop <= COMMAND_NUM; loop++) |
| 238 | if (!strcmp(COMMAND[loop], com_argv[0])) |
| 239 | return loop; |
254 | 240 | |
255 | | for (i = 1; i <= COMMAND_NUM; i++) |
256 | | if (!strcmp(COMMAND[i], com_argv[0])) |
257 | | return i; |
258 | | return COMMAND_NUM + 1; |
| 241 | return -1; |
259 | 242 | } |
260 | 243 | |
261 | 244 | int command_handle(char *buf) |
... | ... | |
317 | 300 | case 29: |
318 | 301 | handle_memtest(); |
319 | 302 | break; |
| 303 | case -1: |
320 | 304 | default: |
321 | 305 | printf(" command not support or input error!\n"); |
322 | 306 | break; |
usbboot/src/main.c |
1 | 1 | /* |
2 | 2 | * Copyright(C) 2009 Qi Hardware Inc., |
3 | | * Authors: Xiangfu Liu <xiangfu@qi-hardware.com> |
| 3 | * Authors: Xiangfu Liu <xiangfu@sharism.com> |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
... | ... | |
37 | 37 | " -h --help\t\t\tPrint this help message\n" |
38 | 38 | " -v --version\t\t\tPrint the version number\n" |
39 | 39 | " -c --command\t\t\tDirect run the commands, split by ';'\n" |
40 | | " -f --configure\t\t\tconfigure file path\n" |
| 40 | " \t\t\tNOTICE: the max commands count is 10!\n" |
| 41 | " -f --configure\t\tconfigure file path\n" |
41 | 42 | " <run without options to enter commands via usbboot prompt>\n\n" |
42 | | "Report bugs to <xiangfu@qi-hardware.com>.\n" |
| 43 | "Report bugs to <xiangfu@sharism.cc>.\n" |
43 | 44 | ); |
44 | 45 | } |
45 | 46 | |
... | ... | |
107 | 108 | return EXIT_FAILURE; |
108 | 109 | |
109 | 110 | if (command) { /* direct run command */ |
110 | | char *delim=";"; |
111 | | char *p; |
112 | | p = strtok(cmdpt, delim); |
113 | | strcpy(com_buf, p); |
114 | | printf(" Execute command: %s \n",com_buf); |
115 | | command_handle(com_buf); |
116 | | |
117 | | while((p = strtok(NULL,delim))) { |
118 | | strcpy(com_buf, p); |
119 | | printf(" Execute command: %s \n",com_buf); |
120 | | command_handle(com_buf); |
| 111 | char *p[10]; |
| 112 | int i, loop = 0; |
| 113 | p[loop++] = strtok(cmdpt, ";"); |
| 114 | while(p[loop++] = strtok(NULL, ";")); |
| 115 | |
| 116 | for(i = 0; i < loop - 1 && i < 10; i++) { |
| 117 | printf(" Execute command: %s \n",p[i]); |
| 118 | command_handle(p[i]); |
121 | 119 | } |
122 | 120 | goto out; |
123 | 121 | } |