cmd_bootm.c 32 KB

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