int spl_load_simple_fit_ex(struct spl_image_info *spl_image, struct spl_load_info *info, ulong sector, void *fit, void *load_only_addr) { printf("spl_load_simple_fit_ex: init: %x\n", *(int*)0x8086a4ec); int sectors; ulong size; unsigned long count; struct spl_image_info image_info; int node = -1; int images, ret; int base_offset, hsize, align_len = ARCH_DMA_MINALIGN - 1; int index = 0; /* * For FIT with external data, figure out where the external images * start. This is the base for the data-offset properties in each * image. */ size = fdt_totalsize(fit); size = (size + 3) & ~3; size = board_spl_fit_size_align(size); base_offset = (size + 3) & ~3; /* * So far we only have one block of data from the FIT. Read the entire * thing, including that first block, placing it so it finishes before * where we will load the image. * * Note that we will load the image such that its first byte will be * at the load address. Since that byte may be part-way through a * block, we may load the image up to one block before the load * address. So take account of that here by subtracting an addition * block length from the FIT start position. * * In fact the FIT has its own load address, but we assume it cannot * be before CONFIG_SYS_TEXT_BASE. * * For FIT with data embedded, data is loaded as part of FIT image. * For FIT with external data, data is not loaded in this step. */ /* * If load_only_addr is set this means we are operating in "loader * mode", in which we a) force a specific destination address, and b) * skip the standard post-loading image processing steps. */ if (load_only_addr) { fit = load_only_addr; } else { hsize = (size + info->bl_len + align_len) & ~align_len; fit = spl_get_load_buffer(-hsize, hsize); } printf("spl_load_simple_fit_ex: load_only_addr: %x\n", *(int*)0x8086a4ec); sectors = get_aligned_image_size(info, size, 0); count = info->read(info, sector, sectors, fit); debug("fit read sector %lx, sectors=%d, dst=%p, count=%lu, size=0x%lx\n", sector, sectors, fit, count, size); printf("spl_load_simple_fit_ex: info->read: %x\n", *(int*)0x8086a4ec); if (count == 0) return -EIO; /* * Perform early successful exit if we are in "loader mode", meaning * extracting the (U-Boot) image is not desired. */ if (load_only_addr) return 0; /* find the node holding the images information */ images = fdt_path_offset(fit, FIT_IMAGES_PATH); if (images < 0) { debug("%s: Cannot find /images node: %d\n", __func__, images); return -1; } #ifdef CONFIG_SPL_FPGA_SUPPORT node = spl_fit_get_image_node(fit, images, "fpga", 0); printf("spl_load_simple_fit_ex: spl_fit_get_image_node: %x\n", *(int*)0x8086a4ec); if (node >= 0) { /* Load the image and set up the spl_image structure */ ret = spl_load_fit_image(info, sector, fit, base_offset, node, spl_image); printf("spl_load_simple_fit_ex: spl_load_fit_image(fpga): %x\n", *(int*)0x8086a4ec); if (ret) { printf("%s: Cannot load the FPGA: %i\n", __func__, ret); return ret; } debug("FPGA bitstream at: %x, size: %x\n", (u32)spl_image->load_addr, spl_image->size); ret = fpga_load(0, (const void *)spl_image->load_addr, spl_image->size, BIT_FULL); if (ret) { printf("%s: Cannot load the image to the FPGA\n", __func__); return ret; } puts("FPGA image loaded from FIT\n"); node = -1; } #endif /* * Find the U-Boot image using the following search order: * - start at 'firmware' (e.g. an ARM Trusted Firmware) * - fall back 'kernel' (e.g. a Falcon-mode OS boot * - fall back to using the first 'loadables' entry */ if (node < 0) node = spl_fit_get_image_node(fit, images, FIT_FIRMWARE_PROP, 0); #ifdef CONFIG_SPL_OS_BOOT printf("spl_load_simple_fit_ex: CONFIG_SPL_OS_BOOT: %x\n", *(int*)0x8086a4ec); if (node < 0) node = spl_fit_get_image_node(fit, images, FIT_KERNEL_PROP, 0); printf("spl_load_simple_fit_ex: spl_fit_get_image_node(FIT_KERNEL_PROP): %x\n", *(int*)0x8086a4ec); #endif if (node < 0) { debug("could not find firmware image, trying loadables...\n"); node = spl_fit_get_image_node(fit, images, "loadables", 0); printf("spl_load_simple_fit_ex: spl_fit_get_image_node(loadables): %x\n", *(int*)0x8086a4ec); /* * If we pick the U-Boot image from "loadables", start at * the second image when later loading additional images. */ index = 1; } if (node < 0) { debug("%s: Cannot find u-boot image node: %d\n", __func__, node); return -1; } /* Load the image and set up the spl_image structure */ ret = spl_load_fit_image(info, sector, fit, base_offset, node, spl_image); printf("spl_load_simple_fit_ex: spl_load_fit_image: %x\n", *(int*)0x8086a4ec); if (ret) return ret; /* * For backward compatibility, we treat the first node that is * as a U-Boot image, if no OS-type has been declared. */ if (!spl_fit_image_get_os(fit, node, &spl_image->os)){ debug("Image OS is %s\n", genimg_get_os_name(spl_image->os)); printf("spl_load_simple_fit_ex: spl_fit_image_get_os: %x\n", *(int*)0x8086a4ec); } #if !defined(CONFIG_SPL_OS_BOOT) else spl_image->os = IH_OS_U_BOOT; #endif /* * Booting a next-stage U-Boot may require us to append the FDT. * We allow this to fail, as the U-Boot image might embed its FDT. */ printf("spl_load_simple_fit_ex: spl_image->os: %d\n", spl_image->os); if (spl_image->os == IH_OS_U_BOOT){ spl_fit_append_fdt(spl_image, info, sector, fit, images, base_offset); printf("spl_load_simple_fit_ex: spl_fit_append_fdt: %x\n", *(int*)0x8086a4ec); } /* Now check if there are more images for us to load */ for (; ; index++) { uint8_t os_type = IH_OS_INVALID; node = spl_fit_get_image_node(fit, images, "loadables", index); if (node < 0) break; ret = spl_load_fit_image(info, sector, fit, base_offset, node, &image_info); if (ret < 0) continue; if (!spl_fit_image_get_os(fit, node, &os_type)) debug("Loadable is %s\n", genimg_get_os_name(os_type)); if (os_type == IH_OS_U_BOOT) { spl_fit_append_fdt(&image_info, info, sector, fit, images, base_offset); spl_image->fdt_addr = image_info.fdt_addr; } /* * If the "firmware" image did not provide an entry point, * use the first valid entry point from the loadables. */ if (spl_image->entry_point == FDT_ERROR && image_info.entry_point != FDT_ERROR) spl_image->entry_point = image_info.entry_point; /* Record our loadables into the FDT */ if (spl_image->fdt_addr) spl_fit_record_loadable(fit, images, index, spl_image->fdt_addr, &image_info); } /* * If a platform does not provide CONFIG_SYS_UBOOT_START, U-Boot's * Makefile will set it to 0 and it will end up as the entry point * here. What it actually means is: use the load address. */ if (spl_image->entry_point == FDT_ERROR || spl_image->entry_point == 0) spl_image->entry_point = spl_image->load_addr; spl_image->flags |= SPL_FIT_FOUND; #ifdef CONFIG_SECURE_BOOT board_spl_fit_post_load((ulong)fit, size); #endif return 0; }