X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=common%2Fcmd_itest.c;h=91ae5c2704c882be8d4457d67d5f8488b19d2f1c;hb=4edde96111aefac63d6aaca6ba87a90d149e973e;hp=ae2527bfecdb8e2d55ad211bf6de6715a922f752;hpb=1ad6364eeb4f578e423081d1748e8a3fdf1ab01d;p=oweals%2Fu-boot.git diff --git a/common/cmd_itest.c b/common/cmd_itest.c index ae2527bfec..91ae5c2704 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,21 +52,35 @@ 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); + break; + case 2: + l = (long)(*(unsigned short *)buf); + break; + case 4: + l = (long)(*(unsigned long *)buf); + break; } + unmap_physmem(buf, w); + return l; } else { l = simple_strtoul(s, NULL, 16); } - return (l & ((1 << (w * 8)) - 1)); + return l & ((1UL << (w * 8)) - 1); } static char * evalstr(char *s)