Commit 0f64140b69ecf18f488164739374ca13aa0a5517
Committed by
Tom Rini
1 parent
68dc8769e3
Exists in
v2017.01-smarct4x
and in
37 other branches
image: introduce genimg_get_kernel_addr()
Kernel address is normally stored as a string argument of bootm or bootz. This function is taken out from boot_get_kernel() of bootm.c, which can be reused by others. Signed-off-by: Bryan Wu <pengw@nvidia.com> [trini: Fix warnings with CONFIG_FIT] Signed-off-by: Tom Rini <trini@ti.com>
Showing 2 changed files with 44 additions and 0 deletions Side-by-side Diff
common/image.c
... | ... | @@ -643,6 +643,49 @@ |
643 | 643 | |
644 | 644 | #ifndef USE_HOSTCC |
645 | 645 | /** |
646 | + * genimg_get_kernel_addr - get the real kernel address | |
647 | + * @img_addr: a string might contain real image address | |
648 | + * | |
649 | + * genimg_get_kernel_addr() get the real kernel start address from a string | |
650 | + * which is normally the first argv of bootm/bootz | |
651 | + * | |
652 | + * returns: | |
653 | + * kernel start address | |
654 | + */ | |
655 | +ulong genimg_get_kernel_addr(char * const img_addr) | |
656 | +{ | |
657 | +#if defined(CONFIG_FIT) | |
658 | + const char *fit_uname_config = NULL; | |
659 | + const char *fit_uname_kernel = NULL; | |
660 | +#endif | |
661 | + | |
662 | + ulong kernel_addr; | |
663 | + | |
664 | + /* find out kernel image address */ | |
665 | + if (!img_addr) { | |
666 | + kernel_addr = load_addr; | |
667 | + debug("* kernel: default image load address = 0x%08lx\n", | |
668 | + load_addr); | |
669 | +#if defined(CONFIG_FIT) | |
670 | + } else if (fit_parse_conf(img_addr, load_addr, &kernel_addr, | |
671 | + &fit_uname_config)) { | |
672 | + debug("* kernel: config '%s' from image at 0x%08lx\n", | |
673 | + fit_uname_config, kernel_addr); | |
674 | + } else if (fit_parse_subimage(img_addr, load_addr, &kernel_addr, | |
675 | + &fit_uname_kernel)) { | |
676 | + debug("* kernel: subimage '%s' from image at 0x%08lx\n", | |
677 | + fit_uname_kernel, kernel_addr); | |
678 | +#endif | |
679 | + } else { | |
680 | + kernel_addr = simple_strtoul(img_addr, NULL, 16); | |
681 | + debug("* kernel: cmdline image address = 0x%08lx\n", | |
682 | + kernel_addr); | |
683 | + } | |
684 | + | |
685 | + return kernel_addr; | |
686 | +} | |
687 | + | |
688 | +/** | |
646 | 689 | * genimg_get_format - get image format type |
647 | 690 | * @img_addr: image start address |
648 | 691 | * |
include/image.h
... | ... | @@ -424,6 +424,7 @@ |
424 | 424 | #define IMAGE_FORMAT_FIT 0x02 /* new, libfdt based format */ |
425 | 425 | #define IMAGE_FORMAT_ANDROID 0x03 /* Android boot image */ |
426 | 426 | |
427 | +ulong genimg_get_kernel_addr(char * const img_addr); | |
427 | 428 | int genimg_get_format(const void *img_addr); |
428 | 429 | int genimg_has_config(bootm_headers_t *images); |
429 | 430 | ulong genimg_get_image(ulong img_addr); |