public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] cmd: cp: add missing map_sysmem
@ 2019-12-02 16:33 Philippe Reynes
  2019-12-05 22:10 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe Reynes @ 2019-12-02 16:33 UTC (permalink / raw)
  To: u-boot

The command cp fails on sandbox because the address is used
directly. To fix this issue, we call the function map_sysmem
to translate the address.

Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
---
 cmd/mem.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/cmd/mem.c b/cmd/mem.c
index c6b8038..1757c84 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;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] cmd: cp: add missing map_sysmem
  2019-12-02 16:33 [U-Boot] [PATCH] cmd: cp: add missing map_sysmem Philippe Reynes
@ 2019-12-05 22:10 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2019-12-05 22:10 UTC (permalink / raw)
  To: u-boot

On Mon, Dec 02, 2019 at 05:33:22PM +0100, Philippe Reynes wrote:

> The command cp fails on sandbox because the address is used
> directly. To fix this issue, we call the function map_sysmem
> to translate the address.
> 
> Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191205/bd6bfa76/attachment.sig>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-05 22:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-02 16:33 [U-Boot] [PATCH] cmd: cp: add missing map_sysmem Philippe Reynes
2019-12-05 22:10 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox