Fix memory commands for 64-bit platforms

For aarch64, unsigned long is 64-bit data. Memory commands should be fixed
with u32 for 32-bit address access. To be clear, ushort is replace with
u16, u_char is replaced with u8.

Signed-off-by: York Sun <yorksun@freescale.com>
Acked-by: Wolfgang Denk <wd@denx.de>
This commit is contained in:
York Sun 2014-02-12 15:55:35 -08:00 committed by Tom Rini
parent e22361af07
commit 76698b4e6c
1 changed files with 36 additions and 36 deletions

View File

@ -188,11 +188,11 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
buf = map_sysmem(addr, bytes); buf = map_sysmem(addr, bytes);
while (count-- > 0) { while (count-- > 0) {
if (size == 4) if (size == 4)
*((ulong *)buf) = (ulong)writeval; *((u32 *)buf) = (u32)writeval;
else if (size == 2) else if (size == 2)
*((ushort *)buf) = (ushort)writeval; *((u16 *)buf) = (u16)writeval;
else else
*((u_char *)buf) = (u_char)writeval; *((u8 *)buf) = (u8)writeval;
buf += size; buf += size;
} }
unmap_sysmem(buf); unmap_sysmem(buf);
@ -300,14 +300,14 @@ static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
for (ngood = 0; ngood < count; ++ngood) { for (ngood = 0; ngood < count; ++ngood) {
ulong word1, word2; ulong word1, word2;
if (size == 4) { if (size == 4) {
word1 = *(ulong *)buf1; word1 = *(u32 *)buf1;
word2 = *(ulong *)buf2; word2 = *(u32 *)buf2;
} else if (size == 2) { } else if (size == 2) {
word1 = *(ushort *)buf1; word1 = *(u16 *)buf1;
word2 = *(ushort *)buf2; word2 = *(u16 *)buf2;
} else { } else {
word1 = *(u_char *)buf1; word1 = *(u8 *)buf1;
word2 = *(u_char *)buf2; word2 = *(u8 *)buf2;
} }
if (word1 != word2) { if (word1 != word2) {
ulong offset = buf1 - base; ulong offset = buf1 - base;
@ -433,11 +433,11 @@ static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
src = map_sysmem(addr, bytes); src = map_sysmem(addr, bytes);
while (count-- > 0) { while (count-- > 0) {
if (size == 4) if (size == 4)
*((ulong *)buf) = *((ulong *)src); *((u32 *)buf) = *((u32 *)src);
else if (size == 2) else if (size == 2)
*((ushort *)buf) = *((ushort *)src); *((u16 *)buf) = *((u16 *)src);
else else
*((u_char *)buf) = *((u_char *)src); *((u8 *)buf) = *((u8 *)src);
src += size; src += size;
buf += size; buf += size;
@ -467,9 +467,9 @@ static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
{ {
ulong addr, length, i, bytes; ulong addr, length, i, bytes;
int size; int size;
volatile uint *longp; volatile u32 *longp;
volatile ushort *shortp; volatile u16 *shortp;
volatile u_char *cp; volatile u8 *cp;
const void *buf; const void *buf;
if (argc < 3) if (argc < 3)
@ -498,23 +498,23 @@ static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
*/ */
if (length == 1) { if (length == 1) {
if (size == 4) { if (size == 4) {
longp = (uint *)buf; longp = (u32 *)buf;
for (;;) for (;;)
i = *longp; i = *longp;
} }
if (size == 2) { if (size == 2) {
shortp = (ushort *)buf; shortp = (u16 *)buf;
for (;;) for (;;)
i = *shortp; i = *shortp;
} }
cp = (u_char *)buf; cp = (u8 *)buf;
for (;;) for (;;)
i = *cp; i = *cp;
} }
if (size == 4) { if (size == 4) {
for (;;) { for (;;) {
longp = (uint *)buf; longp = (u32 *)buf;
i = length; i = length;
while (i-- > 0) while (i-- > 0)
*longp++; *longp++;
@ -522,14 +522,14 @@ static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
} }
if (size == 2) { if (size == 2) {
for (;;) { for (;;) {
shortp = (ushort *)buf; shortp = (u16 *)buf;
i = length; i = length;
while (i-- > 0) while (i-- > 0)
*shortp++; *shortp++;
} }
} }
for (;;) { for (;;) {
cp = (u_char *)buf; cp = (u8 *)buf;
i = length; i = length;
while (i-- > 0) while (i-- > 0)
*cp++; *cp++;
@ -544,9 +544,9 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{ {
ulong addr, length, i, data, bytes; ulong addr, length, i, data, bytes;
int size; int size;
volatile uint *longp; volatile u32 *longp;
volatile ushort *shortp; volatile u16 *shortp;
volatile u_char *cp; volatile u8 *cp;
void *buf; void *buf;
if (argc < 4) if (argc < 4)
@ -578,23 +578,23 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
*/ */
if (length == 1) { if (length == 1) {
if (size == 4) { if (size == 4) {
longp = (uint *)buf; longp = (u32 *)buf;
for (;;) for (;;)
*longp = data; *longp = data;
} }
if (size == 2) { if (size == 2) {
shortp = (ushort *)buf; shortp = (u16 *)buf;
for (;;) for (;;)
*shortp = data; *shortp = data;
} }
cp = (u_char *)buf; cp = (u8 *)buf;
for (;;) for (;;)
*cp = data; *cp = data;
} }
if (size == 4) { if (size == 4) {
for (;;) { for (;;) {
longp = (uint *)buf; longp = (u32 *)buf;
i = length; i = length;
while (i-- > 0) while (i-- > 0)
*longp++ = data; *longp++ = data;
@ -602,14 +602,14 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
} }
if (size == 2) { if (size == 2) {
for (;;) { for (;;) {
shortp = (ushort *)buf; shortp = (u16 *)buf;
i = length; i = length;
while (i-- > 0) while (i-- > 0)
*shortp++ = data; *shortp++ = data;
} }
} }
for (;;) { for (;;) {
cp = (u_char *)buf; cp = (u8 *)buf;
i = length; i = length;
while (i-- > 0) while (i-- > 0)
*cp++ = data; *cp++ = data;
@ -1054,11 +1054,11 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
ptr = map_sysmem(addr, size); ptr = map_sysmem(addr, size);
printf("%08lx:", addr); printf("%08lx:", addr);
if (size == 4) if (size == 4)
printf(" %08x", *((uint *)ptr)); printf(" %08x", *((u32 *)ptr));
else if (size == 2) else if (size == 2)
printf(" %04x", *((ushort *)ptr)); printf(" %04x", *((u16 *)ptr));
else else
printf(" %02x", *((u_char *)ptr)); printf(" %02x", *((u8 *)ptr));
nbytes = readline (" ? "); nbytes = readline (" ? ");
if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) { if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
@ -1088,11 +1088,11 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
reset_cmd_timeout(); reset_cmd_timeout();
#endif #endif
if (size == 4) if (size == 4)
*((uint *)ptr) = i; *((u32 *)ptr) = i;
else if (size == 2) else if (size == 2)
*((ushort *)ptr) = i; *((u16 *)ptr) = i;
else else
*((u_char *)ptr) = i; *((u8 *)ptr) = i;
if (incrflag) if (incrflag)
addr += size; addr += size;
} }