cmd_bootm.c 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871
  1. /*
  2. * (C) Copyright 2000-2009
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. /*
  8. * Boot support
  9. */
  10. #include <common.h>
  11. #include <watchdog.h>
  12. #include <command.h>
  13. #include <image.h>
  14. #include <malloc.h>
  15. #include <u-boot/zlib.h>
  16. #include <bzlib.h>
  17. #include <environment.h>
  18. #include <lmb.h>
  19. #include <linux/ctype.h>
  20. #include <asm/byteorder.h>
  21. #include <asm/io.h>
  22. #include <linux/compiler.h>
  23. #if defined(CONFIG_CMD_USB)
  24. #include <usb.h>
  25. #endif
  26. #ifdef CONFIG_SYS_HUSH_PARSER
  27. #include <hush.h>
  28. #endif
  29. #if defined(CONFIG_OF_LIBFDT)
  30. #include <libfdt.h>
  31. #include <fdt_support.h>
  32. #endif
  33. #ifdef CONFIG_LZMA
  34. #include <lzma/LzmaTypes.h>
  35. #include <lzma/LzmaDec.h>
  36. #include <lzma/LzmaTools.h>
  37. #endif /* CONFIG_LZMA */
  38. #ifdef CONFIG_LZO
  39. #include <linux/lzo.h>
  40. #endif /* CONFIG_LZO */
  41. DECLARE_GLOBAL_DATA_PTR;
  42. #ifndef CONFIG_SYS_BOOTM_LEN
  43. #define CONFIG_SYS_BOOTM_LEN 0x800000 /* use 8MByte as default max gunzip size */
  44. #endif
  45. #ifdef CONFIG_BZIP2
  46. extern void bz_internal_error(int);
  47. #endif
  48. #if defined(CONFIG_CMD_IMI)
  49. static int image_info(unsigned long addr);
  50. #endif
  51. #if defined(CONFIG_CMD_IMLS)
  52. #include <flash.h>
  53. #include <mtd/cfi_flash.h>
  54. extern flash_info_t flash_info[]; /* info for FLASH chips */
  55. #endif
  56. #if defined(CONFIG_CMD_IMLS) || defined(CONFIG_CMD_IMLS_NAND)
  57. static int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
  58. #endif
  59. #include <linux/err.h>
  60. #include <nand.h>
  61. #if defined(CONFIG_SILENT_CONSOLE) && !defined(CONFIG_SILENT_U_BOOT_ONLY)
  62. static void fixup_silent_linux(void);
  63. #endif
  64. static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
  65. char * const argv[], bootm_headers_t *images,
  66. ulong *os_data, ulong *os_len);
  67. /*
  68. * Continue booting an OS image; caller already has:
  69. * - copied image header to global variable `header'
  70. * - checked header magic number, checksums (both header & image),
  71. * - verified image architecture (PPC) and type (KERNEL or MULTI),
  72. * - loaded (first part of) image to header load address,
  73. * - disabled interrupts.
  74. *
  75. * @flag: Flags indicating what to do (BOOTM_STATE_...)
  76. * @argc: Number of arguments. Note that the arguments are shifted down
  77. * so that 0 is the first argument not processed by U-Boot, and
  78. * argc is adjusted accordingly. This avoids confusion as to how
  79. * many arguments are available for the OS.
  80. * @images: Pointers to os/initrd/fdt
  81. * @return 1 on error. On success the OS boots so this function does
  82. * not return.
  83. */
  84. typedef int boot_os_fn(int flag, int argc, char * const argv[],
  85. bootm_headers_t *images);
  86. #ifdef CONFIG_BOOTM_LINUX
  87. extern boot_os_fn do_bootm_linux;
  88. #endif
  89. #ifdef CONFIG_BOOTM_NETBSD
  90. static boot_os_fn do_bootm_netbsd;
  91. #endif
  92. #if defined(CONFIG_LYNXKDI)
  93. static boot_os_fn do_bootm_lynxkdi;
  94. extern void lynxkdi_boot(image_header_t *);
  95. #endif
  96. #ifdef CONFIG_BOOTM_RTEMS
  97. static boot_os_fn do_bootm_rtems;
  98. #endif
  99. #if defined(CONFIG_BOOTM_OSE)
  100. static boot_os_fn do_bootm_ose;
  101. #endif
  102. #if defined(CONFIG_BOOTM_PLAN9)
  103. static boot_os_fn do_bootm_plan9;
  104. #endif
  105. #if defined(CONFIG_BOOTM_VXWORKS)
  106. static boot_os_fn do_bootm_vxworks;
  107. #endif
  108. #if defined(CONFIG_CMD_ELF)
  109. static boot_os_fn do_bootm_qnxelf;
  110. int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
  111. int do_bootelf(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
  112. #endif
  113. #if defined(CONFIG_INTEGRITY)
  114. static boot_os_fn do_bootm_integrity;
  115. #endif
  116. static boot_os_fn *boot_os[] = {
  117. #ifdef CONFIG_BOOTM_LINUX
  118. [IH_OS_LINUX] = do_bootm_linux,
  119. #endif
  120. #ifdef CONFIG_BOOTM_NETBSD
  121. [IH_OS_NETBSD] = do_bootm_netbsd,
  122. #endif
  123. #ifdef CONFIG_LYNXKDI
  124. [IH_OS_LYNXOS] = do_bootm_lynxkdi,
  125. #endif
  126. #ifdef CONFIG_BOOTM_RTEMS
  127. [IH_OS_RTEMS] = do_bootm_rtems,
  128. #endif
  129. #if defined(CONFIG_BOOTM_OSE)
  130. [IH_OS_OSE] = do_bootm_ose,
  131. #endif
  132. #if defined(CONFIG_BOOTM_PLAN9)
  133. [IH_OS_PLAN9] = do_bootm_plan9,
  134. #endif
  135. #if defined(CONFIG_BOOTM_VXWORKS)
  136. [IH_OS_VXWORKS] = do_bootm_vxworks,
  137. #endif
  138. #if defined(CONFIG_CMD_ELF)
  139. [IH_OS_QNX] = do_bootm_qnxelf,
  140. #endif
  141. #ifdef CONFIG_INTEGRITY
  142. [IH_OS_INTEGRITY] = do_bootm_integrity,
  143. #endif
  144. };
  145. bootm_headers_t images; /* pointers to os/initrd/fdt images */
  146. /* Allow for arch specific config before we boot */
  147. static void __arch_preboot_os(void)
  148. {
  149. /* please define platform specific arch_preboot_os() */
  150. }
  151. void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os")));
  152. #define IH_INITRD_ARCH IH_ARCH_DEFAULT
  153. #ifdef CONFIG_LMB
  154. static void boot_start_lmb(bootm_headers_t *images)
  155. {
  156. ulong mem_start;
  157. phys_size_t mem_size;
  158. lmb_init(&images->lmb);
  159. mem_start = getenv_bootm_low();
  160. mem_size = getenv_bootm_size();
  161. lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
  162. arch_lmb_reserve(&images->lmb);
  163. board_lmb_reserve(&images->lmb);
  164. }
  165. #else
  166. #define lmb_reserve(lmb, base, size)
  167. static inline void boot_start_lmb(bootm_headers_t *images) { }
  168. #endif
  169. static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  170. {
  171. memset((void *)&images, 0, sizeof(images));
  172. images.verify = getenv_yesno("verify");
  173. boot_start_lmb(&images);
  174. bootstage_mark_name(BOOTSTAGE_ID_BOOTM_START, "bootm_start");
  175. images.state = BOOTM_STATE_START;
  176. return 0;
  177. }
  178. static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc,
  179. char * const argv[])
  180. {
  181. const void *os_hdr;
  182. /* get kernel image header, start address and length */
  183. os_hdr = boot_get_kernel(cmdtp, flag, argc, argv,
  184. &images, &images.os.image_start, &images.os.image_len);
  185. if (images.os.image_len == 0) {
  186. puts("ERROR: can't get kernel image!\n");
  187. return 1;
  188. }
  189. /* get image parameters */
  190. switch (genimg_get_format(os_hdr)) {
  191. case IMAGE_FORMAT_LEGACY:
  192. images.os.type = image_get_type(os_hdr);
  193. images.os.comp = image_get_comp(os_hdr);
  194. images.os.os = image_get_os(os_hdr);
  195. images.os.end = image_get_image_end(os_hdr);
  196. images.os.load = image_get_load(os_hdr);
  197. break;
  198. #if defined(CONFIG_FIT)
  199. case IMAGE_FORMAT_FIT:
  200. if (fit_image_get_type(images.fit_hdr_os,
  201. images.fit_noffset_os, &images.os.type)) {
  202. puts("Can't get image type!\n");
  203. bootstage_error(BOOTSTAGE_ID_FIT_TYPE);
  204. return 1;
  205. }
  206. if (fit_image_get_comp(images.fit_hdr_os,
  207. images.fit_noffset_os, &images.os.comp)) {
  208. puts("Can't get image compression!\n");
  209. bootstage_error(BOOTSTAGE_ID_FIT_COMPRESSION);
  210. return 1;
  211. }
  212. if (fit_image_get_os(images.fit_hdr_os,
  213. images.fit_noffset_os, &images.os.os)) {
  214. puts("Can't get image OS!\n");
  215. bootstage_error(BOOTSTAGE_ID_FIT_OS);
  216. return 1;
  217. }
  218. images.os.end = fit_get_end(images.fit_hdr_os);
  219. if (fit_image_get_load(images.fit_hdr_os, images.fit_noffset_os,
  220. &images.os.load)) {
  221. puts("Can't get image load address!\n");
  222. bootstage_error(BOOTSTAGE_ID_FIT_LOADADDR);
  223. return 1;
  224. }
  225. break;
  226. #endif
  227. default:
  228. puts("ERROR: unknown image format type!\n");
  229. return 1;
  230. }
  231. /* find kernel entry point */
  232. if (images.legacy_hdr_valid) {
  233. images.ep = image_get_ep(&images.legacy_hdr_os_copy);
  234. #if defined(CONFIG_FIT)
  235. } else if (images.fit_uname_os) {
  236. int ret;
  237. ret = fit_image_get_entry(images.fit_hdr_os,
  238. images.fit_noffset_os, &images.ep);
  239. if (ret) {
  240. puts("Can't get entry point property!\n");
  241. return 1;
  242. }
  243. #endif
  244. } else {
  245. puts("Could not find kernel entry point!\n");
  246. return 1;
  247. }
  248. if (images.os.type == IH_TYPE_KERNEL_NOLOAD) {
  249. images.os.load = images.os.image_start;
  250. images.ep += images.os.load;
  251. }
  252. images.os.start = (ulong)os_hdr;
  253. return 0;
  254. }
  255. static int bootm_find_ramdisk(int flag, int argc, char * const argv[])
  256. {
  257. int ret;
  258. /* find ramdisk */
  259. ret = boot_get_ramdisk(argc, argv, &images, IH_INITRD_ARCH,
  260. &images.rd_start, &images.rd_end);
  261. if (ret) {
  262. puts("Ramdisk image is corrupt or invalid\n");
  263. return 1;
  264. }
  265. return 0;
  266. }
  267. #if defined(CONFIG_OF_LIBFDT)
  268. static int bootm_find_fdt(int flag, int argc, char * const argv[])
  269. {
  270. int ret;
  271. /* find flattened device tree */
  272. ret = boot_get_fdt(flag, argc, argv, IH_ARCH_DEFAULT, &images,
  273. &images.ft_addr, &images.ft_len);
  274. if (ret) {
  275. puts("Could not find a valid device tree\n");
  276. return 1;
  277. }
  278. set_working_fdt_addr(images.ft_addr);
  279. return 0;
  280. }
  281. #endif
  282. static int bootm_find_other(cmd_tbl_t *cmdtp, int flag, int argc,
  283. char * const argv[])
  284. {
  285. if (((images.os.type == IH_TYPE_KERNEL) ||
  286. (images.os.type == IH_TYPE_KERNEL_NOLOAD) ||
  287. (images.os.type == IH_TYPE_MULTI)) &&
  288. (images.os.os == IH_OS_LINUX)) {
  289. if (bootm_find_ramdisk(flag, argc, argv))
  290. return 1;
  291. #if defined(CONFIG_OF_LIBFDT)
  292. if (bootm_find_fdt(flag, argc, argv))
  293. return 1;
  294. #endif
  295. }
  296. return 0;
  297. }
  298. #define BOOTM_ERR_RESET -1
  299. #define BOOTM_ERR_OVERLAP -2
  300. #define BOOTM_ERR_UNIMPLEMENTED -3
  301. static int bootm_load_os(bootm_headers_t *images, unsigned long *load_end,
  302. int boot_progress)
  303. {
  304. image_info_t os = images->os;
  305. uint8_t comp = os.comp;
  306. ulong load = os.load;
  307. ulong blob_start = os.start;
  308. ulong blob_end = os.end;
  309. ulong image_start = os.image_start;
  310. ulong image_len = os.image_len;
  311. __maybe_unused uint unc_len = CONFIG_SYS_BOOTM_LEN;
  312. int no_overlap = 0;
  313. void *load_buf, *image_buf;
  314. #if defined(CONFIG_LZMA) || defined(CONFIG_LZO)
  315. int ret;
  316. #endif /* defined(CONFIG_LZMA) || defined(CONFIG_LZO) */
  317. const char *type_name = genimg_get_type_name(os.type);
  318. load_buf = map_sysmem(load, unc_len);
  319. image_buf = map_sysmem(image_start, image_len);
  320. switch (comp) {
  321. case IH_COMP_NONE:
  322. if (load == blob_start || load == image_start) {
  323. printf(" XIP %s ... ", type_name);
  324. no_overlap = 1;
  325. } else {
  326. printf(" Loading %s ... ", type_name);
  327. memmove_wd(load_buf, image_buf, image_len, CHUNKSZ);
  328. }
  329. *load_end = load + image_len;
  330. break;
  331. #ifdef CONFIG_GZIP
  332. case IH_COMP_GZIP:
  333. printf(" Uncompressing %s ... ", type_name);
  334. if (gunzip(load_buf, unc_len, image_buf, &image_len) != 0) {
  335. puts("GUNZIP: uncompress, out-of-mem or overwrite "
  336. "error - must RESET board to recover\n");
  337. if (boot_progress)
  338. bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
  339. return BOOTM_ERR_RESET;
  340. }
  341. *load_end = load + image_len;
  342. break;
  343. #endif /* CONFIG_GZIP */
  344. #ifdef CONFIG_BZIP2
  345. case IH_COMP_BZIP2:
  346. printf(" Uncompressing %s ... ", type_name);
  347. /*
  348. * If we've got less than 4 MB of malloc() space,
  349. * use slower decompression algorithm which requires
  350. * at most 2300 KB of memory.
  351. */
  352. int i = BZ2_bzBuffToBuffDecompress(load_buf, &unc_len,
  353. image_buf, image_len,
  354. CONFIG_SYS_MALLOC_LEN < (4096 * 1024), 0);
  355. if (i != BZ_OK) {
  356. printf("BUNZIP2: uncompress or overwrite error %d "
  357. "- must RESET board to recover\n", i);
  358. if (boot_progress)
  359. bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
  360. return BOOTM_ERR_RESET;
  361. }
  362. *load_end = load + unc_len;
  363. break;
  364. #endif /* CONFIG_BZIP2 */
  365. #ifdef CONFIG_LZMA
  366. case IH_COMP_LZMA: {
  367. SizeT lzma_len = unc_len;
  368. printf(" Uncompressing %s ... ", type_name);
  369. ret = lzmaBuffToBuffDecompress(load_buf, &lzma_len,
  370. image_buf, image_len);
  371. unc_len = lzma_len;
  372. if (ret != SZ_OK) {
  373. printf("LZMA: uncompress or overwrite error %d "
  374. "- must RESET board to recover\n", ret);
  375. bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
  376. return BOOTM_ERR_RESET;
  377. }
  378. *load_end = load + unc_len;
  379. break;
  380. }
  381. #endif /* CONFIG_LZMA */
  382. #ifdef CONFIG_LZO
  383. case IH_COMP_LZO: {
  384. size_t size;
  385. printf(" Uncompressing %s ... ", type_name);
  386. ret = lzop_decompress(image_buf, image_len, load_buf, &size);
  387. if (ret != LZO_E_OK) {
  388. printf("LZO: uncompress or overwrite error %d "
  389. "- must RESET board to recover\n", ret);
  390. if (boot_progress)
  391. bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
  392. return BOOTM_ERR_RESET;
  393. }
  394. *load_end = load + size;
  395. break;
  396. }
  397. #endif /* CONFIG_LZO */
  398. default:
  399. printf("Unimplemented compression type %d\n", comp);
  400. return BOOTM_ERR_UNIMPLEMENTED;
  401. }
  402. flush_cache(load, (*load_end - load) * sizeof(ulong));
  403. puts("OK\n");
  404. debug(" kernel loaded at 0x%08lx, end = 0x%08lx\n", load, *load_end);
  405. bootstage_mark(BOOTSTAGE_ID_KERNEL_LOADED);
  406. if (!no_overlap && (load < blob_end) && (*load_end > blob_start)) {
  407. debug("images.os.start = 0x%lX, images.os.end = 0x%lx\n",
  408. blob_start, blob_end);
  409. debug("images.os.load = 0x%lx, load_end = 0x%lx\n", load,
  410. *load_end);
  411. /* Check what type of image this is. */
  412. if (images->legacy_hdr_valid) {
  413. if (image_get_type(&images->legacy_hdr_os_copy)
  414. == IH_TYPE_MULTI)
  415. puts("WARNING: legacy format multi component image overwritten\n");
  416. return BOOTM_ERR_OVERLAP;
  417. } else {
  418. puts("ERROR: new format image overwritten - must RESET the board to recover\n");
  419. bootstage_error(BOOTSTAGE_ID_OVERWRITTEN);
  420. return BOOTM_ERR_RESET;
  421. }
  422. }
  423. return 0;
  424. }
  425. static int bootm_start_standalone(int argc, char * const argv[])
  426. {
  427. char *s;
  428. int (*appl)(int, char * const []);
  429. /* Don't start if "autostart" is set to "no" */
  430. if (((s = getenv("autostart")) != NULL) && (strcmp(s, "no") == 0)) {
  431. setenv_hex("filesize", images.os.image_len);
  432. return 0;
  433. }
  434. appl = (int (*)(int, char * const []))(ulong)ntohl(images.ep);
  435. (*appl)(argc, argv);
  436. return 0;
  437. }
  438. /* we overload the cmd field with our state machine info instead of a
  439. * function pointer */
  440. static cmd_tbl_t cmd_bootm_sub[] = {
  441. U_BOOT_CMD_MKENT(start, 0, 1, (void *)BOOTM_STATE_START, "", ""),
  442. U_BOOT_CMD_MKENT(loados, 0, 1, (void *)BOOTM_STATE_LOADOS, "", ""),
  443. #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
  444. U_BOOT_CMD_MKENT(ramdisk, 0, 1, (void *)BOOTM_STATE_RAMDISK, "", ""),
  445. #endif
  446. #ifdef CONFIG_OF_LIBFDT
  447. U_BOOT_CMD_MKENT(fdt, 0, 1, (void *)BOOTM_STATE_FDT, "", ""),
  448. #endif
  449. U_BOOT_CMD_MKENT(cmdline, 0, 1, (void *)BOOTM_STATE_OS_CMDLINE, "", ""),
  450. U_BOOT_CMD_MKENT(bdt, 0, 1, (void *)BOOTM_STATE_OS_BD_T, "", ""),
  451. U_BOOT_CMD_MKENT(prep, 0, 1, (void *)BOOTM_STATE_OS_PREP, "", ""),
  452. U_BOOT_CMD_MKENT(fake, 0, 1, (void *)BOOTM_STATE_OS_FAKE_GO, "", ""),
  453. U_BOOT_CMD_MKENT(go, 0, 1, (void *)BOOTM_STATE_OS_GO, "", ""),
  454. };
  455. static int boot_selected_os(int argc, char * const argv[], int state,
  456. bootm_headers_t *images, boot_os_fn *boot_fn)
  457. {
  458. if (images->os.type == IH_TYPE_STANDALONE) {
  459. /* This may return when 'autostart' is 'no' */
  460. bootm_start_standalone(argc, argv);
  461. return 0;
  462. }
  463. arch_preboot_os();
  464. boot_fn(state, argc, argv, images);
  465. if (state == BOOTM_STATE_OS_FAKE_GO) /* We expect to return */
  466. return 0;
  467. bootstage_error(BOOTSTAGE_ID_BOOT_OS_RETURNED);
  468. #ifdef DEBUG
  469. puts("\n## Control returned to monitor - resetting...\n");
  470. #endif
  471. return BOOTM_ERR_RESET;
  472. }
  473. /**
  474. * bootm_disable_interrupts() - Disable interrupts in preparation for load/boot
  475. *
  476. * @return interrupt flag (0 if interrupts were disabled, non-zero if they were
  477. * enabled)
  478. */
  479. static ulong bootm_disable_interrupts(void)
  480. {
  481. ulong iflag;
  482. /*
  483. * We have reached the point of no return: we are going to
  484. * overwrite all exception vector code, so we cannot easily
  485. * recover from any failures any more...
  486. */
  487. iflag = disable_interrupts();
  488. #ifdef CONFIG_NETCONSOLE
  489. /* Stop the ethernet stack if NetConsole could have left it up */
  490. eth_halt();
  491. eth_unregister(eth_get_dev());
  492. #endif
  493. #if defined(CONFIG_CMD_USB)
  494. /*
  495. * turn off USB to prevent the host controller from writing to the
  496. * SDRAM while Linux is booting. This could happen (at least for OHCI
  497. * controller), because the HCCA (Host Controller Communication Area)
  498. * lies within the SDRAM and the host controller writes continously to
  499. * this area (as busmaster!). The HccaFrameNumber is for example
  500. * updated every 1 ms within the HCCA structure in SDRAM! For more
  501. * details see the OpenHCI specification.
  502. */
  503. usb_stop();
  504. #endif
  505. return iflag;
  506. }
  507. /**
  508. * Execute selected states of the bootm command.
  509. *
  510. * Note the arguments to this state must be the first argument, Any 'bootm'
  511. * or sub-command arguments must have already been taken.
  512. *
  513. * Note that if states contains more than one flag it MUST contain
  514. * BOOTM_STATE_START, since this handles and consumes the command line args.
  515. *
  516. * Also note that aside from boot_os_fn functions and bootm_load_os no other
  517. * functions we store the return value of in 'ret' may use a negative return
  518. * value, without special handling.
  519. *
  520. * @param cmdtp Pointer to bootm command table entry
  521. * @param flag Command flags (CMD_FLAG_...)
  522. * @param argc Number of subcommand arguments (0 = no arguments)
  523. * @param argv Arguments
  524. * @param states Mask containing states to run (BOOTM_STATE_...)
  525. * @param images Image header information
  526. * @param boot_progress 1 to show boot progress, 0 to not do this
  527. * @return 0 if ok, something else on error. Some errors will cause this
  528. * function to perform a reboot! If states contains BOOTM_STATE_OS_GO
  529. * then the intent is to boot an OS, so this function will not return
  530. * unless the image type is standalone.
  531. */
  532. static int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc,
  533. char * const argv[], int states, bootm_headers_t *images,
  534. int boot_progress)
  535. {
  536. boot_os_fn *boot_fn;
  537. ulong iflag = 0;
  538. int ret = 0, need_boot_fn;
  539. images->state |= states;
  540. /*
  541. * Work through the states and see how far we get. We stop on
  542. * any error.
  543. */
  544. if (states & BOOTM_STATE_START)
  545. ret = bootm_start(cmdtp, flag, argc, argv);
  546. if (!ret && (states & BOOTM_STATE_FINDOS))
  547. ret = bootm_find_os(cmdtp, flag, argc, argv);
  548. if (!ret && (states & BOOTM_STATE_FINDOTHER)) {
  549. ret = bootm_find_other(cmdtp, flag, argc, argv);
  550. argc = 0; /* consume the args */
  551. }
  552. /* Load the OS */
  553. if (!ret && (states & BOOTM_STATE_LOADOS)) {
  554. ulong load_end;
  555. iflag = bootm_disable_interrupts();
  556. ret = bootm_load_os(images, &load_end, 0);
  557. if (ret == 0)
  558. lmb_reserve(&images->lmb, images->os.load,
  559. (load_end - images->os.load));
  560. else if (ret && ret != BOOTM_ERR_OVERLAP)
  561. goto err;
  562. else if (ret == BOOTM_ERR_OVERLAP)
  563. ret = 0;
  564. #if defined(CONFIG_SILENT_CONSOLE) && !defined(CONFIG_SILENT_U_BOOT_ONLY)
  565. if (images->os.os == IH_OS_LINUX)
  566. fixup_silent_linux();
  567. #endif
  568. }
  569. /* Relocate the ramdisk */
  570. #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
  571. if (!ret && (states & BOOTM_STATE_RAMDISK)) {
  572. ulong rd_len = images->rd_end - images->rd_start;
  573. ret = boot_ramdisk_high(&images->lmb, images->rd_start,
  574. rd_len, &images->initrd_start, &images->initrd_end);
  575. if (!ret) {
  576. setenv_hex("initrd_start", images->initrd_start);
  577. setenv_hex("initrd_end", images->initrd_end);
  578. }
  579. }
  580. #endif
  581. #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_LMB)
  582. if (!ret && (states & BOOTM_STATE_FDT)) {
  583. boot_fdt_add_mem_rsv_regions(&images->lmb, images->ft_addr);
  584. ret = boot_relocate_fdt(&images->lmb, &images->ft_addr,
  585. &images->ft_len);
  586. }
  587. #endif
  588. /* From now on, we need the OS boot function */
  589. if (ret)
  590. return ret;
  591. boot_fn = boot_os[images->os.os];
  592. need_boot_fn = states & (BOOTM_STATE_OS_CMDLINE |
  593. BOOTM_STATE_OS_BD_T | BOOTM_STATE_OS_PREP |
  594. BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO);
  595. if (boot_fn == NULL && need_boot_fn) {
  596. if (iflag)
  597. enable_interrupts();
  598. printf("ERROR: booting os '%s' (%d) is not supported\n",
  599. genimg_get_os_name(images->os.os), images->os.os);
  600. bootstage_error(BOOTSTAGE_ID_CHECK_BOOT_OS);
  601. return 1;
  602. }
  603. /* Call various other states that are not generally used */
  604. if (!ret && (states & BOOTM_STATE_OS_CMDLINE))
  605. ret = boot_fn(BOOTM_STATE_OS_CMDLINE, argc, argv, images);
  606. if (!ret && (states & BOOTM_STATE_OS_BD_T))
  607. ret = boot_fn(BOOTM_STATE_OS_BD_T, argc, argv, images);
  608. if (!ret && (states & BOOTM_STATE_OS_PREP))
  609. ret = boot_fn(BOOTM_STATE_OS_PREP, argc, argv, images);
  610. #ifdef CONFIG_TRACE
  611. /* Pretend to run the OS, then run a user command */
  612. if (!ret && (states & BOOTM_STATE_OS_FAKE_GO)) {
  613. char *cmd_list = getenv("fakegocmd");
  614. ret = boot_selected_os(argc, argv, BOOTM_STATE_OS_FAKE_GO,
  615. images, boot_fn);
  616. if (!ret && cmd_list)
  617. ret = run_command_list(cmd_list, -1, flag);
  618. }
  619. #endif
  620. /* Check for unsupported subcommand. */
  621. if (ret) {
  622. puts("subcommand not supported\n");
  623. return ret;
  624. }
  625. /* Now run the OS! We hope this doesn't return */
  626. if (!ret && (states & BOOTM_STATE_OS_GO))
  627. ret = boot_selected_os(argc, argv, BOOTM_STATE_OS_GO,
  628. images, boot_fn);
  629. /* Deal with any fallout */
  630. err:
  631. if (iflag)
  632. enable_interrupts();
  633. if (ret == BOOTM_ERR_UNIMPLEMENTED)
  634. bootstage_error(BOOTSTAGE_ID_DECOMP_UNIMPL);
  635. else if (ret == BOOTM_ERR_RESET)
  636. do_reset(cmdtp, flag, argc, argv);
  637. return ret;
  638. }
  639. static int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc,
  640. char * const argv[])
  641. {
  642. int ret = 0;
  643. long state;
  644. cmd_tbl_t *c;
  645. c = find_cmd_tbl(argv[0], &cmd_bootm_sub[0], ARRAY_SIZE(cmd_bootm_sub));
  646. argc--; argv++;
  647. if (c) {
  648. state = (long)c->cmd;
  649. if (state == BOOTM_STATE_START)
  650. state |= BOOTM_STATE_FINDOS | BOOTM_STATE_FINDOTHER;
  651. } else {
  652. /* Unrecognized command */
  653. return CMD_RET_USAGE;
  654. }
  655. if (state != BOOTM_STATE_START && images.state >= state) {
  656. printf("Trying to execute a command out of order\n");
  657. return CMD_RET_USAGE;
  658. }
  659. ret = do_bootm_states(cmdtp, flag, argc, argv, state, &images, 0);
  660. return ret;
  661. }
  662. /*******************************************************************/
  663. /* bootm - boot application image from image in memory */
  664. /*******************************************************************/
  665. int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  666. {
  667. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  668. static int relocated = 0;
  669. if (!relocated) {
  670. int i;
  671. /* relocate boot function table */
  672. for (i = 0; i < ARRAY_SIZE(boot_os); i++)
  673. if (boot_os[i] != NULL)
  674. boot_os[i] += gd->reloc_off;
  675. /* relocate names of sub-command table */
  676. for (i = 0; i < ARRAY_SIZE(cmd_bootm_sub); i++)
  677. cmd_bootm_sub[i].name += gd->reloc_off;
  678. relocated = 1;
  679. }
  680. #endif
  681. /* determine if we have a sub command */
  682. argc--; argv++;
  683. if (argc > 0) {
  684. char *endp;
  685. simple_strtoul(argv[0], &endp, 16);
  686. /* endp pointing to NULL means that argv[0] was just a
  687. * valid number, pass it along to the normal bootm processing
  688. *
  689. * If endp is ':' or '#' assume a FIT identifier so pass
  690. * along for normal processing.
  691. *
  692. * Right now we assume the first arg should never be '-'
  693. */
  694. if ((*endp != 0) && (*endp != ':') && (*endp != '#'))
  695. return do_bootm_subcommand(cmdtp, flag, argc, argv);
  696. }
  697. return do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START |
  698. BOOTM_STATE_FINDOS | BOOTM_STATE_FINDOTHER |
  699. BOOTM_STATE_LOADOS |
  700. #if defined(CONFIG_PPC) || defined(CONFIG_MIPS)
  701. BOOTM_STATE_OS_CMDLINE |
  702. #endif
  703. BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
  704. BOOTM_STATE_OS_GO, &images, 1);
  705. }
  706. int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)
  707. {
  708. const char *ep = getenv("autostart");
  709. if (ep && !strcmp(ep, "yes")) {
  710. char *local_args[2];
  711. local_args[0] = (char *)cmd;
  712. local_args[1] = NULL;
  713. printf("Automatic boot of image at addr 0x%08lX ...\n", load_addr);
  714. return do_bootm(cmdtp, 0, 1, local_args);
  715. }
  716. return 0;
  717. }
  718. /**
  719. * image_get_kernel - verify legacy format kernel image
  720. * @img_addr: in RAM address of the legacy format image to be verified
  721. * @verify: data CRC verification flag
  722. *
  723. * image_get_kernel() verifies legacy image integrity and returns pointer to
  724. * legacy image header if image verification was completed successfully.
  725. *
  726. * returns:
  727. * pointer to a legacy image header if valid image was found
  728. * otherwise return NULL
  729. */
  730. static image_header_t *image_get_kernel(ulong img_addr, int verify)
  731. {
  732. image_header_t *hdr = (image_header_t *)img_addr;
  733. if (!image_check_magic(hdr)) {
  734. puts("Bad Magic Number\n");
  735. bootstage_error(BOOTSTAGE_ID_CHECK_MAGIC);
  736. return NULL;
  737. }
  738. bootstage_mark(BOOTSTAGE_ID_CHECK_HEADER);
  739. if (!image_check_hcrc(hdr)) {
  740. puts("Bad Header Checksum\n");
  741. bootstage_error(BOOTSTAGE_ID_CHECK_HEADER);
  742. return NULL;
  743. }
  744. bootstage_mark(BOOTSTAGE_ID_CHECK_CHECKSUM);
  745. image_print_contents(hdr);
  746. if (verify) {
  747. puts(" Verifying Checksum ... ");
  748. if (!image_check_dcrc(hdr)) {
  749. printf("Bad Data CRC\n");
  750. bootstage_error(BOOTSTAGE_ID_CHECK_CHECKSUM);
  751. return NULL;
  752. }
  753. puts("OK\n");
  754. }
  755. bootstage_mark(BOOTSTAGE_ID_CHECK_ARCH);
  756. if (!image_check_target_arch(hdr)) {
  757. printf("Unsupported Architecture 0x%x\n", image_get_arch(hdr));
  758. bootstage_error(BOOTSTAGE_ID_CHECK_ARCH);
  759. return NULL;
  760. }
  761. return hdr;
  762. }
  763. /**
  764. * boot_get_kernel - find kernel image
  765. * @os_data: pointer to a ulong variable, will hold os data start address
  766. * @os_len: pointer to a ulong variable, will hold os data length
  767. *
  768. * boot_get_kernel() tries to find a kernel image, verifies its integrity
  769. * and locates kernel data.
  770. *
  771. * returns:
  772. * pointer to image header if valid image was found, plus kernel start
  773. * address and length, otherwise NULL
  774. */
  775. static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
  776. char * const argv[], bootm_headers_t *images, ulong *os_data,
  777. ulong *os_len)
  778. {
  779. image_header_t *hdr;
  780. ulong img_addr;
  781. const void *buf;
  782. #if defined(CONFIG_FIT)
  783. const char *fit_uname_config = NULL;
  784. const char *fit_uname_kernel = NULL;
  785. int os_noffset;
  786. #endif
  787. /* find out kernel image address */
  788. if (argc < 1) {
  789. img_addr = load_addr;
  790. debug("* kernel: default image load address = 0x%08lx\n",
  791. load_addr);
  792. #if defined(CONFIG_FIT)
  793. } else if (fit_parse_conf(argv[0], load_addr, &img_addr,
  794. &fit_uname_config)) {
  795. debug("* kernel: config '%s' from image at 0x%08lx\n",
  796. fit_uname_config, img_addr);
  797. } else if (fit_parse_subimage(argv[0], load_addr, &img_addr,
  798. &fit_uname_kernel)) {
  799. debug("* kernel: subimage '%s' from image at 0x%08lx\n",
  800. fit_uname_kernel, img_addr);
  801. #endif
  802. } else {
  803. img_addr = simple_strtoul(argv[0], NULL, 16);
  804. debug("* kernel: cmdline image address = 0x%08lx\n", img_addr);
  805. }
  806. bootstage_mark(BOOTSTAGE_ID_CHECK_MAGIC);
  807. /* copy from dataflash if needed */
  808. img_addr = genimg_get_image(img_addr);
  809. /* check image type, for FIT images get FIT kernel node */
  810. *os_data = *os_len = 0;
  811. buf = map_sysmem(img_addr, 0);
  812. switch (genimg_get_format(buf)) {
  813. case IMAGE_FORMAT_LEGACY:
  814. printf("## Booting kernel from Legacy Image at %08lx ...\n",
  815. img_addr);
  816. hdr = image_get_kernel(img_addr, images->verify);
  817. if (!hdr)
  818. return NULL;
  819. bootstage_mark(BOOTSTAGE_ID_CHECK_IMAGETYPE);
  820. /* get os_data and os_len */
  821. switch (image_get_type(hdr)) {
  822. case IH_TYPE_KERNEL:
  823. case IH_TYPE_KERNEL_NOLOAD:
  824. *os_data = image_get_data(hdr);
  825. *os_len = image_get_data_size(hdr);
  826. break;
  827. case IH_TYPE_MULTI:
  828. image_multi_getimg(hdr, 0, os_data, os_len);
  829. break;
  830. case IH_TYPE_STANDALONE:
  831. *os_data = image_get_data(hdr);
  832. *os_len = image_get_data_size(hdr);
  833. break;
  834. default:
  835. printf("Wrong Image Type for %s command\n",
  836. cmdtp->name);
  837. bootstage_error(BOOTSTAGE_ID_CHECK_IMAGETYPE);
  838. return NULL;
  839. }
  840. /*
  841. * copy image header to allow for image overwrites during
  842. * kernel decompression.
  843. */
  844. memmove(&images->legacy_hdr_os_copy, hdr,
  845. sizeof(image_header_t));
  846. /* save pointer to image header */
  847. images->legacy_hdr_os = hdr;
  848. images->legacy_hdr_valid = 1;
  849. bootstage_mark(BOOTSTAGE_ID_DECOMP_IMAGE);
  850. break;
  851. #if defined(CONFIG_FIT)
  852. case IMAGE_FORMAT_FIT:
  853. os_noffset = fit_image_load(images, FIT_KERNEL_PROP,
  854. img_addr,
  855. &fit_uname_kernel, &fit_uname_config,
  856. IH_ARCH_DEFAULT, IH_TYPE_KERNEL,
  857. BOOTSTAGE_ID_FIT_KERNEL_START,
  858. FIT_LOAD_IGNORED, os_data, os_len);
  859. if (os_noffset < 0)
  860. return NULL;
  861. images->fit_hdr_os = map_sysmem(img_addr, 0);
  862. images->fit_uname_os = fit_uname_kernel;
  863. images->fit_uname_cfg = fit_uname_config;
  864. images->fit_noffset_os = os_noffset;
  865. break;
  866. #endif
  867. default:
  868. printf("Wrong Image Format for %s command\n", cmdtp->name);
  869. bootstage_error(BOOTSTAGE_ID_FIT_KERNEL_INFO);
  870. return NULL;
  871. }
  872. debug(" kernel data at 0x%08lx, len = 0x%08lx (%ld)\n",
  873. *os_data, *os_len, *os_len);
  874. return buf;
  875. }
  876. #ifdef CONFIG_SYS_LONGHELP
  877. static char bootm_help_text[] =
  878. "[addr [arg ...]]\n - boot application image stored in memory\n"
  879. "\tpassing arguments 'arg ...'; when booting a Linux kernel,\n"
  880. "\t'arg' can be the address of an initrd image\n"
  881. #if defined(CONFIG_OF_LIBFDT)
  882. "\tWhen booting a Linux kernel which requires a flat device-tree\n"
  883. "\ta third argument is required which is the address of the\n"
  884. "\tdevice-tree blob. To boot that kernel without an initrd image,\n"
  885. "\tuse a '-' for the second argument. If you do not pass a third\n"
  886. "\ta bd_info struct will be passed instead\n"
  887. #endif
  888. #if defined(CONFIG_FIT)
  889. "\t\nFor the new multi component uImage format (FIT) addresses\n"
  890. "\tmust be extened to include component or configuration unit name:\n"
  891. "\taddr:<subimg_uname> - direct component image specification\n"
  892. "\taddr#<conf_uname> - configuration specification\n"
  893. "\tUse iminfo command to get the list of existing component\n"
  894. "\timages and configurations.\n"
  895. #endif
  896. "\nSub-commands to do part of the bootm sequence. The sub-commands "
  897. "must be\n"
  898. "issued in the order below (it's ok to not issue all sub-commands):\n"
  899. "\tstart [addr [arg ...]]\n"
  900. "\tloados - load OS image\n"
  901. #if defined(CONFIG_SYS_BOOT_RAMDISK_HIGH)
  902. "\tramdisk - relocate initrd, set env initrd_start/initrd_end\n"
  903. #endif
  904. #if defined(CONFIG_OF_LIBFDT)
  905. "\tfdt - relocate flat device tree\n"
  906. #endif
  907. "\tcmdline - OS specific command line processing/setup\n"
  908. "\tbdt - OS specific bd_t processing\n"
  909. "\tprep - OS specific prep before relocation or go\n"
  910. "\tgo - start OS";
  911. #endif
  912. U_BOOT_CMD(
  913. bootm, CONFIG_SYS_MAXARGS, 1, do_bootm,
  914. "boot application image from memory", bootm_help_text
  915. );
  916. /*******************************************************************/
  917. /* bootd - boot default image */
  918. /*******************************************************************/
  919. #if defined(CONFIG_CMD_BOOTD)
  920. int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  921. {
  922. int rcode = 0;
  923. if (run_command(getenv("bootcmd"), flag) < 0)
  924. rcode = 1;
  925. return rcode;
  926. }
  927. U_BOOT_CMD(
  928. boot, 1, 1, do_bootd,
  929. "boot default, i.e., run 'bootcmd'",
  930. ""
  931. );
  932. /* keep old command name "bootd" for backward compatibility */
  933. U_BOOT_CMD(
  934. bootd, 1, 1, do_bootd,
  935. "boot default, i.e., run 'bootcmd'",
  936. ""
  937. );
  938. #endif
  939. /*******************************************************************/
  940. /* iminfo - print header info for a requested image */
  941. /*******************************************************************/
  942. #if defined(CONFIG_CMD_IMI)
  943. static int do_iminfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  944. {
  945. int arg;
  946. ulong addr;
  947. int rcode = 0;
  948. if (argc < 2) {
  949. return image_info(load_addr);
  950. }
  951. for (arg = 1; arg < argc; ++arg) {
  952. addr = simple_strtoul(argv[arg], NULL, 16);
  953. if (image_info(addr) != 0)
  954. rcode = 1;
  955. }
  956. return rcode;
  957. }
  958. static int image_info(ulong addr)
  959. {
  960. void *hdr = (void *)addr;
  961. printf("\n## Checking Image at %08lx ...\n", addr);
  962. switch (genimg_get_format(hdr)) {
  963. case IMAGE_FORMAT_LEGACY:
  964. puts(" Legacy image found\n");
  965. if (!image_check_magic(hdr)) {
  966. puts(" Bad Magic Number\n");
  967. return 1;
  968. }
  969. if (!image_check_hcrc(hdr)) {
  970. puts(" Bad Header Checksum\n");
  971. return 1;
  972. }
  973. image_print_contents(hdr);
  974. puts(" Verifying Checksum ... ");
  975. if (!image_check_dcrc(hdr)) {
  976. puts(" Bad Data CRC\n");
  977. return 1;
  978. }
  979. puts("OK\n");
  980. return 0;
  981. #if defined(CONFIG_FIT)
  982. case IMAGE_FORMAT_FIT:
  983. puts(" FIT image found\n");
  984. if (!fit_check_format(hdr)) {
  985. puts("Bad FIT image format!\n");
  986. return 1;
  987. }
  988. fit_print_contents(hdr);
  989. if (!fit_all_image_verify(hdr)) {
  990. puts("Bad hash in FIT image!\n");
  991. return 1;
  992. }
  993. return 0;
  994. #endif
  995. default:
  996. puts("Unknown image format!\n");
  997. break;
  998. }
  999. return 1;
  1000. }
  1001. U_BOOT_CMD(
  1002. iminfo, CONFIG_SYS_MAXARGS, 1, do_iminfo,
  1003. "print header information for application image",
  1004. "addr [addr ...]\n"
  1005. " - print header information for application image starting at\n"
  1006. " address 'addr' in memory; this includes verification of the\n"
  1007. " image contents (magic number, header and payload checksums)"
  1008. );
  1009. #endif
  1010. /*******************************************************************/
  1011. /* imls - list all images found in flash */
  1012. /*******************************************************************/
  1013. #if defined(CONFIG_CMD_IMLS)
  1014. static int do_imls_nor(void)
  1015. {
  1016. flash_info_t *info;
  1017. int i, j;
  1018. void *hdr;
  1019. for (i = 0, info = &flash_info[0];
  1020. i < CONFIG_SYS_MAX_FLASH_BANKS; ++i, ++info) {
  1021. if (info->flash_id == FLASH_UNKNOWN)
  1022. goto next_bank;
  1023. for (j = 0; j < info->sector_count; ++j) {
  1024. hdr = (void *)info->start[j];
  1025. if (!hdr)
  1026. goto next_sector;
  1027. switch (genimg_get_format(hdr)) {
  1028. case IMAGE_FORMAT_LEGACY:
  1029. if (!image_check_hcrc(hdr))
  1030. goto next_sector;
  1031. printf("Legacy Image at %08lX:\n", (ulong)hdr);
  1032. image_print_contents(hdr);
  1033. puts(" Verifying Checksum ... ");
  1034. if (!image_check_dcrc(hdr)) {
  1035. puts("Bad Data CRC\n");
  1036. } else {
  1037. puts("OK\n");
  1038. }
  1039. break;
  1040. #if defined(CONFIG_FIT)
  1041. case IMAGE_FORMAT_FIT:
  1042. if (!fit_check_format(hdr))
  1043. goto next_sector;
  1044. printf("FIT Image at %08lX:\n", (ulong)hdr);
  1045. fit_print_contents(hdr);
  1046. break;
  1047. #endif
  1048. default:
  1049. goto next_sector;
  1050. }
  1051. next_sector: ;
  1052. }
  1053. next_bank: ;
  1054. }
  1055. return 0;
  1056. }
  1057. #endif
  1058. #if defined(CONFIG_CMD_IMLS_NAND)
  1059. static int nand_imls_legacyimage(nand_info_t *nand, int nand_dev, loff_t off,
  1060. size_t len)
  1061. {
  1062. void *imgdata;
  1063. int ret;
  1064. imgdata = malloc(len);
  1065. if (!imgdata) {
  1066. printf("May be a Legacy Image at NAND device %d offset %08llX:\n",
  1067. nand_dev, off);
  1068. printf(" Low memory(cannot allocate memory for image)\n");
  1069. return -ENOMEM;
  1070. }
  1071. ret = nand_read_skip_bad(nand, off, &len,
  1072. imgdata);
  1073. if (ret < 0 && ret != -EUCLEAN) {
  1074. free(imgdata);
  1075. return ret;
  1076. }
  1077. if (!image_check_hcrc(imgdata)) {
  1078. free(imgdata);
  1079. return 0;
  1080. }
  1081. printf("Legacy Image at NAND device %d offset %08llX:\n",
  1082. nand_dev, off);
  1083. image_print_contents(imgdata);
  1084. puts(" Verifying Checksum ... ");
  1085. if (!image_check_dcrc(imgdata))
  1086. puts("Bad Data CRC\n");
  1087. else
  1088. puts("OK\n");
  1089. free(imgdata);
  1090. return 0;
  1091. }
  1092. static int nand_imls_fitimage(nand_info_t *nand, int nand_dev, loff_t off,
  1093. size_t len)
  1094. {
  1095. void *imgdata;
  1096. int ret;
  1097. imgdata = malloc(len);
  1098. if (!imgdata) {
  1099. printf("May be a FIT Image at NAND device %d offset %08llX:\n",
  1100. nand_dev, off);
  1101. printf(" Low memory(cannot allocate memory for image)\n");
  1102. return -ENOMEM;
  1103. }
  1104. ret = nand_read_skip_bad(nand, off, &len,
  1105. imgdata);
  1106. if (ret < 0 && ret != -EUCLEAN) {
  1107. free(imgdata);
  1108. return ret;
  1109. }
  1110. if (!fit_check_format(imgdata)) {
  1111. free(imgdata);
  1112. return 0;
  1113. }
  1114. printf("FIT Image at NAND device %d offset %08llX:\n", nand_dev, off);
  1115. fit_print_contents(imgdata);
  1116. free(imgdata);
  1117. return 0;
  1118. }
  1119. static int do_imls_nand(void)
  1120. {
  1121. nand_info_t *nand;
  1122. int nand_dev = nand_curr_device;
  1123. size_t len;
  1124. loff_t off;
  1125. u32 buffer[16];
  1126. if (nand_dev < 0 || nand_dev >= CONFIG_SYS_MAX_NAND_DEVICE) {
  1127. puts("\nNo NAND devices available\n");
  1128. return -ENODEV;
  1129. }
  1130. printf("\n");
  1131. for (nand_dev = 0; nand_dev < CONFIG_SYS_MAX_NAND_DEVICE; nand_dev++) {
  1132. nand = &nand_info[nand_dev];
  1133. if (!nand->name || !nand->size)
  1134. continue;
  1135. for (off = 0; off < nand->size; off += nand->erasesize) {
  1136. const image_header_t *header;
  1137. int ret;
  1138. if (nand_block_isbad(nand, off))
  1139. continue;
  1140. len = sizeof(buffer);
  1141. ret = nand_read(nand, off, &len, (u8 *)buffer);
  1142. if (ret < 0 && ret != -EUCLEAN) {
  1143. printf("NAND read error %d at offset %08llX\n",
  1144. ret, off);
  1145. continue;
  1146. }
  1147. switch (genimg_get_format(buffer)) {
  1148. case IMAGE_FORMAT_LEGACY:
  1149. header = (const image_header_t *)buffer;
  1150. len = image_get_image_size(header);
  1151. nand_imls_legacyimage(nand, nand_dev, off, len);
  1152. break;
  1153. #if defined(CONFIG_FIT)
  1154. case IMAGE_FORMAT_FIT:
  1155. len = fit_get_size(buffer);
  1156. nand_imls_fitimage(nand, nand_dev, off, len);
  1157. break;
  1158. #endif
  1159. }
  1160. }
  1161. }
  1162. return 0;
  1163. }
  1164. #endif
  1165. #if defined(CONFIG_CMD_IMLS) || defined(CONFIG_CMD_IMLS_NAND)
  1166. static int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  1167. {
  1168. int ret_nor = 0, ret_nand = 0;
  1169. #if defined(CONFIG_CMD_IMLS)
  1170. ret_nor = do_imls_nor();
  1171. #endif
  1172. #if defined(CONFIG_CMD_IMLS_NAND)
  1173. ret_nand = do_imls_nand();
  1174. #endif
  1175. if (ret_nor)
  1176. return ret_nor;
  1177. if (ret_nand)
  1178. return ret_nand;
  1179. return (0);
  1180. }
  1181. U_BOOT_CMD(
  1182. imls, 1, 1, do_imls,
  1183. "list all images found in flash",
  1184. "\n"
  1185. " - Prints information about all images found at sector/block\n"
  1186. " boundaries in nor/nand flash."
  1187. );
  1188. #endif
  1189. /*******************************************************************/
  1190. /* helper routines */
  1191. /*******************************************************************/
  1192. #if defined(CONFIG_SILENT_CONSOLE) && !defined(CONFIG_SILENT_U_BOOT_ONLY)
  1193. #define CONSOLE_ARG "console="
  1194. #define CONSOLE_ARG_LEN (sizeof(CONSOLE_ARG) - 1)
  1195. static void fixup_silent_linux(void)
  1196. {
  1197. char *buf;
  1198. const char *env_val;
  1199. char *cmdline = getenv("bootargs");
  1200. int want_silent;
  1201. /*
  1202. * Only fix cmdline when requested. The environment variable can be:
  1203. *
  1204. * no - we never fixup
  1205. * yes - we always fixup
  1206. * unset - we rely on the console silent flag
  1207. */
  1208. want_silent = getenv_yesno("silent_linux");
  1209. if (want_silent == 0)
  1210. return;
  1211. else if (want_silent == -1 && !(gd->flags & GD_FLG_SILENT))
  1212. return;
  1213. debug("before silent fix-up: %s\n", cmdline);
  1214. if (cmdline && (cmdline[0] != '\0')) {
  1215. char *start = strstr(cmdline, CONSOLE_ARG);
  1216. /* Allocate space for maximum possible new command line */
  1217. buf = malloc(strlen(cmdline) + 1 + CONSOLE_ARG_LEN + 1);
  1218. if (!buf) {
  1219. debug("%s: out of memory\n", __func__);
  1220. return;
  1221. }
  1222. if (start) {
  1223. char *end = strchr(start, ' ');
  1224. int num_start_bytes = start - cmdline + CONSOLE_ARG_LEN;
  1225. strncpy(buf, cmdline, num_start_bytes);
  1226. if (end)
  1227. strcpy(buf + num_start_bytes, end);
  1228. else
  1229. buf[num_start_bytes] = '\0';
  1230. } else {
  1231. sprintf(buf, "%s %s", cmdline, CONSOLE_ARG);
  1232. }
  1233. env_val = buf;
  1234. } else {
  1235. buf = NULL;
  1236. env_val = CONSOLE_ARG;
  1237. }
  1238. setenv("bootargs", env_val);
  1239. debug("after silent fix-up: %s\n", env_val);
  1240. free(buf);
  1241. }
  1242. #endif /* CONFIG_SILENT_CONSOLE */
  1243. #if defined(CONFIG_BOOTM_NETBSD) || defined(CONFIG_BOOTM_PLAN9)
  1244. static void copy_args(char *dest, int argc, char * const argv[], char delim)
  1245. {
  1246. int i;
  1247. for (i = 0; i < argc; i++) {
  1248. if (i > 0)
  1249. *dest++ = delim;
  1250. strcpy(dest, argv[i]);
  1251. dest += strlen(argv[i]);
  1252. }
  1253. }
  1254. #endif
  1255. /*******************************************************************/
  1256. /* OS booting routines */
  1257. /*******************************************************************/
  1258. #ifdef CONFIG_BOOTM_NETBSD
  1259. static int do_bootm_netbsd(int flag, int argc, char * const argv[],
  1260. bootm_headers_t *images)
  1261. {
  1262. void (*loader)(bd_t *, image_header_t *, char *, char *);
  1263. image_header_t *os_hdr, *hdr;
  1264. ulong kernel_data, kernel_len;
  1265. char *consdev;
  1266. char *cmdline;
  1267. if (flag != BOOTM_STATE_OS_GO)
  1268. return 0;
  1269. #if defined(CONFIG_FIT)
  1270. if (!images->legacy_hdr_valid) {
  1271. fit_unsupported_reset("NetBSD");
  1272. return 1;
  1273. }
  1274. #endif
  1275. hdr = images->legacy_hdr_os;
  1276. /*
  1277. * Booting a (NetBSD) kernel image
  1278. *
  1279. * This process is pretty similar to a standalone application:
  1280. * The (first part of an multi-) image must be a stage-2 loader,
  1281. * which in turn is responsible for loading & invoking the actual
  1282. * kernel. The only differences are the parameters being passed:
  1283. * besides the board info strucure, the loader expects a command
  1284. * line, the name of the console device, and (optionally) the
  1285. * address of the original image header.
  1286. */
  1287. os_hdr = NULL;
  1288. if (image_check_type(&images->legacy_hdr_os_copy, IH_TYPE_MULTI)) {
  1289. image_multi_getimg(hdr, 1, &kernel_data, &kernel_len);
  1290. if (kernel_len)
  1291. os_hdr = hdr;
  1292. }
  1293. consdev = "";
  1294. #if defined(CONFIG_8xx_CONS_SMC1)
  1295. consdev = "smc1";
  1296. #elif defined(CONFIG_8xx_CONS_SMC2)
  1297. consdev = "smc2";
  1298. #elif defined(CONFIG_8xx_CONS_SCC2)
  1299. consdev = "scc2";
  1300. #elif defined(CONFIG_8xx_CONS_SCC3)
  1301. consdev = "scc3";
  1302. #endif
  1303. if (argc > 0) {
  1304. ulong len;
  1305. int i;
  1306. for (i = 0, len = 0; i < argc; i += 1)
  1307. len += strlen(argv[i]) + 1;
  1308. cmdline = malloc(len);
  1309. copy_args(cmdline, argc, argv, ' ');
  1310. } else if ((cmdline = getenv("bootargs")) == NULL) {
  1311. cmdline = "";
  1312. }
  1313. loader = (void (*)(bd_t *, image_header_t *, char *, char *))images->ep;
  1314. printf("## Transferring control to NetBSD stage-2 loader "
  1315. "(at address %08lx) ...\n",
  1316. (ulong)loader);
  1317. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  1318. /*
  1319. * NetBSD Stage-2 Loader Parameters:
  1320. * arg[0]: pointer to board info data
  1321. * arg[1]: image load address
  1322. * arg[2]: char pointer to the console device to use
  1323. * arg[3]: char pointer to the boot arguments
  1324. */
  1325. (*loader)(gd->bd, os_hdr, consdev, cmdline);
  1326. return 1;
  1327. }
  1328. #endif /* CONFIG_BOOTM_NETBSD*/
  1329. #ifdef CONFIG_LYNXKDI
  1330. static int do_bootm_lynxkdi(int flag, int argc, char * const argv[],
  1331. bootm_headers_t *images)
  1332. {
  1333. image_header_t *hdr = &images->legacy_hdr_os_copy;
  1334. if (flag != BOOTM_STATE_OS_GO)
  1335. return 0;
  1336. #if defined(CONFIG_FIT)
  1337. if (!images->legacy_hdr_valid) {
  1338. fit_unsupported_reset("Lynx");
  1339. return 1;
  1340. }
  1341. #endif
  1342. lynxkdi_boot((image_header_t *)hdr);
  1343. return 1;
  1344. }
  1345. #endif /* CONFIG_LYNXKDI */
  1346. #ifdef CONFIG_BOOTM_RTEMS
  1347. static int do_bootm_rtems(int flag, int argc, char * const argv[],
  1348. bootm_headers_t *images)
  1349. {
  1350. void (*entry_point)(bd_t *);
  1351. if (flag != BOOTM_STATE_OS_GO)
  1352. return 0;
  1353. #if defined(CONFIG_FIT)
  1354. if (!images->legacy_hdr_valid) {
  1355. fit_unsupported_reset("RTEMS");
  1356. return 1;
  1357. }
  1358. #endif
  1359. entry_point = (void (*)(bd_t *))images->ep;
  1360. printf("## Transferring control to RTEMS (at address %08lx) ...\n",
  1361. (ulong)entry_point);
  1362. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  1363. /*
  1364. * RTEMS Parameters:
  1365. * r3: ptr to board info data
  1366. */
  1367. (*entry_point)(gd->bd);
  1368. return 1;
  1369. }
  1370. #endif /* CONFIG_BOOTM_RTEMS */
  1371. #if defined(CONFIG_BOOTM_OSE)
  1372. static int do_bootm_ose(int flag, int argc, char * const argv[],
  1373. bootm_headers_t *images)
  1374. {
  1375. void (*entry_point)(void);
  1376. if (flag != BOOTM_STATE_OS_GO)
  1377. return 0;
  1378. #if defined(CONFIG_FIT)
  1379. if (!images->legacy_hdr_valid) {
  1380. fit_unsupported_reset("OSE");
  1381. return 1;
  1382. }
  1383. #endif
  1384. entry_point = (void (*)(void))images->ep;
  1385. printf("## Transferring control to OSE (at address %08lx) ...\n",
  1386. (ulong)entry_point);
  1387. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  1388. /*
  1389. * OSE Parameters:
  1390. * None
  1391. */
  1392. (*entry_point)();
  1393. return 1;
  1394. }
  1395. #endif /* CONFIG_BOOTM_OSE */
  1396. #if defined(CONFIG_BOOTM_PLAN9)
  1397. static int do_bootm_plan9(int flag, int argc, char * const argv[],
  1398. bootm_headers_t *images)
  1399. {
  1400. void (*entry_point)(void);
  1401. char *s;
  1402. if (flag != BOOTM_STATE_OS_GO)
  1403. return 0;
  1404. #if defined(CONFIG_FIT)
  1405. if (!images->legacy_hdr_valid) {
  1406. fit_unsupported_reset("Plan 9");
  1407. return 1;
  1408. }
  1409. #endif
  1410. /* See README.plan9 */
  1411. s = getenv("confaddr");
  1412. if (s != NULL) {
  1413. char *confaddr = (char *)simple_strtoul(s, NULL, 16);
  1414. if (argc > 0) {
  1415. copy_args(confaddr, argc, argv, '\n');
  1416. } else {
  1417. s = getenv("bootargs");
  1418. if (s != NULL)
  1419. strcpy(confaddr, s);
  1420. }
  1421. }
  1422. entry_point = (void (*)(void))images->ep;
  1423. printf("## Transferring control to Plan 9 (at address %08lx) ...\n",
  1424. (ulong)entry_point);
  1425. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  1426. /*
  1427. * Plan 9 Parameters:
  1428. * None
  1429. */
  1430. (*entry_point)();
  1431. return 1;
  1432. }
  1433. #endif /* CONFIG_BOOTM_PLAN9 */
  1434. #if defined(CONFIG_BOOTM_VXWORKS)
  1435. static int do_bootm_vxworks(int flag, int argc, char * const argv[],
  1436. bootm_headers_t *images)
  1437. {
  1438. char str[80];
  1439. if (flag != BOOTM_STATE_OS_GO)
  1440. return 0;
  1441. #if defined(CONFIG_FIT)
  1442. if (!images->legacy_hdr_valid) {
  1443. fit_unsupported_reset("VxWorks");
  1444. return 1;
  1445. }
  1446. #endif
  1447. sprintf(str, "%lx", images->ep); /* write entry-point into string */
  1448. setenv("loadaddr", str);
  1449. #if defined(CONFIG_CMD_ELF)
  1450. do_bootvx(NULL, 0, 0, NULL);
  1451. #endif
  1452. return 1;
  1453. }
  1454. #endif
  1455. #if defined(CONFIG_CMD_ELF)
  1456. static int do_bootm_qnxelf(int flag, int argc, char * const argv[],
  1457. bootm_headers_t *images)
  1458. {
  1459. char *local_args[2];
  1460. char str[16];
  1461. if (flag != BOOTM_STATE_OS_GO)
  1462. return 0;
  1463. #if defined(CONFIG_FIT)
  1464. if (!images->legacy_hdr_valid) {
  1465. fit_unsupported_reset("QNX");
  1466. return 1;
  1467. }
  1468. #endif
  1469. sprintf(str, "%lx", images->ep); /* write entry-point into string */
  1470. local_args[0] = argv[0];
  1471. local_args[1] = str; /* and provide it via the arguments */
  1472. do_bootelf(NULL, 0, 2, local_args);
  1473. return 1;
  1474. }
  1475. #endif
  1476. #ifdef CONFIG_INTEGRITY
  1477. static int do_bootm_integrity(int flag, int argc, char * const argv[],
  1478. bootm_headers_t *images)
  1479. {
  1480. void (*entry_point)(void);
  1481. if (flag != BOOTM_STATE_OS_GO)
  1482. return 0;
  1483. #if defined(CONFIG_FIT)
  1484. if (!images->legacy_hdr_valid) {
  1485. fit_unsupported_reset("INTEGRITY");
  1486. return 1;
  1487. }
  1488. #endif
  1489. entry_point = (void (*)(void))images->ep;
  1490. printf("## Transferring control to INTEGRITY (at address %08lx) ...\n",
  1491. (ulong)entry_point);
  1492. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  1493. /*
  1494. * INTEGRITY Parameters:
  1495. * None
  1496. */
  1497. (*entry_point)();
  1498. return 1;
  1499. }
  1500. #endif
  1501. #ifdef CONFIG_CMD_BOOTZ
  1502. int __weak bootz_setup(ulong image, ulong *start, ulong *end)
  1503. {
  1504. /* Please define bootz_setup() for your platform */
  1505. puts("Your platform's zImage format isn't supported yet!\n");
  1506. return -1;
  1507. }
  1508. /*
  1509. * zImage booting support
  1510. */
  1511. static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
  1512. char * const argv[], bootm_headers_t *images)
  1513. {
  1514. int ret;
  1515. ulong zi_start, zi_end;
  1516. ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
  1517. images, 1);
  1518. /* Setup Linux kernel zImage entry point */
  1519. if (!argc) {
  1520. images->ep = load_addr;
  1521. debug("* kernel: default image load address = 0x%08lx\n",
  1522. load_addr);
  1523. } else {
  1524. images->ep = simple_strtoul(argv[0], NULL, 16);
  1525. debug("* kernel: cmdline image address = 0x%08lx\n",
  1526. images->ep);
  1527. }
  1528. ret = bootz_setup(images->ep, &zi_start, &zi_end);
  1529. if (ret != 0)
  1530. return 1;
  1531. lmb_reserve(&images->lmb, images->ep, zi_end - zi_start);
  1532. /*
  1533. * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
  1534. * have a header that provide this informaiton.
  1535. */
  1536. if (bootm_find_ramdisk(flag, argc, argv))
  1537. return 1;
  1538. #if defined(CONFIG_OF_LIBFDT)
  1539. if (bootm_find_fdt(flag, argc, argv))
  1540. return 1;
  1541. #endif
  1542. return 0;
  1543. }
  1544. int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  1545. {
  1546. int ret;
  1547. /* Consume 'bootz' */
  1548. argc--; argv++;
  1549. if (bootz_start(cmdtp, flag, argc, argv, &images))
  1550. return 1;
  1551. /*
  1552. * We are doing the BOOTM_STATE_LOADOS state ourselves, so must
  1553. * disable interrupts ourselves
  1554. */
  1555. bootm_disable_interrupts();
  1556. images.os.os = IH_OS_LINUX;
  1557. ret = do_bootm_states(cmdtp, flag, argc, argv,
  1558. BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
  1559. BOOTM_STATE_OS_GO,
  1560. &images, 1);
  1561. return ret;
  1562. }
  1563. #ifdef CONFIG_SYS_LONGHELP
  1564. static char bootz_help_text[] =
  1565. "[addr [initrd[:size]] [fdt]]\n"
  1566. " - boot Linux zImage stored in memory\n"
  1567. "\tThe argument 'initrd' is optional and specifies the address\n"
  1568. "\tof the initrd in memory. The optional argument ':size' allows\n"
  1569. "\tspecifying the size of RAW initrd.\n"
  1570. #if defined(CONFIG_OF_LIBFDT)
  1571. "\tWhen booting a Linux kernel which requires a flat device-tree\n"
  1572. "\ta third argument is required which is the address of the\n"
  1573. "\tdevice-tree blob. To boot that kernel without an initrd image,\n"
  1574. "\tuse a '-' for the second argument. If you do not pass a third\n"
  1575. "\ta bd_info struct will be passed instead\n"
  1576. #endif
  1577. "";
  1578. #endif
  1579. U_BOOT_CMD(
  1580. bootz, CONFIG_SYS_MAXARGS, 1, do_bootz,
  1581. "boot Linux zImage image from memory", bootz_help_text
  1582. );
  1583. #endif /* CONFIG_CMD_BOOTZ */