diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-04-17 13:35:14 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-04-17 13:35:17 +0200 |
commit | 255e5b4c4231ec381f87992109a15098ec00f8d6 (patch) | |
tree | 5817734b143b57bc8b6801782df89916eb2add2b /commands/mem.c | |
parent | d91b7772c48fa47bbd73857471e91a5d0cc8b876 (diff) | |
download | barebox-255e5b4c4231ec381f87992109a15098ec00f8d6.tar.gz barebox-255e5b4c4231ec381f87992109a15098ec00f8d6.tar.xz |
memory commands: move memory_display to separate file
memory_display is a function which should generally be available.
Currently it depends on memory command support being compiled in,
so move the function to a separate file.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/mem.c')
-rw-r--r-- | commands/mem.c | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/commands/mem.c b/commands/mem.c index f25c6b6256..a4a16583c3 100644 --- a/commands/mem.c +++ b/commands/mem.c @@ -44,74 +44,6 @@ static char *rw_buf; static char *DEVMEM = "/dev/mem"; -/* Memory Display - * - * Syntax: - * md{.b, .w, .l} {addr} {len} - */ -#define DISP_LINE_LEN 16 - -int memory_display(char *addr, loff_t offs, ulong nbytes, int size, int swab) -{ - ulong linebytes, i; - u_char *cp; - - /* Print the lines. - * - * We buffer all read data, so we can make sure data is read only - * once, and all accesses are with the specified bus width. - */ - do { - char linebuf[DISP_LINE_LEN]; - uint *uip = (uint *)linebuf; - ushort *usp = (ushort *)linebuf; - u_char *ucp = (u_char *)linebuf; - uint count = 52; - - printf("%08llx:", offs); - linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes; - - for (i = 0; i < linebytes; i += size) { - if (size == 4) { - u32 res; - res = (*uip++ = *((uint *)addr)); - if (swab) - res = __swab32(res); - count -= printf(" %08x", res); - } else if (size == 2) { - u16 res; - res = (*usp++ = *((ushort *)addr)); - if (swab) - res = __swab16(res); - count -= printf(" %04x", res); - } else { - count -= printf(" %02x", (*ucp++ = *((u_char *)addr))); - } - addr += size; - offs += size; - } - - while(count--) - putchar(' '); - - cp = (u_char *)linebuf; - for (i=0; i<linebytes; i++) { - if ((*cp < 0x20) || (*cp > 0x7e)) - putchar('.'); - else - printf("%c", *cp); - cp++; - } - putchar('\n'); - nbytes -= linebytes; - if (ctrlc()) { - return -EINTR; - } - } while (nbytes > 0); - - return 0; -} - int open_and_lseek(const char *filename, int mode, loff_t pos) { int fd, ret; |