diff options
author | Simon Glass <sjg@chromium.org> | 2020-11-01 14:15:37 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-12-01 10:33:38 -0500 |
commit | 25a43ac84a9509b8ccd093808bb39b71e4438cf5 (patch) | |
tree | 491181cd84bae451bafd6215014cbf722745e28f /cmd | |
parent | 7526deec7e52da92dee25aaf3a47514e639c2bb0 (diff) | |
download | u-boot-25a43ac84a9509b8ccd093808bb39b71e4438cf5.tar.gz u-boot-25a43ac84a9509b8ccd093808bb39b71e4438cf5.tar.bz2 u-boot-25a43ac84a9509b8ccd093808bb39b71e4438cf5.zip |
setexpr: Add explicit support for 32- and 64-bit ints
At present this function assumes that a size of 4 refers to a ulong. This
is true on 32-bit machines but not commonly on 64-bit machines.
This means that the 'l' specify does not work correctly with setexpr.
Add an explicit case for 32-bit values so that 64-bit machines can still
use the 'l' specifier. On 32-bit machines, 64-bit is still not supported.
This corrects the operation of the default size (which is 4 for setexpr),
so update the tests accordingly.
The original code for reading from memory was included in 47ab5ad1457
("cmd_setexpr: allow memory addresses in expressions") but I am not adding
a Fixes: tag since that code was not written with 64-bit machines in mind.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/setexpr.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/cmd/setexpr.c b/cmd/setexpr.c index 770dc24d2b..dd9c2574fd 100644 --- a/cmd/setexpr.c +++ b/cmd/setexpr.c @@ -39,6 +39,10 @@ static ulong get_arg(char *s, int w) unmap_sysmem(p); return val; case 4: + p = map_sysmem(addr, sizeof(u32)); + val = *(u32 *)p; + unmap_sysmem(p); + return val; default: p = map_sysmem(addr, sizeof(ulong)); val = *p; |