cmd_bootm.c 46 KB

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