summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-05-28 12:26:30 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-05-28 12:26:33 +0200
commit6792d94a4b1a1b3cbdf55bf4e357a46030c060fa (patch)
tree712169bc5043ae83449c429889a2a588cdcaa2fa /commands
parentf13f1c269ebffca25697deb420cce64b099d66b5 (diff)
downloadbarebox-6792d94a4b1a1b3cbdf55bf4e357a46030c060fa.tar.gz
barebox-6792d94a4b1a1b3cbdf55bf4e357a46030c060fa.tar.xz
md: use memmap when possible
This adds the missing pieces for: d8a6e1c ARM/mem: handle data aborts gracefully for md When possible use memmap and directly and dereference the input pointer directly in memory_display() so that the data abort occurs where we expect it and not in the md command. With this d8a6e1c can work as expected. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/md.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/commands/md.c b/commands/md.c
index c1361a6a21..07a03d51f3 100644
--- a/commands/md.c
+++ b/commands/md.c
@@ -44,6 +44,7 @@ static int do_mem_md(int argc, char *argv[])
char *filename = "/dev/mem";
int mode = O_RWSIZE_4;
int swab = 0;
+ void *map;
if (argc < 2)
return COMMAND_ERROR_USAGE;
@@ -65,6 +66,13 @@ static int do_mem_md(int argc, char *argv[])
if (fd < 0)
return 1;
+ map = memmap(fd, PROT_READ);
+ if (map != (void *)-1) {
+ ret = memory_display(map + start, start, size,
+ mode >> O_RWSIZE_SHIFT, swab);
+ goto out;
+ }
+
do {
now = min(size, (loff_t)RW_BUF_SIZE);
r = read(fd, mem_rw_buf, now);