]> git.ipfire.org Git - thirdparty/u-boot.git/blame - cmd/mem.c
tools: imx8m_image: fix warning message
[thirdparty/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, wd@denx.de.
3863585b
WD
5 */
6
7/*
8 * Memory Functions
9 *
10 * Copied from FADS ROM, Dan Malek (dmalek@jlc.net)
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
4aaf29b2 168#ifdef CONFIG_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}
222#endif /* CONFIG_MX_CYCLIC */
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
5512d5b0
SG
804static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
805 vu_long pattern, int iteration)
c9638f50 806{
5512d5b0 807 vu_long *end;
c9638f50 808 vu_long *addr;
c9638f50 809 ulong errs = 0;
5512d5b0 810 ulong incr, length;
c9638f50 811 ulong val, readback;
3863585b 812
51209b1f 813 /* Alternate the pattern */
3863585b 814 incr = 1;
51209b1f
SG
815 if (iteration & 1) {
816 incr = -incr;
817 /*
818 * Flip the pattern each time to make lots of zeros and
819 * then, the next time, lots of ones. We decrement
820 * the "negative" patterns and increment the "positive"
821 * patterns to preserve this feature.
822 */
823 if (pattern & 0x80000000)
824 pattern = -pattern; /* complement & increment */
825 else
826 pattern = ~pattern;
827 }
5512d5b0
SG
828 length = (end_addr - start_addr) / sizeof(ulong);
829 end = buf + length;
7ecbd4d7
SG
830 printf("\rPattern %08lX Writing..."
831 "%12s"
832 "\b\b\b\b\b\b\b\b\b\b",
833 pattern, "");
3863585b 834
5512d5b0 835 for (addr = buf, val = pattern; addr < end; addr++) {
7ecbd4d7
SG
836 WATCHDOG_RESET();
837 *addr = val;
838 val += incr;
839 }
3863585b 840
7ecbd4d7 841 puts("Reading...");
3863585b 842
5512d5b0 843 for (addr = buf, val = pattern; addr < end; addr++) {
7ecbd4d7
SG
844 WATCHDOG_RESET();
845 readback = *addr;
846 if (readback != val) {
5512d5b0
SG
847 ulong offset = addr - buf;
848
7ecbd4d7
SG
849 printf("\nMem error @ 0x%08X: "
850 "found %08lX, expected %08lX\n",
102c051f 851 (uint)(uintptr_t)(start_addr + offset*sizeof(vu_long)),
5512d5b0 852 readback, val);
7ecbd4d7 853 errs++;
c44d4386 854 if (ctrlc())
7ecbd4d7 855 return -1;
3863585b 856 }
7ecbd4d7
SG
857 val += incr;
858 }
3863585b 859
fea6730e 860 return errs;
c9638f50
SG
861}
862
863/*
864 * Perform a memory test. A more complete alternative test can be
865 * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
866 * interrupted by ctrl-c or by a failure of one of the sub-tests.
867 */
868static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
869 char * const argv[])
870{
8c86bbe0 871 ulong start, end;
5512d5b0 872 vu_long *buf, *dummy;
adcc5705 873 ulong iteration_limit = 0;
c9638f50 874 int ret;
51209b1f 875 ulong errs = 0; /* number of errors, or -1 if interrupted */
e37f1eb4 876 ulong pattern = 0;
51209b1f 877 int iteration;
c9638f50
SG
878#if defined(CONFIG_SYS_ALT_MEMTEST)
879 const int alt_test = 1;
880#else
881 const int alt_test = 0;
3863585b 882#endif
c9638f50 883
e37f1eb4
PM
884 start = CONFIG_SYS_MEMTEST_START;
885 end = CONFIG_SYS_MEMTEST_END;
886
c9638f50 887 if (argc > 1)
e37f1eb4
PM
888 if (strict_strtoul(argv[1], 16, &start) < 0)
889 return CMD_RET_USAGE;
c9638f50
SG
890
891 if (argc > 2)
e37f1eb4
PM
892 if (strict_strtoul(argv[2], 16, &end) < 0)
893 return CMD_RET_USAGE;
c9638f50
SG
894
895 if (argc > 3)
e37f1eb4
PM
896 if (strict_strtoul(argv[3], 16, &pattern) < 0)
897 return CMD_RET_USAGE;
c9638f50
SG
898
899 if (argc > 4)
e37f1eb4
PM
900 if (strict_strtoul(argv[4], 16, &iteration_limit) < 0)
901 return CMD_RET_USAGE;
902
903 if (end < start) {
904 printf("Refusing to do empty test\n");
905 return -1;
906 }
c9638f50 907
dfe461d6 908 printf("Testing %08lx ... %08lx:\n", start, end);
8c86bbe0
SG
909 debug("%s:%d: start %#08lx end %#08lx\n", __func__, __LINE__,
910 start, end);
51209b1f 911
5512d5b0
SG
912 buf = map_sysmem(start, end - start);
913 dummy = map_sysmem(CONFIG_SYS_MEMTEST_SCRATCH, sizeof(vu_long));
51209b1f
SG
914 for (iteration = 0;
915 !iteration_limit || iteration < iteration_limit;
916 iteration++) {
917 if (ctrlc()) {
51209b1f
SG
918 errs = -1UL;
919 break;
920 }
921
922 printf("Iteration: %6d\r", iteration + 1);
923 debug("\n");
5512d5b0
SG
924 if (alt_test) {
925 errs = mem_test_alt(buf, start, end, dummy);
926 } else {
927 errs = mem_test_quick(buf, start, end, pattern,
928 iteration);
929 }
930 if (errs == -1UL)
931 break;
932 }
933
934 /*
935 * Work-around for eldk-4.2 which gives this warning if we try to
936 * case in the unmap_sysmem() call:
937 * warning: initialization discards qualifiers from pointer target type
938 */
939 {
940 void *vbuf = (void *)buf;
941 void *vdummy = (void *)dummy;
942
943 unmap_sysmem(vbuf);
944 unmap_sysmem(vdummy);
51209b1f
SG
945 }
946
947 if (errs == -1UL) {
c44d4386
SG
948 /* Memory test was aborted - write a newline to finish off */
949 putc('\n');
51209b1f
SG
950 ret = 1;
951 } else {
952 printf("Tested %d iteration(s) with %lu errors.\n",
953 iteration, errs);
954 ret = errs != 0;
955 }
c9638f50 956
e37f1eb4 957 return ret;
3863585b 958}
a2681707 959#endif /* CONFIG_CMD_MEMTEST */
3863585b
WD
960
961/* Modify memory.
962 *
963 * Syntax:
4d1fd7f1
YS
964 * mm{.b, .w, .l, .q} {addr}
965 * nm{.b, .w, .l, .q} {addr}
3863585b
WD
966 */
967static int
54841ab5 968mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
3863585b 969{
4d1fd7f1 970 ulong addr;
4d979bfd 971#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
972 u64 i;
973#else
974 ulong i;
975#endif
27b207fd 976 int nbytes, size;
0628ab8e 977 void *ptr = NULL;
3863585b 978
47e26b1b 979 if (argc != 2)
4c12eeb8 980 return CMD_RET_USAGE;
3863585b 981
b26440f1 982 bootretry_reset_cmd_timeout(); /* got a good command to get here */
3863585b
WD
983 /* We use the last specified parameters, unless new ones are
984 * entered.
985 */
986 addr = mm_last_addr;
987 size = mm_last_size;
988
989 if ((flag & CMD_FLAG_REPEAT) == 0) {
990 /* New command specified. Check for a size specification.
991 * Defaults to long if no or incorrect specification.
992 */
27b207fd
WD
993 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
994 return 1;
3863585b
WD
995
996 /* Address is specified since argc > 1
997 */
998 addr = simple_strtoul(argv[1], NULL, 16);
999 addr += base_address;
1000 }
1001
1002 /* Print the address, followed by value. Then accept input for
1003 * the next value. A non-converted value exits.
1004 */
1005 do {
0628ab8e 1006 ptr = map_sysmem(addr, size);
3863585b
WD
1007 printf("%08lx:", addr);
1008 if (size == 4)
76698b4e 1009 printf(" %08x", *((u32 *)ptr));
4d979bfd 1010#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1 1011 else if (size == 8)
dee37fc9 1012 printf(" %016llx", *((u64 *)ptr));
4d1fd7f1 1013#endif
3863585b 1014 else if (size == 2)
76698b4e 1015 printf(" %04x", *((u16 *)ptr));
3863585b 1016 else
76698b4e 1017 printf(" %02x", *((u8 *)ptr));
3863585b 1018
e1bf824d 1019 nbytes = cli_readline(" ? ");
3863585b
WD
1020 if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
1021 /* <CR> pressed as only input, don't modify current
1022 * location and move to next. "-" pressed will go back.
1023 */
1024 if (incrflag)
1025 addr += nbytes ? -size : size;
1026 nbytes = 1;
b26440f1
SG
1027 /* good enough to not time out */
1028 bootretry_reset_cmd_timeout();
3863585b
WD
1029 }
1030#ifdef CONFIG_BOOT_RETRY_TIME
1031 else if (nbytes == -2) {
1032 break; /* timed out, exit the command */
1033 }
1034#endif
1035 else {
1036 char *endp;
4d979bfd 1037#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1038 i = simple_strtoull(console_buffer, &endp, 16);
1039#else
3863585b 1040 i = simple_strtoul(console_buffer, &endp, 16);
4d1fd7f1 1041#endif
3863585b
WD
1042 nbytes = endp - console_buffer;
1043 if (nbytes) {
3863585b
WD
1044 /* good enough to not time out
1045 */
b26440f1 1046 bootretry_reset_cmd_timeout();
3863585b 1047 if (size == 4)
76698b4e 1048 *((u32 *)ptr) = i;
4d979bfd 1049#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1050 else if (size == 8)
1051 *((u64 *)ptr) = i;
1052#endif
3863585b 1053 else if (size == 2)
76698b4e 1054 *((u16 *)ptr) = i;
3863585b 1055 else
76698b4e 1056 *((u8 *)ptr) = i;
3863585b
WD
1057 if (incrflag)
1058 addr += size;
1059 }
1060 }
1061 } while (nbytes);
0628ab8e
SG
1062 if (ptr)
1063 unmap_sysmem(ptr);
3863585b
WD
1064
1065 mm_last_addr = addr;
1066 mm_last_size = size;
1067 return 0;
1068}
1069
710b9938
MF
1070#ifdef CONFIG_CMD_CRC32
1071
088f1b19 1072static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
3863585b 1073{
d20a40de 1074 int flags = 0;
c26e454d 1075 int ac;
54841ab5 1076 char * const *av;
c26e454d 1077
d20a40de 1078 if (argc < 3)
4c12eeb8 1079 return CMD_RET_USAGE;
c26e454d
WD
1080
1081 av = argv + 1;
1082 ac = argc - 1;
221a949e 1083#ifdef CONFIG_CRC32_VERIFY
c26e454d 1084 if (strcmp(*av, "-v") == 0) {
a69bdba9 1085 flags |= HASH_FLAG_VERIFY | HASH_FLAG_ENV;
c26e454d
WD
1086 av++;
1087 ac--;
c26e454d 1088 }
d20a40de 1089#endif
c26e454d 1090
d20a40de 1091 return hash_command("crc32", flags, cmdtp, flag, ac, av);
c26e454d 1092}
c26e454d 1093
710b9938
MF
1094#endif
1095
803e1a3d
JJH
1096#ifdef CONFIG_CMD_RANDOM
1097static int do_random(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1098{
1099 unsigned long addr, len;
1100 unsigned long seed; // NOT INITIALIZED ON PURPOSE
1101 unsigned int *buf, *start;
1102 unsigned char *buf8;
1103 unsigned int i;
1104
1105 if (argc < 3 || argc > 4) {
1106 printf("usage: %s <addr> <len> [<seed>]\n", argv[0]);
1107 return 0;
1108 }
1109
1110 len = simple_strtoul(argv[2], NULL, 16);
1111 addr = simple_strtoul(argv[1], NULL, 16);
1112
1113 if (argc == 4) {
1114 seed = simple_strtoul(argv[3], NULL, 16);
1115 if (seed == 0) {
1116 printf("The seed cannot be 0. Using 0xDEADBEEF.\n");
1117 seed = 0xDEADBEEF;
1118 }
1119 } else {
1120 seed = get_timer(0) ^ rand();
1121 }
1122
1123 srand(seed);
1124 start = map_sysmem(addr, len);
1125 buf = start;
1126 for (i = 0; i < (len / 4); i++)
1127 *buf++ = rand();
1128
1129 buf8 = (unsigned char *)buf;
1130 for (i = 0; i < (len % 4); i++)
1131 *buf8++ = rand() & 0xFF;
1132
1133 unmap_sysmem(start);
1134 printf("%lu bytes filled with random data\n", len);
1135 return 1;
1136}
1137#endif
1138
8bde7f77 1139/**************************************************/
0d498393 1140U_BOOT_CMD(
53677ef1 1141 md, 3, 1, do_mem_md,
2fb2604d 1142 "memory display",
4d979bfd 1143#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1144 "[.b, .w, .l, .q] address [# of objects]"
1145#else
a89c33db 1146 "[.b, .w, .l] address [# of objects]"
4d1fd7f1 1147#endif
8bde7f77
WD
1148);
1149
1150
0d498393 1151U_BOOT_CMD(
53677ef1 1152 mm, 2, 1, do_mem_mm,
a89c33db 1153 "memory modify (auto-incrementing address)",
4d979bfd 1154#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1155 "[.b, .w, .l, .q] address"
1156#else
a89c33db 1157 "[.b, .w, .l] address"
4d1fd7f1 1158#endif
8bde7f77
WD
1159);
1160
1161
0d498393 1162U_BOOT_CMD(
53677ef1 1163 nm, 2, 1, do_mem_nm,
2fb2604d 1164 "memory modify (constant address)",
4d979bfd 1165#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1166 "[.b, .w, .l, .q] address"
1167#else
a89c33db 1168 "[.b, .w, .l] address"
4d1fd7f1 1169#endif
8bde7f77
WD
1170);
1171
0d498393 1172U_BOOT_CMD(
53677ef1 1173 mw, 4, 1, do_mem_mw,
2fb2604d 1174 "memory write (fill)",
4d979bfd 1175#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1176 "[.b, .w, .l, .q] address value [count]"
1177#else
a89c33db 1178 "[.b, .w, .l] address value [count]"
4d1fd7f1 1179#endif
8bde7f77
WD
1180);
1181
0d498393 1182U_BOOT_CMD(
53677ef1 1183 cp, 4, 1, do_mem_cp,
2fb2604d 1184 "memory copy",
4d979bfd 1185#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1186 "[.b, .w, .l, .q] source target count"
1187#else
a89c33db 1188 "[.b, .w, .l] source target count"
4d1fd7f1 1189#endif
8bde7f77
WD
1190);
1191
0d498393 1192U_BOOT_CMD(
53677ef1 1193 cmp, 4, 1, do_mem_cmp,
2fb2604d 1194 "memory compare",
4d979bfd 1195#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1196 "[.b, .w, .l, .q] addr1 addr2 count"
1197#else
a89c33db 1198 "[.b, .w, .l] addr1 addr2 count"
4d1fd7f1 1199#endif
8bde7f77
WD
1200);
1201
710b9938
MF
1202#ifdef CONFIG_CMD_CRC32
1203
221a949e 1204#ifndef CONFIG_CRC32_VERIFY
c26e454d 1205
0d498393 1206U_BOOT_CMD(
53677ef1 1207 crc32, 4, 1, do_mem_crc,
2fb2604d 1208 "checksum calculation",
a89c33db 1209 "address count [addr]\n - compute CRC32 checksum [save at addr]"
8bde7f77
WD
1210);
1211
221a949e 1212#else /* CONFIG_CRC32_VERIFY */
c26e454d
WD
1213
1214U_BOOT_CMD(
53677ef1 1215 crc32, 5, 1, do_mem_crc,
2fb2604d 1216 "checksum calculation",
c26e454d 1217 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
a89c33db 1218 "-v address count crc\n - verify crc of memory area"
c26e454d
WD
1219);
1220
221a949e 1221#endif /* CONFIG_CRC32_VERIFY */
c26e454d 1222
710b9938
MF
1223#endif
1224
15a33e49 1225#ifdef CONFIG_CMD_MEMINFO
15a33e49
SG
1226static int do_mem_info(cmd_tbl_t *cmdtp, int flag, int argc,
1227 char * const argv[])
1228{
428a6a18
SG
1229 puts("DRAM: ");
1230 print_size(gd->ram_size, "\n");
15a33e49
SG
1231
1232 return 0;
1233}
1234#endif
1235
0d498393 1236U_BOOT_CMD(
53677ef1 1237 base, 2, 1, do_mem_base,
2fb2604d 1238 "print or set address offset",
8bde7f77 1239 "\n - print address offset for memory commands\n"
a89c33db 1240 "base off\n - set address offset for memory commands to 'off'"
8bde7f77
WD
1241);
1242
0d498393 1243U_BOOT_CMD(
53677ef1 1244 loop, 3, 1, do_mem_loop,
2fb2604d 1245 "infinite loop on address range",
4d979bfd 1246#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1247 "[.b, .w, .l, .q] address number_of_objects"
1248#else
a89c33db 1249 "[.b, .w, .l] address number_of_objects"
4d1fd7f1 1250#endif
8bde7f77
WD
1251);
1252
56523f12
WD
1253#ifdef CONFIG_LOOPW
1254U_BOOT_CMD(
53677ef1 1255 loopw, 4, 1, do_mem_loopw,
2fb2604d 1256 "infinite write loop on address range",
4d979bfd 1257#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1258 "[.b, .w, .l, .q] address number_of_objects data_to_write"
1259#else
a89c33db 1260 "[.b, .w, .l] address number_of_objects data_to_write"
4d1fd7f1 1261#endif
56523f12
WD
1262);
1263#endif /* CONFIG_LOOPW */
1264
a2681707 1265#ifdef CONFIG_CMD_MEMTEST
0d498393 1266U_BOOT_CMD(
b6fc6fd4 1267 mtest, 5, 1, do_mem_mtest,
a89c33db
WD
1268 "simple RAM read/write test",
1269 "[start [end [pattern [iterations]]]]"
8bde7f77 1270);
a2681707 1271#endif /* CONFIG_CMD_MEMTEST */
8bde7f77 1272
4aaf29b2
SR
1273#ifdef CONFIG_MX_CYCLIC
1274U_BOOT_CMD(
53677ef1 1275 mdc, 4, 1, do_mem_mdc,
2fb2604d 1276 "memory display cyclic",
4d979bfd 1277#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1278 "[.b, .w, .l, .q] address count delay(ms)"
1279#else
a89c33db 1280 "[.b, .w, .l] address count delay(ms)"
4d1fd7f1 1281#endif
4aaf29b2
SR
1282);
1283
1284U_BOOT_CMD(
53677ef1 1285 mwc, 4, 1, do_mem_mwc,
2fb2604d 1286 "memory write cyclic",
4d979bfd 1287#ifdef MEM_SUPPORT_64BIT_DATA
4d1fd7f1
YS
1288 "[.b, .w, .l, .q] address value delay(ms)"
1289#else
a89c33db 1290 "[.b, .w, .l] address value delay(ms)"
4d1fd7f1 1291#endif
4aaf29b2
SR
1292);
1293#endif /* CONFIG_MX_CYCLIC */
15a33e49
SG
1294
1295#ifdef CONFIG_CMD_MEMINFO
1296U_BOOT_CMD(
1297 meminfo, 3, 1, do_mem_info,
1298 "display memory information",
1299 ""
1300);
1301#endif
803e1a3d
JJH
1302
1303#ifdef CONFIG_CMD_RANDOM
1304U_BOOT_CMD(
1305 random, 4, 0, do_random,
1306 "fill memory with random pattern",
1307 "<addr> <len> [<seed>]\n"
1308 " - Fill 'len' bytes of memory starting at 'addr' with random data\n"
1309);
1310#endif