cmd_bootm.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244
  1. /*
  2. * (C) Copyright 2000-2002
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. /*
  24. * Boot support
  25. */
  26. #include <common.h>
  27. #include <watchdog.h>
  28. #include <command.h>
  29. #include <image.h>
  30. #include <malloc.h>
  31. #include <zlib.h>
  32. #include <environment.h>
  33. #include <asm/byteorder.h>
  34. /*cmd_boot.c*/
  35. extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
  36. #if (CONFIG_COMMANDS & CFG_CMD_DATE) || defined(CONFIG_TIMESTAMP)
  37. #include <rtc.h>
  38. #endif
  39. #ifdef CFG_HUSH_PARSER
  40. #include <hush.h>
  41. #endif
  42. #ifdef CONFIG_SHOW_BOOT_PROGRESS
  43. # include <status_led.h>
  44. # define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg)
  45. #else
  46. # define SHOW_BOOT_PROGRESS(arg)
  47. #endif
  48. #ifdef CFG_INIT_RAM_LOCK
  49. #include <asm/cache.h>
  50. #endif
  51. #ifdef CONFIG_LOGBUFFER
  52. #include <logbuff.h>
  53. #endif
  54. #ifdef CONFIG_HAS_DATAFLASH
  55. #include <dataflash.h>
  56. #endif
  57. /*
  58. * Some systems (for example LWMON) have very short watchdog periods;
  59. * we must make sure to split long operations like memmove() or
  60. * crc32() into reasonable chunks.
  61. */
  62. #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
  63. # define CHUNKSZ (64 * 1024)
  64. #endif
  65. int gunzip (void *, int, unsigned char *, int *);
  66. static void *zalloc(void *, unsigned, unsigned);
  67. static void zfree(void *, void *, unsigned);
  68. #if (CONFIG_COMMANDS & CFG_CMD_IMI)
  69. static int image_info (unsigned long addr);
  70. #endif
  71. #if (CONFIG_COMMANDS & CFG_CMD_IMLS)
  72. #include <flash.h>
  73. extern flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
  74. static int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
  75. #endif
  76. static void print_type (image_header_t *hdr);
  77. #ifdef __I386__
  78. image_header_t *fake_header(image_header_t *hdr, void *ptr, int size);
  79. #endif
  80. /*
  81. * Continue booting an OS image; caller already has:
  82. * - copied image header to global variable `header'
  83. * - checked header magic number, checksums (both header & image),
  84. * - verified image architecture (PPC) and type (KERNEL or MULTI),
  85. * - loaded (first part of) image to header load address,
  86. * - disabled interrupts.
  87. */
  88. typedef void boot_os_Fcn (cmd_tbl_t *cmdtp, int flag,
  89. int argc, char *argv[],
  90. ulong addr, /* of image to boot */
  91. ulong *len_ptr, /* multi-file image length table */
  92. int verify); /* getenv("verify")[0] != 'n' */
  93. #ifdef DEBUG
  94. extern int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
  95. #endif
  96. #ifdef CONFIG_PPC
  97. static boot_os_Fcn do_bootm_linux;
  98. #else
  99. extern boot_os_Fcn do_bootm_linux;
  100. #endif
  101. static boot_os_Fcn do_bootm_netbsd;
  102. static boot_os_Fcn do_bootm_rtems;
  103. #if (CONFIG_COMMANDS & CFG_CMD_ELF)
  104. static boot_os_Fcn do_bootm_vxworks;
  105. static boot_os_Fcn do_bootm_qnxelf;
  106. int do_bootvx ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] );
  107. int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] );
  108. #endif /* CFG_CMD_ELF */
  109. #if defined(CONFIG_ARTOS) && defined(CONFIG_PPC)
  110. static boot_os_Fcn do_bootm_artos;
  111. #endif
  112. image_header_t header;
  113. ulong load_addr = CFG_LOAD_ADDR; /* Default Load Address */
  114. int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  115. {
  116. ulong iflag;
  117. ulong addr;
  118. ulong data, len, checksum;
  119. ulong *len_ptr;
  120. int i, verify;
  121. char *name, *s;
  122. int (*appl)(cmd_tbl_t *, int, int, char *[]);
  123. image_header_t *hdr = &header;
  124. s = getenv ("verify");
  125. verify = (s && (*s == 'n')) ? 0 : 1;
  126. if (argc < 2) {
  127. addr = load_addr;
  128. } else {
  129. addr = simple_strtoul(argv[1], NULL, 16);
  130. }
  131. SHOW_BOOT_PROGRESS (1);
  132. printf ("## Booting image at %08lx ...\n", addr);
  133. /* Copy header so we can blank CRC field for re-calculation */
  134. #ifdef CONFIG_HAS_DATAFLASH
  135. if (addr_dataflash(addr)){
  136. read_dataflash(addr, sizeof(image_header_t), (char *)&header);
  137. } else
  138. #endif
  139. memmove (&header, (char *)addr, sizeof(image_header_t));
  140. if (ntohl(hdr->ih_magic) != IH_MAGIC) {
  141. #ifdef __I386__ /* correct image format not implemented yet - fake it */
  142. if (fake_header(hdr, (void*)addr, -1) != NULL) {
  143. /* to compensate for the addition below */
  144. addr -= sizeof(image_header_t);
  145. /* turnof verify,
  146. * fake_header() does not fake the data crc
  147. */
  148. verify = 0;
  149. } else
  150. #endif /* __I386__ */
  151. {
  152. printf ("Bad Magic Number\n");
  153. SHOW_BOOT_PROGRESS (-1);
  154. return 1;
  155. }
  156. }
  157. SHOW_BOOT_PROGRESS (2);
  158. data = (ulong)&header;
  159. len = sizeof(image_header_t);
  160. checksum = ntohl(hdr->ih_hcrc);
  161. hdr->ih_hcrc = 0;
  162. if (crc32 (0, (char *)data, len) != checksum) {
  163. printf ("Bad Header Checksum\n");
  164. SHOW_BOOT_PROGRESS (-2);
  165. return 1;
  166. }
  167. SHOW_BOOT_PROGRESS (3);
  168. /* for multi-file images we need the data part, too */
  169. print_image_hdr (hdr);
  170. data = addr + sizeof(image_header_t);
  171. len = ntohl(hdr->ih_size);
  172. #ifdef CONFIG_HAS_DATAFLASH
  173. if (addr_dataflash(addr)){
  174. read_dataflash(data, len, (char *)CFG_LOAD_ADDR);
  175. data = CFG_LOAD_ADDR;
  176. }
  177. #endif
  178. if (verify) {
  179. printf (" Verifying Checksum ... ");
  180. if (crc32 (0, (char *)data, len) != ntohl(hdr->ih_dcrc)) {
  181. printf ("Bad Data CRC\n");
  182. SHOW_BOOT_PROGRESS (-3);
  183. return 1;
  184. }
  185. printf ("OK\n");
  186. }
  187. SHOW_BOOT_PROGRESS (4);
  188. len_ptr = (ulong *)data;
  189. #if defined(__PPC__)
  190. if (hdr->ih_arch != IH_CPU_PPC)
  191. #elif defined(__ARM__)
  192. if (hdr->ih_arch != IH_CPU_ARM)
  193. #elif defined(__I386__)
  194. if (hdr->ih_arch != IH_CPU_I386)
  195. #elif defined(__mips__)
  196. if (hdr->ih_arch != IH_CPU_MIPS)
  197. #else
  198. # error Unknown CPU type
  199. #endif
  200. {
  201. printf ("Unsupported Architecture 0x%x\n", hdr->ih_arch);
  202. SHOW_BOOT_PROGRESS (-4);
  203. return 1;
  204. }
  205. SHOW_BOOT_PROGRESS (5);
  206. switch (hdr->ih_type) {
  207. case IH_TYPE_STANDALONE: name = "Standalone Application";
  208. break;
  209. case IH_TYPE_KERNEL: name = "Kernel Image";
  210. break;
  211. case IH_TYPE_MULTI: name = "Multi-File Image";
  212. len = ntohl(len_ptr[0]);
  213. /* OS kernel is always the first image */
  214. data += 8; /* kernel_len + terminator */
  215. for (i=1; len_ptr[i]; ++i)
  216. data += 4;
  217. break;
  218. default: printf ("Wrong Image Type for %s command\n", cmdtp->name);
  219. SHOW_BOOT_PROGRESS (-5);
  220. return 1;
  221. }
  222. SHOW_BOOT_PROGRESS (6);
  223. /*
  224. * We have reached the point of no return: we are going to
  225. * overwrite all exception vector code, so we cannot easily
  226. * recover from any failures any more...
  227. */
  228. iflag = disable_interrupts();
  229. #ifdef CONFIG_AMIGAONEG3SE
  230. /*
  231. * We've possible left the caches enabled during
  232. * bios emulation, so turn them off again
  233. */
  234. icache_disable();
  235. invalidate_l1_instruction_cache();
  236. flush_data_cache();
  237. dcache_disable();
  238. #endif
  239. switch (hdr->ih_comp) {
  240. case IH_COMP_NONE:
  241. if(ntohl(hdr->ih_load) == addr) {
  242. printf (" XIP %s ... ", name);
  243. } else {
  244. #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
  245. size_t l = len;
  246. void *to = (void *)ntohl(hdr->ih_load);
  247. void *from = (void *)data;
  248. printf (" Loading %s ... ", name);
  249. while (l > 0) {
  250. size_t tail = (l > CHUNKSZ) ? CHUNKSZ : l;
  251. WATCHDOG_RESET();
  252. memmove (to, from, tail);
  253. to += tail;
  254. from += tail;
  255. l -= tail;
  256. }
  257. #else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
  258. memmove ((void *) ntohl(hdr->ih_load), (uchar *)data, len);
  259. #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
  260. }
  261. break;
  262. case IH_COMP_GZIP:
  263. printf (" Uncompressing %s ... ", name);
  264. if (gunzip ((void *)ntohl(hdr->ih_load), 0x400000,
  265. (uchar *)data, (int *)&len) != 0) {
  266. printf ("GUNZIP ERROR - must RESET board to recover\n");
  267. SHOW_BOOT_PROGRESS (-6);
  268. do_reset (cmdtp, flag, argc, argv);
  269. }
  270. break;
  271. default:
  272. if (iflag)
  273. enable_interrupts();
  274. printf ("Unimplemented compression type %d\n", hdr->ih_comp);
  275. SHOW_BOOT_PROGRESS (-7);
  276. return 1;
  277. }
  278. printf ("OK\n");
  279. SHOW_BOOT_PROGRESS (7);
  280. switch (hdr->ih_type) {
  281. case IH_TYPE_STANDALONE:
  282. if (iflag)
  283. enable_interrupts();
  284. /* load (and uncompress), but don't start if "autostart"
  285. * is set to "no"
  286. */
  287. if (((s = getenv("autostart")) != NULL) && (strcmp(s,"no") == 0))
  288. return 0;
  289. appl = (int (*)(cmd_tbl_t *, int, int, char *[]))ntohl(hdr->ih_ep);
  290. (*appl)(cmdtp, flag, argc-1, &argv[1]);
  291. return 0;
  292. case IH_TYPE_KERNEL:
  293. case IH_TYPE_MULTI:
  294. /* handled below */
  295. break;
  296. default:
  297. if (iflag)
  298. enable_interrupts();
  299. printf ("Can't boot image type %d\n", hdr->ih_type);
  300. SHOW_BOOT_PROGRESS (-8);
  301. return 1;
  302. }
  303. SHOW_BOOT_PROGRESS (8);
  304. switch (hdr->ih_os) {
  305. default: /* handled by (original) Linux case */
  306. case IH_OS_LINUX:
  307. do_bootm_linux (cmdtp, flag, argc, argv,
  308. addr, len_ptr, verify);
  309. break;
  310. case IH_OS_NETBSD:
  311. do_bootm_netbsd (cmdtp, flag, argc, argv,
  312. addr, len_ptr, verify);
  313. break;
  314. case IH_OS_RTEMS:
  315. do_bootm_rtems (cmdtp, flag, argc, argv,
  316. addr, len_ptr, verify);
  317. break;
  318. #if (CONFIG_COMMANDS & CFG_CMD_ELF)
  319. case IH_OS_VXWORKS:
  320. do_bootm_vxworks (cmdtp, flag, argc, argv,
  321. addr, len_ptr, verify);
  322. break;
  323. case IH_OS_QNX:
  324. do_bootm_qnxelf (cmdtp, flag, argc, argv,
  325. addr, len_ptr, verify);
  326. break;
  327. #endif /* CFG_CMD_ELF */
  328. #ifdef CONFIG_ARTOS
  329. case IH_OS_ARTOS:
  330. do_bootm_artos (cmdtp, flag, argc, argv,
  331. addr, len_ptr, verify);
  332. break;
  333. #endif
  334. }
  335. SHOW_BOOT_PROGRESS (-9);
  336. #ifdef DEBUG
  337. printf ("\n## Control returned to monitor - resetting...\n");
  338. do_reset (cmdtp, flag, argc, argv);
  339. #endif
  340. return 1;
  341. }
  342. U_BOOT_CMD(
  343. bootm, CFG_MAXARGS, 1, do_bootm,
  344. "bootm - boot application image from memory\n",
  345. "[addr [arg ...]]\n - boot application image stored in memory\n"
  346. " passing arguments 'arg ...'; when booting a Linux kernel,\n"
  347. " 'arg' can be the address of an initrd image\n"
  348. );
  349. #ifdef CONFIG_PPC
  350. static void
  351. do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
  352. int argc, char *argv[],
  353. ulong addr,
  354. ulong *len_ptr,
  355. int verify)
  356. {
  357. DECLARE_GLOBAL_DATA_PTR;
  358. ulong sp;
  359. ulong len, checksum;
  360. ulong initrd_start, initrd_end;
  361. ulong cmd_start, cmd_end;
  362. ulong initrd_high;
  363. ulong data;
  364. int initrd_copy_to_ram = 1;
  365. char *cmdline;
  366. char *s;
  367. bd_t *kbd;
  368. void (*kernel)(bd_t *, ulong, ulong, ulong, ulong);
  369. image_header_t *hdr = &header;
  370. if ((s = getenv ("initrd_high")) != NULL) {
  371. /* a value of "no" or a similar string will act like 0,
  372. * turning the "load high" feature off. This is intentional.
  373. */
  374. initrd_high = simple_strtoul(s, NULL, 16);
  375. if (initrd_high == ~0)
  376. initrd_copy_to_ram = 0;
  377. } else { /* not set, no restrictions to load high */
  378. initrd_high = ~0;
  379. }
  380. #ifdef CONFIG_LOGBUFFER
  381. kbd=gd->bd;
  382. /* Prevent initrd from overwriting logbuffer */
  383. if (initrd_high < (kbd->bi_memsize-LOGBUFF_LEN-LOGBUFF_OVERHEAD))
  384. initrd_high = kbd->bi_memsize-LOGBUFF_LEN-LOGBUFF_OVERHEAD;
  385. debug ("## Logbuffer at 0x%08lX ", kbd->bi_memsize-LOGBUFF_LEN);
  386. #endif
  387. /*
  388. * Booting a (Linux) kernel image
  389. *
  390. * Allocate space for command line and board info - the
  391. * address should be as high as possible within the reach of
  392. * the kernel (see CFG_BOOTMAPSZ settings), but in unused
  393. * memory, which means far enough below the current stack
  394. * pointer.
  395. */
  396. asm( "mr %0,1": "=r"(sp) : );
  397. debug ("## Current stack ends at 0x%08lX ", sp);
  398. sp -= 2048; /* just to be sure */
  399. if (sp > CFG_BOOTMAPSZ)
  400. sp = CFG_BOOTMAPSZ;
  401. sp &= ~0xF;
  402. debug ("=> set upper limit to 0x%08lX\n", sp);
  403. cmdline = (char *)((sp - CFG_BARGSIZE) & ~0xF);
  404. kbd = (bd_t *)(((ulong)cmdline - sizeof(bd_t)) & ~0xF);
  405. if ((s = getenv("bootargs")) == NULL)
  406. s = "";
  407. strcpy (cmdline, s);
  408. cmd_start = (ulong)&cmdline[0];
  409. cmd_end = cmd_start + strlen(cmdline);
  410. *kbd = *(gd->bd);
  411. #ifdef DEBUG
  412. printf ("## cmdline at 0x%08lX ... 0x%08lX\n", cmd_start, cmd_end);
  413. do_bdinfo (NULL, 0, 0, NULL);
  414. #endif
  415. if ((s = getenv ("clocks_in_mhz")) != NULL) {
  416. /* convert all clock information to MHz */
  417. kbd->bi_intfreq /= 1000000L;
  418. kbd->bi_busfreq /= 1000000L;
  419. #if defined(CONFIG_8260)
  420. kbd->bi_cpmfreq /= 1000000L;
  421. kbd->bi_brgfreq /= 1000000L;
  422. kbd->bi_sccfreq /= 1000000L;
  423. kbd->bi_vco /= 1000000L;
  424. #endif /* CONFIG_8260 */
  425. #if defined(CONFIG_MPC5XXXX)
  426. kbd->bi_ipbfreq /= 1000000L;
  427. kbd->bi_pcifreq /= 1000000L;
  428. #endif /* CONFIG_MPC5XXXX */
  429. }
  430. kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))hdr->ih_ep;
  431. /*
  432. * Check if there is an initrd image
  433. */
  434. if (argc >= 3) {
  435. SHOW_BOOT_PROGRESS (9);
  436. addr = simple_strtoul(argv[2], NULL, 16);
  437. printf ("## Loading RAMDisk Image at %08lx ...\n", addr);
  438. /* Copy header so we can blank CRC field for re-calculation */
  439. memmove (&header, (char *)addr, sizeof(image_header_t));
  440. if (hdr->ih_magic != IH_MAGIC) {
  441. printf ("Bad Magic Number\n");
  442. SHOW_BOOT_PROGRESS (-10);
  443. do_reset (cmdtp, flag, argc, argv);
  444. }
  445. data = (ulong)&header;
  446. len = sizeof(image_header_t);
  447. checksum = hdr->ih_hcrc;
  448. hdr->ih_hcrc = 0;
  449. if (crc32 (0, (char *)data, len) != checksum) {
  450. printf ("Bad Header Checksum\n");
  451. SHOW_BOOT_PROGRESS (-11);
  452. do_reset (cmdtp, flag, argc, argv);
  453. }
  454. SHOW_BOOT_PROGRESS (10);
  455. print_image_hdr (hdr);
  456. data = addr + sizeof(image_header_t);
  457. len = hdr->ih_size;
  458. if (verify) {
  459. ulong csum = 0;
  460. #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
  461. ulong cdata = data, edata = cdata + len;
  462. #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
  463. printf (" Verifying Checksum ... ");
  464. #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
  465. while (cdata < edata) {
  466. ulong chunk = edata - cdata;
  467. if (chunk > CHUNKSZ)
  468. chunk = CHUNKSZ;
  469. csum = crc32 (csum, (char *)cdata, chunk);
  470. cdata += chunk;
  471. WATCHDOG_RESET();
  472. }
  473. #else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
  474. csum = crc32 (0, (char *)data, len);
  475. #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
  476. if (csum != hdr->ih_dcrc) {
  477. printf ("Bad Data CRC\n");
  478. SHOW_BOOT_PROGRESS (-12);
  479. do_reset (cmdtp, flag, argc, argv);
  480. }
  481. printf ("OK\n");
  482. }
  483. SHOW_BOOT_PROGRESS (11);
  484. if ((hdr->ih_os != IH_OS_LINUX) ||
  485. (hdr->ih_arch != IH_CPU_PPC) ||
  486. (hdr->ih_type != IH_TYPE_RAMDISK) ) {
  487. printf ("No Linux PPC Ramdisk Image\n");
  488. SHOW_BOOT_PROGRESS (-13);
  489. do_reset (cmdtp, flag, argc, argv);
  490. }
  491. /*
  492. * Now check if we have a multifile image
  493. */
  494. } else if ((hdr->ih_type==IH_TYPE_MULTI) && (len_ptr[1])) {
  495. u_long tail = ntohl(len_ptr[0]) % 4;
  496. int i;
  497. SHOW_BOOT_PROGRESS (13);
  498. /* skip kernel length and terminator */
  499. data = (ulong)(&len_ptr[2]);
  500. /* skip any additional image length fields */
  501. for (i=1; len_ptr[i]; ++i)
  502. data += 4;
  503. /* add kernel length, and align */
  504. data += ntohl(len_ptr[0]);
  505. if (tail) {
  506. data += 4 - tail;
  507. }
  508. len = ntohl(len_ptr[1]);
  509. } else {
  510. /*
  511. * no initrd image
  512. */
  513. SHOW_BOOT_PROGRESS (14);
  514. len = data = 0;
  515. }
  516. if (!data) {
  517. debug ("No initrd\n");
  518. }
  519. if (data) {
  520. if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */
  521. initrd_start = data;
  522. initrd_end = initrd_start + len;
  523. } else {
  524. initrd_start = (ulong)kbd - len;
  525. initrd_start &= ~(4096 - 1); /* align on page */
  526. if (initrd_high) {
  527. ulong nsp;
  528. /*
  529. * the inital ramdisk does not need to be within
  530. * CFG_BOOTMAPSZ as it is not accessed until after
  531. * the mm system is initialised.
  532. *
  533. * do the stack bottom calculation again and see if
  534. * the initrd will fit just below the monitor stack
  535. * bottom without overwriting the area allocated
  536. * above for command line args and board info.
  537. */
  538. asm( "mr %0,1": "=r"(nsp) : );
  539. nsp -= 2048; /* just to be sure */
  540. nsp &= ~0xF;
  541. if (nsp > initrd_high) /* limit as specified */
  542. nsp = initrd_high;
  543. nsp -= len;
  544. nsp &= ~(4096 - 1); /* align on page */
  545. if (nsp >= sp)
  546. initrd_start = nsp;
  547. }
  548. SHOW_BOOT_PROGRESS (12);
  549. debug ("## initrd at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n",
  550. data, data + len - 1, len, len);
  551. initrd_end = initrd_start + len;
  552. printf (" Loading Ramdisk to %08lx, end %08lx ... ",
  553. initrd_start, initrd_end);
  554. #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
  555. {
  556. size_t l = len;
  557. void *to = (void *)initrd_start;
  558. void *from = (void *)data;
  559. while (l > 0) {
  560. size_t tail = (l > CHUNKSZ) ? CHUNKSZ : l;
  561. WATCHDOG_RESET();
  562. memmove (to, from, tail);
  563. to += tail;
  564. from += tail;
  565. l -= tail;
  566. }
  567. }
  568. #else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
  569. memmove ((void *)initrd_start, (void *)data, len);
  570. #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
  571. printf ("OK\n");
  572. }
  573. } else {
  574. initrd_start = 0;
  575. initrd_end = 0;
  576. }
  577. debug ("## Transferring control to Linux (at address %08lx) ...\n",
  578. (ulong)kernel);
  579. SHOW_BOOT_PROGRESS (15);
  580. #ifdef CFG_INIT_RAM_LOCK
  581. unlock_ram_in_cache();
  582. #endif
  583. /*
  584. * Linux Kernel Parameters:
  585. * r3: ptr to board info data
  586. * r4: initrd_start or 0 if no initrd
  587. * r5: initrd_end - unused if r4 is 0
  588. * r6: Start of command line string
  589. * r7: End of command line string
  590. */
  591. (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
  592. }
  593. #endif /* CONFIG_PPC */
  594. static void
  595. do_bootm_netbsd (cmd_tbl_t *cmdtp, int flag,
  596. int argc, char *argv[],
  597. ulong addr,
  598. ulong *len_ptr,
  599. int verify)
  600. {
  601. DECLARE_GLOBAL_DATA_PTR;
  602. image_header_t *hdr = &header;
  603. void (*loader)(bd_t *, image_header_t *, char *, char *);
  604. image_header_t *img_addr;
  605. char *consdev;
  606. char *cmdline;
  607. /*
  608. * Booting a (NetBSD) kernel image
  609. *
  610. * This process is pretty similar to a standalone application:
  611. * The (first part of an multi-) image must be a stage-2 loader,
  612. * which in turn is responsible for loading & invoking the actual
  613. * kernel. The only differences are the parameters being passed:
  614. * besides the board info strucure, the loader expects a command
  615. * line, the name of the console device, and (optionally) the
  616. * address of the original image header.
  617. */
  618. img_addr = 0;
  619. if ((hdr->ih_type==IH_TYPE_MULTI) && (len_ptr[1]))
  620. img_addr = (image_header_t *) addr;
  621. consdev = "";
  622. #if defined (CONFIG_8xx_CONS_SMC1)
  623. consdev = "smc1";
  624. #elif defined (CONFIG_8xx_CONS_SMC2)
  625. consdev = "smc2";
  626. #elif defined (CONFIG_8xx_CONS_SCC2)
  627. consdev = "scc2";
  628. #elif defined (CONFIG_8xx_CONS_SCC3)
  629. consdev = "scc3";
  630. #endif
  631. if (argc > 2) {
  632. ulong len;
  633. int i;
  634. for (i=2, len=0 ; i<argc ; i+=1)
  635. len += strlen (argv[i]) + 1;
  636. cmdline = malloc (len);
  637. for (i=2, len=0 ; i<argc ; i+=1) {
  638. if (i > 2)
  639. cmdline[len++] = ' ';
  640. strcpy (&cmdline[len], argv[i]);
  641. len += strlen (argv[i]);
  642. }
  643. } else if ((cmdline = getenv("bootargs")) == NULL) {
  644. cmdline = "";
  645. }
  646. loader = (void (*)(bd_t *, image_header_t *, char *, char *)) hdr->ih_ep;
  647. printf ("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n",
  648. (ulong)loader);
  649. SHOW_BOOT_PROGRESS (15);
  650. /*
  651. * NetBSD Stage-2 Loader Parameters:
  652. * r3: ptr to board info data
  653. * r4: image address
  654. * r5: console device
  655. * r6: boot args string
  656. */
  657. (*loader) (gd->bd, img_addr, consdev, cmdline);
  658. }
  659. #if defined(CONFIG_ARTOS) && defined(CONFIG_PPC)
  660. /* Function that returns a character from the environment */
  661. extern uchar (*env_get_char)(int);
  662. static void
  663. do_bootm_artos (cmd_tbl_t *cmdtp, int flag,
  664. int argc, char *argv[],
  665. ulong addr,
  666. ulong *len_ptr,
  667. int verify)
  668. {
  669. DECLARE_GLOBAL_DATA_PTR;
  670. ulong top;
  671. char *s, *cmdline;
  672. char **fwenv, **ss;
  673. int i, j, nxt, len, envno, envsz;
  674. bd_t *kbd;
  675. void (*entry)(bd_t *bd, char *cmdline, char **fwenv, ulong top);
  676. image_header_t *hdr = &header;
  677. /*
  678. * Booting an ARTOS kernel image + application
  679. */
  680. /* this used to be the top of memory, but was wrong... */
  681. #ifdef CONFIG_PPC
  682. /* get stack pointer */
  683. asm volatile ("mr %0,1" : "=r"(top) );
  684. #endif
  685. debug ("## Current stack ends at 0x%08lX ", top);
  686. top -= 2048; /* just to be sure */
  687. if (top > CFG_BOOTMAPSZ)
  688. top = CFG_BOOTMAPSZ;
  689. top &= ~0xF;
  690. debug ("=> set upper limit to 0x%08lX\n", top);
  691. /* first check the artos specific boot args, then the linux args*/
  692. if ((s = getenv("abootargs")) == NULL && (s = getenv("bootargs")) == NULL)
  693. s = "";
  694. /* get length of cmdline, and place it */
  695. len = strlen(s);
  696. top = (top - (len + 1)) & ~0xF;
  697. cmdline = (char *)top;
  698. debug ("## cmdline at 0x%08lX ", top);
  699. strcpy(cmdline, s);
  700. /* copy bdinfo */
  701. top = (top - sizeof(bd_t)) & ~0xF;
  702. debug ("## bd at 0x%08lX ", top);
  703. kbd = (bd_t *)top;
  704. memcpy(kbd, gd->bd, sizeof(bd_t));
  705. /* first find number of env entries, and their size */
  706. envno = 0;
  707. envsz = 0;
  708. for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
  709. for (nxt = i; env_get_char(nxt) != '\0'; ++nxt)
  710. ;
  711. envno++;
  712. envsz += (nxt - i) + 1; /* plus trailing zero */
  713. }
  714. envno++; /* plus the terminating zero */
  715. debug ("## %u envvars total size %u ", envno, envsz);
  716. top = (top - sizeof(char **)*envno) & ~0xF;
  717. fwenv = (char **)top;
  718. debug ("## fwenv at 0x%08lX ", top);
  719. top = (top - envsz) & ~0xF;
  720. s = (char *)top;
  721. ss = fwenv;
  722. /* now copy them */
  723. for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
  724. for (nxt = i; env_get_char(nxt) != '\0'; ++nxt)
  725. ;
  726. *ss++ = s;
  727. for (j = i; j < nxt; ++j)
  728. *s++ = env_get_char(j);
  729. *s++ = '\0';
  730. }
  731. *ss++ = NULL; /* terminate */
  732. entry = (void (*)(bd_t *, char *, char **, ulong))ntohl(hdr->ih_ep);
  733. (*entry)(kbd, cmdline, fwenv, top);
  734. }
  735. #endif
  736. #if (CONFIG_COMMANDS & CFG_CMD_BOOTD)
  737. int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  738. {
  739. int rcode = 0;
  740. #ifndef CFG_HUSH_PARSER
  741. if (run_command (getenv ("bootcmd"), flag) < 0) rcode = 1;
  742. #else
  743. if (parse_string_outer(getenv("bootcmd"),
  744. FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0 ) rcode = 1;
  745. #endif
  746. return rcode;
  747. }
  748. U_BOOT_CMD(
  749. boot, 1, 1, do_bootd,
  750. "boot - boot default, i.e., run 'bootcmd'\n",
  751. NULL
  752. );
  753. /* keep old command name "bootd" for backward compatibility */
  754. U_BOOT_CMD(
  755. bootd, 1, 1, do_bootd,
  756. "bootd - boot default, i.e., run 'bootcmd'\n",
  757. NULL
  758. );
  759. #endif
  760. #if (CONFIG_COMMANDS & CFG_CMD_IMI)
  761. int do_iminfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  762. {
  763. int arg;
  764. ulong addr;
  765. int rcode=0;
  766. if (argc < 2) {
  767. return image_info (load_addr);
  768. }
  769. for (arg=1; arg <argc; ++arg) {
  770. addr = simple_strtoul(argv[arg], NULL, 16);
  771. if (image_info (addr) != 0) rcode = 1;
  772. }
  773. return rcode;
  774. }
  775. static int image_info (ulong addr)
  776. {
  777. ulong data, len, checksum;
  778. image_header_t *hdr = &header;
  779. printf ("\n## Checking Image at %08lx ...\n", addr);
  780. /* Copy header so we can blank CRC field for re-calculation */
  781. memmove (&header, (char *)addr, sizeof(image_header_t));
  782. if (ntohl(hdr->ih_magic) != IH_MAGIC) {
  783. printf (" Bad Magic Number\n");
  784. return 1;
  785. }
  786. data = (ulong)&header;
  787. len = sizeof(image_header_t);
  788. checksum = ntohl(hdr->ih_hcrc);
  789. hdr->ih_hcrc = 0;
  790. if (crc32 (0, (char *)data, len) != checksum) {
  791. printf (" Bad Header Checksum\n");
  792. return 1;
  793. }
  794. /* for multi-file images we need the data part, too */
  795. print_image_hdr ((image_header_t *)addr);
  796. data = addr + sizeof(image_header_t);
  797. len = ntohl(hdr->ih_size);
  798. printf (" Verifying Checksum ... ");
  799. if (crc32 (0, (char *)data, len) != ntohl(hdr->ih_dcrc)) {
  800. printf (" Bad Data CRC\n");
  801. return 1;
  802. }
  803. printf ("OK\n");
  804. return 0;
  805. }
  806. U_BOOT_CMD(
  807. iminfo, CFG_MAXARGS, 1, do_iminfo,
  808. "iminfo - print header information for application image\n",
  809. "addr [addr ...]\n"
  810. " - print header information for application image starting at\n"
  811. " address 'addr' in memory; this includes verification of the\n"
  812. " image contents (magic number, header and payload checksums)\n"
  813. );
  814. #endif /* CFG_CMD_IMI */
  815. #if (CONFIG_COMMANDS & CFG_CMD_IMLS)
  816. /*-----------------------------------------------------------------------
  817. * List all images found in flash.
  818. */
  819. int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  820. {
  821. flash_info_t *info;
  822. int i, j;
  823. image_header_t *hdr;
  824. ulong checksum;
  825. for (i=0, info=&flash_info[0]; i<CFG_MAX_FLASH_BANKS; ++i, ++info) {
  826. if (info->flash_id == FLASH_UNKNOWN)
  827. goto next_bank;
  828. for (j=0; j<CFG_MAX_FLASH_SECT; ++j) {
  829. if (!(hdr=(image_header_t *)info->start[j]) ||
  830. (ntohl(hdr->ih_magic) != IH_MAGIC))
  831. goto next_sector;
  832. /* Copy header so we can blank CRC field for re-calculation */
  833. memmove (&header, (char *)hdr, sizeof(image_header_t));
  834. checksum = ntohl(header.ih_hcrc);
  835. header.ih_hcrc = 0;
  836. if (crc32 (0, (char *)&header, sizeof(image_header_t))
  837. != checksum)
  838. goto next_sector;
  839. printf ("Image at %08lX:\n", (ulong)hdr);
  840. print_image_hdr( hdr );
  841. putc ('\n');
  842. next_sector:
  843. }
  844. next_bank:
  845. }
  846. return (0);
  847. }
  848. U_BOOT_CMD(
  849. imls, 1, 1, do_imls,
  850. "imls - list all images found in flash\n",
  851. "\n"
  852. " - Prints information about all images found at sector\n"
  853. " boundaries in flash.\n"
  854. );
  855. #endif /* CFG_CMD_IMLS */
  856. void
  857. print_image_hdr (image_header_t *hdr)
  858. {
  859. #if (CONFIG_COMMANDS & CFG_CMD_DATE) || defined(CONFIG_TIMESTAMP)
  860. time_t timestamp = (time_t)ntohl(hdr->ih_time);
  861. struct rtc_time tm;
  862. #endif
  863. printf (" Image Name: %.*s\n", IH_NMLEN, hdr->ih_name);
  864. #if (CONFIG_COMMANDS & CFG_CMD_DATE) || defined(CONFIG_TIMESTAMP)
  865. to_tm (timestamp, &tm);
  866. printf (" Created: %4d-%02d-%02d %2d:%02d:%02d UTC\n",
  867. tm.tm_year, tm.tm_mon, tm.tm_mday,
  868. tm.tm_hour, tm.tm_min, tm.tm_sec);
  869. #endif /* CFG_CMD_DATE, CONFIG_TIMESTAMP */
  870. printf (" Image Type: "); print_type(hdr); printf ("\n");
  871. printf (" Data Size: %d Bytes = ", ntohl(hdr->ih_size));
  872. print_size (ntohl(hdr->ih_size), "\n");
  873. printf (" Load Address: %08x\n", ntohl(hdr->ih_load));
  874. printf (" Entry Point: %08x\n", ntohl(hdr->ih_ep));
  875. if (hdr->ih_type == IH_TYPE_MULTI) {
  876. int i;
  877. ulong len;
  878. ulong *len_ptr = (ulong *)((ulong)hdr + sizeof(image_header_t));
  879. printf (" Contents:\n");
  880. for (i=0; (len = ntohl(*len_ptr)); ++i, ++len_ptr) {
  881. printf (" Image %d: %8ld Bytes = ", i, len);
  882. print_size (len, "\n");
  883. }
  884. }
  885. }
  886. static void
  887. print_type (image_header_t *hdr)
  888. {
  889. char *os, *arch, *type, *comp;
  890. switch (hdr->ih_os) {
  891. case IH_OS_INVALID: os = "Invalid OS"; break;
  892. case IH_OS_NETBSD: os = "NetBSD"; break;
  893. case IH_OS_LINUX: os = "Linux"; break;
  894. case IH_OS_VXWORKS: os = "VxWorks"; break;
  895. case IH_OS_QNX: os = "QNX"; break;
  896. case IH_OS_U_BOOT: os = "U-Boot"; break;
  897. case IH_OS_RTEMS: os = "RTEMS"; break;
  898. #ifdef CONFIG_ARTOS
  899. case IH_OS_ARTOS: os = "ARTOS"; break;
  900. #endif
  901. default: os = "Unknown OS"; break;
  902. }
  903. switch (hdr->ih_arch) {
  904. case IH_CPU_INVALID: arch = "Invalid CPU"; break;
  905. case IH_CPU_ALPHA: arch = "Alpha"; break;
  906. case IH_CPU_ARM: arch = "ARM"; break;
  907. case IH_CPU_I386: arch = "Intel x86"; break;
  908. case IH_CPU_IA64: arch = "IA64"; break;
  909. case IH_CPU_MIPS: arch = "MIPS"; break;
  910. case IH_CPU_MIPS64: arch = "MIPS 64 Bit"; break;
  911. case IH_CPU_PPC: arch = "PowerPC"; break;
  912. case IH_CPU_S390: arch = "IBM S390"; break;
  913. case IH_CPU_SH: arch = "SuperH"; break;
  914. case IH_CPU_SPARC: arch = "SPARC"; break;
  915. case IH_CPU_SPARC64: arch = "SPARC 64 Bit"; break;
  916. case IH_CPU_M68K: arch = "M68K"; break;
  917. default: arch = "Unknown Architecture"; break;
  918. }
  919. switch (hdr->ih_type) {
  920. case IH_TYPE_INVALID: type = "Invalid Image"; break;
  921. case IH_TYPE_STANDALONE:type = "Standalone Program"; break;
  922. case IH_TYPE_KERNEL: type = "Kernel Image"; break;
  923. case IH_TYPE_RAMDISK: type = "RAMDisk Image"; break;
  924. case IH_TYPE_MULTI: type = "Multi-File Image"; break;
  925. case IH_TYPE_FIRMWARE: type = "Firmware"; break;
  926. case IH_TYPE_SCRIPT: type = "Script"; break;
  927. default: type = "Unknown Image"; break;
  928. }
  929. switch (hdr->ih_comp) {
  930. case IH_COMP_NONE: comp = "uncompressed"; break;
  931. case IH_COMP_GZIP: comp = "gzip compressed"; break;
  932. case IH_COMP_BZIP2: comp = "bzip2 compressed"; break;
  933. default: comp = "unknown compression"; break;
  934. }
  935. printf ("%s %s %s (%s)", arch, os, type, comp);
  936. }
  937. #define ZALLOC_ALIGNMENT 16
  938. static void *zalloc(void *x, unsigned items, unsigned size)
  939. {
  940. void *p;
  941. size *= items;
  942. size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1);
  943. p = malloc (size);
  944. return (p);
  945. }
  946. static void zfree(void *x, void *addr, unsigned nb)
  947. {
  948. free (addr);
  949. }
  950. #define HEAD_CRC 2
  951. #define EXTRA_FIELD 4
  952. #define ORIG_NAME 8
  953. #define COMMENT 0x10
  954. #define RESERVED 0xe0
  955. #define DEFLATED 8
  956. int gunzip(void *dst, int dstlen, unsigned char *src, int *lenp)
  957. {
  958. z_stream s;
  959. int r, i, flags;
  960. /* skip header */
  961. i = 10;
  962. flags = src[3];
  963. if (src[2] != DEFLATED || (flags & RESERVED) != 0) {
  964. printf ("Error: Bad gzipped data\n");
  965. return (-1);
  966. }
  967. if ((flags & EXTRA_FIELD) != 0)
  968. i = 12 + src[10] + (src[11] << 8);
  969. if ((flags & ORIG_NAME) != 0)
  970. while (src[i++] != 0)
  971. ;
  972. if ((flags & COMMENT) != 0)
  973. while (src[i++] != 0)
  974. ;
  975. if ((flags & HEAD_CRC) != 0)
  976. i += 2;
  977. if (i >= *lenp) {
  978. printf ("Error: gunzip out of data in header\n");
  979. return (-1);
  980. }
  981. s.zalloc = zalloc;
  982. s.zfree = zfree;
  983. #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
  984. s.outcb = (cb_func)WATCHDOG_RESET;
  985. #else
  986. s.outcb = Z_NULL;
  987. #endif /* CONFIG_HW_WATCHDOG */
  988. r = inflateInit2(&s, -MAX_WBITS);
  989. if (r != Z_OK) {
  990. printf ("Error: inflateInit2() returned %d\n", r);
  991. return (-1);
  992. }
  993. s.next_in = src + i;
  994. s.avail_in = *lenp - i;
  995. s.next_out = dst;
  996. s.avail_out = dstlen;
  997. r = inflate(&s, Z_FINISH);
  998. if (r != Z_OK && r != Z_STREAM_END) {
  999. printf ("Error: inflate() returned %d\n", r);
  1000. return (-1);
  1001. }
  1002. *lenp = s.next_out - (unsigned char *) dst;
  1003. inflateEnd(&s);
  1004. return (0);
  1005. }
  1006. static void
  1007. do_bootm_rtems (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
  1008. ulong addr, ulong *len_ptr, int verify)
  1009. {
  1010. DECLARE_GLOBAL_DATA_PTR;
  1011. image_header_t *hdr = &header;
  1012. void (*entry_point)(bd_t *);
  1013. entry_point = (void (*)(bd_t *)) hdr->ih_ep;
  1014. printf ("## Transferring control to RTEMS (at address %08lx) ...\n",
  1015. (ulong)entry_point);
  1016. SHOW_BOOT_PROGRESS (15);
  1017. /*
  1018. * RTEMS Parameters:
  1019. * r3: ptr to board info data
  1020. */
  1021. (*entry_point ) ( gd->bd );
  1022. }
  1023. #if (CONFIG_COMMANDS & CFG_CMD_ELF)
  1024. static void
  1025. do_bootm_vxworks (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
  1026. ulong addr, ulong *len_ptr, int verify)
  1027. {
  1028. image_header_t *hdr = &header;
  1029. char str[80];
  1030. sprintf(str, "%x", hdr->ih_ep); /* write entry-point into string */
  1031. setenv("loadaddr", str);
  1032. do_bootvx(cmdtp, 0, 0, NULL);
  1033. }
  1034. static void
  1035. do_bootm_qnxelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
  1036. ulong addr, ulong *len_ptr, int verify)
  1037. {
  1038. image_header_t *hdr = &header;
  1039. char *local_args[2];
  1040. char str[16];
  1041. sprintf(str, "%x", hdr->ih_ep); /* write entry-point into string */
  1042. local_args[0] = argv[0];
  1043. local_args[1] = str; /* and provide it via the arguments */
  1044. do_bootelf(cmdtp, 0, 2, local_args);
  1045. }
  1046. #endif /* CFG_CMD_ELF */