]> Git Repo - u-boot.git/blobdiff - boot/image-board.c
Merge tag 'v2024.07-rc5' into next
[u-boot.git] / boot / image-board.c
index d500da1b4b918288a1f3f006028ddd4ef8717f6d..f212401304648ad37a8744a4caf06b50271f2ea6 100644 (file)
@@ -8,7 +8,7 @@
  * Wolfgang Denk, DENX Software Engineering, [email protected].
  */
 
-#include <common.h>
+#include <config.h>
 #include <bootstage.h>
 #include <cpu_func.h>
 #include <display_options.h>
@@ -107,14 +107,12 @@ static int on_loadaddr(const char *name, const char *value, enum env_op op,
 }
 U_BOOT_ENV_CALLBACK(loadaddr, on_loadaddr);
 
-ulong env_get_bootm_low(void)
+phys_addr_t env_get_bootm_low(void)
 {
        char *s = env_get("bootm_low");
 
-       if (s) {
-               ulong tmp = hextoul(s, NULL);
-               return tmp;
-       }
+       if (s)
+               return simple_strtoull(s, NULL, 16);
 
 #if defined(CFG_SYS_SDRAM_BASE)
        return CFG_SYS_SDRAM_BASE;
@@ -127,14 +125,12 @@ ulong env_get_bootm_low(void)
 
 phys_size_t env_get_bootm_size(void)
 {
-       phys_size_t tmp, size;
-       phys_addr_t start;
+       phys_addr_t start, low;
+       phys_size_t size;
        char *s = env_get("bootm_size");
 
-       if (s) {
-               tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
-               return tmp;
-       }
+       if (s)
+               return simple_strtoull(s, NULL, 16);
 
        start = gd->ram_base;
        size = gd->ram_size;
@@ -144,22 +140,19 @@ phys_size_t env_get_bootm_size(void)
 
        s = env_get("bootm_low");
        if (s)
-               tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
+               low = simple_strtoull(s, NULL, 16);
        else
-               tmp = start;
+               low = start;
 
-       return size - (tmp - start);
+       return size - (low - start);
 }
 
 phys_size_t env_get_bootm_mapsize(void)
 {
-       phys_size_t tmp;
        char *s = env_get("bootm_mapsize");
 
-       if (s) {
-               tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
-               return tmp;
-       }
+       if (s)
+               return simple_strtoull(s, NULL, 16);
 
 #if defined(CFG_SYS_BOOTMAPSZ)
        return CFG_SYS_BOOTMAPSZ;
@@ -198,22 +191,7 @@ void memmove_wd(void *to, void *from, size_t len, ulong chunksz)
        }
 }
 
