mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-18 21:21:37 +00:00
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 <swarren@wwwdotorg.org> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
40d2154726
commit
7861204c9a
1 changed files with 17 additions and 6 deletions
|
@ -15,6 +15,9 @@
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
|
#include <mapmem.h>
|
||||||
|
|
||||||
|
#include <asm/io.h>
|
||||||
|
|
||||||
#define EQ 0
|
#define EQ 0
|
||||||
#define NE 1
|
#define NE 1
|
||||||
|
@ -49,16 +52,24 @@ static const op_tbl_t op_table [] = {
|
||||||
static long evalexp(char *s, int w)
|
static long evalexp(char *s, int w)
|
||||||
{
|
{
|
||||||
long l = 0;
|
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 the parameter starts with a * then assume is a pointer to the value we want */
|
||||||
if (s[0] == '*') {
|
if (s[0] == '*') {
|
||||||
p = (long *)simple_strtoul(&s[1], NULL, 16);
|
addr = simple_strtoul(&s[1], NULL, 16);
|
||||||
switch (w) {
|
buf = map_physmem(addr, w, MAP_WRBACK);
|
||||||
case 1: return((long)(*(unsigned char *)p));
|
if (!buf) {
|
||||||
case 2: return((long)(*(unsigned short *)p));
|
puts("Failed to map physical memory\n");
|
||||||
case 4: return(*p);
|
return 0;
|
||||||
}
|
}
|
||||||
|
switch (w) {
|
||||||
|
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 {
|
} else {
|
||||||
l = simple_strtoul(s, NULL, 16);
|
l = simple_strtoul(s, NULL, 16);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue