cmd_bootm.c 46 KB

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