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>
54 extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
57 extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
60 DECLARE_GLOBAL_DATA_PTR;
62 static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
63 int argc, char *argv[],
64 ulong rd_addr, uint8_t arch, int verify);
67 #endif /* USE_HOSTCC*/
71 unsigned long crc32 (unsigned long, const unsigned char *, unsigned int);
73 int image_check_hcrc (image_header_t *hdr)
76 ulong len = image_get_header_size ();
77 image_header_t header;
79 /* Copy header so we can blank CRC field for re-calculation */
80 memmove (&header, (char *)hdr, image_get_header_size ());
81 image_set_hcrc (&header, 0);
83 hcrc = crc32 (0, (unsigned char *)&header, len);
85 return (hcrc == image_get_hcrc (hdr));
88 int image_check_dcrc (image_header_t *hdr)
90 ulong data = image_get_data (hdr);
91 ulong len = image_get_data_size (hdr);
92 ulong dcrc = crc32 (0, (unsigned char *)data, len);
94 return (dcrc == image_get_dcrc (hdr));
98 int image_check_dcrc_wd (image_header_t *hdr, ulong chunksz)
101 ulong len = image_get_data_size (hdr);
102 ulong data = image_get_data (hdr);
104 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
106 ulong edata = cdata + len;
108 while (cdata < edata) {
109 ulong chunk = edata - cdata;
113 dcrc = crc32 (dcrc, (unsigned char *)cdata, chunk);
119 dcrc = crc32 (0, (unsigned char *)data, len);
122 return (dcrc == image_get_dcrc (hdr));
125 int getenv_verify (void)
127 char *s = getenv ("verify");
128 return (s && (*s == 'n')) ? 0 : 1;
131 void memmove_wd (void *to, void *from, size_t len, ulong chunksz)
133 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
135 size_t tail = (len > chunksz) ? chunksz : len;
137 memmove (to, from, tail);
142 #else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
143 memmove (to, from, len);
144 #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
146 #endif /* USE_HOSTCC */
149 * image_multi_count - get component (sub-image) count
150 * @hdr: pointer to the header of the multi component image
152 * image_multi_count() returns number of components in a multi
155 * Note: no checking of the image type is done, caller must pass
156 * a valid multi component image.
159 * number of components
161 ulong image_multi_count (image_header_t *hdr)
166 /* get start of the image payload, which in case of multi
167 * component images that points to a table of component sizes */
168 size = (ulong *)image_get_data (hdr);
170 /* count non empty slots */
171 for (i = 0; size[i]; ++i)
178 * image_multi_getimg - get component data address and size
179 * @hdr: pointer to the header of the multi component image
180 * @idx: index of the requested component
181 * @data: pointer to a ulong variable, will hold component data address
182 * @len: pointer to a ulong variable, will hold component size
184 * image_multi_getimg() returns size and data address for the requested
185 * component in a multi component image.
187 * Note: no checking of the image type is done, caller must pass
188 * a valid multi component image.
191 * data address and size of the component, if idx is valid
192 * 0 in data and len, if idx is out of range
194 void image_multi_getimg (image_header_t *hdr, ulong idx,
195 ulong *data, ulong *len)
199 ulong offset, tail, count, img_data;
201 /* get number of component */
202 count = image_multi_count (hdr);
204 /* get start of the image payload, which in case of multi
205 * component images that points to a table of component sizes */
206 size = (ulong *)image_get_data (hdr);
208 /* get address of the proper component data start, which means
209 * skipping sizes table (add 1 for last, null entry) */
210 img_data = image_get_data (hdr) + (count + 1) * sizeof (ulong);
217 /* go over all indices preceding requested component idx */
218 for (i = 0; i < idx; i++) {
219 /* add up i-th component size */
222 /* add up alignment for i-th component */
223 tail += (4 - size[i] % 4);
226 /* calculate idx-th component data address */
227 *data = img_data + offset + tail;
235 const char* image_get_os_name (uint8_t os)
240 case IH_OS_INVALID: name = "Invalid OS"; break;
241 case IH_OS_NETBSD: name = "NetBSD"; break;
242 case IH_OS_LINUX: name = "Linux"; break;
243 case IH_OS_VXWORKS: name = "VxWorks"; break;
244 case IH_OS_QNX: name = "QNX"; break;
245 case IH_OS_U_BOOT: name = "U-Boot"; break;
246 case IH_OS_RTEMS: name = "RTEMS"; break;
248 case IH_OS_ARTOS: name = "ARTOS"; break;
250 #ifdef CONFIG_LYNXKDI
251 case IH_OS_LYNXOS: name = "LynxOS"; break;
253 default: name = "Unknown OS"; break;
259 const char* image_get_arch_name (uint8_t arch)
264 case IH_ARCH_INVALID: name = "Invalid Architecture"; break;
265 case IH_ARCH_ALPHA: name = "Alpha"; break;
266 case IH_ARCH_ARM: name = "ARM"; break;
267 case IH_ARCH_AVR32: name = "AVR32"; break;
268 case IH_ARCH_BLACKFIN: name = "Blackfin"; break;
269 case IH_ARCH_I386: name = "Intel x86"; break;
270 case IH_ARCH_IA64: name = "IA64"; break;
271 case IH_ARCH_M68K: name = "M68K"; break;
272 case IH_ARCH_MICROBLAZE:name = "Microblaze"; break;
273 case IH_ARCH_MIPS64: name = "MIPS 64 Bit"; break;
274 case IH_ARCH_MIPS: name = "MIPS"; break;
275 case IH_ARCH_NIOS2: name = "Nios-II"; break;
276 case IH_ARCH_NIOS: name = "Nios"; break;
277 case IH_ARCH_PPC: name = "PowerPC"; break;
278 case IH_ARCH_S390: name = "IBM S390"; break;
279 case IH_ARCH_SH: name = "SuperH"; break;
280 case IH_ARCH_SPARC64: name = "SPARC 64 Bit"; break;
281 case IH_ARCH_SPARC: name = "SPARC"; break;
282 default: name = "Unknown Architecture"; break;
288 const char* image_get_type_name (uint8_t type)
293 case IH_TYPE_INVALID: name = "Invalid Image"; break;
294 case IH_TYPE_STANDALONE:name = "Standalone Program"; break;
295 case IH_TYPE_KERNEL: name = "Kernel Image"; break;
296 case IH_TYPE_RAMDISK: name = "RAMDisk Image"; break;
297 case IH_TYPE_MULTI: name = "Multi-File Image"; break;
298 case IH_TYPE_FIRMWARE: name = "Firmware"; break;
299 case IH_TYPE_SCRIPT: name = "Script"; break;
300 case IH_TYPE_FLATDT: name = "Flat Device Tree"; break;
301 default: name = "Unknown Image"; break;
307 const char* image_get_comp_name (uint8_t comp)
312 case IH_COMP_NONE: name = "uncompressed"; break;
313 case IH_COMP_GZIP: name = "gzip compressed"; break;
314 case IH_COMP_BZIP2: name = "bzip2 compressed"; break;
315 default: name = "unknown compression"; break;
321 static void image_print_type (image_header_t *hdr)
323 const char *os, *arch, *type, *comp;
325 os = image_get_os_name (image_get_os (hdr));
326 arch = image_get_arch_name (image_get_arch (hdr));
327 type = image_get_type_name (image_get_type (hdr));
328 comp = image_get_comp_name (image_get_comp (hdr));
330 printf ("%s %s %s (%s)", arch, os, type, comp);
333 void image_print_contents (image_header_t *hdr)
335 #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
336 time_t timestamp = (time_t)image_get_time (hdr);
340 printf (" Image Name: %.*s\n", IH_NMLEN, image_get_name (hdr));
342 #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
343 to_tm (timestamp, &tm);
344 printf (" Created: %4d-%02d-%02d %2d:%02d:%02d UTC\n",
345 tm.tm_year, tm.tm_mon, tm.tm_mday,
346 tm.tm_hour, tm.tm_min, tm.tm_sec);
348 puts (" Image Type: ");
349 image_print_type (hdr);
351 printf ("\n Data Size: %d Bytes = ", image_get_data_size (hdr));
352 print_size (image_get_data_size (hdr), "\n");
353 printf (" Load Address: %08x\n"
354 " Entry Point: %08x\n",
355 image_get_load (hdr), image_get_ep (hdr));
357 if (image_check_type (hdr, IH_TYPE_MULTI)) {
360 ulong count = image_multi_count (hdr);
362 puts (" Contents:\n");
363 for (i = 0; i < count; i++) {
364 image_multi_getimg (hdr, i, &data, &len);
365 printf (" Image %d: %8ld Bytes = ", i, len);
366 print_size (len, "\n");
372 * gen_image_get_format - get image format type
373 * @img_addr: image start address
375 * gen_image_get_format() checks whether provided address points to a valid
376 * legacy or FIT image.
379 * image format type or IMAGE_FORMAT_INVALID if no image is present
381 int gen_image_get_format (void *img_addr)
383 ulong format = IMAGE_FORMAT_INVALID;
385 #if defined(CONFIG_FIT)
389 hdr = (image_header_t *)img_addr;
390 if (image_check_magic(hdr))
391 format = IMAGE_FORMAT_LEGACY;
392 #if defined(CONFIG_FIT)
394 fit_hdr = (char *)img_addr;
395 if (fdt_check_header (fit_hdr) == 0)
396 format = IMAGE_FORMAT_FIT;
404 * gen_get_image - get image from special storage (if necessary)
405 * @img_addr: image start address
407 * gen_get_image() checks if provided image start adddress is located
408 * in a dataflash storage. If so, image is moved to a system RAM memory.
411 * image start address after possible relocation from special storage
413 ulong gen_get_image (ulong img_addr)
415 ulong ram_addr = img_addr;
417 #ifdef CONFIG_HAS_DATAFLASH
418 ulong h_size, d_size;
420 if (addr_dataflash (img_addr)){
421 /* ger RAM address */
422 ram_addr = CFG_LOAD_ADDR;
424 /* get header size */
425 h_size = image_get_header_size ();
426 #if defined(CONFIG_FIT)
427 if (sizeof(struct fdt_header) > h_size)
428 h_size = sizeof(struct fdt_header);
432 debug (" Reading image header from dataflash address "
433 "%08lx to RAM address %08lx\n", img_addr, ram_addr);
435 read_dataflash (img_addr, h_size, (char *)ram_addr);
438 switch (gen_image_get_format ((void *)ram_addr)) {
439 case IMAGE_FORMAT_LEGACY:
440 d_size = image_get_data_size ((image_header_t *)ram_addr);
441 debug (" Legacy format image found at 0x%08lx, size 0x%08lx\n",
444 #if defined(CONFIG_FIT)
445 case IMAGE_FORMAT_FIT:
446 d_size = fdt_totalsize((void *)ram_addr) - h_size;
447 debug (" FIT/FDT format image found at 0x%08lx, size 0x%08lx\n",
452 printf (" No valid image found at 0x%08lx\n", img_addr);
456 /* read in image data */
457 debug (" Reading image remaining data from dataflash address "
458 "%08lx to RAM address %08lx\n", img_addr + h_size,
461 read_dataflash (img_addr + h_size, d_size,
462 (char *)(ram_addr + h_size));
465 #endif /* CONFIG_HAS_DATAFLASH */
471 * image_get_ramdisk - get and verify ramdisk image
472 * @cmdtp: command table pointer
473 * @flag: command flag
474 * @argc: command argument count
475 * @argv: command argument list
476 * @rd_addr: ramdisk image start address
477 * @arch: expected ramdisk architecture
478 * @verify: checksum verification flag
480 * image_get_ramdisk() returns a pointer to the verified ramdisk image
481 * header. Routine receives image start address and expected architecture
482 * flag. Verification done covers data and header integrity and os/type/arch
485 * If dataflash support is enabled routine checks for dataflash addresses
486 * and handles required dataflash reads.
489 * pointer to a ramdisk image header, if image was found and valid
490 * otherwise, board is reset
492 static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
493 int argc, char *argv[],
494 ulong rd_addr, uint8_t arch, int verify)
496 image_header_t *rd_hdr;
498 show_boot_progress (9);
499 rd_hdr = (image_header_t *)rd_addr;
501 if (!image_check_magic (rd_hdr)) {
502 puts ("Bad Magic Number\n");
503 show_boot_progress (-10);
504 do_reset (cmdtp, flag, argc, argv);
507 if (!image_check_hcrc (rd_hdr)) {
508 puts ("Bad Header Checksum\n");
509 show_boot_progress (-11);
510 do_reset (cmdtp, flag, argc, argv);
513 show_boot_progress (10);
514 image_print_contents (rd_hdr);
517 puts(" Verifying Checksum ... ");
518 if (!image_check_dcrc_wd (rd_hdr, CHUNKSZ)) {
519 puts ("Bad Data CRC\n");
520 show_boot_progress (-12);
521 do_reset (cmdtp, flag, argc, argv);
526 show_boot_progress (11);
528 if (!image_check_os (rd_hdr, IH_OS_LINUX) ||
529 !image_check_arch (rd_hdr, arch) ||
530 !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) {
531 printf ("No Linux %s Ramdisk Image\n",
532 image_get_arch_name(arch));
533 show_boot_progress (-13);
534 do_reset (cmdtp, flag, argc, argv);
541 * get_ramdisk - main ramdisk handling routine
542 * @cmdtp: command table pointer
543 * @flag: command flag
544 * @argc: command argument count
545 * @argv: command argument list
546 * @images: pointer to the bootm images structure
547 * @arch: expected ramdisk architecture
548 * @rd_start: pointer to a ulong variable, will hold ramdisk start address
549 * @rd_end: pointer to a ulong variable, will hold ramdisk end
551 * get_ramdisk() is responsible for finding a valid ramdisk image.
552 * Curently supported are the following ramdisk sources:
553 * - multicomponent kernel/ramdisk image,
554 * - commandline provided address of decicated ramdisk image.
557 * rd_start and rd_end are set to ramdisk start/end addresses if
558 * ramdisk image is found and valid
559 * rd_start and rd_end are set to 0 if no ramdisk exists
560 * board is reset if ramdisk image is found but corrupted
562 void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
563 bootm_headers_t *images, uint8_t arch,
564 ulong *rd_start, ulong *rd_end)
566 ulong rd_addr, rd_load;
567 ulong rd_data, rd_len;
568 image_header_t *rd_hdr;
569 #if defined(CONFIG_FIT)
571 const char *fit_uname_config = NULL;
572 const char *fit_uname_ramdisk = NULL;
577 * Look for a '-' which indicates to ignore the
580 if ((argc >= 3) && (strcmp(argv[2], "-") == 0)) {
581 debug ("## Skipping init Ramdisk\n");
582 rd_len = rd_data = 0;
583 } else if (argc >= 3) {
584 #if defined(CONFIG_FIT)
586 * If the init ramdisk comes from the FIT image and the FIT image
587 * address is omitted in the command line argument, try to use
588 * os FIT image address or default load address.
590 if (images->fit_uname_os)
591 default_addr = (ulong)images->fit_hdr_os;
593 default_addr = load_addr;
595 if (fit_parse_conf (argv[2], default_addr,
596 &rd_addr, &fit_uname_config)) {
597 debug ("* ramdisk: config '%s' from image at 0x%08lx\n",
598 fit_uname_config, rd_addr);
599 } else if (fit_parse_subimage (argv[2], default_addr,
600 &rd_addr, &fit_uname_ramdisk)) {
601 debug ("* ramdisk: subimage '%s' from image at 0x%08lx\n",
602 fit_uname_ramdisk, rd_addr);
606 rd_addr = simple_strtoul(argv[2], NULL, 16);
607 debug ("* ramdisk: cmdline image address = 0x%08lx\n",
611 /* copy from dataflash if needed */
612 printf ("## Loading init Ramdisk Image at %08lx ...\n",
614 rd_addr = gen_get_image (rd_addr);
617 * Check if there is an initrd image at the
618 * address provided in the second bootm argument
619 * check image type, for FIT images get FIT node.
621 switch (gen_image_get_format ((void *)rd_addr)) {
622 case IMAGE_FORMAT_LEGACY:
624 debug ("* ramdisk: legacy format image\n");
626 rd_hdr = image_get_ramdisk (cmdtp, flag, argc, argv,
627 rd_addr, arch, images->verify);
629 rd_data = image_get_data (rd_hdr);
630 rd_len = image_get_data_size (rd_hdr);
631 rd_load = image_get_load (rd_hdr);
633 #if defined(CONFIG_FIT)
634 case IMAGE_FORMAT_FIT:
635 fit_hdr = (void *)rd_addr;
636 debug ("* ramdisk: FIT format image\n");
637 fit_unsupported_reset ("ramdisk");
638 do_reset (cmdtp, flag, argc, argv);
641 printf ("Wrong Image Format for %s command\n",
643 rd_data = rd_len = 0;
646 #if defined(CONFIG_B2) || defined(CONFIG_EVB4510) || defined(CONFIG_ARMADILLO)
648 * We need to copy the ramdisk to SRAM to let Linux boot
651 memmove ((void *)rd_load, (uchar *)rd_data, rd_len);
654 #endif /* CONFIG_B2 || CONFIG_EVB4510 || CONFIG_ARMADILLO */
656 } else if (images->legacy_hdr_valid &&
657 image_check_type (images->legacy_hdr_os, IH_TYPE_MULTI)) {
659 * Now check if we have a legacy mult-component image,
660 * get second entry data start address and len.
662 show_boot_progress (13);
663 printf ("## Loading init Ramdisk from multi component "
664 "Image at %08lx ...\n",
665 (ulong)images->legacy_hdr_os);
667 image_multi_getimg (images->legacy_hdr_os, 1, &rd_data, &rd_len);
672 show_boot_progress (14);
673 rd_len = rd_data = 0;
677 debug ("## No init Ramdisk\n");
682 *rd_end = rd_data + rd_len;
684 debug (" ramdisk start = 0x%08lx, ramdisk end = 0x%08lx\n",
688 #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
690 * ramdisk_high - relocate init ramdisk
691 * @rd_data: ramdisk data start address
692 * @rd_len: ramdisk data length
693 * @kbd: kernel board info copy (within BOOTMAPSZ boundary)
694 * @sp_limit: stack pointer limit (including BOOTMAPSZ)
695 * @sp: current stack pointer
696 * @initrd_start: pointer to a ulong variable, will hold final init ramdisk
697 * start address (after possible relocation)
698 * @initrd_end: pointer to a ulong variable, will hold final init ramdisk
699 * end address (after possible relocation)
701 * ramdisk_high() takes a relocation hint from "initrd_high" environement
702 * variable and if requested ramdisk data is moved to a specified location.
705 * - initrd_start and initrd_end are set to final (after relocation) ramdisk
706 * start/end addresses if ramdisk image start and len were provided
707 * otherwise set initrd_start and initrd_end set to zeros
708 * - returns new allc_current, next free address below BOOTMAPSZ
710 ulong ramdisk_high (ulong alloc_current, ulong rd_data, ulong rd_len,
711 bd_t *kbd, ulong sp_limit, ulong sp,
712 ulong *initrd_start, ulong *initrd_end)
716 int initrd_copy_to_ram = 1;
717 ulong new_alloc_current = alloc_current;
719 if ((s = getenv ("initrd_high")) != NULL) {
720 /* a value of "no" or a similar string will act like 0,
721 * turning the "load high" feature off. This is intentional.
723 initrd_high = simple_strtoul (s, NULL, 16);
724 if (initrd_high == ~0)
725 initrd_copy_to_ram = 0;
727 /* not set, no restrictions to load high */
731 #ifdef CONFIG_LOGBUFFER
732 /* Prevent initrd from overwriting logbuffer */
733 if (initrd_high < (kbd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD))
734 initrd_high = kbd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD;
735 debug ("## Logbuffer at 0x%08lx ", kbd->bi_memsize - LOGBUFF_LEN);
737 debug ("## initrd_high = 0x%08lx, copy_to_ram = %d\n",
738 initrd_high, initrd_copy_to_ram);
741 if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */
742 debug (" in-place initrd\n");
743 *initrd_start = rd_data;
744 *initrd_end = rd_data + rd_len;
746 new_alloc_current = alloc_current - rd_len;
747 *initrd_start = new_alloc_current;
748 *initrd_start &= ~(4096 - 1); /* align on page */
754 * the inital ramdisk does not need to be within
755 * CFG_BOOTMAPSZ as it is not accessed until after
756 * the mm system is initialised.
758 * do the stack bottom calculation again and see if
759 * the initrd will fit just below the monitor stack
760 * bottom without overwriting the area allocated
761 * for command line args and board info.
764 nsp -= 2048; /* just to be sure */
767 if (nsp > initrd_high) /* limit as specified */
771 nsp &= ~(4096 - 1); /* align on page */
773 if (nsp >= sp_limit) {
775 new_alloc_current = alloc_current;
779 show_boot_progress (12);
781 *initrd_end = *initrd_start + rd_len;
782 printf (" Loading Ramdisk to %08lx, end %08lx ... ",
783 *initrd_start, *initrd_end);
785 memmove_wd((void *)*initrd_start,
786 (void *)rd_data, rd_len, CHUNKSZ);
794 debug (" ramdisk load start = 0x%08lx, ramdisk load end = 0x%08lx\n",
795 *initrd_start, *initrd_end);
797 return new_alloc_current;
801 * get_boot_sp_limit - calculate stack pointer limit
802 * @sp: current stack pointer
804 * get_boot_sp_limit() takes current stack pointer adrress and calculates
805 * stack pointer limit, below which kernel boot data (cmdline, board info,
806 * etc.) will be allocated.
809 * stack pointer limit
811 ulong get_boot_sp_limit(ulong sp)
815 sp_limit -= 2048; /* just to be sure */
817 /* make sure sp_limit is within kernel mapped space */
818 if (sp_limit > CFG_BOOTMAPSZ)
819 sp_limit = CFG_BOOTMAPSZ;
826 * get_boot_cmdline - allocate and initialize kernel cmdline
827 * @alloc_current: current boot allocation address (counting down
829 * @cmd_start: pointer to a ulong variable, will hold cmdline start
830 * @cmd_end: pointer to a ulong variable, will hold cmdline end
832 * get_boot_cmdline() allocates space for kernel command line below
833 * provided alloc_current address. If "bootargs" U-boot environemnt
834 * variable is present its contents is copied to allocated kernel
838 * alloc_current after cmdline allocation
840 ulong get_boot_cmdline (ulong alloc_current, ulong *cmd_start, ulong *cmd_end)
845 cmdline = (char *)((alloc_current - CFG_BARGSIZE) & ~0xF);
847 if ((s = getenv("bootargs")) == NULL)
852 *cmd_start = (ulong) & cmdline[0];
853 *cmd_end = *cmd_start + strlen(cmdline);
855 debug ("## cmdline at 0x%08lx ... 0x%08lx\n", *cmd_start, *cmd_end);
857 return (ulong)cmdline;
861 * get_boot_kbd - allocate and initialize kernel copy of board info
862 * @alloc_current: current boot allocation address (counting down
864 * @kbd: double pointer to board info data
866 * get_boot_kbd() - allocates space for kernel copy of board info data.
867 * Space is allocated below provided alloc_current address and kernel
868 * board info is initialized with the current u-boot board info data.
871 * alloc_current after kbd allocation
873 ulong get_boot_kbd (ulong alloc_current, bd_t **kbd)
875 *kbd = (bd_t *) (((ulong)alloc_current - sizeof(bd_t)) & ~0xF);
878 debug ("## kernel board info at 0x%08lx\n", (ulong)*kbd);
880 #if defined(DEBUG) && defined(CONFIG_CMD_BDI)
881 do_bdinfo(NULL, 0, 0, NULL);
886 #endif /* CONFIG_PPC || CONFIG_M68K */
888 #if defined(CONFIG_FIT)
889 /*****************************************************************************/
890 /* New uImage format routines */
891 /*****************************************************************************/
892 static int fit_parse_spec (const char *spec, char sepc, ulong addr_curr,
893 ulong *addr, const char **name)
900 sep = strchr (spec, sepc);
903 *addr = simple_strtoul (spec, NULL, 16);
913 * fit_parse_conf - parse FIT configuration spec
914 * @spec: input string, containing configuration spec
915 * @add_curr: current image address (to be used as a possible default)
916 * @addr: pointer to a ulong variable, will hold FIT image address of a given
918 * @conf_name double pointer to a char, will hold pointer to a configuration
921 * fit_parse_conf() expects configuration spec in the for of [<addr>]#<conf>,
922 * where <addr> is a FIT image address that contains configuration
923 * with a <conf> unit name.
925 * Address part is optional, and if omitted default add_curr will
929 * 1 if spec is a valid configuration string,
930 * addr and conf_name are set accordingly
933 inline int fit_parse_conf (const char *spec, ulong addr_curr,
934 ulong *addr, const char **conf_name)
936 return fit_parse_spec (spec, '#', addr_curr, addr, conf_name);
940 * fit_parse_subimage - parse FIT subimage spec
941 * @spec: input string, containing subimage spec
942 * @add_curr: current image address (to be used as a possible default)
943 * @addr: pointer to a ulong variable, will hold FIT image address of a given
945 * @image_name: double pointer to a char, will hold pointer to a subimage name
947 * fit_parse_subimage() expects subimage spec in the for of
948 * [<addr>]:<subimage>, where <addr> is a FIT image address that contains
949 * subimage with a <subimg> unit name.
951 * Address part is optional, and if omitted default add_curr will
955 * 1 if spec is a valid subimage string,
956 * addr and image_name are set accordingly
959 inline int fit_parse_subimage (const char *spec, ulong addr_curr,
960 ulong *addr, const char **image_name)
962 return fit_parse_spec (spec, ':', addr_curr, addr, image_name);
965 #endif /* CONFIG_FIT */
967 #endif /* USE_HOSTCC */