X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=common%2Fcmd_setexpr.c;h=e7194fc4f4137a1652250c0de047200aed75469c;hb=04e3c4eb930a761b561cb87f964aa8a5d694c501;hp=1fc080b9b57f47494ce32105851fc146e454d84e;hpb=aaf5e825606a70ddc8fca8e366d8c16a6fd3cc7c;p=oweals%2Fu-boot.git diff --git a/common/cmd_setexpr.c b/common/cmd_setexpr.c index 1fc080b9b5..e7194fc4f4 100644 --- a/common/cmd_setexpr.c +++ b/common/cmd_setexpr.c @@ -2,7 +2,7 @@ * Copyright 2008 Freescale Semiconductor, Inc. * Copyright 2013 Wolfgang Denk * - * SPDX-License-Identifier: GPL-2.0+ + * SPDX-License-Identifier: GPL-2.0+ */ /* @@ -12,23 +12,37 @@ #include #include #include +#include static ulong get_arg(char *s, int w) { - ulong *p; - /* - * if the parameter starts with a '*' then assume - * it is a pointer to the value we want + * If the parameter starts with a '*' then assume it is a pointer to + * the value we want. */ - if (s[0] == '*') { - p = (ulong *)simple_strtoul(&s[1], NULL, 16); + ulong *p; + ulong addr; + ulong val; + + addr = simple_strtoul(&s[1], NULL, 16); switch (w) { - case 1: return((ulong)(*(uchar *)p)); - case 2: return((ulong)(*(ushort *)p)); + case 1: + p = map_sysmem(addr, sizeof(uchar)); + val = (ulong)*(uchar *)p; + unmap_sysmem(p); + return val; + case 2: + p = map_sysmem(addr, sizeof(ushort)); + val = (ulong)*(ushort *)p; + unmap_sysmem(p); + return val; case 4: - default: return(*p); + default: + p = map_sysmem(addr, sizeof(ulong)); + val = *p; + unmap_sysmem(p); + return val; } } else { return simple_strtoul(s, NULL, 16);