summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/mem.c17
-rw-r--r--commands/spi.c4
-rw-r--r--fs/tftp.c2
-rw-r--r--include/common.h2
-rw-r--r--net/net.c2
5 files changed, 18 insertions, 9 deletions
diff --git a/commands/mem.c b/commands/mem.c
index 6fbc7cc4af..a42b7bacb3 100644
--- a/commands/mem.c
+++ b/commands/mem.c
@@ -51,7 +51,7 @@ static char *DEVMEM = "/dev/mem";
*/
#define DISP_LINE_LEN 16
-int memory_display(char *addr, loff_t offs, ulong nbytes, int size)
+int memory_display(char *addr, loff_t offs, ulong nbytes, int size, int swab)
{
ulong linebytes, i;
u_char *cp;
@@ -73,9 +73,17 @@ int memory_display(char *addr, loff_t offs, ulong nbytes, int size)
for (i = 0; i < linebytes; i += size) {
if (size == 4) {
- count -= printf(" %08x", (*uip++ = *((uint *)addr)));
+ u32 res;
+ res = (*uip++ = *((uint *)addr));
+ if (swab)
+ res = __swab32(res);
+ count -= printf(" %08x", res);
} else if (size == 2) {
- count -= printf(" %04x", (*usp++ = *((ushort *)addr)));
+ u16 res;
+ res = (*usp++ = *((ushort *)addr));
+ if (swab)
+ res = __swab16(res);
+ count -= printf(" %04x", res);
} else {
count -= printf(" %02x", (*ucp++ = *((u_char *)addr)));
}
@@ -195,7 +203,8 @@ static int do_mem_md(int argc, char *argv[])
if (!r)
goto out;
- if ((ret = memory_display(rw_buf, start, r, mode >> O_RWSIZE_SHIFT)))
+ if ((ret = memory_display(rw_buf, start, r,
+ mode >> O_RWSIZE_SHIFT, 0)))
goto out;
start += r;
diff --git a/commands/spi.c b/commands/spi.c
index 899bf62608..2f6b430baa 100644
--- a/commands/spi.c
+++ b/commands/spi.c
@@ -101,12 +101,12 @@ static int do_spi(int argc, char *argv[])
printf("\n");
printf("wrote %i bytes\n", count);
- memory_display(tx_buf, 0, count, byte_per_word);
+ memory_display(tx_buf, 0, count, byte_per_word, 0);
printf("read %i bytes\n", read);
}
- memory_display(rx_buf, 0, read, byte_per_word);
+ memory_display(rx_buf, 0, read, byte_per_word, 0);
out:
free(rx_buf);
diff --git a/fs/tftp.c b/fs/tftp.c
index dff41e9c17..98cbb379ba 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -227,7 +227,7 @@ static void tftp_parse_oack(struct file_priv *priv, unsigned char *pkt, int len)
debug("got OACK\n");
#ifdef DEBUG
- memory_display(pkt, 0, len, 1);
+ memory_display(pkt, 0, len, 1, 0);
#endif
s = pkt;
diff --git a/include/common.h b/include/common.h
index e30774a43e..6256879f83 100644
--- a/include/common.h
+++ b/include/common.h
@@ -226,7 +226,7 @@ int run_shell(void);
#define PAGE_SIZE 4096
#define PAGE_SHIFT 12
-int memory_display(char *addr, loff_t offs, ulong nbytes, int size);
+int memory_display(char *addr, loff_t offs, ulong nbytes, int size, int swab);
extern const char version_string[];
#ifdef CONFIG_BANNER
diff --git a/net/net.c b/net/net.c
index 3ac098fcff..639bc2d985 100644
--- a/net/net.c
+++ b/net/net.c
@@ -511,7 +511,7 @@ static void net_bad_packet(unsigned char *pkt, int len)
* We received a bad packet. for now just dump it.
* We could add more sophisticated debugging here
*/
- memory_display(pkt, 0, len, 1);
+ memory_display(pkt, 0, len, 1, 0);
#endif
}