]> Git Repo - J-u-boot.git/blame - cmd/mem.c
Merge tag 'video-for-v2020.07-rc1' of https://gitlab.denx.de/u-boot/custodians/u...
[J-u-boot.git] / cmd / mem.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
3863585b
WD
2/*
3 * (C) Copyright 2000
4 * Wolfgang Denk, DENX Software Engineering, [email protected].
3863585b
WD
5 */
6
7/*
8 * Memory Functions
9 *
10 * Copied from FADS ROM, Dan Malek ([email protected])
11 */
12
13#include <common.h>
24b852a7 14#include <console.h>
0098e179 15#include <bootretry.h>
18d66533 16#include <cli.h>
3863585b 17#include <command.h>
24b852a7 18#include <console.h>
0ee48252 19#include <flash.h>
d20a40de 20#include <hash.h>
0eb25b61 21#include <mapmem.h>
a6e6fc61 22#include <watchdog.h>
0628ab8e 23#include <asm/io.h>
15a33e49
SG
24#include <linux/compiler.h>
25
26DECLARE_GLOBAL_DATA_PTR;
3863585b 27
8e169cc9
SG
28#ifndef CONFIG_SYS_MEMTEST_SCRATCH
29#define CONFIG_SYS_MEMTEST_SCRATCH 0
30#endif
31
54841ab5 32static int mod_mem(cmd_tbl_t *, int, int, int, char * const []);
3863585b
WD
33
34/* Display values from last command.
35 * Memory modify remembered values are different from display memory.
36 */
581508bd
SW
37static ulong dp_last_addr, dp_last_size;
38static ulong dp_last_length = 0x40;
39static ulong mm_last_addr, mm_last_size;
3863585b
WD
40
41static ulong base_address = 0;
42
43/* Memory Display
44 *
45 * Syntax:
4d1fd7f1 46 * md{.b, .w, .l, .q} {addr} {len}
3863585b
WD
47 */
48#define DISP_LINE_LEN 16
088f1b19 49static int do_mem_md(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
3863585b 50{
c68c03f5
TT
51 ulong addr, length, bytes;
52 const void *buf;
27b207fd 53 int size;
3863585b
WD
54 int rc = 0;
55
56 /* We use the last specified parameters, unless new ones are
57 * entered.
58 */
59 addr = dp_last_addr;
60 size = dp_last_size;
61 length = dp_last_length;
62
47e26b1b 63 if (argc < 2)
4c12eeb8 64 return CMD_RET_USAGE;
3863585b
WD
65
66 if ((flag & CMD_FLAG_REPEAT) == 0) {
67 /* New command specified. Check for a size specification.
68 * Defaults to long if no or incorrect specification.
69 */
27b207fd
WD
70 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
71 return 1;
3863585b
WD
72
73 /* Address is specified since argc > 1
74 */
75 addr = simple_strtoul(argv[1], NULL, 16);
76 addr += base_address;
77
78 /* If another parameter, it is the length to display.
79 * Length is the number of objects, not number of bytes.
80 */
81 if (argc > 2)
82 length = simple_strtoul(argv[2], NULL, 16);
83 }
84
c68c03f5
TT
85 bytes = size * length;
86 buf = map_sysmem(addr, bytes);
0628ab8e 87
c68c03f5
TT
88 /* Print the lines. */
89 print_buffer(addr, buf, size, length, DISP_LINE_LEN / size);
90 addr += bytes;
91 unmap_sysmem(buf);
3863585b
WD
92
93 dp_last_addr = addr;
94 dp_last_length = length;
95 dp_last_size = size;
96 return (rc);
97}
98
088f1b19 99static int do_mem_mm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
3863585b
WD
100{
101 return mod_mem (cmdtp, 1, flag, argc, argv);
102}
088f1b19 103static int do_mem_nm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
3863585b
WD
104{
105 return mod_mem (cmdtp, 0, flag, argc, argv);
106}
107
088f1b19 108static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
3863585b 109{
4d979bfd 110#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
111 u64 writeval;
112#else
113 ulong writeval;
114#endif
115 ulong addr, count;
27b207fd 116 int size;
cc5e196e 117 void *buf, *start;
0628ab8e 118 ulong bytes;
3863585b 119
47e26b1b 120 if ((argc < 3) || (argc > 4))
4c12eeb8 121 return CMD_RET_USAGE;
3863585b
WD
122
123 /* Check for size specification.
124 */
27b207fd
WD
125 if ((size = cmd_get_data_size(argv[0], 4)) < 1)
126 return 1;
3863585b
WD
127
128 /* Address is specified since argc > 1
129 */
130 addr = simple_strtoul(argv[1], NULL, 16);
131 addr += base_address;
132
133 /* Get the value to write.
134 */
4d979bfd 135#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
136 writeval = simple_strtoull(argv[2], NULL, 16);
137#else
3863585b 138 writeval = simple_strtoul(argv[2], NULL, 16);
4d1fd7f1 139#endif
3863585b
WD
140
141 /* Count ? */
142 if (argc == 4) {
143 count = simple_strtoul(argv[3], NULL, 16);
144 } else {
145 count = 1;
146 }
147
0628ab8e 148 bytes = size * count;
cc5e196e
SG
149 start = map_sysmem(addr, bytes);
150 buf = start;
3863585b
WD
151 while (count-- > 0) {
152 if (size == 4)
76698b4e 153 *((u32 *)buf) = (u32)writeval;
4d979bfd 154#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
155 else if (size == 8)
156 *((u64 *)buf) = (u64)writeval;
157#endif
3863585b 158 else if (size == 2)
76698b4e 159 *((u16 *)buf) = (u16)writeval;
3863585b 160 else
76698b4e 161 *((u8 *)buf) = (u8)writeval;
0628ab8e 162 buf += size;
3863585b 163 }
cc5e196e 164 unmap_sysmem(start);
3863585b
WD
165 return 0;
166}
167
72732318 168#ifdef CONFIG_CMD_MX_CYCLIC
5a8608e5 169static int do_mem_mdc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
4aaf29b2
SR
170{
171 int i;
172 ulong count;
173
47e26b1b 174 if (argc < 4)
4c12eeb8 175 return CMD_RET_USAGE;
4aaf29b2
SR
176
177 count = simple_strtoul(argv[3], NULL, 10);
178
179 for (;;) {
180 do_mem_md (NULL, 0, 3, argv);
181
182 /* delay for <count> ms... */
183 for (i=0; i<count; i++)
184 udelay (1000);
185
186 /* check for ctrl-c to abort... */
187 if (ctrlc()) {
188 puts("Abort\n");
189 return 0;
190 }
191 }
192
193 return 0;
194}
195
5a8608e5 196static int do_mem_mwc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
4aaf29b2
SR
197{
198 int i;
199 ulong count;
200
47e26b1b 201 if (argc < 4)
4c12eeb8 202 return CMD_RET_USAGE;
4aaf29b2
SR
203
204 count = simple_strtoul(argv[3], NULL, 10);
205
206 for (;;) {
207 do_mem_mw (NULL, 0, 3, argv);
208
209 /* delay for <count> ms... */
210 for (i=0; i<count; i++)
211 udelay (1000);
212
213 /* check for ctrl-c to abort... */
214 if (ctrlc()) {
215 puts("Abort\n");
216 return 0;
217 }
218 }
219
220 return 0;
221}
72732318 222#endif /* CONFIG_CMD_MX_CYCLIC */
4aaf29b2 223
088f1b19 224static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
3863585b 225{
0628ab8e 226 ulong addr1, addr2, count, ngood, bytes;
27b207fd 227 int size;
3863585b 228 int rcode = 0;
054ea170 229 const char *type;
0628ab8e 230 const void *buf1, *buf2, *base;
4d979bfd 231#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
232 u64 word1, word2;
233#else
234 ulong word1, word2;
235#endif
3863585b 236
47e26b1b 237 if (argc != 4)
4c12eeb8 238 return CMD_RET_USAGE;
3863585b
WD
239
240 /* Check for size specification.
241 */
27b207fd
WD
242 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
243 return 1;
4d1fd7f1
YS
244 type = size == 8 ? "double word" :
245 size == 4 ? "word" :
246 size == 2 ? "halfword" : "byte";
3863585b
WD
247
248 addr1 = simple_strtoul(argv[1], NULL, 16);
249 addr1 += base_address;
250
251 addr2 = simple_strtoul(argv[2], NULL, 16);
252 addr2 += base_address;
253
254 count = simple_strtoul(argv[3], NULL, 16);
255
0628ab8e
SG
256 bytes = size * count;
257 base = buf1 = map_sysmem(addr1, bytes);
258 buf2 = map_sysmem(addr2, bytes);
feb12a1f 259 for (ngood = 0; ngood < count; ++ngood) {
3863585b 260 if (size == 4) {
76698b4e
YS
261 word1 = *(u32 *)buf1;
262 word2 = *(u32 *)buf2;
4d979bfd 263#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
264 } else if (size == 8) {
265 word1 = *(u64 *)buf1;
266 word2 = *(u64 *)buf2;
267#endif
054ea170 268 } else if (size == 2) {
76698b4e
YS
269 word1 = *(u16 *)buf1;
270 word2 = *(u16 *)buf2;
054ea170 271 } else {
76698b4e
YS
272 word1 = *(u8 *)buf1;
273 word2 = *(u8 *)buf2;
3863585b 274 }
054ea170 275 if (word1 != word2) {
0628ab8e 276 ulong offset = buf1 - base;
4d979bfd 277#ifdef MEM_SUPPORT_64BIT_DATA
dee37fc9 278 printf("%s at 0x%p (%#0*llx) != %s at 0x%p (%#0*llx)\n",
4d1fd7f1
YS
279 type, (void *)(addr1 + offset), size, word1,
280 type, (void *)(addr2 + offset), size, word2);
281#else
054ea170 282 printf("%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx)\n",
0628ab8e
SG
283 type, (ulong)(addr1 + offset), size, word1,
284 type, (ulong)(addr2 + offset), size, word2);
4d1fd7f1 285#endif
054ea170
MF
286 rcode = 1;
287 break;
3863585b 288 }
054ea170 289
0628ab8e
SG
290 buf1 += size;
291 buf2 += size;
eaadb44e
SR
292
293 /* reset watchdog from time to time */
feb12a1f 294 if ((ngood % (64 << 10)) == 0)
eaadb44e 295 WATCHDOG_RESET();
3863585b 296 }
0628ab8e
SG
297 unmap_sysmem(buf1);
298 unmap_sysmem(buf2);
3863585b 299
054ea170 300 printf("Total of %ld %s(s) were the same\n", ngood, type);
3863585b
WD
301 return rcode;
302}
303
088f1b19 304static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
3863585b 305{
c2538421 306 ulong addr, dest, count;
787f10a9 307 void *src, *dst;
27b207fd 308 int size;
3863585b 309
47e26b1b 310 if (argc != 4)
4c12eeb8 311 return CMD_RET_USAGE;
3863585b
WD
312
313 /* Check for size specification.
314 */
27b207fd
WD
315 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
316 return 1;
3863585b
WD
317
318 addr = simple_strtoul(argv[1], NULL, 16);
319 addr += base_address;
320
321 dest = simple_strtoul(argv[2], NULL, 16);
322 dest += base_address;
323
324 count = simple_strtoul(argv[3], NULL, 16);
325
326 if (count == 0) {
327 puts ("Zero length ???\n");
328 return 1;
329 }
330
787f10a9
PR
331 src = map_sysmem(addr, count * size);
332 dst = map_sysmem(dest, count * size);
333
e856bdcf 334#ifdef CONFIG_MTD_NOR_FLASH
3863585b 335 /* check if we are copying to Flash */
787f10a9 336 if (addr2info((ulong)dst)) {
3863585b
WD
337 int rc;
338
4b9206ed 339 puts ("Copy to Flash... ");
3863585b 340
787f10a9 341 rc = flash_write((char *)src, (ulong)dst, count * size);
3863585b 342 if (rc != 0) {
0ee48252 343 flash_perror(rc);
787f10a9
PR
344 unmap_sysmem(src);
345 unmap_sysmem(dst);
3863585b
WD
346 return (1);
347 }
348 puts ("done\n");
787f10a9
PR
349 unmap_sysmem(src);
350 unmap_sysmem(dst);
3863585b
WD
351 return 0;
352 }
353#endif
354
787f10a9 355 memcpy(dst, src, count * size);
a3a4749d 356
787f10a9
PR
357 unmap_sysmem(src);
358 unmap_sysmem(dst);
3863585b
WD
359 return 0;
360}
361
088f1b19
KP
362static int do_mem_base(cmd_tbl_t *cmdtp, int flag, int argc,
363 char * const argv[])
3863585b
WD
364{
365 if (argc > 1) {
366 /* Set new base address.
367 */
368 base_address = simple_strtoul(argv[1], NULL, 16);
369 }
370 /* Print the current base address.
371 */
372 printf("Base Address: 0x%08lx\n", base_address);
373 return 0;
374}
375
088f1b19
KP
376static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
377 char * const argv[])
3863585b 378{
0628ab8e 379 ulong addr, length, i, bytes;
27b207fd 380 int size;
4d979bfd 381#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
382 volatile u64 *llp;
383#endif
76698b4e
YS
384 volatile u32 *longp;
385 volatile u16 *shortp;
386 volatile u8 *cp;
0628ab8e 387 const void *buf;
3863585b 388
47e26b1b 389 if (argc < 3)
4c12eeb8 390 return CMD_RET_USAGE;
3863585b 391
85de63e2
RD
392 /*
393 * Check for a size specification.
3863585b
WD
394 * Defaults to long if no or incorrect specification.
395 */
27b207fd
WD
396 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
397 return 1;
3863585b
WD
398
399 /* Address is always specified.
400 */
401 addr = simple_strtoul(argv[1], NULL, 16);
402
403 /* Length is the number of objects, not number of bytes.
404 */
405 length = simple_strtoul(argv[2], NULL, 16);
406
0628ab8e
SG
407 bytes = size * length;
408 buf = map_sysmem(addr, bytes);
409
3863585b
WD
410 /* We want to optimize the loops to run as fast as possible.
411 * If we have only one object, just run infinite loops.
412 */
413 if (length == 1) {
4d979bfd 414#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
415 if (size == 8) {
416 llp = (u64 *)buf;
417 for (;;)
418 i = *llp;
419 }
420#endif
3863585b 421 if (size == 4) {
76698b4e 422 longp = (u32 *)buf;
3863585b
WD
423 for (;;)
424 i = *longp;
425 }
426 if (size == 2) {
76698b4e 427 shortp = (u16 *)buf;
3863585b
WD
428 for (;;)
429 i = *shortp;
430 }
76698b4e 431 cp = (u8 *)buf;
3863585b
WD
432 for (;;)
433 i = *cp;
434 }
435
4d979bfd 436#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
437 if (size == 8) {
438 for (;;) {
439 llp = (u64 *)buf;
440 i = length;
441 while (i-- > 0)
442 *llp++;
443 }
444 }
445#endif
3863585b
WD
446 if (size == 4) {
447 for (;;) {
76698b4e 448 longp = (u32 *)buf;
3863585b
WD
449 i = length;
450 while (i-- > 0)
f3b3c3df 451 *longp++;
3863585b
WD
452 }
453 }
454 if (size == 2) {
455 for (;;) {
76698b4e 456 shortp = (u16 *)buf;
3863585b
WD
457 i = length;
458 while (i-- > 0)
f3b3c3df 459 *shortp++;
3863585b
WD
460 }
461 }
462 for (;;) {
76698b4e 463 cp = (u8 *)buf;
3863585b
WD
464 i = length;
465 while (i-- > 0)
f3b3c3df 466 *cp++;
3863585b 467 }
0628ab8e 468 unmap_sysmem(buf);
92765f42
SG
469
470 return 0;
3863585b
WD
471}
472
56523f12 473#ifdef CONFIG_LOOPW
5a8608e5
MY
474static int do_mem_loopw(cmd_tbl_t *cmdtp, int flag, int argc,
475 char * const argv[])
56523f12 476{
4d1fd7f1 477 ulong addr, length, i, bytes;
56523f12 478 int size;
4d979bfd 479#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
480 volatile u64 *llp;
481 u64 data;
482#else
483 ulong data;
484#endif
76698b4e
YS
485 volatile u32 *longp;
486 volatile u16 *shortp;
487 volatile u8 *cp;
0628ab8e 488 void *buf;
81050926 489
47e26b1b 490 if (argc < 4)
4c12eeb8 491 return CMD_RET_USAGE;
56523f12 492
85de63e2
RD
493 /*
494 * Check for a size specification.
56523f12
WD
495 * Defaults to long if no or incorrect specification.
496 */
497 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
498 return 1;
499
500 /* Address is always specified.
501 */
502 addr = simple_strtoul(argv[1], NULL, 16);
503
504 /* Length is the number of objects, not number of bytes.
505 */
506 length = simple_strtoul(argv[2], NULL, 16);
507
508 /* data to write */
4d979bfd 509#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
510 data = simple_strtoull(argv[3], NULL, 16);
511#else
56523f12 512 data = simple_strtoul(argv[3], NULL, 16);
4d1fd7f1 513#endif
81050926 514
0628ab8e
SG
515 bytes = size * length;
516 buf = map_sysmem(addr, bytes);
517
56523f12
WD
518 /* We want to optimize the loops to run as fast as possible.
519 * If we have only one object, just run infinite loops.
520 */
521 if (length == 1) {
4d979bfd 522#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
523 if (size == 8) {
524 llp = (u64 *)buf;
525 for (;;)
526 *llp = data;
527 }
528#endif
56523f12 529 if (size == 4) {
76698b4e 530 longp = (u32 *)buf;
56523f12
WD
531 for (;;)
532 *longp = data;
4d1fd7f1 533 }
56523f12 534 if (size == 2) {
76698b4e 535 shortp = (u16 *)buf;
56523f12
WD
536 for (;;)
537 *shortp = data;
538 }
76698b4e 539 cp = (u8 *)buf;
56523f12
WD
540 for (;;)
541 *cp = data;
542 }
543
4d979bfd 544#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
545 if (size == 8) {
546 for (;;) {
547 llp = (u64 *)buf;
548 i = length;
549 while (i-- > 0)
550 *llp++ = data;
551 }
552 }
553#endif
56523f12
WD
554 if (size == 4) {
555 for (;;) {
76698b4e 556 longp = (u32 *)buf;
56523f12
WD
557 i = length;
558 while (i-- > 0)
559 *longp++ = data;
560 }
561 }
562 if (size == 2) {
563 for (;;) {
76698b4e 564 shortp = (u16 *)buf;
56523f12
WD
565 i = length;
566 while (i-- > 0)
567 *shortp++ = data;
568 }
569 }
570 for (;;) {
76698b4e 571 cp = (u8 *)buf;
56523f12
WD
572 i = length;
573 while (i-- > 0)
574 *cp++ = data;
575 }
576}
577#endif /* CONFIG_LOOPW */
578
68149e94 579#ifdef CONFIG_CMD_MEMTEST
5512d5b0
SG
580static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
581 vu_long *dummy)
3863585b 582{
c9638f50 583 vu_long *addr;
c9638f50
SG
584 ulong errs = 0;
585 ulong val, readback;
586 int j;
c9638f50
SG
587 vu_long offset;
588 vu_long test_offset;
589 vu_long pattern;
590 vu_long temp;
591 vu_long anti_pattern;
592 vu_long num_words;
3863585b
WD
593 static const ulong bitpattern[] = {
594 0x00000001, /* single bit */
595 0x00000003, /* two adjacent bits */
596 0x00000007, /* three adjacent bits */
597 0x0000000F, /* four adjacent bits */
598 0x00000005, /* two non-adjacent bits */
599 0x00000015, /* three non-adjacent bits */
600 0x00000055, /* four non-adjacent bits */
601 0xaaaaaaaa, /* alternating 1/0 */
602 };
3863585b 603
5512d5b0 604 num_words = (end_addr - start_addr) / sizeof(vu_long);
8c86bbe0 605
7ecbd4d7
SG
606 /*
607 * Data line test: write a pattern to the first
608 * location, write the 1's complement to a 'parking'
609 * address (changes the state of the data bus so a
610 * floating bus doesn't give a false OK), and then
611 * read the value back. Note that we read it back
612 * into a variable because the next time we read it,
613 * it might be right (been there, tough to explain to
614 * the quality guys why it prints a failure when the
615 * "is" and "should be" are obviously the same in the
616 * error message).
617 *
618 * Rather than exhaustively testing, we test some
619 * patterns by shifting '1' bits through a field of
620 * '0's and '0' bits through a field of '1's (i.e.
621 * pattern and ~pattern).
622 */
5512d5b0 623 addr = buf;
7ecbd4d7
SG
624 for (j = 0; j < sizeof(bitpattern) / sizeof(bitpattern[0]); j++) {
625 val = bitpattern[j];
626 for (; val != 0; val <<= 1) {
5512d5b0 627 *addr = val;
c9638f50 628 *dummy = ~val; /* clear the test data off the bus */
3863585b 629 readback = *addr;
7ecbd4d7 630 if (readback != val) {
c9638f50
SG
631 printf("FAILURE (data line): "
632 "expected %08lx, actual %08lx\n",
633 val, readback);
634 errs++;
c44d4386 635 if (ctrlc())
51209b1f 636 return -1;
3863585b
WD
637 }
638 *addr = ~val;
639 *dummy = val;
640 readback = *addr;
c9638f50
SG
641 if (readback != ~val) {
642 printf("FAILURE (data line): "
643 "Is %08lx, should be %08lx\n",
644 readback, ~val);
645 errs++;
c44d4386 646 if (ctrlc())
51209b1f 647 return -1;
3863585b 648 }
3863585b 649 }
7ecbd4d7 650 }
3863585b 651
7ecbd4d7
SG
652 /*
653 * Based on code whose Original Author and Copyright
654 * information follows: Copyright (c) 1998 by Michael
655 * Barr. This software is placed into the public
656 * domain and may be used for any purpose. However,
657 * this notice must not be changed or removed and no
658 * warranty is either expressed or implied by its
659 * publication or distribution.
660 */
3863585b 661
7ecbd4d7
SG
662 /*
663 * Address line test
664
665 * Description: Test the address bus wiring in a
666 * memory region by performing a walking
667 * 1's test on the relevant bits of the
668 * address and checking for aliasing.
669 * This test will find single-bit
670 * address failures such as stuck-high,
671 * stuck-low, and shorted pins. The base
672 * address and size of the region are
673 * selected by the caller.
674
675 * Notes: For best results, the selected base
676 * address should have enough LSB 0's to
677 * guarantee single address bit changes.
678 * For example, to test a 64-Kbyte
679 * region, select a base address on a
680 * 64-Kbyte boundary. Also, select the
681 * region size as a power-of-two if at
682 * all possible.
683 *
684 * Returns: 0 if the test succeeds, 1 if the test fails.
685 */
7ecbd4d7
SG
686 pattern = (vu_long) 0xaaaaaaaa;
687 anti_pattern = (vu_long) 0x55555555;
3863585b 688
5512d5b0 689 debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words);
7ecbd4d7
SG
690 /*
691 * Write the default pattern at each of the
692 * power-of-two offsets.
693 */
5512d5b0
SG
694 for (offset = 1; offset < num_words; offset <<= 1)
695 addr[offset] = pattern;
3863585b 696
7ecbd4d7
SG
697 /*
698 * Check for address bits stuck high.
699 */
700 test_offset = 0;
5512d5b0 701 addr[test_offset] = anti_pattern;
3863585b 702
5512d5b0
SG
703 for (offset = 1; offset < num_words; offset <<= 1) {
704 temp = addr[offset];
7ecbd4d7 705 if (temp != pattern) {
c9638f50 706 printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
3863585b 707 " expected 0x%.8lx, actual 0x%.8lx\n",
102c051f
DF
708 start_addr + offset*sizeof(vu_long),
709 pattern, temp);
87b22b77 710 errs++;
c44d4386 711 if (ctrlc())
7ecbd4d7 712 return -1;
3863585b 713 }
7ecbd4d7 714 }
5512d5b0 715 addr[test_offset] = pattern;
7ecbd4d7 716 WATCHDOG_RESET();
3863585b 717
7ecbd4d7
SG
718 /*
719 * Check for addr bits stuck low or shorted.
720 */
5512d5b0
SG
721 for (test_offset = 1; test_offset < num_words; test_offset <<= 1) {
722 addr[test_offset] = anti_pattern;
3863585b 723
5512d5b0
SG
724 for (offset = 1; offset < num_words; offset <<= 1) {
725 temp = addr[offset];
3863585b 726 if ((temp != pattern) && (offset != test_offset)) {
7ecbd4d7
SG
727 printf("\nFAILURE: Address bit stuck low or"
728 " shorted @ 0x%.8lx: expected 0x%.8lx,"
729 " actual 0x%.8lx\n",
102c051f
DF
730 start_addr + offset*sizeof(vu_long),
731 pattern, temp);
7ecbd4d7 732 errs++;
c44d4386 733 if (ctrlc())
7ecbd4d7 734 return -1;
3863585b 735 }
3863585b 736 }
5512d5b0 737 addr[test_offset] = pattern;
7ecbd4d7 738 }
3863585b 739
7ecbd4d7
SG
740 /*
741 * Description: Test the integrity of a physical
742 * memory device by performing an
743 * increment/decrement test over the
744 * entire region. In the process every
745 * storage bit in the device is tested
746 * as a zero and a one. The base address
747 * and the size of the region are
748 * selected by the caller.
749 *
750 * Returns: 0 if the test succeeds, 1 if the test fails.
751 */
5512d5b0 752 num_words++;
3863585b 753
7ecbd4d7
SG
754 /*
755 * Fill memory with a known pattern.
756 */
757 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
758 WATCHDOG_RESET();
5512d5b0 759 addr[offset] = pattern;
7ecbd4d7 760 }
3863585b 761
7ecbd4d7
SG
762 /*
763 * Check each location and invert it for the second pass.
764 */
765 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
766 WATCHDOG_RESET();
5512d5b0 767 temp = addr[offset];
7ecbd4d7 768 if (temp != pattern) {
c9638f50 769 printf("\nFAILURE (read/write) @ 0x%.8lx:"
3863585b 770 " expected 0x%.8lx, actual 0x%.8lx)\n",
102c051f
DF
771 start_addr + offset*sizeof(vu_long),
772 pattern, temp);
87b22b77 773 errs++;
c44d4386 774 if (ctrlc())
51209b1f 775 return -1;
3863585b
WD
776 }
777
7ecbd4d7 778 anti_pattern = ~pattern;
5512d5b0 779 addr[offset] = anti_pattern;
7ecbd4d7
SG
780 }
781
782 /*
783 * Check each location for the inverted pattern and zero it.
784 */
785 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
786 WATCHDOG_RESET();
787 anti_pattern = ~pattern;
5512d5b0 788 temp = addr[offset];
7ecbd4d7 789 if (temp != anti_pattern) {
c9638f50 790 printf("\nFAILURE (read/write): @ 0x%.8lx:"
3863585b 791 " expected 0x%.8lx, actual 0x%.8lx)\n",
102c051f
DF
792 start_addr + offset*sizeof(vu_long),
793 anti_pattern, temp);
87b22b77 794 errs++;
c44d4386 795 if (ctrlc())
51209b1f 796 return -1;
3863585b 797 }
5512d5b0 798 addr[offset] = 0;
7ecbd4d7 799 }
51209b1f 800
fea6730e 801 return errs;
c9638f50
SG
802}
803
8e434cb7
SR
804static int compare_regions(volatile unsigned long *bufa,
805 volatile unsigned long *bufb, size_t count)
806{
807 volatile unsigned long *p1 = bufa;
808 volatile unsigned long *p2 = bufb;
809 int errs = 0;
810 size_t i;
811
812 for (i = 0; i < count; i++, p1++, p2++) {
813 if (*p1 != *p2) {
814 printf("FAILURE: 0x%08lx != 0x%08lx (delta=0x%08lx -> bit %ld) at offset 0x%08lx\n",
815 (unsigned long)*p1, (unsigned long)*p2,
816 *p1 ^ *p2, __ffs(*p1 ^ *p2),
817 (unsigned long)(i * sizeof(unsigned long)));
818 errs++;
819 }
820 }
821
822 return errs;
823}
824
825static ulong test_bitflip_comparison(volatile unsigned long *bufa,
826 volatile unsigned long *bufb, size_t count)
827{
828 volatile unsigned long *p1 = bufa;
829 volatile unsigned long *p2 = bufb;
830 unsigned int j, k;
831 unsigned long q;
832 size_t i;
833 int max;
834 int errs = 0;
835
836 max = sizeof(unsigned long) * 8;
837 for (k = 0; k < max; k++) {
838 q = 0x00000001L << k;
839 for (j = 0; j < 8; j++) {
840 WATCHDOG_RESET();
841 q = ~q;
842 p1 = (volatile unsigned long *)bufa;
843 p2 = (volatile unsigned long *)bufb;
844 for (i = 0; i < count; i++)
845 *p1++ = *p2++ = (i % 2) == 0 ? q : ~q;
846
847 errs += compare_regions(bufa, bufb, count);
848 }
849
850 if (ctrlc())
851 return -1UL;
852 }
853
854 return errs;
855}
856
5512d5b0
SG
857static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
858 vu_long pattern, int iteration)
c9638f50 859{
5512d5b0 860 vu_long *end;
c9638f50 861 vu_long *addr;
c9638f50 862 ulong errs = 0;
5512d5b0 863 ulong incr, length;
c9638f50 864 ulong val, readback;
3863585b 865
51209b1f 866 /* Alternate the pattern */
3863585b 867 incr = 1;
51209b1f
SG
868 if (iteration & 1) {
869 incr = -incr;
870 /*
871 * Flip the pattern each time to make lots of zeros and
872 * then, the next time, lots of ones. We decrement
873 * the "negative" patterns and increment the "positive"
874 * patterns to preserve this feature.
875 */
876 if (pattern & 0x80000000)
877 pattern = -pattern; /* complement & increment */
878 else
879 pattern = ~pattern;
880 }
5512d5b0
SG
881 length = (end_addr - start_addr) / sizeof(ulong);
882 end = buf + length;
7ecbd4d7
SG
883 printf("\rPattern %08lX Writing..."
884 "%12s"
885 "\b\b\b\b\b\b\b\b\b\b",
886 pattern, "");
3863585b 887
5512d5b0 888 for (addr = buf, val = pattern; addr < end; addr++) {
7ecbd4d7
SG
889 WATCHDOG_RESET();
890 *addr = val;
891 val += incr;
892 }
3863585b 893
7ecbd4d7 894 puts("Reading...");
3863585b 895
5512d5b0 896 for (addr = buf, val = pattern; addr < end; addr++) {
7ecbd4d7
SG
897 WATCHDOG_RESET();
898 readback = *addr;
899 if (readback != val) {
5512d5b0
SG
900 ulong offset = addr - buf;
901
7ecbd4d7
SG
902 printf("\nMem error @ 0x%08X: "
903 "found %08lX, expected %08lX\n",
102c051f 904 (uint)(uintptr_t)(start_addr + offset*sizeof(vu_long)),
5512d5b0 905 readback, val);
7ecbd4d7 906 errs++;
c44d4386 907 if (ctrlc())
7ecbd4d7 908 return -1;
3863585b 909 }
7ecbd4d7
SG
910 val += incr;
911 }
3863585b 912
fea6730e 913 return errs;
c9638f50
SG
914}
915
916/*
917 * Perform a memory test. A more complete alternative test can be
918 * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
919 * interrupted by ctrl-c or by a failure of one of the sub-tests.
920 */
921static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
922 char * const argv[])
923{
8c86bbe0 924 ulong start, end;
5512d5b0 925 vu_long *buf, *dummy;
adcc5705 926 ulong iteration_limit = 0;
a8c708ea 927 ulong count = 0;
51209b1f 928 ulong errs = 0; /* number of errors, or -1 if interrupted */
e37f1eb4 929 ulong pattern = 0;
51209b1f 930 int iteration;
c9638f50 931
e37f1eb4
PM
932 start = CONFIG_SYS_MEMTEST_START;
933 end = CONFIG_SYS_MEMTEST_END;
934
c9638f50 935 if (argc > 1)
e37f1eb4
PM
936 if (strict_strtoul(argv[1], 16, &start) < 0)
937 return CMD_RET_USAGE;
c9638f50
SG
938
939 if (argc > 2)
e37f1eb4
PM
940 if (strict_strtoul(argv[2], 16, &end) < 0)
941 return CMD_RET_USAGE;
c9638f50
SG
942
943 if (argc > 3)
e37f1eb4
PM
944 if (strict_strtoul(argv[3], 16, &pattern) < 0)
945 return CMD_RET_USAGE;
c9638f50
SG
946
947 if (argc > 4)
e37f1eb4
PM
948 if (strict_strtoul(argv[4], 16, &iteration_limit) < 0)
949 return CMD_RET_USAGE;
950
951 if (end < start) {
952 printf("Refusing to do empty test\n");
953 return -1;
954 }
c9638f50 955
dfe461d6 956 printf("Testing %08lx ... %08lx:\n", start, end);
8c86bbe0
SG
957 debug("%s:%d: start %#08lx end %#08lx\n", __func__, __LINE__,
958 start, end);
51209b1f 959
5512d5b0
SG
960 buf = map_sysmem(start, end - start);
961 dummy = map_sysmem(CONFIG_SYS_MEMTEST_SCRATCH, sizeof(vu_long));
51209b1f
SG
962 for (iteration = 0;
963 !iteration_limit || iteration < iteration_limit;
964 iteration++) {
965 if (ctrlc()) {
51209b1f
SG
966 errs = -1UL;
967 break;
968 }
969
970 printf("Iteration: %6d\r", iteration + 1);
971 debug("\n");
f14bfa7e 972 if (IS_ENABLED(CONFIG_SYS_ALT_MEMTEST)) {
5512d5b0 973 errs = mem_test_alt(buf, start, end, dummy);
8e434cb7
SR
974 if (errs == -1UL)
975 break;
976 count += errs;
977 errs = test_bitflip_comparison(buf,
978 buf + (end - start) / 2,
979 (end - start) /
980 sizeof(unsigned long));
5512d5b0
SG
981 } else {
982 errs = mem_test_quick(buf, start, end, pattern,
983 iteration);
984 }
985 if (errs == -1UL)
986 break;
a8c708ea 987 count += errs;
5512d5b0
SG
988 }
989
54de244c
SR
990 unmap_sysmem((void *)buf);
991 unmap_sysmem((void *)dummy);
51209b1f
SG
992
993 if (errs == -1UL) {
c44d4386
SG
994 /* Memory test was aborted - write a newline to finish off */
995 putc('\n');
51209b1f 996 }
a8c708ea 997 printf("Tested %d iteration(s) with %lu errors.\n", iteration, count);
c9638f50 998
a8c708ea 999 return errs != 0;
3863585b 1000}
a2681707 1001#endif /* CONFIG_CMD_MEMTEST */
3863585b
WD
1002
1003/* Modify memory.
1004 *
1005 * Syntax:
4d1fd7f1
YS
1006 * mm{.b, .w, .l, .q} {addr}
1007 * nm{.b, .w, .l, .q} {addr}
3863585b
WD
1008 */
1009static int
54841ab5 1010mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
3863585b 1011{
4d1fd7f1 1012 ulong addr;
4d979bfd 1013#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1014 u64 i;
1015#else
1016 ulong i;
1017#endif
27b207fd 1018 int nbytes, size;
0628ab8e 1019 void *ptr = NULL;
3863585b 1020
47e26b1b 1021 if (argc != 2)
4c12eeb8 1022 return CMD_RET_USAGE;
3863585b 1023
b26440f1 1024 bootretry_reset_cmd_timeout(); /* got a good command to get here */
3863585b
WD
1025 /* We use the last specified parameters, unless new ones are
1026 * entered.
1027 */
1028 addr = mm_last_addr;
1029 size = mm_last_size;
1030
1031 if ((flag & CMD_FLAG_REPEAT) == 0) {
1032 /* New command specified. Check for a size specification.
1033 * Defaults to long if no or incorrect specification.
1034 */
27b207fd
WD
1035 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
1036 return 1;
3863585b
WD
1037
1038 /* Address is specified since argc > 1
1039 */
1040 addr = simple_strtoul(argv[1], NULL, 16);
1041 addr += base_address;
1042 }
1043
1044 /* Print the address, followed by value. Then accept input for
1045 * the next value. A non-converted value exits.
1046 */
1047 do {
0628ab8e 1048 ptr = map_sysmem(addr, size);
3863585b
WD
1049 printf("%08lx:", addr);
1050 if (size == 4)
76698b4e 1051 printf(" %08x", *((u32 *)ptr));
4d979bfd 1052#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1 1053 else if (size == 8)
dee37fc9 1054 printf(" %016llx", *((u64 *)ptr));
4d1fd7f1 1055#endif
3863585b 1056 else if (size == 2)
76698b4e 1057 printf(" %04x", *((u16 *)ptr));
3863585b 1058 else
76698b4e 1059 printf(" %02x", *((u8 *)ptr));
3863585b 1060
e1bf824d 1061 nbytes = cli_readline(" ? ");
3863585b
WD
1062 if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
1063 /* <CR> pressed as only input, don't modify current
1064 * location and move to next. "-" pressed will go back.
1065 */
1066 if (incrflag)
1067 addr += nbytes ? -size : size;
1068 nbytes = 1;
b26440f1
SG
1069 /* good enough to not time out */
1070 bootretry_reset_cmd_timeout();
3863585b
WD
1071 }
1072#ifdef CONFIG_BOOT_RETRY_TIME
1073 else if (nbytes == -2) {
1074 break; /* timed out, exit the command */
1075 }
1076#endif
1077 else {
1078 char *endp;
4d979bfd 1079#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1080 i = simple_strtoull(console_buffer, &endp, 16);
1081#else
3863585b 1082 i = simple_strtoul(console_buffer, &endp, 16);
4d1fd7f1 1083#endif
3863585b
WD
1084 nbytes = endp - console_buffer;
1085 if (nbytes) {
3863585b
WD
1086 /* good enough to not time out
1087 */
b26440f1 1088 bootretry_reset_cmd_timeout();
3863585b 1089 if (size == 4)
76698b4e 1090 *((u32 *)ptr) = i;
4d979bfd 1091#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1092 else if (size == 8)
1093 *((u64 *)ptr) = i;
1094#endif
3863585b 1095 else if (size == 2)
76698b4e 1096 *((u16 *)ptr) = i;
3863585b 1097 else
76698b4e 1098 *((u8 *)ptr) = i;
3863585b
WD
1099 if (incrflag)
1100 addr += size;
1101 }
1102 }
1103 } while (nbytes);
0628ab8e
SG
1104 if (ptr)
1105 unmap_sysmem(ptr);
3863585b
WD
1106
1107 mm_last_addr = addr;
1108 mm_last_size = size;
1109 return 0;
1110}
1111
710b9938
MF
1112#ifdef CONFIG_CMD_CRC32
1113
088f1b19 1114static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
3863585b 1115{
d20a40de 1116 int flags = 0;
c26e454d 1117 int ac;
54841ab5 1118 char * const *av;
c26e454d 1119
d20a40de 1120 if (argc < 3)
4c12eeb8 1121 return CMD_RET_USAGE;
c26e454d
WD
1122
1123 av = argv + 1;
1124 ac = argc - 1;
221a949e 1125#ifdef CONFIG_CRC32_VERIFY
c26e454d 1126 if (strcmp(*av, "-v") == 0) {
a69bdba9 1127 flags |= HASH_FLAG_VERIFY | HASH_FLAG_ENV;
c26e454d
WD
1128 av++;
1129 ac--;
c26e454d 1130 }
d20a40de 1131#endif
c26e454d 1132
d20a40de 1133 return hash_command("crc32", flags, cmdtp, flag, ac, av);
c26e454d 1134}
c26e454d 1135
710b9938
MF
1136#endif
1137
803e1a3d
JJH
1138#ifdef CONFIG_CMD_RANDOM
1139static int do_random(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1140{
1141 unsigned long addr, len;
1142 unsigned long seed; // NOT INITIALIZED ON PURPOSE
1143 unsigned int *buf, *start;
1144 unsigned char *buf8;
1145 unsigned int i;
1146
1147 if (argc < 3 || argc > 4) {
1148 printf("usage: %s <addr> <len> [<seed>]\n", argv[0]);
1149 return 0;
1150 }
1151
1152 len = simple_strtoul(argv[2], NULL, 16);
1153 addr = simple_strtoul(argv[1], NULL, 16);
1154
1155 if (argc == 4) {
1156 seed = simple_strtoul(argv[3], NULL, 16);
1157 if (seed == 0) {
1158 printf("The seed cannot be 0. Using 0xDEADBEEF.\n");
1159 seed = 0xDEADBEEF;
1160 }
1161 } else {
1162 seed = get_timer(0) ^ rand();
1163 }
1164
1165 srand(seed);
1166 start = map_sysmem(addr, len);
1167 buf = start;
1168 for (i = 0; i < (len / 4); i++)
1169 *buf++ = rand();
1170
1171 buf8 = (unsigned char *)buf;
1172 for (i = 0; i < (len % 4); i++)
1173 *buf8++ = rand() & 0xFF;
1174
1175 unmap_sysmem(start);
1176 printf("%lu bytes filled with random data\n", len);
1177 return 1;
1178}
1179#endif
1180
8bde7f77 1181/**************************************************/
0d498393 1182U_BOOT_CMD(
53677ef1 1183 md, 3, 1, do_mem_md,
2fb2604d 1184 "memory display",
4d979bfd 1185#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1186 "[.b, .w, .l, .q] address [# of objects]"
1187#else
a89c33db 1188 "[.b, .w, .l] address [# of objects]"
4d1fd7f1 1189#endif
8bde7f77
WD
1190);
1191
1192
0d498393 1193U_BOOT_CMD(
53677ef1 1194 mm, 2, 1, do_mem_mm,
a89c33db 1195 "memory modify (auto-incrementing address)",
4d979bfd 1196#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1197 "[.b, .w, .l, .q] address"
1198#else
a89c33db 1199 "[.b, .w, .l] address"
4d1fd7f1 1200#endif
8bde7f77
WD
1201);
1202
1203
0d498393 1204U_BOOT_CMD(
53677ef1 1205 nm, 2, 1, do_mem_nm,
2fb2604d 1206 "memory modify (constant address)",
4d979bfd 1207#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1208 "[.b, .w, .l, .q] address"
1209#else
a89c33db 1210 "[.b, .w, .l] address"
4d1fd7f1 1211#endif
8bde7f77
WD
1212);
1213
0d498393 1214U_BOOT_CMD(
53677ef1 1215 mw, 4, 1, do_mem_mw,
2fb2604d 1216 "memory write (fill)",
4d979bfd 1217#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1218 "[.b, .w, .l, .q] address value [count]"
1219#else
a89c33db 1220 "[.b, .w, .l] address value [count]"
4d1fd7f1 1221#endif
8bde7f77
WD
1222);
1223
0d498393 1224U_BOOT_CMD(
53677ef1 1225 cp, 4, 1, do_mem_cp,
2fb2604d 1226 "memory copy",
4d979bfd 1227#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1228 "[.b, .w, .l, .q] source target count"
1229#else
a89c33db 1230 "[.b, .w, .l] source target count"
4d1fd7f1 1231#endif
8bde7f77
WD
1232);
1233
0d498393 1234U_BOOT_CMD(
53677ef1 1235 cmp, 4, 1, do_mem_cmp,
2fb2604d 1236 "memory compare",
4d979bfd 1237#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1238 "[.b, .w, .l, .q] addr1 addr2 count"
1239#else
a89c33db 1240 "[.b, .w, .l] addr1 addr2 count"
4d1fd7f1 1241#endif
8bde7f77
WD
1242);
1243
710b9938
MF
1244#ifdef CONFIG_CMD_CRC32
1245
221a949e 1246#ifndef CONFIG_CRC32_VERIFY
c26e454d 1247
0d498393 1248U_BOOT_CMD(
53677ef1 1249 crc32, 4, 1, do_mem_crc,
2fb2604d 1250 "checksum calculation",
a89c33db 1251 "address count [addr]\n - compute CRC32 checksum [save at addr]"
8bde7f77
WD
1252);
1253
221a949e 1254#else /* CONFIG_CRC32_VERIFY */
c26e454d
WD
1255
1256U_BOOT_CMD(
53677ef1 1257 crc32, 5, 1, do_mem_crc,
2fb2604d 1258 "checksum calculation",
c26e454d 1259 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
a89c33db 1260 "-v address count crc\n - verify crc of memory area"
c26e454d
WD
1261);
1262
221a949e 1263#endif /* CONFIG_CRC32_VERIFY */
c26e454d 1264
710b9938
MF
1265#endif
1266
15a33e49 1267#ifdef CONFIG_CMD_MEMINFO
15a33e49
SG
1268static int do_mem_info(cmd_tbl_t *cmdtp, int flag, int argc,
1269 char * const argv[])
1270{
428a6a18
SG
1271 puts("DRAM: ");
1272 print_size(gd->ram_size, "\n");
15a33e49
SG
1273
1274 return 0;
1275}
1276#endif
1277
0d498393 1278U_BOOT_CMD(
53677ef1 1279 base, 2, 1, do_mem_base,
2fb2604d 1280 "print or set address offset",
8bde7f77 1281 "\n - print address offset for memory commands\n"
a89c33db 1282 "base off\n - set address offset for memory commands to 'off'"
8bde7f77
WD
1283);
1284
0d498393 1285U_BOOT_CMD(
53677ef1 1286 loop, 3, 1, do_mem_loop,
2fb2604d 1287 "infinite loop on address range",
4d979bfd 1288#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1289 "[.b, .w, .l, .q] address number_of_objects"
1290#else
a89c33db 1291 "[.b, .w, .l] address number_of_objects"
4d1fd7f1 1292#endif
8bde7f77
WD
1293);
1294
56523f12
WD
1295#ifdef CONFIG_LOOPW
1296U_BOOT_CMD(
53677ef1 1297 loopw, 4, 1, do_mem_loopw,
2fb2604d 1298 "infinite write loop on address range",
4d979bfd 1299#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1300 "[.b, .w, .l, .q] address number_of_objects data_to_write"
1301#else
a89c33db 1302 "[.b, .w, .l] address number_of_objects data_to_write"
4d1fd7f1 1303#endif
56523f12
WD
1304);
1305#endif /* CONFIG_LOOPW */
1306
a2681707 1307#ifdef CONFIG_CMD_MEMTEST
0d498393 1308U_BOOT_CMD(
b6fc6fd4 1309 mtest, 5, 1, do_mem_mtest,
a89c33db
WD
1310 "simple RAM read/write test",
1311 "[start [end [pattern [iterations]]]]"
8bde7f77 1312);
a2681707 1313#endif /* CONFIG_CMD_MEMTEST */
8bde7f77 1314
72732318 1315#ifdef CONFIG_CMD_MX_CYCLIC
4aaf29b2 1316U_BOOT_CMD(
53677ef1 1317 mdc, 4, 1, do_mem_mdc,
2fb2604d 1318 "memory display cyclic",
4d979bfd 1319#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1320 "[.b, .w, .l, .q] address count delay(ms)"
1321#else
a89c33db 1322 "[.b, .w, .l] address count delay(ms)"
4d1fd7f1 1323#endif
4aaf29b2
SR
1324);
1325
1326U_BOOT_CMD(
53677ef1 1327 mwc, 4, 1, do_mem_mwc,
2fb2604d 1328 "memory write cyclic",
4d979bfd 1329#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1330 "[.b, .w, .l, .q] address value delay(ms)"
1331#else
a89c33db 1332 "[.b, .w, .l] address value delay(ms)"
4d1fd7f1 1333#endif
4aaf29b2 1334);
72732318 1335#endif /* CONFIG_CMD_MX_CYCLIC */
15a33e49
SG
1336
1337#ifdef CONFIG_CMD_MEMINFO
1338U_BOOT_CMD(
1339 meminfo, 3, 1, do_mem_info,
1340 "display memory information",
1341 ""
1342);
1343#endif
803e1a3d
JJH
1344
1345#ifdef CONFIG_CMD_RANDOM
1346U_BOOT_CMD(
1347 random, 4, 0, do_random,
1348 "fill memory with random pattern",
1349 "<addr> <len> [<seed>]\n"
1350 " - Fill 'len' bytes of memory starting at 'addr' with random data\n"
1351);
1352#endif
This page took 0.686141 seconds and 4 git commands to generate.