-/**
- * genimg_get_kernel_addr_fit - get the real kernel address and return 2
- *                              FIT strings
- * @img_addr: a string might contain real image address
- * @fit_uname_config: double pointer to a char, will hold pointer to a
- *                    configuration unit name
- * @fit_uname_kernel: double pointer to a char, will hold pointer to a subimage
- *                    name
- *
- * genimg_get_kernel_addr_fit get the real kernel start address from a string
- * which is normally the first argv of bootm/bootz
- *
- * returns:
- *     kernel start address
- */
-ulong genimg_get_kernel_addr_fit(char * const img_addr,
+ulong genimg_get_kernel_addr_fit(const char *const img_addr,
                                 const char **fit_uname_config,
                                 const char **fit_uname_kernel)
 {
@@ -428,13 +406,20 @@ static int select_ramdisk(struct bootm_headers *images, const char *select, u8 a
                if (IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE)) {
                        int ret;
                        if (IS_ENABLED(CONFIG_CMD_ABOOTIMG)) {
-                               void *boot_img = map_sysmem(get_abootimg_addr(), 0);
+                               ulong boot_img = get_abootimg_addr();
+                               ulong init_boot_img = get_ainit_bootimg_addr();
                                void *vendor_boot_img = map_sysmem(get_avendor_bootimg_addr(), 0);
+                               void *ramdisk_img;
 
-                               ret = android_image_get_ramdisk(boot_img, vendor_boot_img,
+                               if (init_boot_img == -1)
+                                       ramdisk_img = map_sysmem(boot_img, 0);
+                               else
+                                       ramdisk_img = map_sysmem(init_boot_img, 0);
+
+                               ret = android_image_get_ramdisk(ramdisk_img, vendor_boot_img,
                                                                rd_datap, rd_lenp);
                                unmap_sysmem(vendor_boot_img);
-                               unmap_sysmem(boot_img);
+                               unmap_sysmem(ramdisk_img);
                        } else {
                                void *ptr = map_sysmem(images->os.start, 0);
 
@@ -471,49 +456,14 @@ static int select_ramdisk(struct bootm_headers *images, const char *select, u8 a
        return 0;
 }
 
-/**
- * boot_get_ramdisk - main ramdisk handling routine
- * @argc: command argument count
- * @argv: command argument list
- * @images: pointer to the bootm images structure
- * @arch: expected ramdisk architecture
- * @rd_start: pointer to a ulong variable, will hold ramdisk start address
- * @rd_end: pointer to a ulong variable, will hold ramdisk end
- *
- * boot_get_ramdisk() is responsible for finding a valid ramdisk image.
- * Currently supported are the following ramdisk sources:
- *      - multicomponent kernel/ramdisk image,
- *      - commandline provided address of decicated ramdisk image.
- *
- * returns:
- *     0, if ramdisk image was found and valid, or skiped
- *     rd_start and rd_end are set to ramdisk start/end addresses if
- *     ramdisk image is found and valid
- *
- *     1, if ramdisk image is found but corrupted, or invalid
- *     rd_start and rd_end are set to 0 if no ramdisk exists
- */
-int boot_get_ramdisk(int argc, char *const argv[], struct bootm_headers *images,
-                    u8 arch, ulong *rd_start, ulong *rd_end)
+int boot_get_ramdisk(char const *select, struct bootm_headers *images,
+                    uint arch, ulong *rd_start, ulong *rd_end)
 {
        ulong rd_data, rd_len;
-       const char *select = NULL;
 
        *rd_start = 0;
        *rd_end = 0;
 
-       if (IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE)) {
-               char *buf;
-
-               /* Look for an Android boot image */
-               buf = map_sysmem(images->os.start, 0);
-               if (buf && genimg_get_format(buf) == IMAGE_FORMAT_ANDROID)
-                       select = (argc == 0) ? env_get("loadaddr") : argv[0];
-       }
-
-       if (argc >= 2)
-               select = argv[1];
-
        /*
         * Look for a '-' which indicates to ignore the
         * ramdisk argument
@@ -588,7 +538,7 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
                      ulong *initrd_start, ulong *initrd_end)
 {
        char    *s;
-       ulong   initrd_high;
+       phys_addr_t initrd_high;
        int     initrd_copy_to_ram = 1;
 
        s = env_get("initrd_high");
@@ -603,8 +553,8 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
                initrd_high = env_get_bootm_mapsize() + env_get_bootm_low();
        }
 
-       debug("## initrd_high = 0x%08lx, copy_to_ram = %d\n",
-             initrd_high, initrd_copy_to_ram);
+       debug("## initrd_high = 0x%llx, copy_to_ram = %d\n",
+             (u64)initrd_high, initrd_copy_to_ram);
 
        if (rd_data) {
                if (!initrd_copy_to_ram) {      /* zero-copy ramdisk support */
@@ -666,8 +616,7 @@ int boot_get_setup(struct bootm_headers *images, u8 arch,
        return boot_get_setup_fit(images, arch, setup_start, setup_len);
 }
 
-int boot_get_fpga(int argc, char *const argv[], struct bootm_headers *images,
-                 u8 arch, const ulong *ld_start, ulong * const ld_len)
+int boot_get_fpga(struct bootm_headers *images)
 {
        ulong tmp_img_addr, img_data, img_len;
        void *buf;
@@ -709,7 +658,7 @@ int boot_get_fpga(int argc, char *const argv[], struct bootm_headers *images,
                                                tmp_img_addr,
                                                (const char **)&uname,
                                                &images->fit_uname_cfg,
-                                               arch,
+                                               IH_ARCH_DEFAULT,
                                                IH_TYPE_FPGA,
                                                BOOTSTAGE_ID_FPGA_INIT,
                                                FIT_LOAD_OPTIONAL_NON_ZERO,
@@ -769,8 +718,7 @@ static void fit_loadable_process(u8 img_type,
                        fit_loadable_handler->handler(img_data, img_len);
 }
 
-int boot_get_loadable(int argc, char *const argv[], struct bootm_headers *images,
-                     u8 arch, const ulong *ld_start, ulong * const ld_len)
+int boot_get_loadable(struct bootm_headers *images)
 {
        /*
         * These variables are used to hold the current image location
@@ -816,7 +764,8 @@ int boot_get_loadable(int argc, char *const argv[], struct bootm_headers *images
                        fit_img_result = fit_image_load(images, tmp_img_addr,
                                                        &uname,
                                                        &images->fit_uname_cfg,
-                                                       arch, IH_TYPE_LOADABLE,
+                                                       IH_ARCH_DEFAULT,
+                                                       IH_TYPE_LOADABLE,
                                                        BOOTSTAGE_ID_FIT_LOADABLE_START,
                                                        FIT_LOAD_OPTIONAL_NON_ZERO,
                                                        &img_data, &img_len);
@@ -959,7 +908,7 @@ int image_setup_linux(struct bootm_headers *images)
        }
 
        if (CONFIG_IS_ENABLED(OF_LIBFDT) && of_size) {
-               ret = image_setup_libfdt(images, *of_flat_tree, of_size, lmb);
+               ret = image_setup_libfdt(images, *of_flat_tree, lmb);
                if (ret)
                        return ret;
        }
This page took 0.030419 seconds and 4 git commands to generate.