From: Stephen Warren Date: Sat, 3 Oct 2015 19:56:46 +0000 (-0600) Subject: itest: make memory access work under sandbox X-Git-Tag: v2016.01-rc1~177 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7861204c9af7fec1ea9b41541c272516235a6c93;p=platform%2Fkernel%2Fu-boot.git itest: make memory access work under sandbox itest accesses memory, and hence must map/unmap it. Without doing so, it accesses invalid addresses and crashes. Signed-off-by: Stephen Warren Reviewed-by: Simon Glass --- diff --git a/common/cmd_itest.c b/common/cmd_itest.c index 76af62b..596341c 100644 --- a/common/cmd_itest.c +++ b/common/cmd_itest.c @@ -15,6 +15,9 @@ #include #include #include +#include + +#include #define EQ 0 #define NE 1 @@ -49,16 +52,24 @@ static const op_tbl_t op_table [] = { static long evalexp(char *s, int w) { long l = 0; - long *p; + unsigned long addr; + void *buf; /* if the parameter starts with a * then assume is a pointer to the value we want */ if (s[0] == '*') { - p = (long *)simple_strtoul(&s[1], NULL, 16); + addr = simple_strtoul(&s[1], NULL, 16); + buf = map_physmem(addr, w, MAP_WRBACK); + if (!buf) { + puts("Failed to map physical memory\n"); + return 0; + } switch (w) { - case 1: return((long)(*(unsigned char *)p)); - case 2: return((long)(*(unsigned short *)p)); - case 4: return(*p); + case 1: l = (long)(*(unsigned char *)buf); + case 2: l = (long)(*(unsigned short *)buf); + case 4: l = (long)(*(unsigned long *)buf); } + unmap_physmem(buf, w); + return l; } else { l = simple_strtoul(s, NULL, 16); }