2 * (C) Copyright 2008 Semihalf
4 * (C) Copyright 2000-2006
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
7 * See file CREDITS for list of people who contributed to this
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.
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.
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,
32 #ifdef CONFIG_SHOW_BOOT_PROGRESS
33 #include <status_led.h>
36 #ifdef CONFIG_HAS_DATAFLASH
37 #include <dataflash.h>
40 #ifdef CONFIG_LOGBUFFER
44 #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
48 #if defined(CONFIG_FIT)
51 #include <fdt_support.h>
55 extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
58 DECLARE_GLOBAL_DATA_PTR;
60 static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
61 int argc, char *argv[],
62 ulong rd_addr, uint8_t arch, int verify);
65 #endif /* USE_HOSTCC*/
69 unsigned long crc32 (unsigned long, const unsigned char *, unsigned int);
71 /*****************************************************************************/
72 /* Legacy format routines */
73 /*****************************************************************************/
74 int image_check_hcrc (image_header_t *hdr)
77 ulong len = image_get_header_size ();
78 image_header_t header;
80 /* Copy header so we can blank CRC field for re-calculation */
81 memmove (&header, (char *)hdr, image_get_header_size ());
82 image_set_hcrc (&header, 0);
84 hcrc = crc32 (0, (unsigned char *)&header, len);
86 return (hcrc == image_get_hcrc (hdr));
89 int image_check_dcrc (image_header_t *hdr)
91 ulong data = image_get_data (hdr);
92 ulong len = image_get_data_size (hdr);
93 ulong dcrc = crc32 (0, (unsigned char *)data, len);
95 return (dcrc == image_get_dcrc (hdr));
99 int image_check_dcrc_wd (image_header_t *hdr, ulong chunksz)
102 ulong len = image_get_data_size (hdr);
103 ulong data = image_get_data (hdr);
105 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
107 ulong edata = cdata + len;
109 while (cdata < edata) {
110 ulong chunk = edata - cdata;
114 dcrc = crc32 (dcrc, (unsigned char *)cdata, chunk);
120 dcrc = crc32 (0, (unsigned char *)data, len);
123 return (dcrc == image_get_dcrc (hdr));
127 * image_multi_count - get component (sub-image) count
128 * @hdr: pointer to the header of the multi component image
130 * image_multi_count() returns number of components in a multi
133 * Note: no checking of the image type is done, caller must pass
134 * a valid multi component image.
137 * number of components
139 ulong image_multi_count (image_header_t *hdr)
144 /* get start of the image payload, which in case of multi
145 * component images that points to a table of component sizes */
146 size = (ulong *)image_get_data (hdr);
148 /* count non empty slots */
149 for (i = 0; size[i]; ++i)
156 * image_multi_getimg - get component data address and size
157 * @hdr: pointer to the header of the multi component image
158 * @idx: index of the requested component
159 * @data: pointer to a ulong variable, will hold component data address
160 * @len: pointer to a ulong variable, will hold component size
162 * image_multi_getimg() returns size and data address for the requested
163 * component in a multi component image.
165 * Note: no checking of the image type is done, caller must pass
166 * a valid multi component image.
169 * data address and size of the component, if idx is valid
170 * 0 in data and len, if idx is out of range
172 void image_multi_getimg (image_header_t *hdr, ulong idx,
173 ulong *data, ulong *len)
177 ulong offset, tail, count, img_data;
179 /* get number of component */
180 count = image_multi_count (hdr);
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 = (ulong *)image_get_data (hdr);
186 /* get address of the proper component data start, which means
187 * skipping sizes table (add 1 for last, null entry) */
188 img_data = image_get_data (hdr) + (count + 1) * sizeof (ulong);
195 /* go over all indices preceding requested component idx */
196 for (i = 0; i < idx; i++) {
197 /* add up i-th component size */
200 /* add up alignment for i-th component */
201 tail += (4 - size[i] % 4);
204 /* calculate idx-th component data address */
205 *data = img_data + offset + tail;
213 static void image_print_type (image_header_t *hdr)
215 const char *os, *arch, *type, *comp;
217 os = genimg_get_os_name (image_get_os (hdr));
218 arch = genimg_get_arch_name (image_get_arch (hdr));
219 type = genimg_get_type_name (image_get_type (hdr));
220 comp = genimg_get_comp_name (image_get_comp (hdr));
222 printf ("%s %s %s (%s)", arch, os, type, comp);
225 void image_print_contents (image_header_t *hdr)
227 #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
228 time_t timestamp = (time_t)image_get_time (hdr);
232 printf (" Image Name: %.*s\n", IH_NMLEN, image_get_name (hdr));
234 #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
235 to_tm (timestamp, &tm);
236 printf (" Created: %4d-%02d-%02d %2d:%02d:%02d UTC\n",
237 tm.tm_year, tm.tm_mon, tm.tm_mday,
238 tm.tm_hour, tm.tm_min, tm.tm_sec);
240 puts (" Image Type: ");
241 image_print_type (hdr);
243 printf ("\n Data Size: %d Bytes = ", image_get_data_size (hdr));
244 print_size (image_get_data_size (hdr), "\n");
245 printf (" Load Address: %08x\n"
246 " Entry Point: %08x\n",
247 image_get_load (hdr), image_get_ep (hdr));
249 if (image_check_type (hdr, IH_TYPE_MULTI)) {
252 ulong count = image_multi_count (hdr);
254 puts (" Contents:\n");
255 for (i = 0; i < count; i++) {
256 image_multi_getimg (hdr, i, &data, &len);
257 printf (" Image %d: %8ld Bytes = ", i, len);
258 print_size (len, "\n");
264 * image_get_ramdisk - get and verify ramdisk image
265 * @cmdtp: command table pointer
266 * @flag: command flag
267 * @argc: command argument count
268 * @argv: command argument list
269 * @rd_addr: ramdisk image start address
270 * @arch: expected ramdisk architecture
271 * @verify: checksum verification flag
273 * image_get_ramdisk() returns a pointer to the verified ramdisk image
274 * header. Routine receives image start address and expected architecture
275 * flag. Verification done covers data and header integrity and os/type/arch
278 * If dataflash support is enabled routine checks for dataflash addresses
279 * and handles required dataflash reads.
282 * pointer to a ramdisk image header, if image was found and valid
283 * otherwise, return NULL
285 static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
286 int argc, char *argv[],
287 ulong rd_addr, uint8_t arch, int verify)
289 image_header_t *rd_hdr;
291 show_boot_progress (9);
292 rd_hdr = (image_header_t *)rd_addr;
294 if (!image_check_magic (rd_hdr)) {
295 puts ("Bad Magic Number\n");
296 show_boot_progress (-10);
300 if (!image_check_hcrc (rd_hdr)) {
301 puts ("Bad Header Checksum\n");
302 show_boot_progress (-11);
306 show_boot_progress (10);
307 image_print_contents (rd_hdr);
310 puts(" Verifying Checksum ... ");
311 if (!image_check_dcrc_wd (rd_hdr, CHUNKSZ)) {
312 puts ("Bad Data CRC\n");
313 show_boot_progress (-12);
319 show_boot_progress (11);
321 if (!image_check_os (rd_hdr, IH_OS_LINUX) ||
322 !image_check_arch (rd_hdr, arch) ||
323 !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) {
324 printf ("No Linux %s Ramdisk Image\n",
325 genimg_get_arch_name(arch));
326 show_boot_progress (-13);
333 /*****************************************************************************/
334 /* Shared dual-format routines */
335 /*****************************************************************************/
336 int getenv_verify (void)
338 char *s = getenv ("verify");
339 return (s && (*s == 'n')) ? 0 : 1;
342 int getenv_autostart (void)
344 char *s = getenv ("autostart");
345 return (s && (*s == 'n')) ? 0 : 1;
348 ulong getenv_bootm_low(void)
350 char *s = getenv ("bootm_low");
352 ulong tmp = simple_strtoul (s, NULL, 16);
356 #ifdef CFG_SDRAM_BASE
357 return CFG_SDRAM_BASE;
363 ulong getenv_bootm_size(void)
365 char *s = getenv ("bootm_size");
367 ulong tmp = simple_strtoul (s, NULL, 16);
371 return gd->bd->bi_memsize;
374 void memmove_wd (void *to, void *from, size_t len, ulong chunksz)
376 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
378 size_t tail = (len > chunksz) ? chunksz : len;
380 memmove (to, from, tail);
385 #else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
386 memmove (to, from, len);
387 #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
389 #endif /* USE_HOSTCC */
391 const char* genimg_get_os_name (uint8_t os)
396 case IH_OS_INVALID: name = "Invalid OS"; break;
397 case IH_OS_NETBSD: name = "NetBSD"; break;
398 case IH_OS_LINUX: name = "Linux"; break;
399 case IH_OS_VXWORKS: name = "VxWorks"; break;
400 case IH_OS_QNX: name = "QNX"; break;
401 case IH_OS_U_BOOT: name = "U-Boot"; break;
402 case IH_OS_RTEMS: name = "RTEMS"; break;
404 case IH_OS_ARTOS: name = "ARTOS"; break;
406 #ifdef CONFIG_LYNXKDI
407 case IH_OS_LYNXOS: name = "LynxOS"; break;
409 default: name = "Unknown OS"; break;
415 const char* genimg_get_arch_name (uint8_t arch)
420 case IH_ARCH_INVALID: name = "Invalid Architecture"; break;
421 case IH_ARCH_ALPHA: name = "Alpha"; break;
422 case IH_ARCH_ARM: name = "ARM"; break;
423 case IH_ARCH_AVR32: name = "AVR32"; break;
424 case IH_ARCH_BLACKFIN: name = "Blackfin"; break;
425 case IH_ARCH_I386: name = "Intel x86"; break;
426 case IH_ARCH_IA64: name = "IA64"; break;
427 case IH_ARCH_M68K: name = "M68K"; break;
428 case IH_ARCH_MICROBLAZE:name = "Microblaze"; break;
429 case IH_ARCH_MIPS64: name = "MIPS 64 Bit"; break;
430 case IH_ARCH_MIPS: name = "MIPS"; break;
431 case IH_ARCH_NIOS2: name = "Nios-II"; break;
432 case IH_ARCH_NIOS: name = "Nios"; break;
433 case IH_ARCH_PPC: name = "PowerPC"; break;
434 case IH_ARCH_S390: name = "IBM S390"; break;
435 case IH_ARCH_SH: name = "SuperH"; break;
436 case IH_ARCH_SPARC64: name = "SPARC 64 Bit"; break;
437 case IH_ARCH_SPARC: name = "SPARC"; break;
438 default: name = "Unknown Architecture"; break;
444 const char* genimg_get_type_name (uint8_t type)
449 case IH_TYPE_INVALID: name = "Invalid Image"; break;
450 case IH_TYPE_STANDALONE:name = "Standalone Program"; break;
451 case IH_TYPE_KERNEL: name = "Kernel Image"; break;
452 case IH_TYPE_RAMDISK: name = "RAMDisk Image"; break;
453 case IH_TYPE_MULTI: name = "Multi-File Image"; break;
454 case IH_TYPE_FIRMWARE: name = "Firmware"; break;
455 case IH_TYPE_SCRIPT: name = "Script"; break;
456 case IH_TYPE_FLATDT: name = "Flat Device Tree"; break;
457 default: name = "Unknown Image"; break;
463 const char* genimg_get_comp_name (uint8_t comp)
468 case IH_COMP_NONE: name = "uncompressed"; break;
469 case IH_COMP_GZIP: name = "gzip compressed"; break;
470 case IH_COMP_BZIP2: name = "bzip2 compressed"; break;
471 default: name = "unknown compression"; break;
478 * genimg_get_format - get image format type
479 * @img_addr: image start address
481 * genimg_get_format() checks whether provided address points to a valid
482 * legacy or FIT image.
484 * New uImage format and FDT blob are based on a libfdt. FDT blob
485 * may be passed directly or embedded in a FIT image. In both situations
486 * genimg_get_format() must be able to dectect libfdt header.
489 * image format type or IMAGE_FORMAT_INVALID if no image is present
491 int genimg_get_format (void *img_addr)
493 ulong format = IMAGE_FORMAT_INVALID;
495 #if defined(CONFIG_FIT) || defined(CONFIG_OF_LIBFDT)
499 hdr = (image_header_t *)img_addr;
500 if (image_check_magic(hdr))
501 format = IMAGE_FORMAT_LEGACY;
502 #if defined(CONFIG_FIT) || defined(CONFIG_OF_LIBFDT)
504 fit_hdr = (char *)img_addr;
505 if (fdt_check_header (fit_hdr) == 0)
506 format = IMAGE_FORMAT_FIT;
514 * genimg_get_image - get image from special storage (if necessary)
515 * @img_addr: image start address
517 * genimg_get_image() checks if provided image start adddress is located
518 * in a dataflash storage. If so, image is moved to a system RAM memory.
521 * image start address after possible relocation from special storage
523 ulong genimg_get_image (ulong img_addr)
525 ulong ram_addr = img_addr;
527 #ifdef CONFIG_HAS_DATAFLASH
528 ulong h_size, d_size;
530 if (addr_dataflash (img_addr)){
531 /* ger RAM address */
532 ram_addr = CFG_LOAD_ADDR;
534 /* get header size */
535 h_size = image_get_header_size ();
536 #if defined(CONFIG_FIT)
537 if (sizeof(struct fdt_header) > h_size)
538 h_size = sizeof(struct fdt_header);
542 debug (" Reading image header from dataflash address "
543 "%08lx to RAM address %08lx\n", img_addr, ram_addr);
545 read_dataflash (img_addr, h_size, (char *)ram_addr);
548 switch (genimg_get_format ((void *)ram_addr)) {
549 case IMAGE_FORMAT_LEGACY:
550 d_size = image_get_data_size ((image_header_t *)ram_addr);
551 debug (" Legacy format image found at 0x%08lx, size 0x%08lx\n",
554 #if defined(CONFIG_FIT)
555 case IMAGE_FORMAT_FIT:
556 d_size = fdt_totalsize((void *)ram_addr) - h_size;
557 debug (" FIT/FDT format image found at 0x%08lx, size 0x%08lx\n",
562 printf (" No valid image found at 0x%08lx\n", img_addr);
566 /* read in image data */
567 debug (" Reading image remaining data from dataflash address "
568 "%08lx to RAM address %08lx\n", img_addr + h_size,
571 read_dataflash (img_addr + h_size, d_size,
572 (char *)(ram_addr + h_size));
575 #endif /* CONFIG_HAS_DATAFLASH */
581 * boot_get_ramdisk - main ramdisk handling routine
582 * @cmdtp: command table pointer
583 * @flag: command flag
584 * @argc: command argument count
585 * @argv: command argument list
586 * @images: pointer to the bootm images structure
587 * @arch: expected ramdisk architecture
588 * @rd_start: pointer to a ulong variable, will hold ramdisk start address
589 * @rd_end: pointer to a ulong variable, will hold ramdisk end
591 * boot_get_ramdisk() is responsible for finding a valid ramdisk image.
592 * Curently supported are the following ramdisk sources:
593 * - multicomponent kernel/ramdisk image,
594 * - commandline provided address of decicated ramdisk image.
597 * rd_start and rd_end are set to ramdisk start/end addresses if
598 * ramdisk image is found and valid
599 * rd_start and rd_end are set to 0 if no ramdisk exists
600 * return 1 if ramdisk image is found but corrupted
602 int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
603 bootm_headers_t *images, uint8_t arch,
604 ulong *rd_start, ulong *rd_end)
606 ulong rd_addr, rd_load;
607 ulong rd_data, rd_len;
608 image_header_t *rd_hdr;
609 #if defined(CONFIG_FIT)
611 const char *fit_uname_config = NULL;
612 const char *fit_uname_ramdisk = NULL;
617 * Look for a '-' which indicates to ignore the
620 if ((argc >= 3) && (strcmp(argv[2], "-") == 0)) {
621 debug ("## Skipping init Ramdisk\n");
622 rd_len = rd_data = 0;
623 } else if (argc >= 3) {
624 #if defined(CONFIG_FIT)
626 * If the init ramdisk comes from the FIT image and the FIT image
627 * address is omitted in the command line argument, try to use
628 * os FIT image address or default load address.
630 if (images->fit_uname_os)
631 default_addr = (ulong)images->fit_hdr_os;
633 default_addr = load_addr;
635 if (fit_parse_conf (argv[2], default_addr,
636 &rd_addr, &fit_uname_config)) {
637 debug ("* ramdisk: config '%s' from image at 0x%08lx\n",
638 fit_uname_config, rd_addr);
639 } else if (fit_parse_subimage (argv[2], default_addr,
640 &rd_addr, &fit_uname_ramdisk)) {
641 debug ("* ramdisk: subimage '%s' from image at 0x%08lx\n",
642 fit_uname_ramdisk, rd_addr);
646 rd_addr = simple_strtoul(argv[2], NULL, 16);
647 debug ("* ramdisk: cmdline image address = 0x%08lx\n",
651 /* copy from dataflash if needed */
652 printf ("## Loading init Ramdisk Image at %08lx ...\n",
654 rd_addr = genimg_get_image (rd_addr);
657 * Check if there is an initrd image at the
658 * address provided in the second bootm argument
659 * check image type, for FIT images get FIT node.
661 switch (genimg_get_format ((void *)rd_addr)) {
662 case IMAGE_FORMAT_LEGACY:
664 debug ("* ramdisk: legacy format image\n");
666 rd_hdr = image_get_ramdisk (cmdtp, flag, argc, argv,
667 rd_addr, arch, images->verify);
669 if (rd_hdr == NULL) {
675 rd_data = image_get_data (rd_hdr);
676 rd_len = image_get_data_size (rd_hdr);
677 rd_load = image_get_load (rd_hdr);
679 #if defined(CONFIG_FIT)
680 case IMAGE_FORMAT_FIT:
681 fit_hdr = (void *)rd_addr;
682 debug ("* ramdisk: FIT format image\n");
683 fit_unsupported_reset ("ramdisk");
687 printf ("Wrong Image Format for %s command\n",
689 rd_data = rd_len = 0;
692 #if defined(CONFIG_B2) || defined(CONFIG_EVB4510) || defined(CONFIG_ARMADILLO)
694 * We need to copy the ramdisk to SRAM to let Linux boot
697 memmove ((void *)rd_load, (uchar *)rd_data, rd_len);
700 #endif /* CONFIG_B2 || CONFIG_EVB4510 || CONFIG_ARMADILLO */
702 } else if (images->legacy_hdr_valid &&
703 image_check_type (images->legacy_hdr_os, IH_TYPE_MULTI)) {
705 * Now check if we have a legacy mult-component image,
706 * get second entry data start address and len.
708 show_boot_progress (13);
709 printf ("## Loading init Ramdisk from multi component "
710 "Image at %08lx ...\n",
711 (ulong)images->legacy_hdr_os);
713 image_multi_getimg (images->legacy_hdr_os, 1, &rd_data, &rd_len);
718 show_boot_progress (14);
719 rd_len = rd_data = 0;
723 debug ("## No init Ramdisk\n");
728 *rd_end = rd_data + rd_len;
730 debug (" ramdisk start = 0x%08lx, ramdisk end = 0x%08lx\n",
736 #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
738 * boot_ramdisk_high - relocate init ramdisk
739 * @lmb: pointer to lmb handle, will be used for memory mgmt
740 * @rd_data: ramdisk data start address
741 * @rd_len: ramdisk data length
742 * @initrd_start: pointer to a ulong variable, will hold final init ramdisk
743 * start address (after possible relocation)
744 * @initrd_end: pointer to a ulong variable, will hold final init ramdisk
745 * end address (after possible relocation)
747 * boot_ramdisk_high() takes a relocation hint from "initrd_high" environement
748 * variable and if requested ramdisk data is moved to a specified location.
750 * Initrd_start and initrd_end are set to final (after relocation) ramdisk
751 * start/end addresses if ramdisk image start and len were provided,
752 * otherwise set initrd_start and initrd_end set to zeros.
758 int boot_ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len,
759 ulong *initrd_start, ulong *initrd_end)
763 int initrd_copy_to_ram = 1;
765 if ((s = getenv ("initrd_high")) != NULL) {
766 /* a value of "no" or a similar string will act like 0,
767 * turning the "load high" feature off. This is intentional.
769 initrd_high = simple_strtoul (s, NULL, 16);
770 if (initrd_high == ~0)
771 initrd_copy_to_ram = 0;
773 /* not set, no restrictions to load high */
777 debug ("## initrd_high = 0x%08lx, copy_to_ram = %d\n",
778 initrd_high, initrd_copy_to_ram);
781 if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */
782 debug (" in-place initrd\n");
783 *initrd_start = rd_data;
784 *initrd_end = rd_data + rd_len;
785 lmb_reserve(lmb, rd_data, rd_len);
788 *initrd_start = lmb_alloc_base (lmb, rd_len, 0x1000, initrd_high);
790 *initrd_start = lmb_alloc (lmb, rd_len, 0x1000);
792 if (*initrd_start == 0) {
793 puts ("ramdisk - allocation error\n");
796 show_boot_progress (12);
798 *initrd_end = *initrd_start + rd_len;
799 printf (" Loading Ramdisk to %08lx, end %08lx ... ",
800 *initrd_start, *initrd_end);
802 memmove_wd ((void *)*initrd_start,
803 (void *)rd_data, rd_len, CHUNKSZ);
811 debug (" ramdisk load start = 0x%08lx, ramdisk load end = 0x%08lx\n",
812 *initrd_start, *initrd_end);
821 * boot_get_cmdline - allocate and initialize kernel cmdline
822 * @lmb: pointer to lmb handle, will be used for memory mgmt
823 * @cmd_start: pointer to a ulong variable, will hold cmdline start
824 * @cmd_end: pointer to a ulong variable, will hold cmdline end
825 * @bootmap_base: ulong variable, holds offset in physical memory to
828 * boot_get_cmdline() allocates space for kernel command line below
829 * BOOTMAPSZ + bootmap_base address. If "bootargs" U-boot environemnt
830 * variable is present its contents is copied to allocated kernel
837 int boot_get_cmdline (struct lmb *lmb, ulong *cmd_start, ulong *cmd_end,
843 cmdline = (char *)lmb_alloc_base(lmb, CFG_BARGSIZE, 0xf,
844 CFG_BOOTMAPSZ + bootmap_base);
849 if ((s = getenv("bootargs")) == NULL)
854 *cmd_start = (ulong) & cmdline[0];
855 *cmd_end = *cmd_start + strlen(cmdline);
857 debug ("## cmdline at 0x%08lx ... 0x%08lx\n", *cmd_start, *cmd_end);
863 * boot_get_kbd - allocate and initialize kernel copy of board info
864 * @lmb: pointer to lmb handle, will be used for memory mgmt
865 * @kbd: double pointer to board info data
866 * @bootmap_base: ulong variable, holds offset in physical memory to
869 * boot_get_kbd() allocates space for kernel copy of board info data below
870 * BOOTMAPSZ + bootmap_base address and kernel board info is initialized with
871 * the current u-boot board info data.
877 int boot_get_kbd (struct lmb *lmb, bd_t **kbd, ulong bootmap_base)
879 *kbd = (bd_t *)lmb_alloc_base(lmb, sizeof(bd_t), 0xf,
880 CFG_BOOTMAPSZ + bootmap_base);
886 debug ("## kernel board info at 0x%08lx\n", (ulong)*kbd);
888 #if defined(DEBUG) && defined(CONFIG_CMD_BDI)
889 do_bdinfo(NULL, 0, 0, NULL);
894 #endif /* CONFIG_PPC || CONFIG_M68K */
896 #if defined(CONFIG_FIT)
897 /*****************************************************************************/
898 /* New uImage format routines */
899 /*****************************************************************************/
900 static int fit_parse_spec (const char *spec, char sepc, ulong addr_curr,
901 ulong *addr, const char **name)
908 sep = strchr (spec, sepc);
911 *addr = simple_strtoul (spec, NULL, 16);
921 * fit_parse_conf - parse FIT configuration spec
922 * @spec: input string, containing configuration spec
923 * @add_curr: current image address (to be used as a possible default)
924 * @addr: pointer to a ulong variable, will hold FIT image address of a given
926 * @conf_name double pointer to a char, will hold pointer to a configuration
929 * fit_parse_conf() expects configuration spec in the for of [<addr>]#<conf>,
930 * where <addr> is a FIT image address that contains configuration
931 * with a <conf> unit name.
933 * Address part is optional, and if omitted default add_curr will
937 * 1 if spec is a valid configuration string,
938 * addr and conf_name are set accordingly
941 inline int fit_parse_conf (const char *spec, ulong addr_curr,
942 ulong *addr, const char **conf_name)
944 return fit_parse_spec (spec, '#', addr_curr, addr, conf_name);
948 * fit_parse_subimage - parse FIT subimage spec
949 * @spec: input string, containing subimage spec
950 * @add_curr: current image address (to be used as a possible default)
951 * @addr: pointer to a ulong variable, will hold FIT image address of a given
953 * @image_name: double pointer to a char, will hold pointer to a subimage name
955 * fit_parse_subimage() expects subimage spec in the for of
956 * [<addr>]:<subimage>, where <addr> is a FIT image address that contains
957 * subimage with a <subimg> unit name.
959 * Address part is optional, and if omitted default add_curr will
963 * 1 if spec is a valid subimage string,
964 * addr and image_name are set accordingly
967 inline int fit_parse_subimage (const char *spec, ulong addr_curr,
968 ulong *addr, const char **image_name)
970 return fit_parse_spec (spec, ':', addr_curr, addr, image_name);
973 #endif /* CONFIG_FIT */
975 #endif /* USE_HOSTCC */