static int splash_load_raw(struct splash_location *location, u32 bmp_load_addr) { struct bmp_header *bmp_hdr; int res; size_t bmp_size, bmp_header_size = sizeof(struct bmp_header); if (bmp_load_addr + bmp_header_size >= gd->start_addr_sp) goto splash_address_too_high; res = splash_storage_read_raw(location, bmp_load_addr, bmp_header_size); if (res < 0) return res; bmp_hdr = (struct bmp_header *)bmp_load_addr; bmp_size = le32_to_cpu(bmp_hdr->file_size); if (bmp_load_addr + bmp_size >= gd->start_addr_sp) goto splash_address_too_high; return splash_storage_read_raw(location, bmp_load_addr, bmp_size); splash_address_too_high: printf("Error: splashimage address too high. Data overwrites U-Boot and/or placed beyond DRAM boundaries.\n"); return -EFAULT; }
static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr) { int res; int node_offset; int splash_offset; int splash_size; struct image_header *img_header; const u32 *fit_header; u32 fit_size; const size_t header_size = sizeof(struct image_header); /* Read in image header */ res = splash_storage_read_raw(location, bmp_load_addr, header_size); if (res < 0) return res; img_header = (struct image_header *)bmp_load_addr; fit_size = fdt_totalsize(img_header); /* Read in entire FIT */ fit_header = (const u32 *)(bmp_load_addr + header_size); res = splash_storage_read_raw(location, (u32)fit_header, fit_size); if (res < 0) return res; res = fit_check_format(fit_header); if (!res) { debug("Could not find valid FIT image\n"); return -EINVAL; } node_offset = fit_image_get_node(fit_header, location->name); if (node_offset < 0) { debug("Could not find splash image '%s' in FIT\n", location->name); return -ENOENT; } res = fit_image_get_data_offset(fit_header, node_offset, &splash_offset); if (res < 0) { printf("Failed to load splash image (err=%d)\n", res); return res; } res = fit_image_get_data_size(fit_header, node_offset, &splash_size); if (res < 0) { printf("Failed to load splash image (err=%d)\n", res); return res; } /* Align data offset to 4-byte boundrary */ fit_size = fdt_totalsize(fit_header); fit_size = (fit_size + 3) & ~3; /* Read in the splash data */ location->offset = (location->offset + fit_size + splash_offset); res = splash_storage_read_raw(location, bmp_load_addr , splash_size); if (res < 0) return res; return 0; }