summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@nxp.com>2016-12-15 16:00:13 -0200
committerTom Rini <trini@konsulko.com>2017-01-12 13:16:26 -0500
commitc2538421b28424b9705865e838c5fba19c9dc651 (patch)
tree309aa03ecaab7c03003e67cbd9fb6a57b83c8c59 /cmd
parent4386feb73da7946fc79b55c4fa41c6dd66dcb2e2 (diff)
downloadu-boot-c2538421b28424b9705865e838c5fba19c9dc651.tar.gz
u-boot-c2538421b28424b9705865e838c5fba19c9dc651.tar.bz2
u-boot-c2538421b28424b9705865e838c5fba19c9dc651.zip
cmd: mem: Use memcpy for 'cp' command
Simplify the 'cp' command implementation by using the memcpy() function, which brings the additional benefit of performance gain for those who have CONFIG_USE_ARCH_MEMCPY selected. Tested on a mx6qsabreauto board where a 5x gain in performance is seen when reading 10MB from the parallel NOR memory. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/mem.c28
1 files changed, 2 insertions, 26 deletions
diff --git a/cmd/mem.c b/cmd/mem.c
index a690957d0f..ff6a7709d2 100644
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -372,10 +372,8 @@ 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, bytes;
+ ulong addr, dest, count;
int size;
- const void *src;
- void *buf;
if (argc != 4)
return CMD_RET_USAGE;
@@ -465,29 +463,7 @@ static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
#endif
- bytes = size * count;
- buf = map_sysmem(dest, bytes);
- src = map_sysmem(addr, bytes);
- while (count-- > 0) {
- if (size == 4)
- *((u32 *)buf) = *((u32 *)src);
-#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
- else if (size == 8)
- *((u64 *)buf) = *((u64 *)src);
-#endif
- else if (size == 2)
- *((u16 *)buf) = *((u16 *)src);
- else
- *((u8 *)buf) = *((u8 *)src);
- src += size;
- buf += size;
-
- /* reset watchdog from time to time */
- if ((count % (64 << 10)) == 0)
- WATCHDOG_RESET();
- }
- unmap_sysmem(buf);
- unmap_sysmem(src);
+ memcpy((void *)dest, (void *)addr, count * size);
return 0;
}