image.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226
  1. /*
  2. * (C) Copyright 2008 Semihalf
  3. *
  4. * (C) Copyright 2000-2006
  5. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #ifndef USE_HOSTCC
  26. #include <common.h>
  27. #include <watchdog.h>
  28. #ifdef CONFIG_SHOW_BOOT_PROGRESS
  29. #include <status_led.h>
  30. #endif
  31. #ifdef CONFIG_HAS_DATAFLASH
  32. #include <dataflash.h>
  33. #endif
  34. #ifdef CONFIG_LOGBUFFER
  35. #include <logbuff.h>
  36. #endif
  37. #include <rtc.h>
  38. #include <environment.h>
  39. #include <image.h>
  40. #if defined(CONFIG_FIT) || defined(CONFIG_OF_LIBFDT)
  41. #include <libfdt.h>
  42. #include <fdt_support.h>
  43. #endif
  44. #include <u-boot/md5.h>
  45. #include <sha1.h>
  46. #include <asm/io.h>
  47. #ifdef CONFIG_CMD_BDI
  48. extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
  49. #endif
  50. DECLARE_GLOBAL_DATA_PTR;
  51. static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
  52. int verify);
  53. #else
  54. #include "mkimage.h"
  55. #include <u-boot/md5.h>
  56. #include <time.h>
  57. #include <image.h>
  58. #endif /* !USE_HOSTCC*/
  59. #include <u-boot/crc.h>
  60. static const table_entry_t uimage_arch[] = {
  61. { IH_ARCH_INVALID, NULL, "Invalid ARCH", },
  62. { IH_ARCH_ALPHA, "alpha", "Alpha", },
  63. { IH_ARCH_ARM, "arm", "ARM", },
  64. { IH_ARCH_I386, "x86", "Intel x86", },
  65. { IH_ARCH_IA64, "ia64", "IA64", },
  66. { IH_ARCH_M68K, "m68k", "M68K", },
  67. { IH_ARCH_MICROBLAZE, "microblaze", "MicroBlaze", },
  68. { IH_ARCH_MIPS, "mips", "MIPS", },
  69. { IH_ARCH_MIPS64, "mips64", "MIPS 64 Bit", },
  70. { IH_ARCH_NIOS2, "nios2", "NIOS II", },
  71. { IH_ARCH_PPC, "powerpc", "PowerPC", },
  72. { IH_ARCH_PPC, "ppc", "PowerPC", },
  73. { IH_ARCH_S390, "s390", "IBM S390", },
  74. { IH_ARCH_SH, "sh", "SuperH", },
  75. { IH_ARCH_SPARC, "sparc", "SPARC", },
  76. { IH_ARCH_SPARC64, "sparc64", "SPARC 64 Bit", },
  77. { IH_ARCH_BLACKFIN, "blackfin", "Blackfin", },
  78. { IH_ARCH_AVR32, "avr32", "AVR32", },
  79. { IH_ARCH_NDS32, "nds32", "NDS32", },
  80. { IH_ARCH_OPENRISC, "or1k", "OpenRISC 1000",},
  81. { IH_ARCH_SANDBOX, "sandbox", "Sandbox", },
  82. { -1, "", "", },
  83. };
  84. static const table_entry_t uimage_os[] = {
  85. { IH_OS_INVALID, NULL, "Invalid OS", },
  86. { IH_OS_LINUX, "linux", "Linux", },
  87. #if defined(CONFIG_LYNXKDI) || defined(USE_HOSTCC)
  88. { IH_OS_LYNXOS, "lynxos", "LynxOS", },
  89. #endif
  90. { IH_OS_NETBSD, "netbsd", "NetBSD", },
  91. { IH_OS_OSE, "ose", "Enea OSE", },
  92. { IH_OS_PLAN9, "plan9", "Plan 9", },
  93. { IH_OS_RTEMS, "rtems", "RTEMS", },
  94. { IH_OS_U_BOOT, "u-boot", "U-Boot", },
  95. #if defined(CONFIG_CMD_ELF) || defined(USE_HOSTCC)
  96. { IH_OS_QNX, "qnx", "QNX", },
  97. { IH_OS_VXWORKS, "vxworks", "VxWorks", },
  98. #endif
  99. #if defined(CONFIG_INTEGRITY) || defined(USE_HOSTCC)
  100. { IH_OS_INTEGRITY,"integrity", "INTEGRITY", },
  101. #endif
  102. #ifdef USE_HOSTCC
  103. { IH_OS_4_4BSD, "4_4bsd", "4_4BSD", },
  104. { IH_OS_DELL, "dell", "Dell", },
  105. { IH_OS_ESIX, "esix", "Esix", },
  106. { IH_OS_FREEBSD, "freebsd", "FreeBSD", },
  107. { IH_OS_IRIX, "irix", "Irix", },
  108. { IH_OS_NCR, "ncr", "NCR", },
  109. { IH_OS_OPENBSD, "openbsd", "OpenBSD", },
  110. { IH_OS_PSOS, "psos", "pSOS", },
  111. { IH_OS_SCO, "sco", "SCO", },
  112. { IH_OS_SOLARIS, "solaris", "Solaris", },
  113. { IH_OS_SVR4, "svr4", "SVR4", },
  114. #endif
  115. { -1, "", "", },
  116. };
  117. static const table_entry_t uimage_type[] = {
  118. { IH_TYPE_AISIMAGE, "aisimage", "Davinci AIS image",},
  119. { IH_TYPE_FILESYSTEM, "filesystem", "Filesystem Image", },
  120. { IH_TYPE_FIRMWARE, "firmware", "Firmware", },
  121. { IH_TYPE_FLATDT, "flat_dt", "Flat Device Tree", },
  122. { IH_TYPE_KERNEL, "kernel", "Kernel Image", },
  123. { IH_TYPE_KERNEL_NOLOAD, "kernel_noload", "Kernel Image (no loading done)", },
  124. { IH_TYPE_KWBIMAGE, "kwbimage", "Kirkwood Boot Image",},
  125. { IH_TYPE_IMXIMAGE, "imximage", "Freescale i.MX Boot Image",},
  126. { IH_TYPE_INVALID, NULL, "Invalid Image", },
  127. { IH_TYPE_MULTI, "multi", "Multi-File Image", },
  128. { IH_TYPE_OMAPIMAGE, "omapimage", "TI OMAP SPL With GP CH",},
  129. { IH_TYPE_PBLIMAGE, "pblimage", "Freescale PBL Boot Image",},
  130. { IH_TYPE_RAMDISK, "ramdisk", "RAMDisk Image", },
  131. { IH_TYPE_SCRIPT, "script", "Script", },
  132. { IH_TYPE_STANDALONE, "standalone", "Standalone Program", },
  133. { IH_TYPE_UBLIMAGE, "ublimage", "Davinci UBL image",},
  134. { -1, "", "", },
  135. };
  136. static const table_entry_t uimage_comp[] = {
  137. { IH_COMP_NONE, "none", "uncompressed", },
  138. { IH_COMP_BZIP2, "bzip2", "bzip2 compressed", },
  139. { IH_COMP_GZIP, "gzip", "gzip compressed", },
  140. { IH_COMP_LZMA, "lzma", "lzma compressed", },
  141. { IH_COMP_LZO, "lzo", "lzo compressed", },
  142. { -1, "", "", },
  143. };
  144. /*****************************************************************************/
  145. /* Legacy format routines */
  146. /*****************************************************************************/
  147. int image_check_hcrc(const image_header_t *hdr)
  148. {
  149. ulong hcrc;
  150. ulong len = image_get_header_size();
  151. image_header_t header;
  152. /* Copy header so we can blank CRC field for re-calculation */
  153. memmove(&header, (char *)hdr, image_get_header_size());
  154. image_set_hcrc(&header, 0);
  155. hcrc = crc32(0, (unsigned char *)&header, len);
  156. return (hcrc == image_get_hcrc(hdr));
  157. }
  158. int image_check_dcrc(const image_header_t *hdr)
  159. {
  160. ulong data = image_get_data(hdr);
  161. ulong len = image_get_data_size(hdr);
  162. ulong dcrc = crc32_wd(0, (unsigned char *)data, len, CHUNKSZ_CRC32);
  163. return (dcrc == image_get_dcrc(hdr));
  164. }
  165. /**
  166. * image_multi_count - get component (sub-image) count
  167. * @hdr: pointer to the header of the multi component image
  168. *
  169. * image_multi_count() returns number of components in a multi
  170. * component image.
  171. *
  172. * Note: no checking of the image type is done, caller must pass
  173. * a valid multi component image.
  174. *
  175. * returns:
  176. * number of components
  177. */
  178. ulong image_multi_count(const image_header_t *hdr)
  179. {
  180. ulong i, count = 0;
  181. uint32_t *size;
  182. /* get start of the image payload, which in case of multi
  183. * component images that points to a table of component sizes */
  184. size = (uint32_t *)image_get_data(hdr);
  185. /* count non empty slots */
  186. for (i = 0; size[i]; ++i)
  187. count++;
  188. return count;
  189. }
  190. /**
  191. * image_multi_getimg - get component data address and size
  192. * @hdr: pointer to the header of the multi component image
  193. * @idx: index of the requested component
  194. * @data: pointer to a ulong variable, will hold component data address
  195. * @len: pointer to a ulong variable, will hold component size
  196. *
  197. * image_multi_getimg() returns size and data address for the requested
  198. * component in a multi component image.
  199. *
  200. * Note: no checking of the image type is done, caller must pass
  201. * a valid multi component image.
  202. *
  203. * returns:
  204. * data address and size of the component, if idx is valid
  205. * 0 in data and len, if idx is out of range
  206. */
  207. void image_multi_getimg(const image_header_t *hdr, ulong idx,
  208. ulong *data, ulong *len)
  209. {
  210. int i;
  211. uint32_t *size;
  212. ulong offset, count, img_data;
  213. /* get number of component */
  214. count = image_multi_count(hdr);
  215. /* get start of the image payload, which in case of multi
  216. * component images that points to a table of component sizes */
  217. size = (uint32_t *)image_get_data(hdr);
  218. /* get address of the proper component data start, which means
  219. * skipping sizes table (add 1 for last, null entry) */
  220. img_data = image_get_data(hdr) + (count + 1) * sizeof(uint32_t);
  221. if (idx < count) {
  222. *len = uimage_to_cpu(size[idx]);
  223. offset = 0;
  224. /* go over all indices preceding requested component idx */
  225. for (i = 0; i < idx; i++) {
  226. /* add up i-th component size, rounding up to 4 bytes */
  227. offset += (uimage_to_cpu(size[i]) + 3) & ~3 ;
  228. }
  229. /* calculate idx-th component data address */
  230. *data = img_data + offset;
  231. } else {
  232. *len = 0;
  233. *data = 0;
  234. }
  235. }
  236. static void image_print_type(const image_header_t *hdr)
  237. {
  238. const char *os, *arch, *type, *comp;
  239. os = genimg_get_os_name(image_get_os(hdr));
  240. arch = genimg_get_arch_name(image_get_arch(hdr));
  241. type = genimg_get_type_name(image_get_type(hdr));
  242. comp = genimg_get_comp_name(image_get_comp(hdr));
  243. printf("%s %s %s (%s)\n", arch, os, type, comp);
  244. }
  245. /**
  246. * image_print_contents - prints out the contents of the legacy format image
  247. * @ptr: pointer to the legacy format image header
  248. * @p: pointer to prefix string
  249. *
  250. * image_print_contents() formats a multi line legacy image contents description.
  251. * The routine prints out all header fields followed by the size/offset data
  252. * for MULTI/SCRIPT images.
  253. *
  254. * returns:
  255. * no returned results
  256. */
  257. void image_print_contents(const void *ptr)
  258. {
  259. const image_header_t *hdr = (const image_header_t *)ptr;
  260. const char *p;
  261. p = IMAGE_INDENT_STRING;
  262. printf("%sImage Name: %.*s\n", p, IH_NMLEN, image_get_name(hdr));
  263. if (IMAGE_ENABLE_TIMESTAMP) {
  264. printf("%sCreated: ", p);
  265. genimg_print_time((time_t)image_get_time(hdr));
  266. }
  267. printf("%sImage Type: ", p);
  268. image_print_type(hdr);
  269. printf("%sData Size: ", p);
  270. genimg_print_size(image_get_data_size(hdr));
  271. printf("%sLoad Address: %08x\n", p, image_get_load(hdr));
  272. printf("%sEntry Point: %08x\n", p, image_get_ep(hdr));
  273. if (image_check_type(hdr, IH_TYPE_MULTI) ||
  274. image_check_type(hdr, IH_TYPE_SCRIPT)) {
  275. int i;
  276. ulong data, len;
  277. ulong count = image_multi_count(hdr);
  278. printf("%sContents:\n", p);
  279. for (i = 0; i < count; i++) {
  280. image_multi_getimg(hdr, i, &data, &len);
  281. printf("%s Image %d: ", p, i);
  282. genimg_print_size(len);
  283. if (image_check_type(hdr, IH_TYPE_SCRIPT) && i > 0) {
  284. /*
  285. * the user may need to know offsets
  286. * if planning to do something with
  287. * multiple files
  288. */
  289. printf("%s Offset = 0x%08lx\n", p, data);
  290. }
  291. }
  292. }
  293. }
  294. #ifndef USE_HOSTCC
  295. /**
  296. * image_get_ramdisk - get and verify ramdisk image
  297. * @rd_addr: ramdisk image start address
  298. * @arch: expected ramdisk architecture
  299. * @verify: checksum verification flag
  300. *
  301. * image_get_ramdisk() returns a pointer to the verified ramdisk image
  302. * header. Routine receives image start address and expected architecture
  303. * flag. Verification done covers data and header integrity and os/type/arch
  304. * fields checking.
  305. *
  306. * If dataflash support is enabled routine checks for dataflash addresses
  307. * and handles required dataflash reads.
  308. *
  309. * returns:
  310. * pointer to a ramdisk image header, if image was found and valid
  311. * otherwise, return NULL
  312. */
  313. static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
  314. int verify)
  315. {
  316. const image_header_t *rd_hdr = (const image_header_t *)rd_addr;
  317. if (!image_check_magic(rd_hdr)) {
  318. puts("Bad Magic Number\n");
  319. bootstage_error(BOOTSTAGE_ID_RD_MAGIC);
  320. return NULL;
  321. }
  322. if (!image_check_hcrc(rd_hdr)) {
  323. puts("Bad Header Checksum\n");
  324. bootstage_error(BOOTSTAGE_ID_RD_HDR_CHECKSUM);
  325. return NULL;
  326. }
  327. bootstage_mark(BOOTSTAGE_ID_RD_MAGIC);
  328. image_print_contents(rd_hdr);
  329. if (verify) {
  330. puts(" Verifying Checksum ... ");
  331. if (!image_check_dcrc(rd_hdr)) {
  332. puts("Bad Data CRC\n");
  333. bootstage_error(BOOTSTAGE_ID_RD_CHECKSUM);
  334. return NULL;
  335. }
  336. puts("OK\n");
  337. }
  338. bootstage_mark(BOOTSTAGE_ID_RD_HDR_CHECKSUM);
  339. if (!image_check_os(rd_hdr, IH_OS_LINUX) ||
  340. !image_check_arch(rd_hdr, arch) ||
  341. !image_check_type(rd_hdr, IH_TYPE_RAMDISK)) {
  342. printf("No Linux %s Ramdisk Image\n",
  343. genimg_get_arch_name(arch));
  344. bootstage_error(BOOTSTAGE_ID_RAMDISK);
  345. return NULL;
  346. }
  347. return rd_hdr;
  348. }
  349. #endif /* !USE_HOSTCC */
  350. /*****************************************************************************/
  351. /* Shared dual-format routines */
  352. /*****************************************************************************/
  353. #ifndef USE_HOSTCC
  354. ulong load_addr = CONFIG_SYS_LOAD_ADDR; /* Default Load Address */
  355. ulong save_addr; /* Default Save Address */
  356. ulong save_size; /* Default Save Size (in bytes) */
  357. static int on_loadaddr(const char *name, const char *value, enum env_op op,
  358. int flags)
  359. {
  360. switch (op) {
  361. case env_op_create:
  362. case env_op_overwrite:
  363. load_addr = simple_strtoul(value, NULL, 16);
  364. break;
  365. default:
  366. break;
  367. }
  368. return 0;
  369. }
  370. U_BOOT_ENV_CALLBACK(loadaddr, on_loadaddr);
  371. ulong getenv_bootm_low(void)
  372. {
  373. char *s = getenv("bootm_low");
  374. if (s) {
  375. ulong tmp = simple_strtoul(s, NULL, 16);
  376. return tmp;
  377. }
  378. #if defined(CONFIG_SYS_SDRAM_BASE)
  379. return CONFIG_SYS_SDRAM_BASE;
  380. #elif defined(CONFIG_ARM)
  381. return gd->bd->bi_dram[0].start;
  382. #else
  383. return 0;
  384. #endif
  385. }
  386. phys_size_t getenv_bootm_size(void)
  387. {
  388. phys_size_t tmp;
  389. char *s = getenv("bootm_size");
  390. if (s) {
  391. tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
  392. return tmp;
  393. }
  394. s = getenv("bootm_low");
  395. if (s)
  396. tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
  397. else
  398. tmp = 0;
  399. #if defined(CONFIG_ARM)
  400. return gd->bd->bi_dram[0].size - tmp;
  401. #else
  402. return gd->bd->bi_memsize - tmp;
  403. #endif
  404. }
  405. phys_size_t getenv_bootm_mapsize(void)
  406. {
  407. phys_size_t tmp;
  408. char *s = getenv("bootm_mapsize");
  409. if (s) {
  410. tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
  411. return tmp;
  412. }
  413. #if defined(CONFIG_SYS_BOOTMAPSZ)
  414. return CONFIG_SYS_BOOTMAPSZ;
  415. #else
  416. return getenv_bootm_size();
  417. #endif
  418. }
  419. void memmove_wd(void *to, void *from, size_t len, ulong chunksz)
  420. {
  421. if (to == from)
  422. return;
  423. #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
  424. while (len > 0) {
  425. size_t tail = (len > chunksz) ? chunksz : len;
  426. WATCHDOG_RESET();
  427. memmove(to, from, tail);
  428. to += tail;
  429. from += tail;
  430. len -= tail;
  431. }
  432. #else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
  433. memmove(to, from, len);
  434. #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
  435. }
  436. #endif /* !USE_HOSTCC */
  437. void genimg_print_size(uint32_t size)
  438. {
  439. #ifndef USE_HOSTCC
  440. printf("%d Bytes = ", size);
  441. print_size(size, "\n");
  442. #else
  443. printf("%d Bytes = %.2f kB = %.2f MB\n",
  444. size, (double)size / 1.024e3,
  445. (double)size / 1.048576e6);
  446. #endif
  447. }
  448. #if IMAGE_ENABLE_TIMESTAMP
  449. void genimg_print_time(time_t timestamp)
  450. {
  451. #ifndef USE_HOSTCC
  452. struct rtc_time tm;
  453. to_tm(timestamp, &tm);
  454. printf("%4d-%02d-%02d %2d:%02d:%02d UTC\n",
  455. tm.tm_year, tm.tm_mon, tm.tm_mday,
  456. tm.tm_hour, tm.tm_min, tm.tm_sec);
  457. #else
  458. printf("%s", ctime(&timestamp));
  459. #endif
  460. }
  461. #endif
  462. /**
  463. * get_table_entry_name - translate entry id to long name
  464. * @table: pointer to a translation table for entries of a specific type
  465. * @msg: message to be returned when translation fails
  466. * @id: entry id to be translated
  467. *
  468. * get_table_entry_name() will go over translation table trying to find
  469. * entry that matches given id. If matching entry is found, its long
  470. * name is returned to the caller.
  471. *
  472. * returns:
  473. * long entry name if translation succeeds
  474. * msg otherwise
  475. */
  476. char *get_table_entry_name(const table_entry_t *table, char *msg, int id)
  477. {
  478. for (; table->id >= 0; ++table) {
  479. if (table->id == id)
  480. #if defined(USE_HOSTCC) || !defined(CONFIG_NEEDS_MANUAL_RELOC)
  481. return table->lname;
  482. #else
  483. return table->lname + gd->reloc_off;
  484. #endif
  485. }
  486. return (msg);
  487. }
  488. const char *genimg_get_os_name(uint8_t os)
  489. {
  490. return (get_table_entry_name(uimage_os, "Unknown OS", os));
  491. }
  492. const char *genimg_get_arch_name(uint8_t arch)
  493. {
  494. return (get_table_entry_name(uimage_arch, "Unknown Architecture",
  495. arch));
  496. }
  497. const char *genimg_get_type_name(uint8_t type)
  498. {
  499. return (get_table_entry_name(uimage_type, "Unknown Image", type));
  500. }
  501. const char *genimg_get_comp_name(uint8_t comp)
  502. {
  503. return (get_table_entry_name(uimage_comp, "Unknown Compression",
  504. comp));
  505. }
  506. /**
  507. * get_table_entry_id - translate short entry name to id
  508. * @table: pointer to a translation table for entries of a specific type
  509. * @table_name: to be used in case of error
  510. * @name: entry short name to be translated
  511. *
  512. * get_table_entry_id() will go over translation table trying to find
  513. * entry that matches given short name. If matching entry is found,
  514. * its id returned to the caller.
  515. *
  516. * returns:
  517. * entry id if translation succeeds
  518. * -1 otherwise
  519. */
  520. int get_table_entry_id(const table_entry_t *table,
  521. const char *table_name, const char *name)
  522. {
  523. const table_entry_t *t;
  524. #ifdef USE_HOSTCC
  525. int first = 1;
  526. for (t = table; t->id >= 0; ++t) {
  527. if (t->sname && strcasecmp(t->sname, name) == 0)
  528. return(t->id);
  529. }
  530. fprintf(stderr, "\nInvalid %s Type - valid names are", table_name);
  531. for (t = table; t->id >= 0; ++t) {
  532. if (t->sname == NULL)
  533. continue;
  534. fprintf(stderr, "%c %s", (first) ? ':' : ',', t->sname);
  535. first = 0;
  536. }
  537. fprintf(stderr, "\n");
  538. #else
  539. for (t = table; t->id >= 0; ++t) {
  540. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  541. if (t->sname && strcmp(t->sname + gd->reloc_off, name) == 0)
  542. #else
  543. if (t->sname && strcmp(t->sname, name) == 0)
  544. #endif
  545. return (t->id);
  546. }
  547. debug("Invalid %s Type: %s\n", table_name, name);
  548. #endif /* USE_HOSTCC */
  549. return (-1);
  550. }
  551. int genimg_get_os_id(const char *name)
  552. {
  553. return (get_table_entry_id(uimage_os, "OS", name));
  554. }
  555. int genimg_get_arch_id(const char *name)
  556. {
  557. return (get_table_entry_id(uimage_arch, "CPU", name));
  558. }
  559. int genimg_get_type_id(const char *name)
  560. {
  561. return (get_table_entry_id(uimage_type, "Image", name));
  562. }
  563. int genimg_get_comp_id(const char *name)
  564. {
  565. return (get_table_entry_id(uimage_comp, "Compression", name));
  566. }
  567. #ifndef USE_HOSTCC
  568. /**
  569. * genimg_get_format - get image format type
  570. * @img_addr: image start address
  571. *
  572. * genimg_get_format() checks whether provided address points to a valid
  573. * legacy or FIT image.
  574. *
  575. * New uImage format and FDT blob are based on a libfdt. FDT blob
  576. * may be passed directly or embedded in a FIT image. In both situations
  577. * genimg_get_format() must be able to dectect libfdt header.
  578. *
  579. * returns:
  580. * image format type or IMAGE_FORMAT_INVALID if no image is present
  581. */
  582. int genimg_get_format(const void *img_addr)
  583. {
  584. ulong format = IMAGE_FORMAT_INVALID;
  585. const image_header_t *hdr;
  586. #if defined(CONFIG_FIT) || defined(CONFIG_OF_LIBFDT)
  587. char *fit_hdr;
  588. #endif
  589. hdr = (const image_header_t *)img_addr;
  590. if (image_check_magic(hdr))
  591. format = IMAGE_FORMAT_LEGACY;
  592. #if defined(CONFIG_FIT) || defined(CONFIG_OF_LIBFDT)
  593. else {
  594. fit_hdr = (char *)img_addr;
  595. if (fdt_check_header(fit_hdr) == 0)
  596. format = IMAGE_FORMAT_FIT;
  597. }
  598. #endif
  599. return format;
  600. }
  601. /**
  602. * genimg_get_image - get image from special storage (if necessary)
  603. * @img_addr: image start address
  604. *
  605. * genimg_get_image() checks if provided image start adddress is located
  606. * in a dataflash storage. If so, image is moved to a system RAM memory.
  607. *
  608. * returns:
  609. * image start address after possible relocation from special storage
  610. */
  611. ulong genimg_get_image(ulong img_addr)
  612. {
  613. ulong ram_addr = img_addr;
  614. #ifdef CONFIG_HAS_DATAFLASH
  615. ulong h_size, d_size;
  616. if (addr_dataflash(img_addr)) {
  617. void *buf;
  618. /* ger RAM address */
  619. ram_addr = CONFIG_SYS_LOAD_ADDR;
  620. /* get header size */
  621. h_size = image_get_header_size();
  622. #if defined(CONFIG_FIT)
  623. if (sizeof(struct fdt_header) > h_size)
  624. h_size = sizeof(struct fdt_header);
  625. #endif
  626. /* read in header */
  627. debug(" Reading image header from dataflash address "
  628. "%08lx to RAM address %08lx\n", img_addr, ram_addr);
  629. buf = map_sysmem(ram_addr, 0);
  630. read_dataflash(img_addr, h_size, buf);
  631. /* get data size */
  632. switch (genimg_get_format(buf)) {
  633. case IMAGE_FORMAT_LEGACY:
  634. d_size = image_get_data_size(buf);
  635. debug(" Legacy format image found at 0x%08lx, "
  636. "size 0x%08lx\n",
  637. ram_addr, d_size);
  638. break;
  639. #if defined(CONFIG_FIT)
  640. case IMAGE_FORMAT_FIT:
  641. d_size = fit_get_size(buf) - h_size;
  642. debug(" FIT/FDT format image found at 0x%08lx, "
  643. "size 0x%08lx\n",
  644. ram_addr, d_size);
  645. break;
  646. #endif
  647. default:
  648. printf(" No valid image found at 0x%08lx\n",
  649. img_addr);
  650. return ram_addr;
  651. }
  652. /* read in image data */
  653. debug(" Reading image remaining data from dataflash address "
  654. "%08lx to RAM address %08lx\n", img_addr + h_size,
  655. ram_addr + h_size);
  656. read_dataflash(img_addr + h_size, d_size,
  657. (char *)(buf + h_size));
  658. }
  659. #endif /* CONFIG_HAS_DATAFLASH */
  660. return ram_addr;
  661. }
  662. /**
  663. * fit_has_config - check if there is a valid FIT configuration
  664. * @images: pointer to the bootm command headers structure
  665. *
  666. * fit_has_config() checks if there is a FIT configuration in use
  667. * (if FTI support is present).
  668. *
  669. * returns:
  670. * 0, no FIT support or no configuration found
  671. * 1, configuration found
  672. */
  673. int genimg_has_config(bootm_headers_t *images)
  674. {
  675. #if defined(CONFIG_FIT)
  676. if (images->fit_uname_cfg)
  677. return 1;
  678. #endif
  679. return 0;
  680. }
  681. /**
  682. * boot_get_ramdisk - main ramdisk handling routine
  683. * @argc: command argument count
  684. * @argv: command argument list
  685. * @images: pointer to the bootm images structure
  686. * @arch: expected ramdisk architecture
  687. * @rd_start: pointer to a ulong variable, will hold ramdisk start address
  688. * @rd_end: pointer to a ulong variable, will hold ramdisk end
  689. *
  690. * boot_get_ramdisk() is responsible for finding a valid ramdisk image.
  691. * Curently supported are the following ramdisk sources:
  692. * - multicomponent kernel/ramdisk image,
  693. * - commandline provided address of decicated ramdisk image.
  694. *
  695. * returns:
  696. * 0, if ramdisk image was found and valid, or skiped
  697. * rd_start and rd_end are set to ramdisk start/end addresses if
  698. * ramdisk image is found and valid
  699. *
  700. * 1, if ramdisk image is found but corrupted, or invalid
  701. * rd_start and rd_end are set to 0 if no ramdisk exists
  702. */
  703. int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
  704. uint8_t arch, ulong *rd_start, ulong *rd_end)
  705. {
  706. ulong rd_addr, rd_load;
  707. ulong rd_data, rd_len;
  708. const image_header_t *rd_hdr;
  709. void *buf;
  710. #ifdef CONFIG_SUPPORT_RAW_INITRD
  711. char *end;
  712. #endif
  713. #if defined(CONFIG_FIT)
  714. void *fit_hdr;
  715. const char *fit_uname_config = NULL;
  716. const char *fit_uname_ramdisk = NULL;
  717. ulong default_addr;
  718. int rd_noffset;
  719. int cfg_noffset;
  720. const void *data;
  721. size_t size;
  722. #endif
  723. *rd_start = 0;
  724. *rd_end = 0;
  725. /*
  726. * Look for a '-' which indicates to ignore the
  727. * ramdisk argument
  728. */
  729. if ((argc >= 3) && (strcmp(argv[2], "-") == 0)) {
  730. debug("## Skipping init Ramdisk\n");
  731. rd_len = rd_data = 0;
  732. } else if (argc >= 3 || genimg_has_config(images)) {
  733. #if defined(CONFIG_FIT)
  734. if (argc >= 3) {
  735. /*
  736. * If the init ramdisk comes from the FIT image and
  737. * the FIT image address is omitted in the command
  738. * line argument, try to use os FIT image address or
  739. * default load address.
  740. */
  741. if (images->fit_uname_os)
  742. default_addr = (ulong)images->fit_hdr_os;
  743. else
  744. default_addr = load_addr;
  745. if (fit_parse_conf(argv[2], default_addr,
  746. &rd_addr, &fit_uname_config)) {
  747. debug("* ramdisk: config '%s' from image at "
  748. "0x%08lx\n",
  749. fit_uname_config, rd_addr);
  750. } else if (fit_parse_subimage(argv[2], default_addr,
  751. &rd_addr, &fit_uname_ramdisk)) {
  752. debug("* ramdisk: subimage '%s' from image at "
  753. "0x%08lx\n",
  754. fit_uname_ramdisk, rd_addr);
  755. } else
  756. #endif
  757. {
  758. rd_addr = simple_strtoul(argv[2], NULL, 16);
  759. debug("* ramdisk: cmdline image address = "
  760. "0x%08lx\n",
  761. rd_addr);
  762. }
  763. #if defined(CONFIG_FIT)
  764. } else {
  765. /* use FIT configuration provided in first bootm
  766. * command argument
  767. */
  768. rd_addr = map_to_sysmem(images->fit_hdr_os);
  769. fit_uname_config = images->fit_uname_cfg;
  770. debug("* ramdisk: using config '%s' from image "
  771. "at 0x%08lx\n",
  772. fit_uname_config, rd_addr);
  773. /*
  774. * Check whether configuration has ramdisk defined,
  775. * if not, don't try to use it, quit silently.
  776. */
  777. fit_hdr = images->fit_hdr_os;
  778. cfg_noffset = fit_conf_get_node(fit_hdr,
  779. fit_uname_config);
  780. if (cfg_noffset < 0) {
  781. debug("* ramdisk: no such config\n");
  782. return 1;
  783. }
  784. rd_noffset = fit_conf_get_ramdisk_node(fit_hdr,
  785. cfg_noffset);
  786. if (rd_noffset < 0) {
  787. debug("* ramdisk: no ramdisk in config\n");
  788. return 0;
  789. }
  790. }
  791. #endif
  792. /* copy from dataflash if needed */
  793. rd_addr = genimg_get_image(rd_addr);
  794. /*
  795. * Check if there is an initrd image at the
  796. * address provided in the second bootm argument
  797. * check image type, for FIT images get FIT node.
  798. */
  799. buf = map_sysmem(rd_addr, 0);
  800. switch (genimg_get_format(buf)) {
  801. case IMAGE_FORMAT_LEGACY:
  802. printf("## Loading init Ramdisk from Legacy "
  803. "Image at %08lx ...\n", rd_addr);
  804. bootstage_mark(BOOTSTAGE_ID_CHECK_RAMDISK);
  805. rd_hdr = image_get_ramdisk(rd_addr, arch,
  806. images->verify);
  807. if (rd_hdr == NULL)
  808. return 1;
  809. rd_data = image_get_data(rd_hdr);
  810. rd_len = image_get_data_size(rd_hdr);
  811. rd_load = image_get_load(rd_hdr);
  812. break;
  813. #if defined(CONFIG_FIT)
  814. case IMAGE_FORMAT_FIT:
  815. fit_hdr = buf;
  816. printf("## Loading init Ramdisk from FIT "
  817. "Image at %08lx ...\n", rd_addr);
  818. bootstage_mark(BOOTSTAGE_ID_FIT_RD_FORMAT);
  819. if (!fit_check_format(fit_hdr)) {
  820. puts("Bad FIT ramdisk image format!\n");
  821. bootstage_error(
  822. BOOTSTAGE_ID_FIT_RD_FORMAT);
  823. return 1;
  824. }
  825. bootstage_mark(BOOTSTAGE_ID_FIT_RD_FORMAT_OK);
  826. if (!fit_uname_ramdisk) {
  827. /*
  828. * no ramdisk image node unit name, try to get config
  829. * node first. If config unit node name is NULL
  830. * fit_conf_get_node() will try to find default config node
  831. */
  832. bootstage_mark(
  833. BOOTSTAGE_ID_FIT_RD_NO_UNIT_NAME);
  834. cfg_noffset = fit_conf_get_node(fit_hdr,
  835. fit_uname_config);
  836. if (cfg_noffset < 0) {
  837. puts("Could not find configuration "
  838. "node\n");
  839. bootstage_error(
  840. BOOTSTAGE_ID_FIT_RD_NO_UNIT_NAME);
  841. return 1;
  842. }
  843. fit_uname_config = fdt_get_name(fit_hdr,
  844. cfg_noffset, NULL);
  845. printf(" Using '%s' configuration\n",
  846. fit_uname_config);
  847. rd_noffset = fit_conf_get_ramdisk_node(fit_hdr,
  848. cfg_noffset);
  849. fit_uname_ramdisk = fit_get_name(fit_hdr,
  850. rd_noffset, NULL);
  851. } else {
  852. /* get ramdisk component image node offset */
  853. bootstage_mark(
  854. BOOTSTAGE_ID_FIT_RD_UNIT_NAME);
  855. rd_noffset = fit_image_get_node(fit_hdr,
  856. fit_uname_ramdisk);
  857. }
  858. if (rd_noffset < 0) {
  859. puts("Could not find subimage node\n");
  860. bootstage_error(BOOTSTAGE_ID_FIT_RD_SUBNODE);
  861. return 1;
  862. }
  863. printf(" Trying '%s' ramdisk subimage\n",
  864. fit_uname_ramdisk);
  865. bootstage_mark(BOOTSTAGE_ID_FIT_RD_CHECK);
  866. if (!fit_check_ramdisk(fit_hdr, rd_noffset, arch,
  867. images->verify))
  868. return 1;
  869. /* get ramdisk image data address and length */
  870. if (fit_image_get_data(fit_hdr, rd_noffset, &data,
  871. &size)) {
  872. puts("Could not find ramdisk subimage data!\n");
  873. bootstage_error(BOOTSTAGE_ID_FIT_RD_GET_DATA);
  874. return 1;
  875. }
  876. bootstage_mark(BOOTSTAGE_ID_FIT_RD_GET_DATA_OK);
  877. rd_data = (ulong)data;
  878. rd_len = size;
  879. if (fit_image_get_load(fit_hdr, rd_noffset, &rd_load)) {
  880. puts("Can't get ramdisk subimage load "
  881. "address!\n");
  882. bootstage_error(BOOTSTAGE_ID_FIT_RD_LOAD);
  883. return 1;
  884. }
  885. bootstage_mark(BOOTSTAGE_ID_FIT_RD_LOAD);
  886. images->fit_hdr_rd = fit_hdr;
  887. images->fit_uname_rd = fit_uname_ramdisk;
  888. images->fit_noffset_rd = rd_noffset;
  889. break;
  890. #endif
  891. default:
  892. #ifdef CONFIG_SUPPORT_RAW_INITRD
  893. if (argc >= 3 && (end = strchr(argv[2], ':'))) {
  894. rd_len = simple_strtoul(++end, NULL, 16);
  895. rd_data = rd_addr;
  896. } else
  897. #endif
  898. {
  899. puts("Wrong Ramdisk Image Format\n");
  900. rd_data = rd_len = rd_load = 0;
  901. return 1;
  902. }
  903. }
  904. } else if (images->legacy_hdr_valid &&
  905. image_check_type(&images->legacy_hdr_os_copy,
  906. IH_TYPE_MULTI)) {
  907. /*
  908. * Now check if we have a legacy mult-component image,
  909. * get second entry data start address and len.
  910. */
  911. bootstage_mark(BOOTSTAGE_ID_RAMDISK);
  912. printf("## Loading init Ramdisk from multi component "
  913. "Legacy Image at %08lx ...\n",
  914. (ulong)images->legacy_hdr_os);
  915. image_multi_getimg(images->legacy_hdr_os, 1, &rd_data, &rd_len);
  916. } else {
  917. /*
  918. * no initrd image
  919. */
  920. bootstage_mark(BOOTSTAGE_ID_NO_RAMDISK);
  921. rd_len = rd_data = 0;
  922. }
  923. if (!rd_data) {
  924. debug("## No init Ramdisk\n");
  925. } else {
  926. *rd_start = rd_data;
  927. *rd_end = rd_data + rd_len;
  928. }
  929. debug(" ramdisk start = 0x%08lx, ramdisk end = 0x%08lx\n",
  930. *rd_start, *rd_end);
  931. return 0;
  932. }
  933. #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
  934. /**
  935. * boot_ramdisk_high - relocate init ramdisk
  936. * @lmb: pointer to lmb handle, will be used for memory mgmt
  937. * @rd_data: ramdisk data start address
  938. * @rd_len: ramdisk data length
  939. * @initrd_start: pointer to a ulong variable, will hold final init ramdisk
  940. * start address (after possible relocation)
  941. * @initrd_end: pointer to a ulong variable, will hold final init ramdisk
  942. * end address (after possible relocation)
  943. *
  944. * boot_ramdisk_high() takes a relocation hint from "initrd_high" environement
  945. * variable and if requested ramdisk data is moved to a specified location.
  946. *
  947. * Initrd_start and initrd_end are set to final (after relocation) ramdisk
  948. * start/end addresses if ramdisk image start and len were provided,
  949. * otherwise set initrd_start and initrd_end set to zeros.
  950. *
  951. * returns:
  952. * 0 - success
  953. * -1 - failure
  954. */
  955. int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
  956. ulong *initrd_start, ulong *initrd_end)
  957. {
  958. char *s;
  959. ulong initrd_high;
  960. int initrd_copy_to_ram = 1;
  961. if ((s = getenv("initrd_high")) != NULL) {
  962. /* a value of "no" or a similar string will act like 0,
  963. * turning the "load high" feature off. This is intentional.
  964. */
  965. initrd_high = simple_strtoul(s, NULL, 16);
  966. if (initrd_high == ~0)
  967. initrd_copy_to_ram = 0;
  968. } else {
  969. /* not set, no restrictions to load high */
  970. initrd_high = ~0;
  971. }
  972. #ifdef CONFIG_LOGBUFFER
  973. /* Prevent initrd from overwriting logbuffer */
  974. lmb_reserve(lmb, logbuffer_base() - LOGBUFF_OVERHEAD, LOGBUFF_RESERVE);
  975. #endif
  976. debug("## initrd_high = 0x%08lx, copy_to_ram = %d\n",
  977. initrd_high, initrd_copy_to_ram);
  978. if (rd_data) {
  979. if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */
  980. debug(" in-place initrd\n");
  981. *initrd_start = rd_data;
  982. *initrd_end = rd_data + rd_len;
  983. lmb_reserve(lmb, rd_data, rd_len);
  984. } else {
  985. if (initrd_high)
  986. *initrd_start = (ulong)lmb_alloc_base(lmb,
  987. rd_len, 0x1000, initrd_high);
  988. else
  989. *initrd_start = (ulong)lmb_alloc(lmb, rd_len,
  990. 0x1000);
  991. if (*initrd_start == 0) {
  992. puts("ramdisk - allocation error\n");
  993. goto error;
  994. }
  995. bootstage_mark(BOOTSTAGE_ID_COPY_RAMDISK);
  996. *initrd_end = *initrd_start + rd_len;
  997. printf(" Loading Ramdisk to %08lx, end %08lx ... ",
  998. *initrd_start, *initrd_end);
  999. memmove_wd((void *)*initrd_start,
  1000. (void *)rd_data, rd_len, CHUNKSZ);
  1001. #ifdef CONFIG_MP
  1002. /*
  1003. * Ensure the image is flushed to memory to handle
  1004. * AMP boot scenarios in which we might not be
  1005. * HW cache coherent
  1006. */
  1007. flush_cache((unsigned long)*initrd_start, rd_len);
  1008. #endif
  1009. puts("OK\n");
  1010. }
  1011. } else {
  1012. *initrd_start = 0;
  1013. *initrd_end = 0;
  1014. }
  1015. debug(" ramdisk load start = 0x%08lx, ramdisk load end = 0x%08lx\n",
  1016. *initrd_start, *initrd_end);
  1017. return 0;
  1018. error:
  1019. return -1;
  1020. }
  1021. #endif /* CONFIG_SYS_BOOT_RAMDISK_HIGH */
  1022. #ifdef CONFIG_SYS_BOOT_GET_CMDLINE
  1023. /**
  1024. * boot_get_cmdline - allocate and initialize kernel cmdline
  1025. * @lmb: pointer to lmb handle, will be used for memory mgmt
  1026. * @cmd_start: pointer to a ulong variable, will hold cmdline start
  1027. * @cmd_end: pointer to a ulong variable, will hold cmdline end
  1028. *
  1029. * boot_get_cmdline() allocates space for kernel command line below
  1030. * BOOTMAPSZ + getenv_bootm_low() address. If "bootargs" U-boot environemnt
  1031. * variable is present its contents is copied to allocated kernel
  1032. * command line.
  1033. *
  1034. * returns:
  1035. * 0 - success
  1036. * -1 - failure
  1037. */
  1038. int boot_get_cmdline(struct lmb *lmb, ulong *cmd_start, ulong *cmd_end)
  1039. {
  1040. char *cmdline;
  1041. char *s;
  1042. cmdline = (char *)(ulong)lmb_alloc_base(lmb, CONFIG_SYS_BARGSIZE, 0xf,
  1043. getenv_bootm_mapsize() + getenv_bootm_low());
  1044. if (cmdline == NULL)
  1045. return -1;
  1046. if ((s = getenv("bootargs")) == NULL)
  1047. s = "";
  1048. strcpy(cmdline, s);
  1049. *cmd_start = (ulong) & cmdline[0];
  1050. *cmd_end = *cmd_start + strlen(cmdline);
  1051. debug("## cmdline at 0x%08lx ... 0x%08lx\n", *cmd_start, *cmd_end);
  1052. return 0;
  1053. }
  1054. #endif /* CONFIG_SYS_BOOT_GET_CMDLINE */
  1055. #ifdef CONFIG_SYS_BOOT_GET_KBD
  1056. /**
  1057. * boot_get_kbd - allocate and initialize kernel copy of board info
  1058. * @lmb: pointer to lmb handle, will be used for memory mgmt
  1059. * @kbd: double pointer to board info data
  1060. *
  1061. * boot_get_kbd() allocates space for kernel copy of board info data below
  1062. * BOOTMAPSZ + getenv_bootm_low() address and kernel board info is initialized
  1063. * with the current u-boot board info data.
  1064. *
  1065. * returns:
  1066. * 0 - success
  1067. * -1 - failure
  1068. */
  1069. int boot_get_kbd(struct lmb *lmb, bd_t **kbd)
  1070. {
  1071. *kbd = (bd_t *)(ulong)lmb_alloc_base(lmb, sizeof(bd_t), 0xf,
  1072. getenv_bootm_mapsize() + getenv_bootm_low());
  1073. if (*kbd == NULL)
  1074. return -1;
  1075. **kbd = *(gd->bd);
  1076. debug("## kernel board info at 0x%08lx\n", (ulong)*kbd);
  1077. #if defined(DEBUG) && defined(CONFIG_CMD_BDI)
  1078. do_bdinfo(NULL, 0, 0, NULL);
  1079. #endif
  1080. return 0;
  1081. }
  1082. #endif /* CONFIG_SYS_BOOT_GET_KBD */
  1083. #endif /* !USE_HOSTCC */