summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/bootm.c12
-rw-r--r--cmd/mem.c16
2 files changed, 24 insertions, 4 deletions
diff --git a/cmd/bootm.c b/cmd/bootm.c
index 8279f2b7cc6..62ee7c4b8a1 100644
--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -19,6 +19,7 @@
#include <linux/ctype.h>
#include <linux/err.h>
#include <u-boot/zlib.h>
+#include <mapmem.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -244,7 +245,7 @@ static int do_iminfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
static int image_info(ulong addr)
{
- void *hdr = (void *)addr;
+ void *hdr = (void *)map_sysmem(addr, 0);
printf("\n## Checking Image at %08lx ...\n", addr);
@@ -254,11 +255,13 @@ static int image_info(ulong addr)
puts(" Legacy image found\n");
if (!image_check_magic(hdr)) {
puts(" Bad Magic Number\n");
+ unmap_sysmem(hdr);
return 1;
}
if (!image_check_hcrc(hdr)) {
puts(" Bad Header Checksum\n");
+ unmap_sysmem(hdr);
return 1;
}
@@ -267,15 +270,18 @@ static int image_info(ulong addr)
puts(" Verifying Checksum ... ");
if (!image_check_dcrc(hdr)) {
puts(" Bad Data CRC\n");
+ unmap_sysmem(hdr);
return 1;
}
puts("OK\n");
+ unmap_sysmem(hdr);
return 0;
#endif
#if defined(CONFIG_ANDROID_BOOT_IMAGE)
case IMAGE_FORMAT_ANDROID:
puts(" Android image found\n");
android_print_contents(hdr);
+ unmap_sysmem(hdr);
return 0;
#endif
#if defined(CONFIG_FIT)
@@ -284,6 +290,7 @@ static int image_info(ulong addr)
if (!fit_check_format(hdr)) {
puts("Bad FIT image format!\n");
+ unmap_sysmem(hdr);
return 1;
}
@@ -291,9 +298,11 @@ static int image_info(ulong addr)
if (!fit_all_image_verify(hdr)) {
puts("Bad hash in FIT image!\n");
+ unmap_sysmem(hdr);
return 1;
}
+ unmap_sysmem(hdr);
return 0;
#endif
default:
@@ -301,6 +310,7 @@ static int image_info(ulong addr)
break;
}
+ unmap_sysmem(hdr);
return 1;
}
diff --git a/cmd/mem.c b/cmd/mem.c
index 545534b1fc7..4ec450b0502 100644
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -303,6 +303,7 @@ static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
ulong addr, dest, count;
+ void *src, *dst;
int size;
if (argc != 4)
@@ -326,25 +327,34 @@ static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 1;
}
+ src = map_sysmem(addr, count * size);
+ dst = map_sysmem(dest, count * size);
+
#ifdef CONFIG_MTD_NOR_FLASH
/* check if we are copying to Flash */
- if (addr2info(dest) != NULL) {
+ if (addr2info((ulong)dst)) {
int rc;
puts ("Copy to Flash... ");
- rc = flash_write ((char *)addr, dest, count*size);
+ rc = flash_write((char *)src, (ulong)dst, count * size);
if (rc != 0) {
flash_perror (rc);
+ unmap_sysmem(src);
+ unmap_sysmem(dst);
return (1);
}
puts ("done\n");
+ unmap_sysmem(src);
+ unmap_sysmem(dst);
return 0;
}
#endif
- memcpy((void *)dest, (void *)addr, count * size);
+ memcpy(dst, src, count * size);
+ unmap_sysmem(src);
+ unmap_sysmem(dst);
return 0;
}