static int spl_fit_append_fdt(struct spl_image_info *spl_image, struct spl_load_info *info, ulong sector, void *fit, int images, ulong base_offset) { printf("spl_fit_append_fdt: init: %x\n", *(int*)0x8086a4ec); struct spl_image_info image_info; int node, ret, index = 0; /* Figure out which device tree the board wants to use */ node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, index++); if (node < 0) { debug("%s: cannot find FDT node\n", __func__); return node; } /* * Read the device tree and place it after the image. * Align the destination address to ARCH_DMA_MINALIGN. */ image_info.load_addr = spl_image->load_addr + spl_image->size; ret = spl_load_fit_image(info, sector, fit, base_offset, node, &image_info); if (ret < 0) return ret; /* Make the load-address of the FDT available for the SPL framework */ spl_image->fdt_addr = (void *)image_info.load_addr; #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY) #if defined(CONFIG_OF_LIBFDT_OVERLAY) void *tmpbuffer; /* * allocate 64kB of memory. This will be used to store the DT overlay * before it is applied. It may not be used depending on how the * overlay is stored. */ tmpbuffer = malloc(64 * 1024); if (!tmpbuffer) debug("%s: unable to allocate space for overlays\n", __func__); for (; ; index++) { node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, index); if (node == -E2BIG) { debug("%s: No additional FDT node\n", __func__); return 0; } else if (node < 0) { debug("%s: unable to find FDT node %d\n", __func__, index); continue; } image_info.load_addr = (ulong) tmpbuffer; ret = spl_load_fit_image(info, sector, fit, base_offset, node, &image_info); if (ret < 0) return ret; /* Make room in FDT for changes coming from the overlay */ ret = fdt_increase_size(spl_image->fdt_addr, image_info.size); if (ret < 0) return ret; ret = fdt_overlay_apply_verbose(spl_image->fdt_addr, (void *)image_info.load_addr); if (ret) { pr_err("failed to apply DT overlay %s\n", fit_get_name(fit, node, NULL)); return ret; } debug("%s: DT overlay %s applied\n", __func__, fit_get_name(fit, node, NULL)); } if (tmpbuffer) free(tmpbuffer); #endif /* Try to make space, so we can inject details on the loadables */ ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192); if (ret < 0) return ret; #endif return ret; }