+// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2000-2004
*
* (C) Copyright 2003
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
*/
#include <common.h>
#include <command.h>
+#include <cpu_func.h>
+#include <env.h>
+#include <gzip.h>
#include <image.h>
+#include <malloc.h>
#include <mapmem.h>
#include <watchdog.h>
#if defined(CONFIG_BZIP2)
#include <bzlib.h>
#endif
#include <asm/byteorder.h>
+#include <asm/cache.h>
#include <asm/io.h>
-#ifndef CONFIG_SYS_XIMG_LEN
+#ifndef CFG_SYS_XIMG_LEN
/* use 8MByte as default max gunzip size */
-#define CONFIG_SYS_XIMG_LEN 0x800000
+#define CFG_SYS_XIMG_LEN 0x800000
#endif
static int
-do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
- ulong addr = load_addr;
+ ulong addr = image_load_addr;
ulong dest = 0;
ulong data, len;
int verify;
int part = 0;
-#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
+#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
ulong count;
- image_header_t *hdr = NULL;
+ struct legacy_img_hdr *hdr = NULL;
#endif
#if defined(CONFIG_FIT)
const char *uname = NULL;
size_t fit_len;
#endif
#ifdef CONFIG_GZIP
- uint unc_len = CONFIG_SYS_XIMG_LEN;
+ uint unc_len = CFG_SYS_XIMG_LEN;
#endif
uint8_t comp;
- verify = getenv_yesno("verify");
+ verify = env_get_yesno("verify");
if (argc > 1) {
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
}
if (argc > 2) {
- part = simple_strtoul(argv[2], NULL, 16);
+ part = hextoul(argv[2], NULL);
#if defined(CONFIG_FIT)
uname = argv[2];
#endif
}
if (argc > 3) {
- dest = simple_strtoul(argv[3], NULL, 16);
+ dest = hextoul(argv[3], NULL);
}
switch (genimg_get_format((void *)addr)) {
-#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
+#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
case IMAGE_FORMAT_LEGACY:
printf("## Copying part %d from legacy image "
"at %08lx ...\n", part, addr);
- hdr = (image_header_t *)addr;
+ hdr = (struct legacy_img_hdr *)addr;
if (!image_check_magic(hdr)) {
printf("Bad Magic Number\n");
return 1;
"at %08lx ...\n", uname, addr);
fit_hdr = (const void *)addr;
- if (!fit_check_format(fit_hdr)) {
+ if (fit_check_format(fit_hdr, IMAGE_SIZE_INVAL)) {
puts("Bad FIT image format\n");
return 1;
}
return 1;
}
- if (fit_image_check_comp(fit_hdr, noffset, IH_COMP_NONE)
+ if (!fit_image_check_comp(fit_hdr, noffset, IH_COMP_NONE)
&& (argc < 4)) {
printf("Must specify load address for %s command "
"with compressed image\n",
}
}
- /* get subimage data address and length */
- if (fit_image_get_data(fit_hdr, noffset,
- &fit_data, &fit_len)) {
+ /* get subimage/external data address and length */
+ if (fit_image_get_data_and_size(fit_hdr, noffset,
+ &fit_data, &fit_len)) {
puts("Could not find script subimage data\n");
return 1;
}
- if (fit_image_get_comp(fit_hdr, noffset, &comp)) {
- puts("Could not find script subimage "
- "compression type\n");
- return 1;
- }
+ if (fit_image_get_comp(fit_hdr, noffset, &comp))
+ comp = IH_COMP_NONE;
data = (ulong)fit_data;
len = (ulong)fit_len;
while (l > 0) {
tail = (l > CHUNKSZ) ? CHUNKSZ : l;
- WATCHDOG_RESET();
+ schedule();
memmove(to, from, tail);
to += tail;
from += tail;
}
break;
#endif
-#if defined(CONFIG_BZIP2) && defined(CONFIG_IMAGE_FORMAT_LEGACY)
+#if defined(CONFIG_BZIP2) && defined(CONFIG_LEGACY_IMAGE_FORMAT)
case IH_COMP_BZIP2:
{
int i;
puts("OK\n");
}
- flush_cache(dest, len);
+ flush_cache(dest, ALIGN(len, ARCH_DMA_MINALIGN));
- setenv_hex("fileaddr", data);
- setenv_hex("filesize", len);
+ env_set_hex("fileaddr", data);
+ env_set_hex("filesize", len);
return 0;
}