void spl_parse_image_header(const struct image_header *header) { u32 header_size = sizeof(struct image_header); if (image_get_magic(header) == IH_MAGIC) { if (spl_image.flags & SPL_COPY_PAYLOAD_ONLY) { /* * On some system (e.g. powerpc), the load-address and * entry-point is located at address 0. We can't load * to 0-0x40. So skip header in this case. */ spl_image.load_addr = image_get_load(header); spl_image.entry_point = image_get_ep(header); spl_image.size = image_get_data_size(header); } else { spl_image.entry_point = image_get_load(header); /* Load including the header */ spl_image.load_addr = spl_image.entry_point - header_size; spl_image.size = image_get_data_size(header) + header_size; } spl_image.os = image_get_os(header); spl_image.name = image_get_name(header); debug("spl: payload image: %.*s load addr: 0x%x size: %d\n", (int)sizeof(spl_image.name), spl_image.name, spl_image.load_addr, spl_image.size); } else { /* Signature not found - assume u-boot.bin */ debug("mkimage signature not found - ih_magic = %x\n", header->ih_magic); spl_set_header_raw_uboot(); } }
int image_check_header(image_header_t *hdr, const char *name) { if (image_check_magic(hdr) && (!strncmp(image_get_name(hdr), name, strlen(name))) && image_check_hcrc(hdr)) { return 1; } return 0; }
int spl_parse_image_header(const struct image_header *header) { u32 header_size = sizeof(struct image_header); if (image_get_magic(header) == IH_MAGIC) { if (spl_image.flags & SPL_COPY_PAYLOAD_ONLY) { /* * On some system (e.g. powerpc), the load-address and * entry-point is located at address 0. We can't load * to 0-0x40. So skip header in this case. */ spl_image.load_addr = image_get_load(header); spl_image.entry_point = image_get_ep(header); spl_image.size = image_get_data_size(header); } else { spl_image.entry_point = image_get_load(header); /* Load including the header */ spl_image.load_addr = spl_image.entry_point - header_size; spl_image.size = image_get_data_size(header) + header_size; } spl_image.os = image_get_os(header); spl_image.name = image_get_name(header); debug("spl: payload image: %.*s load addr: 0x%x size: %d\n", (int)sizeof(spl_image.name), spl_image.name, spl_image.load_addr, spl_image.size); } else { #ifdef CONFIG_SPL_PANIC_ON_RAW_IMAGE /* * CONFIG_SPL_PANIC_ON_RAW_IMAGE is defined when the * code which loads images in SPL cannot guarantee that * absolutely all read errors will be reported. * An example is the LPC32XX MLC NAND driver, which * will consider that a completely unreadable NAND block * is bad, and thus should be skipped silently. */ panic("** no mkimage signature but raw image not supported"); #elif defined(CONFIG_SPL_ABORT_ON_RAW_IMAGE) /* Signature not found, proceed to other boot methods. */ return -EINVAL; #else /* Signature not found - assume u-boot.bin */ debug("mkimage signature not found - ih_magic = %x\n", header->ih_magic); spl_set_header_raw_uboot(); #endif } return 0; }
void image_print_contents(const void *ptr) { const image_header_t *hdr = (const image_header_t *)ptr; const char *p; #ifdef __BAREBOX__ p = " "; #else p = ""; #endif printf("%sImage Name: %.*s\n", p, IH_NMLEN, image_get_name(hdr)); #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || !defined(__BAREBOX__) printf("%sCreated: ", p); image_print_time((time_t)image_get_time(hdr)); #endif printf ("%sImage Type: ", p); image_print_type(hdr); printf ("%sData Size: ", p); image_print_size(image_get_data_size(hdr)); printf ("%sLoad Address: %08x\n", p, image_get_load(hdr)); printf ("%sEntry Point: %08x\n", p, image_get_ep(hdr)); if (image_check_type(hdr, IH_TYPE_MULTI) || image_check_type(hdr, IH_TYPE_SCRIPT)) { int i; ulong data, len; ulong count = image_multi_count(hdr); printf ("%sContents:\n", p); for (i = 0; i < count; i++) { image_multi_getimg(hdr, i, &data, &len); printf("%s Image %d: ", p, i); image_print_size(len); if (image_check_type(hdr, IH_TYPE_SCRIPT) && i > 0) { /* * the user may need to know offsets * if planning to do something with * multiple files */ printf("%s Offset = 0x%08lx\n", p, data); } } } }
/** * image_print_contents - prints out the contents of the legacy format image * @ptr: pointer to the legacy format image header * @p: pointer to prefix string * * image_print_contents() formats a multi line legacy image contents description. * The routine prints out all header fields followed by the size/offset data * for MULTI/SCRIPT images. * * returns: * no returned results */ void image_print_contents(const void *ptr) { const image_header_t *hdr = (const image_header_t *)ptr; const char __maybe_unused *p; p = IMAGE_INDENT_STRING; printf("%sImage Name: %.*s\n", p, IH_NMLEN, image_get_name(hdr)); if (IMAGE_ENABLE_TIMESTAMP) { printf("%sCreated: ", p); genimg_print_time((time_t)image_get_time(hdr)); } printf("%sImage Type: ", p); image_print_type(hdr); printf("%sData Size: ", p); genimg_print_size(image_get_data_size(hdr)); printf("%sLoad Address: %08x\n", p, image_get_load(hdr)); printf("%sEntry Point: %08x\n", p, image_get_ep(hdr)); if (image_check_type(hdr, IH_TYPE_MULTI) || image_check_type(hdr, IH_TYPE_SCRIPT)) { int i; ulong data, len; ulong count = image_multi_count(hdr); printf("%sContents:\n", p); for (i = 0; i < count; i++) { image_multi_getimg(hdr, i, &data, &len); printf("%s Image %d: ", p, i); genimg_print_size(len); if (image_check_type(hdr, IH_TYPE_SCRIPT) && i > 0) { /* * the user may need to know offsets * if planning to do something with * multiple files */ printf("%s Offset = 0x%08lx\n", p, data); } } } else if (image_check_type(hdr, IH_TYPE_FIRMWARE_IVT)) { printf("HAB Blocks: 0x%08x 0x0000 0x%08x\n", image_get_load(hdr) - image_get_header_size(), image_get_size(hdr) + image_get_header_size() - 0x1FE0); } }
void spl_parse_image_header(const struct image_header *header) { u32 header_size = sizeof(struct image_header); if (image_get_magic(header) == IH_MAGIC) { if (spl_image.flags & SPL_COPY_PAYLOAD_ONLY) { /* * On some system (e.g. powerpc), the load-address and * entry-point is located at address 0. We can't load * to 0-0x40. So skip header in this case. */ spl_image.load_addr = image_get_load(header); spl_image.entry_point = image_get_ep(header); spl_image.size = image_get_data_size(header); } else { spl_image.entry_point = image_get_load(header); /* Load including the header */ spl_image.load_addr = spl_image.entry_point - header_size; spl_image.size = image_get_data_size(header) + header_size; } spl_image.os = image_get_os(header); spl_image.name = image_get_name(header); spl_image.crc = image_get_dcrc(header); spl_image.crc_size = image_get_data_size(header); debug("spl: payload image: %s load addr: 0x%x size: %d\n", spl_image.name, spl_image.load_addr, spl_image.size); } else { /* Signature not found - assume u-boot.bin */ debug("mkimage signature not found - ih_magic = %x\n", header->ih_magic); /* Let's assume U-Boot will not be more than 200 KB */ spl_image.size = CONFIG_SYS_MONITOR_LEN; spl_image.entry_point = CONFIG_SYS_UBOOT_START; spl_image.load_addr = CONFIG_SYS_TEXT_BASE; spl_image.os = IH_OS_U_BOOT; spl_image.name = "U-Boot"; spl_image.crc_size = 0; } }
int spl_parse_image_header(struct spl_image_info *spl_image, const struct image_header *header) { if (image_get_magic(header) == IH_MAGIC) { #ifdef CONFIG_SPL_LEGACY_IMAGE_SUPPORT u32 header_size = sizeof(struct image_header); if (spl_image->flags & SPL_COPY_PAYLOAD_ONLY) { /* * On some system (e.g. powerpc), the load-address and * entry-point is located at address 0. We can't load * to 0-0x40. So skip header in this case. */ spl_image->load_addr = image_get_load(header); spl_image->entry_point = image_get_ep(header); spl_image->size = image_get_data_size(header); } else { spl_image->entry_point = image_get_load(header); /* Load including the header */ spl_image->load_addr = spl_image->entry_point - header_size; spl_image->size = image_get_data_size(header) + header_size; } spl_image->os = image_get_os(header); spl_image->name = image_get_name(header); debug("spl: payload image: %.*s load addr: 0x%lx size: %d\n", (int)sizeof(spl_image->name), spl_image->name, spl_image->load_addr, spl_image->size); #else /* LEGACY image not supported */ debug("Legacy boot image support not enabled, proceeding to other boot methods"); return -EINVAL; #endif } else { #ifdef CONFIG_SPL_PANIC_ON_RAW_IMAGE /* * CONFIG_SPL_PANIC_ON_RAW_IMAGE is defined when the * code which loads images in SPL cannot guarantee that * absolutely all read errors will be reported. * An example is the LPC32XX MLC NAND driver, which * will consider that a completely unreadable NAND block * is bad, and thus should be skipped silently. */ panic("** no mkimage signature but raw image not supported"); #endif #ifdef CONFIG_SPL_OS_BOOT ulong start, end; if (!bootz_setup((ulong)header, &start, &end)) { spl_image->name = "Linux"; spl_image->os = IH_OS_LINUX; spl_image->load_addr = CONFIG_SYS_LOAD_ADDR; spl_image->entry_point = CONFIG_SYS_LOAD_ADDR; spl_image->size = end - start; debug("spl: payload zImage, load addr: 0x%lx size: %d\n", spl_image->load_addr, spl_image->size); return 0; } #endif #ifdef CONFIG_SPL_RAW_IMAGE_SUPPORT /* Signature not found - assume u-boot.bin */ debug("mkimage signature not found - ih_magic = %x\n", header->ih_magic); spl_set_header_raw_uboot(spl_image); #else /* RAW image not supported, proceed to other boot methods. */ debug("Raw boot image support not enabled, proceeding to other boot methods"); return -EINVAL; #endif } return 0; }
static GdkPixbuf *image_osd_info_render(ImageWindow *imd) { GdkPixbuf *pixbuf; gint width, height; PangoLayout *layout; const gchar *name; gchar *name_escaped; gchar *text; gchar *size; gint n, t; CollectionData *cd; CollectInfo *info; gchar *ct; name = image_get_name(imd); if (name) { name_escaped = g_markup_escape_text(name, -1); } else { name_escaped = NULL; } cd = image_get_collection(imd, &info); if (cd) { gchar *buf; t = g_list_length(cd->list); n = g_list_index(cd->list, info) + 1; buf = g_markup_escape_text((cd->name) ? cd->name : _("Untitled"), -1); ct = g_strdup_printf("<i>%s</i>\n", buf); g_free(buf); } else { LayoutWindow *lw; lw = layout_find_by_image(imd); if (lw) { if (lw->slideshow) { n = g_list_length(lw->slideshow->list_done); t = n + g_list_length(lw->slideshow->list); if (n == 0) n = t; } else { t = layout_list_count(lw, NULL); n = layout_list_get_index(lw, image_get_path(lw->image)) + 1; } } else if (view_window_find_image(imd, &n, &t)) { n++; } else { t = 1; n = 1; } if (n < 1) n = 1; if (t < 1) t = 1; ct = g_strdup(""); } size = text_from_size_abrev(imd->size); if (!name_escaped) { text = g_strdup_printf(_("Untitled")); } else if (imd->unknown) { text = g_strdup_printf("%s(%d/%d) <b>%s</b>\n%s - %s", ct, n, t, name_escaped, text_from_time(imd->mtime), size); } else { gint w, h; if (imd->delay_flip && imd->il && imd->il->pixbuf && image_get_pixbuf(imd) != imd->il->pixbuf) { w = gdk_pixbuf_get_width(imd->il->pixbuf); h = gdk_pixbuf_get_height(imd->il->pixbuf); } else { pixbuf_renderer_get_image_size(PIXBUF_RENDERER(imd->pr), &w, &h); } text = g_strdup_printf("%s(%d/%d) <b>%s</b>\n%d x %d - %s - %s", ct, n, t, name_escaped, w, h, text_from_time(imd->mtime), size); } g_free(size); g_free(ct); g_free(name_escaped); layout = gtk_widget_create_pango_layout(imd->pr, NULL); pango_layout_set_markup(layout, text, -1); g_free(text); pango_layout_get_pixel_size(layout, &width, &height); width += 10; height += 10; pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); pixbuf_set_rect_fill(pixbuf, 3, 3, width-6, height-6, 240, 240, 240, 210); pixbuf_set_rect(pixbuf, 0, 0, width, height, 240, 240, 240, 80, 1, 1, 1, 1); pixbuf_set_rect(pixbuf, 1, 1, width-2, height-2, 240, 240, 240, 130, 1, 1, 1, 1); pixbuf_set_rect(pixbuf, 2, 2, width-4, height-4, 240, 240, 240, 180, 1, 1, 1, 1); pixbuf_pixel_set(pixbuf, 0, 0, 0, 0, 0, 0); pixbuf_pixel_set(pixbuf, width - 1, 0, 0, 0, 0, 0); pixbuf_pixel_set(pixbuf, 0, height - 1, 0, 0, 0, 0); pixbuf_pixel_set(pixbuf, width - 1, height - 1, 0, 0, 0, 0); pixbuf_draw_layout(pixbuf, layout, imd->pr, 5, 5, 0, 0, 0, 255); g_object_unref(G_OBJECT(layout)); return pixbuf; }
int fpga_init (void) { ulong addr; ulong new_id, old_id = 0; image_header_t *hdr; fpga_t* fpga; int do_load, i, j; char name[16], *s; /* * Port setup for FPGA control */ for (i = 0; i < fpga_count; i++) { fpga_control(&fpga_list[i], FPGA_INIT_PORTS); } /* * Load FPGA(s): a new net-list is loaded if the FPGA is * empty, Power-on-Reset or the old one is not up-to-date */ for (i = 0; i < fpga_count; i++) { fpga = &fpga_list[i]; printf ("%s: ", fpga->name); for (j = 0; j < strlen(fpga->name); j++) name[j] = tolower(fpga->name[j]); name[j] = '\0'; sprintf(name, "%s_addr", name); addr = 0; if ((s = getenv(name)) != NULL) addr = simple_strtoul(s, NULL, 16); if (!addr) { printf ("env. variable %s undefined\n", name); return 1; } hdr = (image_header_t *)addr; #if defined(CONFIG_FIT) if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) { puts ("Non legacy image format not supported\n"); return -1; } #endif if ((new_id = fpga_get_version(fpga, image_get_name (hdr))) == -1) return 1; do_load = 1; if (!power_on_reset() && fpga_control(fpga, FPGA_DONE_IS_HIGH)) { old_id = fpga_control(fpga, FPGA_GET_ID); if (new_id == old_id) do_load = 0; } if (do_load) { printf ("loading "); fpga_load (fpga, addr, 0); } else { printf ("loaded (%08lx)\n", old_id); } } return 0; }
static int fpga_load (fpga_t* fpga, ulong addr, int checkall) { volatile uchar *fpga_addr = (volatile uchar *)fpga->conf_base; image_header_t *hdr = (image_header_t *)addr; ulong len; uchar *data; char msg[32]; int verify, i; #if defined(CONFIG_FIT) if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) { puts ("Non legacy image format not supported\n"); return -1; } #endif /* * Check the image header and data of the net-list */ if (!image_check_magic (hdr)) { strcpy (msg, "Bad Image Magic Number"); goto failure; } if (!image_check_hcrc (hdr)) { strcpy (msg, "Bad Image Header CRC"); goto failure; } data = (uchar*)image_get_data (hdr); len = image_get_data_size (hdr); verify = getenv_yesno ("verify"); if (verify) { if (!image_check_dcrc (hdr)) { strcpy (msg, "Bad Image Data CRC"); goto failure; } } if (checkall && fpga_get_version(fpga, image_get_name (hdr)) < 0) return 1; /* align length */ if (len & 1) ++len; /* * Reset FPGA and wait for completion */ if (fpga_reset(fpga)) { strcpy (msg, "Reset Timeout"); goto failure; } printf ("(%s)... ", image_get_name (hdr)); /* * Copy data to FPGA */ fpga_control (fpga, FPGA_LOAD_MODE); while (len--) { *fpga_addr = *data++; } fpga_control (fpga, FPGA_READ_MODE); /* * Wait for completion and check error status if timeout */ for (i = 0; i < FPGA_LOAD_TIMEOUT; i++) { udelay (100); if (fpga_control (fpga, FPGA_DONE_IS_HIGH)) break; } if (i == FPGA_LOAD_TIMEOUT) { if (fpga_control(fpga, FPGA_INIT_IS_HIGH)) strcpy(msg, "Invalid Size"); else strcpy(msg, "CRC Error"); goto failure; } printf("done\n"); return 0; failure: printf("ERROR: %s\n", msg); return 1; }