blob: 51aa71fca84999b17fd451eb0607925732a22baa [file] [log] [blame]
wdenk38635852002-08-27 05:55:31 +00001/*
2 * (C) Copyright 2000
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24/*
25 * Memory Functions
26 *
27 * Copied from FADS ROM, Dan Malek (dmalek@jlc.net)
28 */
29
30#include <common.h>
31#include <command.h>
Jon Loeligerc76fe472007-07-08 18:02:23 -050032#if defined(CONFIG_CMD_MMC)
wdenk71f95112003-06-15 22:40:42 +000033#include <mmc.h>
34#endif
wdenk2abbe072003-06-16 23:50:08 +000035#ifdef CONFIG_HAS_DATAFLASH
36#include <dataflash.h>
37#endif
Sergei Poselenova6e6fc62008-04-09 16:09:41 +020038#include <watchdog.h>
wdenk38635852002-08-27 05:55:31 +000039
Jon Loeligerc76fe472007-07-08 18:02:23 -050040#if defined(CONFIG_CMD_MEMORY) \
Jon Loeliger65c450b2007-06-11 19:01:54 -050041 || defined(CONFIG_CMD_I2C) \
42 || defined(CONFIG_CMD_ITEST) \
43 || defined(CONFIG_CMD_PCI) \
44 || defined(CONFIG_CMD_PORTIO)
45
wdenk38635852002-08-27 05:55:31 +000046int cmd_get_data_size(char* arg, int default_size)
47{
48 /* Check for a size specification .b, .w or .l.
49 */
50 int len = strlen(arg);
51 if (len > 2 && arg[len-2] == '.') {
52 switch(arg[len-1]) {
53 case 'b':
54 return 1;
55 case 'w':
56 return 2;
57 case 'l':
58 return 4;
wdenk2d1a5372004-02-23 19:30:57 +000059 case 's':
60 return -2;
wdenk27b207f2003-07-24 23:38:38 +000061 default:
62 return -1;
wdenk38635852002-08-27 05:55:31 +000063 }
64 }
65 return default_size;
66}
67#endif
68
Jon Loeligerc76fe472007-07-08 18:02:23 -050069#if defined(CONFIG_CMD_MEMORY)
wdenk38635852002-08-27 05:55:31 +000070
71#ifdef CMD_MEM_DEBUG
72#define PRINTF(fmt,args...) printf (fmt ,##args)
73#else
74#define PRINTF(fmt,args...)
75#endif
76
77static int mod_mem(cmd_tbl_t *, int, int, int, char *[]);
78
79/* Display values from last command.
80 * Memory modify remembered values are different from display memory.
81 */
82uint dp_last_addr, dp_last_size;
83uint dp_last_length = 0x40;
84uint mm_last_addr, mm_last_size;
85
86static ulong base_address = 0;
87
88/* Memory Display
89 *
90 * Syntax:
91 * md{.b, .w, .l} {addr} {len}
92 */
93#define DISP_LINE_LEN 16
94int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
95{
wdenk27b207f2003-07-24 23:38:38 +000096 ulong addr, length;
Grant Likelyc95c4282007-02-20 09:05:00 +010097#if defined(CONFIG_HAS_DATAFLASH)
98 ulong nbytes, linebytes;
99#endif
wdenk27b207f2003-07-24 23:38:38 +0000100 int size;
wdenk38635852002-08-27 05:55:31 +0000101 int rc = 0;
102
103 /* We use the last specified parameters, unless new ones are
104 * entered.
105 */
106 addr = dp_last_addr;
107 size = dp_last_size;
108 length = dp_last_length;
109
110 if (argc < 2) {
111 printf ("Usage:\n%s\n", cmdtp->usage);
112 return 1;
113 }
114
115 if ((flag & CMD_FLAG_REPEAT) == 0) {
116 /* New command specified. Check for a size specification.
117 * Defaults to long if no or incorrect specification.
118 */
wdenk27b207f2003-07-24 23:38:38 +0000119 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
120 return 1;
wdenk38635852002-08-27 05:55:31 +0000121
122 /* Address is specified since argc > 1
123 */
124 addr = simple_strtoul(argv[1], NULL, 16);
125 addr += base_address;
126
127 /* If another parameter, it is the length to display.
128 * Length is the number of objects, not number of bytes.
129 */
130 if (argc > 2)
131 length = simple_strtoul(argv[2], NULL, 16);
132 }
133
Grant Likelyc95c4282007-02-20 09:05:00 +0100134#if defined(CONFIG_HAS_DATAFLASH)
wdenk38635852002-08-27 05:55:31 +0000135 /* Print the lines.
136 *
137 * We buffer all read data, so we can make sure data is read only
138 * once, and all accesses are with the specified bus width.
139 */
140 nbytes = length * size;
141 do {
142 char linebuf[DISP_LINE_LEN];
Grant Likelyc95c4282007-02-20 09:05:00 +0100143 void* p;
wdenk38635852002-08-27 05:55:31 +0000144 linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes;
wdenk2abbe072003-06-16 23:50:08 +0000145
Grant Likelyc95c4282007-02-20 09:05:00 +0100146 rc = read_dataflash(addr, (linebytes/size)*size, linebuf);
147 p = (rc == DATAFLASH_OK) ? linebuf : (void*)addr;
148 print_buffer(addr, p, size, linebytes/size, DISP_LINE_LEN/size);
wdenk8bde7f72003-06-27 21:31:46 +0000149
wdenk38635852002-08-27 05:55:31 +0000150 nbytes -= linebytes;
Grant Likelyc95c4282007-02-20 09:05:00 +0100151 addr += linebytes;
wdenk38635852002-08-27 05:55:31 +0000152 if (ctrlc()) {
153 rc = 1;
154 break;
155 }
156 } while (nbytes > 0);
Grant Likelyc95c4282007-02-20 09:05:00 +0100157#else
Mike Frysinger4c727c72008-02-04 19:26:56 -0500158
159# if defined(CONFIG_BLACKFIN)
160 /* See if we're trying to display L1 inst */
161 if (addr_bfin_on_chip_mem(addr)) {
162 char linebuf[DISP_LINE_LEN];
163 ulong linebytes, nbytes = length * size;
164 do {
165 linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes;
166 memcpy(linebuf, (void *)addr, linebytes);
167 print_buffer(addr, linebuf, size, linebytes/size, DISP_LINE_LEN/size);
168
169 nbytes -= linebytes;
170 addr += linebytes;
171 if (ctrlc()) {
172 rc = 1;
173 break;
174 }
175 } while (nbytes > 0);
176 } else
177# endif
178
179 {
180 /* Print the lines. */
181 print_buffer(addr, (void*)addr, size, length, DISP_LINE_LEN/size);
182 addr += size*length;
183 }
Grant Likelyc95c4282007-02-20 09:05:00 +0100184#endif
wdenk38635852002-08-27 05:55:31 +0000185
186 dp_last_addr = addr;
187 dp_last_length = length;
188 dp_last_size = size;
189 return (rc);
190}
191
192int do_mem_mm ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
193{
194 return mod_mem (cmdtp, 1, flag, argc, argv);
195}
196int do_mem_nm ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
197{
198 return mod_mem (cmdtp, 0, flag, argc, argv);
199}
200
201int do_mem_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
202{
wdenk27b207f2003-07-24 23:38:38 +0000203 ulong addr, writeval, count;
204 int size;
wdenk38635852002-08-27 05:55:31 +0000205
206 if ((argc < 3) || (argc > 4)) {
207 printf ("Usage:\n%s\n", cmdtp->usage);
208 return 1;
209 }
210
211 /* Check for size specification.
212 */
wdenk27b207f2003-07-24 23:38:38 +0000213 if ((size = cmd_get_data_size(argv[0], 4)) < 1)
214 return 1;
wdenk38635852002-08-27 05:55:31 +0000215
216 /* Address is specified since argc > 1
217 */
218 addr = simple_strtoul(argv[1], NULL, 16);
219 addr += base_address;
220
221 /* Get the value to write.
222 */
223 writeval = simple_strtoul(argv[2], NULL, 16);
224
225 /* Count ? */
226 if (argc == 4) {
227 count = simple_strtoul(argv[3], NULL, 16);
228 } else {
229 count = 1;
230 }
231
232 while (count-- > 0) {
233 if (size == 4)
234 *((ulong *)addr) = (ulong )writeval;
235 else if (size == 2)
236 *((ushort *)addr) = (ushort)writeval;
237 else
238 *((u_char *)addr) = (u_char)writeval;
239 addr += size;
240 }
241 return 0;
242}
243
stroese4aaf29b2004-12-16 17:42:39 +0000244#ifdef CONFIG_MX_CYCLIC
245int do_mem_mdc ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
246{
247 int i;
248 ulong count;
249
250 if (argc < 4) {
251 printf ("Usage:\n%s\n", cmdtp->usage);
252 return 1;
253 }
254
255 count = simple_strtoul(argv[3], NULL, 10);
256
257 for (;;) {
258 do_mem_md (NULL, 0, 3, argv);
259
260 /* delay for <count> ms... */
261 for (i=0; i<count; i++)
262 udelay (1000);
263
264 /* check for ctrl-c to abort... */
265 if (ctrlc()) {
266 puts("Abort\n");
267 return 0;
268 }
269 }
270
271 return 0;
272}
273
274int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
275{
276 int i;
277 ulong count;
278
279 if (argc < 4) {
280 printf ("Usage:\n%s\n", cmdtp->usage);
281 return 1;
282 }
283
284 count = simple_strtoul(argv[3], NULL, 10);
285
286 for (;;) {
287 do_mem_mw (NULL, 0, 3, argv);
288
289 /* delay for <count> ms... */
290 for (i=0; i<count; i++)
291 udelay (1000);
292
293 /* check for ctrl-c to abort... */
294 if (ctrlc()) {
295 puts("Abort\n");
296 return 0;
297 }
298 }
299
300 return 0;
301}
302#endif /* CONFIG_MX_CYCLIC */
303
wdenk38635852002-08-27 05:55:31 +0000304int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
305{
wdenk27b207f2003-07-24 23:38:38 +0000306 ulong addr1, addr2, count, ngood;
307 int size;
wdenk38635852002-08-27 05:55:31 +0000308 int rcode = 0;
309
310 if (argc != 4) {
311 printf ("Usage:\n%s\n", cmdtp->usage);
312 return 1;
313 }
314
315 /* Check for size specification.
316 */
wdenk27b207f2003-07-24 23:38:38 +0000317 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
318 return 1;
wdenk38635852002-08-27 05:55:31 +0000319
320 addr1 = simple_strtoul(argv[1], NULL, 16);
321 addr1 += base_address;
322
323 addr2 = simple_strtoul(argv[2], NULL, 16);
324 addr2 += base_address;
325
326 count = simple_strtoul(argv[3], NULL, 16);
327
wdenk2abbe072003-06-16 23:50:08 +0000328#ifdef CONFIG_HAS_DATAFLASH
329 if (addr_dataflash(addr1) | addr_dataflash(addr2)){
wdenk4b9206e2004-03-23 22:14:11 +0000330 puts ("Comparison with DataFlash space not supported.\n\r");
wdenk2abbe072003-06-16 23:50:08 +0000331 return 0;
332 }
333#endif
334
Mike Frysinger4c727c72008-02-04 19:26:56 -0500335#ifdef CONFIG_BLACKFIN
336 if (addr_bfin_on_chip_mem(addr1) || addr_bfin_on_chip_mem(addr2)) {
337 puts ("Comparison with L1 instruction memory not supported.\n\r");
338 return 0;
339 }
340#endif
341
wdenk38635852002-08-27 05:55:31 +0000342 ngood = 0;
343
344 while (count-- > 0) {
345 if (size == 4) {
346 ulong word1 = *(ulong *)addr1;
347 ulong word2 = *(ulong *)addr2;
348 if (word1 != word2) {
349 printf("word at 0x%08lx (0x%08lx) "
350 "!= word at 0x%08lx (0x%08lx)\n",
351 addr1, word1, addr2, word2);
352 rcode = 1;
353 break;
354 }
355 }
356 else if (size == 2) {
357 ushort hword1 = *(ushort *)addr1;
358 ushort hword2 = *(ushort *)addr2;
359 if (hword1 != hword2) {
360 printf("halfword at 0x%08lx (0x%04x) "
361 "!= halfword at 0x%08lx (0x%04x)\n",
362 addr1, hword1, addr2, hword2);
363 rcode = 1;
364 break;
365 }
366 }
367 else {
368 u_char byte1 = *(u_char *)addr1;
369 u_char byte2 = *(u_char *)addr2;
370 if (byte1 != byte2) {
371 printf("byte at 0x%08lx (0x%02x) "
372 "!= byte at 0x%08lx (0x%02x)\n",
373 addr1, byte1, addr2, byte2);
374 rcode = 1;
375 break;
376 }
377 }
378 ngood++;
379 addr1 += size;
380 addr2 += size;
381 }
382
383 printf("Total of %ld %s%s were the same\n",
384 ngood, size == 4 ? "word" : size == 2 ? "halfword" : "byte",
385 ngood == 1 ? "" : "s");
386 return rcode;
387}
388
389int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
390{
wdenk27b207f2003-07-24 23:38:38 +0000391 ulong addr, dest, count;
392 int size;
wdenk38635852002-08-27 05:55:31 +0000393
394 if (argc != 4) {
395 printf ("Usage:\n%s\n", cmdtp->usage);
396 return 1;
397 }
398
399 /* Check for size specification.
400 */
wdenk27b207f2003-07-24 23:38:38 +0000401 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
402 return 1;
wdenk38635852002-08-27 05:55:31 +0000403
404 addr = simple_strtoul(argv[1], NULL, 16);
405 addr += base_address;
406
407 dest = simple_strtoul(argv[2], NULL, 16);
408 dest += base_address;
409
410 count = simple_strtoul(argv[3], NULL, 16);
411
412 if (count == 0) {
413 puts ("Zero length ???\n");
414 return 1;
415 }
416
417#ifndef CFG_NO_FLASH
418 /* check if we are copying to Flash */
wdenk2abbe072003-06-16 23:50:08 +0000419 if ( (addr2info(dest) != NULL)
420#ifdef CONFIG_HAS_DATAFLASH
Kim B. Heino84d0c2f2008-03-03 10:39:13 +0200421 && (!addr_dataflash(dest))
wdenk2abbe072003-06-16 23:50:08 +0000422#endif
423 ) {
wdenk38635852002-08-27 05:55:31 +0000424 int rc;
425
wdenk4b9206e2004-03-23 22:14:11 +0000426 puts ("Copy to Flash... ");
wdenk38635852002-08-27 05:55:31 +0000427
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200428 rc = flash_write ((char *)addr, dest, count*size);
wdenk38635852002-08-27 05:55:31 +0000429 if (rc != 0) {
430 flash_perror (rc);
431 return (1);
432 }
433 puts ("done\n");
434 return 0;
435 }
436#endif
437
Jon Loeligerc76fe472007-07-08 18:02:23 -0500438#if defined(CONFIG_CMD_MMC)
wdenk71f95112003-06-15 22:40:42 +0000439 if (mmc2info(dest)) {
440 int rc;
441
wdenk4b9206e2004-03-23 22:14:11 +0000442 puts ("Copy to MMC... ");
wdenk71f95112003-06-15 22:40:42 +0000443 switch (rc = mmc_write ((uchar *)addr, dest, count*size)) {
444 case 0:
wdenk4b9206e2004-03-23 22:14:11 +0000445 putc ('\n');
wdenk71f95112003-06-15 22:40:42 +0000446 return 1;
447 case -1:
wdenk4b9206e2004-03-23 22:14:11 +0000448 puts ("failed\n");
wdenk71f95112003-06-15 22:40:42 +0000449 return 1;
450 default:
451 printf ("%s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc);
452 return 1;
453 }
454 puts ("done\n");
455 return 0;
456 }
457
458 if (mmc2info(addr)) {
459 int rc;
460
wdenk4b9206e2004-03-23 22:14:11 +0000461 puts ("Copy from MMC... ");
wdenk71f95112003-06-15 22:40:42 +0000462 switch (rc = mmc_read (addr, (uchar *)dest, count*size)) {
463 case 0:
wdenk4b9206e2004-03-23 22:14:11 +0000464 putc ('\n');
wdenk71f95112003-06-15 22:40:42 +0000465 return 1;
466 case -1:
wdenk4b9206e2004-03-23 22:14:11 +0000467 puts ("failed\n");
wdenk71f95112003-06-15 22:40:42 +0000468 return 1;
469 default:
470 printf ("%s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc);
471 return 1;
472 }
473 puts ("done\n");
474 return 0;
475 }
476#endif
477
wdenk2abbe072003-06-16 23:50:08 +0000478#ifdef CONFIG_HAS_DATAFLASH
479 /* Check if we are copying from RAM or Flash to DataFlash */
480 if (addr_dataflash(dest) && !addr_dataflash(addr)){
481 int rc;
482
wdenk4b9206e2004-03-23 22:14:11 +0000483 puts ("Copy to DataFlash... ");
wdenk2abbe072003-06-16 23:50:08 +0000484
485 rc = write_dataflash (dest, addr, count*size);
486
487 if (rc != 1) {
488 dataflash_perror (rc);
489 return (1);
490 }
491 puts ("done\n");
492 return 0;
493 }
wdenk8bde7f72003-06-27 21:31:46 +0000494
wdenk2abbe072003-06-16 23:50:08 +0000495 /* Check if we are copying from DataFlash to RAM */
Stelian Pop880cc432008-03-26 22:52:35 +0100496 if (addr_dataflash(addr) && !addr_dataflash(dest)
497#ifndef CFG_NO_FLASH
498 && (addr2info(dest) == NULL)
499#endif
500 ){
wdenk5779d8d2003-12-06 23:55:10 +0000501 int rc;
502 rc = read_dataflash(addr, count * size, (char *) dest);
503 if (rc != 1) {
wdenkd4ca31c2004-01-02 14:00:00 +0000504 dataflash_perror (rc);
505 return (1);
506 }
wdenk2abbe072003-06-16 23:50:08 +0000507 return 0;
508 }
509
510 if (addr_dataflash(addr) && addr_dataflash(dest)){
wdenk4b9206e2004-03-23 22:14:11 +0000511 puts ("Unsupported combination of source/destination.\n\r");
wdenk2abbe072003-06-16 23:50:08 +0000512 return 1;
513 }
514#endif
515
Mike Frysinger4c727c72008-02-04 19:26:56 -0500516#ifdef CONFIG_BLACKFIN
517 /* See if we're copying to/from L1 inst */
518 if (addr_bfin_on_chip_mem(dest) || addr_bfin_on_chip_mem(addr)) {
519 memcpy((void *)dest, (void *)addr, count * size);
520 return 0;
521 }
522#endif
523
wdenk38635852002-08-27 05:55:31 +0000524 while (count-- > 0) {
525 if (size == 4)
526 *((ulong *)dest) = *((ulong *)addr);
527 else if (size == 2)
528 *((ushort *)dest) = *((ushort *)addr);
529 else
530 *((u_char *)dest) = *((u_char *)addr);
531 addr += size;
532 dest += size;
533 }
534 return 0;
535}
536
537int do_mem_base (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
538{
539 if (argc > 1) {
540 /* Set new base address.
541 */
542 base_address = simple_strtoul(argv[1], NULL, 16);
543 }
544 /* Print the current base address.
545 */
546 printf("Base Address: 0x%08lx\n", base_address);
547 return 0;
548}
549
550int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
551{
wdenk27b207f2003-07-24 23:38:38 +0000552 ulong addr, length, i, junk;
553 int size;
wdenk38635852002-08-27 05:55:31 +0000554 volatile uint *longp;
555 volatile ushort *shortp;
556 volatile u_char *cp;
557
558 if (argc < 3) {
559 printf ("Usage:\n%s\n", cmdtp->usage);
560 return 1;
561 }
562
563 /* Check for a size spefication.
564 * Defaults to long if no or incorrect specification.
565 */
wdenk27b207f2003-07-24 23:38:38 +0000566 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
567 return 1;
wdenk38635852002-08-27 05:55:31 +0000568
569 /* Address is always specified.
570 */
571 addr = simple_strtoul(argv[1], NULL, 16);
572
573 /* Length is the number of objects, not number of bytes.
574 */
575 length = simple_strtoul(argv[2], NULL, 16);
576
577 /* We want to optimize the loops to run as fast as possible.
578 * If we have only one object, just run infinite loops.
579 */
580 if (length == 1) {
581 if (size == 4) {
582 longp = (uint *)addr;
583 for (;;)
584 i = *longp;
585 }
586 if (size == 2) {
587 shortp = (ushort *)addr;
588 for (;;)
589 i = *shortp;
590 }
591 cp = (u_char *)addr;
592 for (;;)
593 i = *cp;
594 }
595
596 if (size == 4) {
597 for (;;) {
598 longp = (uint *)addr;
599 i = length;
600 while (i-- > 0)
601 junk = *longp++;
602 }
603 }
604 if (size == 2) {
605 for (;;) {
606 shortp = (ushort *)addr;
607 i = length;
608 while (i-- > 0)
609 junk = *shortp++;
610 }
611 }
612 for (;;) {
613 cp = (u_char *)addr;
614 i = length;
615 while (i-- > 0)
616 junk = *cp++;
617 }
618}
619
wdenk56523f12004-07-11 17:40:54 +0000620#ifdef CONFIG_LOOPW
621int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
622{
623 ulong addr, length, i, data;
624 int size;
625 volatile uint *longp;
626 volatile ushort *shortp;
627 volatile u_char *cp;
wdenk81050922004-07-11 20:04:51 +0000628
wdenk56523f12004-07-11 17:40:54 +0000629 if (argc < 4) {
630 printf ("Usage:\n%s\n", cmdtp->usage);
631 return 1;
632 }
633
634 /* Check for a size spefication.
635 * Defaults to long if no or incorrect specification.
636 */
637 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
638 return 1;
639
640 /* Address is always specified.
641 */
642 addr = simple_strtoul(argv[1], NULL, 16);
643
644 /* Length is the number of objects, not number of bytes.
645 */
646 length = simple_strtoul(argv[2], NULL, 16);
647
648 /* data to write */
649 data = simple_strtoul(argv[3], NULL, 16);
wdenk81050922004-07-11 20:04:51 +0000650
wdenk56523f12004-07-11 17:40:54 +0000651 /* We want to optimize the loops to run as fast as possible.
652 * If we have only one object, just run infinite loops.
653 */
654 if (length == 1) {
655 if (size == 4) {
656 longp = (uint *)addr;
657 for (;;)
658 *longp = data;
659 }
660 if (size == 2) {
661 shortp = (ushort *)addr;
662 for (;;)
663 *shortp = data;
664 }
665 cp = (u_char *)addr;
666 for (;;)
667 *cp = data;
668 }
669
670 if (size == 4) {
671 for (;;) {
672 longp = (uint *)addr;
673 i = length;
674 while (i-- > 0)
675 *longp++ = data;
676 }
677 }
678 if (size == 2) {
679 for (;;) {
680 shortp = (ushort *)addr;
681 i = length;
682 while (i-- > 0)
683 *shortp++ = data;
684 }
685 }
686 for (;;) {
687 cp = (u_char *)addr;
688 i = length;
689 while (i-- > 0)
690 *cp++ = data;
691 }
692}
693#endif /* CONFIG_LOOPW */
694
wdenk38635852002-08-27 05:55:31 +0000695/*
696 * Perform a memory test. A more complete alternative test can be
697 * configured using CFG_ALT_MEMTEST. The complete test loops until
698 * interrupted by ctrl-c or by a failure of one of the sub-tests.
699 */
700int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
701{
702 vu_long *addr, *start, *end;
703 ulong val;
704 ulong readback;
Guennadi Liakhovetski1f780aa2008-02-13 11:19:19 +0100705 int rcode = 0;
wdenk38635852002-08-27 05:55:31 +0000706
707#if defined(CFG_ALT_MEMTEST)
Guennadi Liakhovetski6f4abee2008-02-08 21:25:58 +0100708 vu_long len;
wdenk38635852002-08-27 05:55:31 +0000709 vu_long offset;
710 vu_long test_offset;
711 vu_long pattern;
712 vu_long temp;
713 vu_long anti_pattern;
714 vu_long num_words;
wdenk5f535fe2003-09-18 09:21:33 +0000715#if defined(CFG_MEMTEST_SCRATCH)
716 vu_long *dummy = (vu_long*)CFG_MEMTEST_SCRATCH;
717#else
Wolfgang Denk029b6dc2006-07-21 11:37:40 +0200718 vu_long *dummy = 0; /* yes, this is address 0x0, not NULL */
wdenk5f535fe2003-09-18 09:21:33 +0000719#endif
wdenk38635852002-08-27 05:55:31 +0000720 int j;
721 int iterations = 1;
722
723 static const ulong bitpattern[] = {
724 0x00000001, /* single bit */
725 0x00000003, /* two adjacent bits */
726 0x00000007, /* three adjacent bits */
727 0x0000000F, /* four adjacent bits */
728 0x00000005, /* two non-adjacent bits */
729 0x00000015, /* three non-adjacent bits */
730 0x00000055, /* four non-adjacent bits */
731 0xaaaaaaaa, /* alternating 1/0 */
732 };
733#else
734 ulong incr;
735 ulong pattern;
wdenk38635852002-08-27 05:55:31 +0000736#endif
737
738 if (argc > 1) {
739 start = (ulong *)simple_strtoul(argv[1], NULL, 16);
740 } else {
741 start = (ulong *)CFG_MEMTEST_START;
742 }
743
744 if (argc > 2) {
745 end = (ulong *)simple_strtoul(argv[2], NULL, 16);
746 } else {
747 end = (ulong *)(CFG_MEMTEST_END);
748 }
749
750 if (argc > 3) {
751 pattern = (ulong)simple_strtoul(argv[3], NULL, 16);
752 } else {
753 pattern = 0;
754 }
755
756#if defined(CFG_ALT_MEMTEST)
757 printf ("Testing %08x ... %08x:\n", (uint)start, (uint)end);
758 PRINTF("%s:%d: start 0x%p end 0x%p\n",
759 __FUNCTION__, __LINE__, start, end);
760
761 for (;;) {
762 if (ctrlc()) {
763 putc ('\n');
764 return 1;
765 }
766
767 printf("Iteration: %6d\r", iterations);
768 PRINTF("Iteration: %6d\n", iterations);
769 iterations++;
770
771 /*
772 * Data line test: write a pattern to the first
773 * location, write the 1's complement to a 'parking'
774 * address (changes the state of the data bus so a
775 * floating bus doen't give a false OK), and then
776 * read the value back. Note that we read it back
777 * into a variable because the next time we read it,
778 * it might be right (been there, tough to explain to
779 * the quality guys why it prints a failure when the
780 * "is" and "should be" are obviously the same in the
781 * error message).
782 *
783 * Rather than exhaustively testing, we test some
784 * patterns by shifting '1' bits through a field of
785 * '0's and '0' bits through a field of '1's (i.e.
786 * pattern and ~pattern).
787 */
788 addr = start;
789 for (j = 0; j < sizeof(bitpattern)/sizeof(bitpattern[0]); j++) {
790 val = bitpattern[j];
791 for(; val != 0; val <<= 1) {
792 *addr = val;
793 *dummy = ~val; /* clear the test data off of the bus */
794 readback = *addr;
795 if(readback != val) {
796 printf ("FAILURE (data line): "
797 "expected %08lx, actual %08lx\n",
798 val, readback);
799 }
800 *addr = ~val;
801 *dummy = val;
802 readback = *addr;
803 if(readback != ~val) {
804 printf ("FAILURE (data line): "
805 "Is %08lx, should be %08lx\n",
wdenke1599e82004-10-10 23:27:33 +0000806 readback, ~val);
wdenk38635852002-08-27 05:55:31 +0000807 }
808 }
809 }
810
811 /*
812 * Based on code whose Original Author and Copyright
813 * information follows: Copyright (c) 1998 by Michael
814 * Barr. This software is placed into the public
815 * domain and may be used for any purpose. However,
816 * this notice must not be changed or removed and no
817 * warranty is either expressed or implied by its
818 * publication or distribution.
819 */
820
821 /*
822 * Address line test
823 *
824 * Description: Test the address bus wiring in a
825 * memory region by performing a walking
826 * 1's test on the relevant bits of the
827 * address and checking for aliasing.
828 * This test will find single-bit
829 * address failures such as stuck -high,
830 * stuck-low, and shorted pins. The base
831 * address and size of the region are
832 * selected by the caller.
833 *
834 * Notes: For best results, the selected base
835 * address should have enough LSB 0's to
836 * guarantee single address bit changes.
837 * For example, to test a 64-Kbyte
838 * region, select a base address on a
839 * 64-Kbyte boundary. Also, select the
840 * region size as a power-of-two if at
841 * all possible.
842 *
843 * Returns: 0 if the test succeeds, 1 if the test fails.
wdenk38635852002-08-27 05:55:31 +0000844 */
Guennadi Liakhovetski6f4abee2008-02-08 21:25:58 +0100845 len = ((ulong)end - (ulong)start)/sizeof(vu_long);
wdenk38635852002-08-27 05:55:31 +0000846 pattern = (vu_long) 0xaaaaaaaa;
847 anti_pattern = (vu_long) 0x55555555;
848
Guennadi Liakhovetski6f4abee2008-02-08 21:25:58 +0100849 PRINTF("%s:%d: length = 0x%.8lx\n",
wdenk38635852002-08-27 05:55:31 +0000850 __FUNCTION__, __LINE__,
Guennadi Liakhovetski6f4abee2008-02-08 21:25:58 +0100851 len);
wdenk38635852002-08-27 05:55:31 +0000852 /*
853 * Write the default pattern at each of the
854 * power-of-two offsets.
855 */
Guennadi Liakhovetski6f4abee2008-02-08 21:25:58 +0100856 for (offset = 1; offset < len; offset <<= 1) {
wdenk38635852002-08-27 05:55:31 +0000857 start[offset] = pattern;
858 }
859
860 /*
861 * Check for address bits stuck high.
862 */
863 test_offset = 0;
864 start[test_offset] = anti_pattern;
865
Guennadi Liakhovetski6f4abee2008-02-08 21:25:58 +0100866 for (offset = 1; offset < len; offset <<= 1) {
wdenk38635852002-08-27 05:55:31 +0000867 temp = start[offset];
868 if (temp != pattern) {
869 printf ("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
870 " expected 0x%.8lx, actual 0x%.8lx\n",
871 (ulong)&start[offset], pattern, temp);
872 return 1;
873 }
874 }
875 start[test_offset] = pattern;
Sergei Poselenova6e6fc62008-04-09 16:09:41 +0200876 WATCHDOG_RESET();
wdenk38635852002-08-27 05:55:31 +0000877
878 /*
879 * Check for addr bits stuck low or shorted.
880 */
Guennadi Liakhovetski6f4abee2008-02-08 21:25:58 +0100881 for (test_offset = 1; test_offset < len; test_offset <<= 1) {
wdenk38635852002-08-27 05:55:31 +0000882 start[test_offset] = anti_pattern;
883
Guennadi Liakhovetski6f4abee2008-02-08 21:25:58 +0100884 for (offset = 1; offset < len; offset <<= 1) {
wdenk38635852002-08-27 05:55:31 +0000885 temp = start[offset];
886 if ((temp != pattern) && (offset != test_offset)) {
887 printf ("\nFAILURE: Address bit stuck low or shorted @"
888 " 0x%.8lx: expected 0x%.8lx, actual 0x%.8lx\n",
889 (ulong)&start[offset], pattern, temp);
890 return 1;
891 }
892 }
893 start[test_offset] = pattern;
894 }
895
896 /*
897 * Description: Test the integrity of a physical
898 * memory device by performing an
899 * increment/decrement test over the
900 * entire region. In the process every
901 * storage bit in the device is tested
902 * as a zero and a one. The base address
903 * and the size of the region are
904 * selected by the caller.
905 *
906 * Returns: 0 if the test succeeds, 1 if the test fails.
907 */
908 num_words = ((ulong)end - (ulong)start)/sizeof(vu_long) + 1;
909
910 /*
911 * Fill memory with a known pattern.
912 */
913 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
Sergei Poselenova6e6fc62008-04-09 16:09:41 +0200914 WATCHDOG_RESET();
wdenk38635852002-08-27 05:55:31 +0000915 start[offset] = pattern;
916 }
917
918 /*
919 * Check each location and invert it for the second pass.
920 */
921 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
Sergei Poselenova6e6fc62008-04-09 16:09:41 +0200922 WATCHDOG_RESET();
wdenk38635852002-08-27 05:55:31 +0000923 temp = start[offset];
924 if (temp != pattern) {
925 printf ("\nFAILURE (read/write) @ 0x%.8lx:"
926 " expected 0x%.8lx, actual 0x%.8lx)\n",
927 (ulong)&start[offset], pattern, temp);
928 return 1;
929 }
930
931 anti_pattern = ~pattern;
932 start[offset] = anti_pattern;
933 }
934
935 /*
936 * Check each location for the inverted pattern and zero it.
937 */
938 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
Sergei Poselenova6e6fc62008-04-09 16:09:41 +0200939 WATCHDOG_RESET();
wdenk38635852002-08-27 05:55:31 +0000940 anti_pattern = ~pattern;
941 temp = start[offset];
942 if (temp != anti_pattern) {
943 printf ("\nFAILURE (read/write): @ 0x%.8lx:"
944 " expected 0x%.8lx, actual 0x%.8lx)\n",
945 (ulong)&start[offset], anti_pattern, temp);
946 return 1;
947 }
948 start[offset] = 0;
949 }
950 }
951
952#else /* The original, quickie test */
953 incr = 1;
954 for (;;) {
955 if (ctrlc()) {
956 putc ('\n');
957 return 1;
958 }
959
960 printf ("\rPattern %08lX Writing..."
961 "%12s"
962 "\b\b\b\b\b\b\b\b\b\b",
963 pattern, "");
964
965 for (addr=start,val=pattern; addr<end; addr++) {
Sergei Poselenova6e6fc62008-04-09 16:09:41 +0200966 WATCHDOG_RESET();
wdenk38635852002-08-27 05:55:31 +0000967 *addr = val;
968 val += incr;
969 }
970
wdenk4b9206e2004-03-23 22:14:11 +0000971 puts ("Reading...");
wdenk38635852002-08-27 05:55:31 +0000972
973 for (addr=start,val=pattern; addr<end; addr++) {
Sergei Poselenova6e6fc62008-04-09 16:09:41 +0200974 WATCHDOG_RESET();
wdenk38635852002-08-27 05:55:31 +0000975 readback = *addr;
976 if (readback != val) {
977 printf ("\nMem error @ 0x%08X: "
978 "found %08lX, expected %08lX\n",
979 (uint)addr, readback, val);
980 rcode = 1;
981 }
982 val += incr;
983 }
984
985 /*
986 * Flip the pattern each time to make lots of zeros and
987 * then, the next time, lots of ones. We decrement
988 * the "negative" patterns and increment the "positive"
989 * patterns to preserve this feature.
990 */
991 if(pattern & 0x80000000) {
992 pattern = -pattern; /* complement & increment */
993 }
994 else {
995 pattern = ~pattern;
996 }
997 incr = -incr;
998 }
wdenk38635852002-08-27 05:55:31 +0000999#endif
Guennadi Liakhovetski1f780aa2008-02-13 11:19:19 +01001000 return rcode;
wdenk38635852002-08-27 05:55:31 +00001001}
1002
1003
1004/* Modify memory.
1005 *
1006 * Syntax:
1007 * mm{.b, .w, .l} {addr}
1008 * nm{.b, .w, .l} {addr}
1009 */
1010static int
1011mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[])
1012{
wdenk27b207f2003-07-24 23:38:38 +00001013 ulong addr, i;
1014 int nbytes, size;
wdenk38635852002-08-27 05:55:31 +00001015 extern char console_buffer[];
1016
1017 if (argc != 2) {
1018 printf ("Usage:\n%s\n", cmdtp->usage);
1019 return 1;
1020 }
1021
1022#ifdef CONFIG_BOOT_RETRY_TIME
1023 reset_cmd_timeout(); /* got a good command to get here */
1024#endif
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 */
wdenk27b207f2003-07-24 23:38:38 +00001035 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
1036 return 1;
wdenk38635852002-08-27 05:55:31 +00001037
1038 /* Address is specified since argc > 1
1039 */
1040 addr = simple_strtoul(argv[1], NULL, 16);
1041 addr += base_address;
1042 }
1043
wdenk2abbe072003-06-16 23:50:08 +00001044#ifdef CONFIG_HAS_DATAFLASH
1045 if (addr_dataflash(addr)){
wdenk4b9206e2004-03-23 22:14:11 +00001046 puts ("Can't modify DataFlash in place. Use cp instead.\n\r");
wdenk2abbe072003-06-16 23:50:08 +00001047 return 0;
1048 }
1049#endif
1050
Mike Frysinger4c727c72008-02-04 19:26:56 -05001051#ifdef CONFIG_BLACKFIN
1052 if (addr_bfin_on_chip_mem(addr)) {
1053 puts ("Can't modify L1 instruction in place. Use cp instead.\n\r");
1054 return 0;
1055 }
1056#endif
1057
wdenk38635852002-08-27 05:55:31 +00001058 /* Print the address, followed by value. Then accept input for
1059 * the next value. A non-converted value exits.
1060 */
1061 do {
1062 printf("%08lx:", addr);
1063 if (size == 4)
1064 printf(" %08x", *((uint *)addr));
1065 else if (size == 2)
1066 printf(" %04x", *((ushort *)addr));
1067 else
1068 printf(" %02x", *((u_char *)addr));
1069
1070 nbytes = readline (" ? ");
1071 if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
1072 /* <CR> pressed as only input, don't modify current
1073 * location and move to next. "-" pressed will go back.
1074 */
1075 if (incrflag)
1076 addr += nbytes ? -size : size;
1077 nbytes = 1;
1078#ifdef CONFIG_BOOT_RETRY_TIME
1079 reset_cmd_timeout(); /* good enough to not time out */
1080#endif
1081 }
1082#ifdef CONFIG_BOOT_RETRY_TIME
1083 else if (nbytes == -2) {
1084 break; /* timed out, exit the command */
1085 }
1086#endif
1087 else {
1088 char *endp;
1089 i = simple_strtoul(console_buffer, &endp, 16);
1090 nbytes = endp - console_buffer;
1091 if (nbytes) {
1092#ifdef CONFIG_BOOT_RETRY_TIME
1093 /* good enough to not time out
1094 */
1095 reset_cmd_timeout();
1096#endif
1097 if (size == 4)
1098 *((uint *)addr) = i;
1099 else if (size == 2)
1100 *((ushort *)addr) = i;
1101 else
1102 *((u_char *)addr) = i;
1103 if (incrflag)
1104 addr += size;
1105 }
1106 }
1107 } while (nbytes);
1108
1109 mm_last_addr = addr;
1110 mm_last_size = size;
1111 return 0;
1112}
1113
wdenkc26e4542004-04-18 10:13:26 +00001114#ifndef CONFIG_CRC32_VERIFY
1115
wdenk38635852002-08-27 05:55:31 +00001116int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
1117{
wdenk71f95112003-06-15 22:40:42 +00001118 ulong addr, length;
1119 ulong crc;
1120 ulong *ptr;
wdenk38635852002-08-27 05:55:31 +00001121
1122 if (argc < 3) {
1123 printf ("Usage:\n%s\n", cmdtp->usage);
1124 return 1;
1125 }
1126
wdenk71f95112003-06-15 22:40:42 +00001127 addr = simple_strtoul (argv[1], NULL, 16);
wdenk38635852002-08-27 05:55:31 +00001128 addr += base_address;
1129
wdenk71f95112003-06-15 22:40:42 +00001130 length = simple_strtoul (argv[2], NULL, 16);
wdenk38635852002-08-27 05:55:31 +00001131
wdenk71f95112003-06-15 22:40:42 +00001132 crc = crc32 (0, (const uchar *) addr, length);
wdenk38635852002-08-27 05:55:31 +00001133
1134 printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
wdenk71f95112003-06-15 22:40:42 +00001135 addr, addr + length - 1, crc);
wdenk38635852002-08-27 05:55:31 +00001136
wdenk71f95112003-06-15 22:40:42 +00001137 if (argc > 3) {
1138 ptr = (ulong *) simple_strtoul (argv[3], NULL, 16);
1139 *ptr = crc;
1140 }
wdenk38635852002-08-27 05:55:31 +00001141
1142 return 0;
1143}
1144
wdenkc26e4542004-04-18 10:13:26 +00001145#else /* CONFIG_CRC32_VERIFY */
1146
1147int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
1148{
1149 ulong addr, length;
1150 ulong crc;
1151 ulong *ptr;
wdenk6e592382004-04-18 17:39:38 +00001152 ulong vcrc;
wdenkc26e4542004-04-18 10:13:26 +00001153 int verify;
1154 int ac;
1155 char **av;
1156
1157 if (argc < 3) {
1158 usage:
1159 printf ("Usage:\n%s\n", cmdtp->usage);
1160 return 1;
1161 }
1162
1163 av = argv + 1;
1164 ac = argc - 1;
1165 if (strcmp(*av, "-v") == 0) {
1166 verify = 1;
1167 av++;
1168 ac--;
1169 if (ac < 3)
1170 goto usage;
1171 } else
1172 verify = 0;
1173
1174 addr = simple_strtoul(*av++, NULL, 16);
1175 addr += base_address;
1176 length = simple_strtoul(*av++, NULL, 16);
1177
1178 crc = crc32(0, (const uchar *) addr, length);
1179
1180 if (!verify) {
1181 printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
1182 addr, addr + length - 1, crc);
1183 if (ac > 2) {
1184 ptr = (ulong *) simple_strtoul (*av++, NULL, 16);
1185 *ptr = crc;
1186 }
1187 } else {
1188 vcrc = simple_strtoul(*av++, NULL, 16);
1189 if (vcrc != crc) {
1190 printf ("CRC32 for %08lx ... %08lx ==> %08lx != %08lx ** ERROR **\n",
1191 addr, addr + length - 1, crc, vcrc);
1192 return 1;
1193 }
1194 }
1195
1196 return 0;
1197
1198}
1199#endif /* CONFIG_CRC32_VERIFY */
1200
wdenk8bde7f72003-06-27 21:31:46 +00001201/**************************************************/
Jon Loeligerc76fe472007-07-08 18:02:23 -05001202#if defined(CONFIG_CMD_MEMORY)
wdenk0d498392003-07-01 21:06:45 +00001203U_BOOT_CMD(
1204 md, 3, 1, do_mem_md,
wdenk8bde7f72003-06-27 21:31:46 +00001205 "md - memory display\n",
1206 "[.b, .w, .l] address [# of objects]\n - memory display\n"
1207);
1208
1209
wdenk0d498392003-07-01 21:06:45 +00001210U_BOOT_CMD(
1211 mm, 2, 1, do_mem_mm,
wdenk8bde7f72003-06-27 21:31:46 +00001212 "mm - memory modify (auto-incrementing)\n",
1213 "[.b, .w, .l] address\n" " - memory modify, auto increment address\n"
1214);
1215
1216
wdenk0d498392003-07-01 21:06:45 +00001217U_BOOT_CMD(
1218 nm, 2, 1, do_mem_nm,
wdenk8bde7f72003-06-27 21:31:46 +00001219 "nm - memory modify (constant address)\n",
1220 "[.b, .w, .l] address\n - memory modify, read and keep address\n"
1221);
1222
wdenk0d498392003-07-01 21:06:45 +00001223U_BOOT_CMD(
1224 mw, 4, 1, do_mem_mw,
wdenk8bde7f72003-06-27 21:31:46 +00001225 "mw - memory write (fill)\n",
1226 "[.b, .w, .l] address value [count]\n - write memory\n"
1227);
1228
wdenk0d498392003-07-01 21:06:45 +00001229U_BOOT_CMD(
1230 cp, 4, 1, do_mem_cp,
wdenk8bde7f72003-06-27 21:31:46 +00001231 "cp - memory copy\n",
1232 "[.b, .w, .l] source target count\n - copy memory\n"
1233);
1234
wdenk0d498392003-07-01 21:06:45 +00001235U_BOOT_CMD(
1236 cmp, 4, 1, do_mem_cmp,
wdenk8bde7f72003-06-27 21:31:46 +00001237 "cmp - memory compare\n",
1238 "[.b, .w, .l] addr1 addr2 count\n - compare memory\n"
1239);
1240
wdenkc26e4542004-04-18 10:13:26 +00001241#ifndef CONFIG_CRC32_VERIFY
1242
wdenk0d498392003-07-01 21:06:45 +00001243U_BOOT_CMD(
1244 crc32, 4, 1, do_mem_crc,
wdenk8bde7f72003-06-27 21:31:46 +00001245 "crc32 - checksum calculation\n",
1246 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1247);
1248
wdenkc26e4542004-04-18 10:13:26 +00001249#else /* CONFIG_CRC32_VERIFY */
1250
1251U_BOOT_CMD(
1252 crc32, 5, 1, do_mem_crc,
1253 "crc32 - checksum calculation\n",
1254 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1255 "-v address count crc\n - verify crc of memory area\n"
1256);
1257
1258#endif /* CONFIG_CRC32_VERIFY */
1259
wdenk0d498392003-07-01 21:06:45 +00001260U_BOOT_CMD(
1261 base, 2, 1, do_mem_base,
wdenk8bde7f72003-06-27 21:31:46 +00001262 "base - print or set address offset\n",
1263 "\n - print address offset for memory commands\n"
1264 "base off\n - set address offset for memory commands to 'off'\n"
1265);
1266
wdenk0d498392003-07-01 21:06:45 +00001267U_BOOT_CMD(
1268 loop, 3, 1, do_mem_loop,
wdenk8bde7f72003-06-27 21:31:46 +00001269 "loop - infinite loop on address range\n",
1270 "[.b, .w, .l] address number_of_objects\n"
1271 " - loop on a set of addresses\n"
1272);
1273
wdenk56523f12004-07-11 17:40:54 +00001274#ifdef CONFIG_LOOPW
1275U_BOOT_CMD(
1276 loopw, 4, 1, do_mem_loopw,
1277 "loopw - infinite write loop on address range\n",
1278 "[.b, .w, .l] address number_of_objects data_to_write\n"
1279 " - loop on a set of addresses\n"
1280);
1281#endif /* CONFIG_LOOPW */
1282
wdenk0d498392003-07-01 21:06:45 +00001283U_BOOT_CMD(
1284 mtest, 4, 1, do_mem_mtest,
wdenk8bde7f72003-06-27 21:31:46 +00001285 "mtest - simple RAM test\n",
1286 "[start [end [pattern]]]\n"
1287 " - simple RAM read/write test\n"
1288);
1289
stroese4aaf29b2004-12-16 17:42:39 +00001290#ifdef CONFIG_MX_CYCLIC
1291U_BOOT_CMD(
1292 mdc, 4, 1, do_mem_mdc,
1293 "mdc - memory display cyclic\n",
1294 "[.b, .w, .l] address count delay(ms)\n - memory display cyclic\n"
1295);
1296
1297U_BOOT_CMD(
1298 mwc, 4, 1, do_mem_mwc,
1299 "mwc - memory write cyclic\n",
1300 "[.b, .w, .l] address value delay(ms)\n - memory write cyclic\n"
1301);
1302#endif /* CONFIG_MX_CYCLIC */
1303
wdenk8bde7f72003-06-27 21:31:46 +00001304#endif
Jon Loeliger90253172007-07-10 11:02:44 -05001305#endif