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