Commit c2538421b28424b9705865e838c5fba19c9dc651

Authored by Fabio Estevam
Committed by Tom Rini
1 parent 4386feb73d

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>

Showing 1 changed file with 2 additions and 26 deletions Side-by-side Diff

... ... @@ -372,10 +372,8 @@
372 372  
373 373 static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
374 374 {
375   - ulong addr, dest, count, bytes;
  375 + ulong addr, dest, count;
376 376 int size;
377   - const void *src;
378   - void *buf;
379 377  
380 378 if (argc != 4)
381 379 return CMD_RET_USAGE;
... ... @@ -465,29 +463,7 @@
465 463 }
466 464 #endif
467 465  
468   - bytes = size * count;
469   - buf = map_sysmem(dest, bytes);
470   - src = map_sysmem(addr, bytes);
471   - while (count-- > 0) {
472   - if (size == 4)
473   - *((u32 *)buf) = *((u32 *)src);
474   -#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
475   - else if (size == 8)
476   - *((u64 *)buf) = *((u64 *)src);
477   -#endif
478   - else if (size == 2)
479   - *((u16 *)buf) = *((u16 *)src);
480   - else
481   - *((u8 *)buf) = *((u8 *)src);
482   - src += size;
483   - buf += size;
484   -
485   - /* reset watchdog from time to time */
486   - if ((count % (64 << 10)) == 0)
487   - WATCHDOG_RESET();
488   - }
489   - unmap_sysmem(buf);
490   - unmap_sysmem(src);
  466 + memcpy((void *)dest, (void *)addr, count * size);
491 467  
492 468 return 0;
493 469 }