mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-28 15:41:40 +00:00
cmd: fix mtest on 64 bit systems
* Use 16 digits on 64 bit systems. * Use 64 bit patterns on 64 bit systems. * Expect the sign bit in bit 63 on 64 bit systems. * Adjust the formatting of a constant. * Always print result on new line Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Stefan Roese <sr@denx.de>
This commit is contained in:
parent
b3b6cc28c2
commit
5c3ea29e43
1 changed files with 11 additions and 15 deletions
26
cmd/mem.c
26
cmd/mem.c
|
@ -818,8 +818,8 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
|
||||||
*
|
*
|
||||||
* Returns: 0 if the test succeeds, 1 if the test fails.
|
* Returns: 0 if the test succeeds, 1 if the test fails.
|
||||||
*/
|
*/
|
||||||
pattern = (vu_long) 0xaaaaaaaa;
|
pattern = (vu_long)0xaaaaaaaaaaaaaaaa;
|
||||||
anti_pattern = (vu_long) 0x55555555;
|
anti_pattern = (vu_long)0x5555555555555555;
|
||||||
|
|
||||||
debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words);
|
debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words);
|
||||||
/*
|
/*
|
||||||
|
@ -970,7 +970,7 @@ static ulong test_bitflip_comparison(volatile unsigned long *bufa,
|
||||||
|
|
||||||
max = sizeof(unsigned long) * 8;
|
max = sizeof(unsigned long) * 8;
|
||||||
for (k = 0; k < max; k++) {
|
for (k = 0; k < max; k++) {
|
||||||
q = 0x00000001L << k;
|
q = 1UL << k;
|
||||||
for (j = 0; j < 8; j++) {
|
for (j = 0; j < 8; j++) {
|
||||||
schedule();
|
schedule();
|
||||||
q = ~q;
|
q = ~q;
|
||||||
|
@ -1009,6 +1009,7 @@ static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
|
||||||
ulong errs = 0;
|
ulong errs = 0;
|
||||||
ulong incr, length;
|
ulong incr, length;
|
||||||
ulong val, readback;
|
ulong val, readback;
|
||||||
|
const int plen = 2 * sizeof(ulong);
|
||||||
|
|
||||||
/* Alternate the pattern */
|
/* Alternate the pattern */
|
||||||
incr = 1;
|
incr = 1;
|
||||||
|
@ -1020,17 +1021,17 @@ static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
|
||||||
* the "negative" patterns and increment the "positive"
|
* the "negative" patterns and increment the "positive"
|
||||||
* patterns to preserve this feature.
|
* patterns to preserve this feature.
|
||||||
*/
|
*/
|
||||||
if (pattern & 0x80000000)
|
if (pattern > (ulong)LONG_MAX)
|
||||||
pattern = -pattern; /* complement & increment */
|
pattern = -pattern; /* complement & increment */
|
||||||
else
|
else
|
||||||
pattern = ~pattern;
|
pattern = ~pattern;
|
||||||
}
|
}
|
||||||
length = (end_addr - start_addr) / sizeof(ulong);
|
length = (end_addr - start_addr) / sizeof(ulong);
|
||||||
end = buf + length;
|
end = buf + length;
|
||||||
printf("\rPattern %08lX Writing..."
|
printf("\rPattern %0*lX Writing..."
|
||||||
"%12s"
|
"%12s"
|
||||||
"\b\b\b\b\b\b\b\b\b\b",
|
"\b\b\b\b\b\b\b\b\b\b",
|
||||||
pattern, "");
|
plen, pattern, "");
|
||||||
|
|
||||||
for (addr = buf, val = pattern; addr < end; addr++) {
|
for (addr = buf, val = pattern; addr < end; addr++) {
|
||||||
schedule();
|
schedule();
|
||||||
|
@ -1046,10 +1047,9 @@ static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
|
||||||
if (readback != val) {
|
if (readback != val) {
|
||||||
ulong offset = addr - buf;
|
ulong offset = addr - buf;
|
||||||
|
|
||||||
printf("\nMem error @ 0x%08X: "
|
printf("\nMem error @ 0x%0*lX: found %0*lX, expected %0*lX\n",
|
||||||
"found %08lX, expected %08lX\n",
|
plen, start_addr + offset * sizeof(vu_long),
|
||||||
(uint)(uintptr_t)(start_addr + offset*sizeof(vu_long)),
|
plen, readback, plen, val);
|
||||||
readback, val);
|
|
||||||
errs++;
|
errs++;
|
||||||
if (ctrlc())
|
if (ctrlc())
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1135,11 +1135,7 @@ static int do_mem_mtest(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
|
|
||||||
unmap_sysmem((void *)buf);
|
unmap_sysmem((void *)buf);
|
||||||
|
|
||||||
if (errs == -1UL) {
|
printf("\nTested %d iteration(s) with %lu errors.\n", iteration, count);
|
||||||
/* Memory test was aborted - write a newline to finish off */
|
|
||||||
putc('\n');
|
|
||||||
}
|
|
||||||
printf("Tested %d iteration(s) with %lu errors.\n", iteration, count);
|
|
||||||
|
|
||||||
return errs != 0;
|
return errs != 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue