]>
git.ipfire.org Git - people/ms/u-boot.git/blob - common/cmd_mem.c
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
27 * Copied from FADS ROM, Dan Malek (dmalek@jlc.net)
32 #if defined(CONFIG_CMD_MMC)
35 #ifdef CONFIG_HAS_DATAFLASH
36 #include <dataflash.h>
40 #if defined(CONFIG_CMD_MEMORY) \
41 || defined(CONFIG_CMD_I2C) \
42 || defined(CONFIG_CMD_ITEST) \
43 || defined(CONFIG_CMD_PCI) \
44 || defined(CONFIG_CMD_PORTIO)
46 int cmd_get_data_size(char* arg
, int default_size
)
48 /* Check for a size specification .b, .w or .l.
50 int len
= strlen(arg
);
51 if (len
> 2 && arg
[len
-2] == '.') {
69 #if defined(CONFIG_CMD_MEMORY)
72 #define PRINTF(fmt,args...) printf (fmt ,##args)
74 #define PRINTF(fmt,args...)
77 static int mod_mem(cmd_tbl_t
*, int, int, int, char *[]);
79 /* Display values from last command.
80 * Memory modify remembered values are different from display memory.
82 uint dp_last_addr
, dp_last_size
;
83 uint dp_last_length
= 0x40;
84 uint mm_last_addr
, mm_last_size
;
86 static ulong base_address
= 0;
91 * md{.b, .w, .l} {addr} {len}
93 #define DISP_LINE_LEN 16
94 int do_mem_md ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
97 #if defined(CONFIG_HAS_DATAFLASH)
98 ulong nbytes
, linebytes
;
103 /* We use the last specified parameters, unless new ones are
108 length
= dp_last_length
;
111 printf ("Usage:\n%s\n", cmdtp
->usage
);
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.
119 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
122 /* Address is specified since argc > 1
124 addr
= simple_strtoul(argv
[1], NULL
, 16);
125 addr
+= base_address
;
127 /* If another parameter, it is the length to display.
128 * Length is the number of objects, not number of bytes.
131 length
= simple_strtoul(argv
[2], NULL
, 16);
134 #if defined(CONFIG_HAS_DATAFLASH)
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.
140 nbytes
= length
* size
;
142 char linebuf
[DISP_LINE_LEN
];
144 linebytes
= (nbytes
>DISP_LINE_LEN
)?DISP_LINE_LEN
:nbytes
;
146 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
);
156 } while (nbytes
> 0);
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
;
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
);
175 } while (nbytes
> 0);
180 /* Print the lines. */
181 print_buffer(addr
, (void*)addr
, size
, length
, DISP_LINE_LEN
/size
);
187 dp_last_length
= length
;
192 int do_mem_mm ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
194 return mod_mem (cmdtp
, 1, flag
, argc
, argv
);
196 int do_mem_nm ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
198 return mod_mem (cmdtp
, 0, flag
, argc
, argv
);
201 int do_mem_mw ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
203 ulong addr
, writeval
, count
;
206 if ((argc
< 3) || (argc
> 4)) {
207 printf ("Usage:\n%s\n", cmdtp
->usage
);
211 /* Check for size specification.
213 if ((size
= cmd_get_data_size(argv
[0], 4)) < 1)
216 /* Address is specified since argc > 1
218 addr
= simple_strtoul(argv
[1], NULL
, 16);
219 addr
+= base_address
;
221 /* Get the value to write.
223 writeval
= simple_strtoul(argv
[2], NULL
, 16);
227 count
= simple_strtoul(argv
[3], NULL
, 16);
232 while (count
-- > 0) {
234 *((ulong
*)addr
) = (ulong
)writeval
;
236 *((ushort
*)addr
) = (ushort
)writeval
;
238 *((u_char
*)addr
) = (u_char
)writeval
;
244 #ifdef CONFIG_MX_CYCLIC
245 int do_mem_mdc ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
251 printf ("Usage:\n%s\n", cmdtp
->usage
);
255 count
= simple_strtoul(argv
[3], NULL
, 10);
258 do_mem_md (NULL
, 0, 3, argv
);
260 /* delay for <count> ms... */
261 for (i
=0; i
<count
; i
++)
264 /* check for ctrl-c to abort... */
274 int do_mem_mwc ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
280 printf ("Usage:\n%s\n", cmdtp
->usage
);
284 count
= simple_strtoul(argv
[3], NULL
, 10);
287 do_mem_mw (NULL
, 0, 3, argv
);
289 /* delay for <count> ms... */
290 for (i
=0; i
<count
; i
++)
293 /* check for ctrl-c to abort... */
302 #endif /* CONFIG_MX_CYCLIC */
304 int do_mem_cmp (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
306 ulong addr1
, addr2
, count
, ngood
;
311 printf ("Usage:\n%s\n", cmdtp
->usage
);
315 /* Check for size specification.
317 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
320 addr1
= simple_strtoul(argv
[1], NULL
, 16);
321 addr1
+= base_address
;
323 addr2
= simple_strtoul(argv
[2], NULL
, 16);
324 addr2
+= base_address
;
326 count
= simple_strtoul(argv
[3], NULL
, 16);
328 #ifdef CONFIG_HAS_DATAFLASH
329 if (addr_dataflash(addr1
) | addr_dataflash(addr2
)){
330 puts ("Comparison with DataFlash space not supported.\n\r");
335 #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");
344 while (count
-- > 0) {
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
);
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
);
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
);
383 printf("Total of %ld %s%s were the same\n",
384 ngood
, size
== 4 ? "word" : size
== 2 ? "halfword" : "byte",
385 ngood
== 1 ? "" : "s");
389 int do_mem_cp ( cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
391 ulong addr
, dest
, count
;
395 printf ("Usage:\n%s\n", cmdtp
->usage
);
399 /* Check for size specification.
401 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
404 addr
= simple_strtoul(argv
[1], NULL
, 16);
405 addr
+= base_address
;
407 dest
= simple_strtoul(argv
[2], NULL
, 16);
408 dest
+= base_address
;
410 count
= simple_strtoul(argv
[3], NULL
, 16);
413 puts ("Zero length ???\n");
418 /* check if we are copying to Flash */
419 if ( (addr2info(dest
) != NULL
)
420 #ifdef CONFIG_HAS_DATAFLASH
421 && (!addr_dataflash(dest
))
426 puts ("Copy to Flash... ");
428 rc
= flash_write ((char *)addr
, dest
, count
*size
);
438 #if defined(CONFIG_CMD_MMC)
439 if (mmc2info(dest
)) {
442 puts ("Copy to MMC... ");
443 switch (rc
= mmc_write ((uchar
*)addr
, dest
, count
*size
)) {
451 printf ("%s[%d] FIXME: rc=%d\n",__FILE__
,__LINE__
,rc
);
458 if (mmc2info(addr
)) {
461 puts ("Copy from MMC... ");
462 switch (rc
= mmc_read (addr
, (uchar
*)dest
, count
*size
)) {
470 printf ("%s[%d] FIXME: rc=%d\n",__FILE__
,__LINE__
,rc
);
478 #ifdef CONFIG_HAS_DATAFLASH
479 /* Check if we are copying from RAM or Flash to DataFlash */
480 if (addr_dataflash(dest
) && !addr_dataflash(addr
)){
483 puts ("Copy to DataFlash... ");
485 rc
= write_dataflash (dest
, addr
, count
*size
);
488 dataflash_perror (rc
);
495 /* Check if we are copying from DataFlash to RAM */
496 if (addr_dataflash(addr
) && !addr_dataflash(dest
)
498 && (addr2info(dest
) == NULL
)
502 rc
= read_dataflash(addr
, count
* size
, (char *) dest
);
504 dataflash_perror (rc
);
510 if (addr_dataflash(addr
) && addr_dataflash(dest
)){
511 puts ("Unsupported combination of source/destination.\n\r");
516 #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
);
524 while (count
-- > 0) {
526 *((ulong
*)dest
) = *((ulong
*)addr
);
528 *((ushort
*)dest
) = *((ushort
*)addr
);
530 *((u_char
*)dest
) = *((u_char
*)addr
);
537 int do_mem_base (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
540 /* Set new base address.
542 base_address
= simple_strtoul(argv
[1], NULL
, 16);
544 /* Print the current base address.
546 printf("Base Address: 0x%08lx\n", base_address
);
550 int do_mem_loop (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
552 ulong addr
, length
, i
, junk
;
554 volatile uint
*longp
;
555 volatile ushort
*shortp
;
559 printf ("Usage:\n%s\n", cmdtp
->usage
);
563 /* Check for a size spefication.
564 * Defaults to long if no or incorrect specification.
566 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
569 /* Address is always specified.
571 addr
= simple_strtoul(argv
[1], NULL
, 16);
573 /* Length is the number of objects, not number of bytes.
575 length
= simple_strtoul(argv
[2], NULL
, 16);
577 /* We want to optimize the loops to run as fast as possible.
578 * If we have only one object, just run infinite loops.
582 longp
= (uint
*)addr
;
587 shortp
= (ushort
*)addr
;
598 longp
= (uint
*)addr
;
606 shortp
= (ushort
*)addr
;
621 int do_mem_loopw (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
623 ulong addr
, length
, i
, data
;
625 volatile uint
*longp
;
626 volatile ushort
*shortp
;
630 printf ("Usage:\n%s\n", cmdtp
->usage
);
634 /* Check for a size spefication.
635 * Defaults to long if no or incorrect specification.
637 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
640 /* Address is always specified.
642 addr
= simple_strtoul(argv
[1], NULL
, 16);
644 /* Length is the number of objects, not number of bytes.
646 length
= simple_strtoul(argv
[2], NULL
, 16);
649 data
= simple_strtoul(argv
[3], NULL
, 16);
651 /* We want to optimize the loops to run as fast as possible.
652 * If we have only one object, just run infinite loops.
656 longp
= (uint
*)addr
;
661 shortp
= (ushort
*)addr
;
672 longp
= (uint
*)addr
;
680 shortp
= (ushort
*)addr
;
693 #endif /* CONFIG_LOOPW */
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.
700 int do_mem_mtest (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
702 vu_long
*addr
, *start
, *end
;
707 #if defined(CFG_ALT_MEMTEST)
713 vu_long anti_pattern
;
715 #if defined(CFG_MEMTEST_SCRATCH)
716 vu_long
*dummy
= (vu_long
*)CFG_MEMTEST_SCRATCH
;
718 vu_long
*dummy
= 0; /* yes, this is address 0x0, not NULL */
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 */
739 start
= (ulong
*)simple_strtoul(argv
[1], NULL
, 16);
741 start
= (ulong
*)CFG_MEMTEST_START
;
745 end
= (ulong
*)simple_strtoul(argv
[2], NULL
, 16);
747 end
= (ulong
*)(CFG_MEMTEST_END
);
751 pattern
= (ulong
)simple_strtoul(argv
[3], NULL
, 16);
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
);
767 printf("Iteration: %6d\r", iterations
);
768 PRINTF("Iteration: %6d\n", iterations
);
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
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).
789 for (j
= 0; j
< sizeof(bitpattern
)/sizeof(bitpattern
[0]); j
++) {
791 for(; val
!= 0; val
<<= 1) {
793 *dummy
= ~val
; /* clear the test data off of the bus */
795 if(readback
!= val
) {
796 printf ("FAILURE (data line): "
797 "expected %08lx, actual %08lx\n",
803 if(readback
!= ~val
) {
804 printf ("FAILURE (data line): "
805 "Is %08lx, should be %08lx\n",
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.
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.
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
843 * Returns: 0 if the test succeeds, 1 if the test fails.
845 len
= ((ulong
)end
- (ulong
)start
)/sizeof(vu_long
);
846 pattern
= (vu_long
) 0xaaaaaaaa;
847 anti_pattern
= (vu_long
) 0x55555555;
849 PRINTF("%s:%d: length = 0x%.8lx\n",
850 __FUNCTION__
, __LINE__
,
853 * Write the default pattern at each of the
854 * power-of-two offsets.
856 for (offset
= 1; offset
< len
; offset
<<= 1) {
857 start
[offset
] = pattern
;
861 * Check for address bits stuck high.
864 start
[test_offset
] = anti_pattern
;
866 for (offset
= 1; offset
< len
; offset
<<= 1) {
867 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
);
875 start
[test_offset
] = pattern
;
879 * Check for addr bits stuck low or shorted.
881 for (test_offset
= 1; test_offset
< len
; test_offset
<<= 1) {
882 start
[test_offset
] = anti_pattern
;
884 for (offset
= 1; offset
< len
; offset
<<= 1) {
885 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
);
893 start
[test_offset
] = pattern
;
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.
906 * Returns: 0 if the test succeeds, 1 if the test fails.
908 num_words
= ((ulong
)end
- (ulong
)start
)/sizeof(vu_long
) + 1;
911 * Fill memory with a known pattern.
913 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
915 start
[offset
] = pattern
;
919 * Check each location and invert it for the second pass.
921 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
923 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
);
931 anti_pattern
= ~pattern
;
932 start
[offset
] = anti_pattern
;
936 * Check each location for the inverted pattern and zero it.
938 for (pattern
= 1, offset
= 0; offset
< num_words
; pattern
++, offset
++) {
940 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
);
952 #else /* The original, quickie test */
960 printf ("\rPattern %08lX Writing..."
962 "\b\b\b\b\b\b\b\b\b\b",
965 for (addr
=start
,val
=pattern
; addr
<end
; addr
++) {
973 for (addr
=start
,val
=pattern
; addr
<end
; addr
++) {
976 if (readback
!= val
) {
977 printf ("\nMem error @ 0x%08X: "
978 "found %08lX, expected %08lX\n",
979 (uint
)addr
, readback
, val
);
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.
991 if(pattern
& 0x80000000) {
992 pattern
= -pattern
; /* complement & increment */
1007 * mm{.b, .w, .l} {addr}
1008 * nm{.b, .w, .l} {addr}
1011 mod_mem(cmd_tbl_t
*cmdtp
, int incrflag
, int flag
, int argc
, char *argv
[])
1015 extern char console_buffer
[];
1018 printf ("Usage:\n%s\n", cmdtp
->usage
);
1022 #ifdef CONFIG_BOOT_RETRY_TIME
1023 reset_cmd_timeout(); /* got a good command to get here */
1025 /* We use the last specified parameters, unless new ones are
1028 addr
= mm_last_addr
;
1029 size
= mm_last_size
;
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.
1035 if ((size
= cmd_get_data_size(argv
[0], 4)) < 0)
1038 /* Address is specified since argc > 1
1040 addr
= simple_strtoul(argv
[1], NULL
, 16);
1041 addr
+= base_address
;
1044 #ifdef CONFIG_HAS_DATAFLASH
1045 if (addr_dataflash(addr
)){
1046 puts ("Can't modify DataFlash in place. Use cp instead.\n\r");
1051 #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");
1058 /* Print the address, followed by value. Then accept input for
1059 * the next value. A non-converted value exits.
1062 printf("%08lx:", addr
);
1064 printf(" %08x", *((uint
*)addr
));
1066 printf(" %04x", *((ushort
*)addr
));
1068 printf(" %02x", *((u_char
*)addr
));
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.
1076 addr
+= nbytes
? -size
: size
;
1078 #ifdef CONFIG_BOOT_RETRY_TIME
1079 reset_cmd_timeout(); /* good enough to not time out */
1082 #ifdef CONFIG_BOOT_RETRY_TIME
1083 else if (nbytes
== -2) {
1084 break; /* timed out, exit the command */
1089 i
= simple_strtoul(console_buffer
, &endp
, 16);
1090 nbytes
= endp
- console_buffer
;
1092 #ifdef CONFIG_BOOT_RETRY_TIME
1093 /* good enough to not time out
1095 reset_cmd_timeout();
1098 *((uint
*)addr
) = i
;
1100 *((ushort
*)addr
) = i
;
1102 *((u_char
*)addr
) = i
;
1109 mm_last_addr
= addr
;
1110 mm_last_size
= size
;
1114 #ifndef CONFIG_CRC32_VERIFY
1116 int do_mem_crc (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
1123 printf ("Usage:\n%s\n", cmdtp
->usage
);
1127 addr
= simple_strtoul (argv
[1], NULL
, 16);
1128 addr
+= base_address
;
1130 length
= simple_strtoul (argv
[2], NULL
, 16);
1132 crc
= crc32 (0, (const uchar
*) addr
, length
);
1134 printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
1135 addr
, addr
+ length
- 1, crc
);
1138 ptr
= (ulong
*) simple_strtoul (argv
[3], NULL
, 16);
1145 #else /* CONFIG_CRC32_VERIFY */
1147 int do_mem_crc (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
1159 printf ("Usage:\n%s\n", cmdtp
->usage
);
1165 if (strcmp(*av
, "-v") == 0) {
1174 addr
= simple_strtoul(*av
++, NULL
, 16);
1175 addr
+= base_address
;
1176 length
= simple_strtoul(*av
++, NULL
, 16);
1178 crc
= crc32(0, (const uchar
*) addr
, length
);
1181 printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
1182 addr
, addr
+ length
- 1, crc
);
1184 ptr
= (ulong
*) simple_strtoul (*av
++, NULL
, 16);
1188 vcrc
= simple_strtoul(*av
++, NULL
, 16);
1190 printf ("CRC32 for %08lx ... %08lx ==> %08lx != %08lx ** ERROR **\n",
1191 addr
, addr
+ length
- 1, crc
, vcrc
);
1199 #endif /* CONFIG_CRC32_VERIFY */
1201 /**************************************************/
1202 #if defined(CONFIG_CMD_MEMORY)
1204 md
, 3, 1, do_mem_md
,
1205 "md - memory display\n",
1206 "[.b, .w, .l] address [# of objects]\n - memory display\n"
1211 mm
, 2, 1, do_mem_mm
,
1212 "mm - memory modify (auto-incrementing)\n",
1213 "[.b, .w, .l] address\n" " - memory modify, auto increment address\n"
1218 nm
, 2, 1, do_mem_nm
,
1219 "nm - memory modify (constant address)\n",
1220 "[.b, .w, .l] address\n - memory modify, read and keep address\n"
1224 mw
, 4, 1, do_mem_mw
,
1225 "mw - memory write (fill)\n",
1226 "[.b, .w, .l] address value [count]\n - write memory\n"
1230 cp
, 4, 1, do_mem_cp
,
1231 "cp - memory copy\n",
1232 "[.b, .w, .l] source target count\n - copy memory\n"
1236 cmp
, 4, 1, do_mem_cmp
,
1237 "cmp - memory compare\n",
1238 "[.b, .w, .l] addr1 addr2 count\n - compare memory\n"
1241 #ifndef CONFIG_CRC32_VERIFY
1244 crc32
, 4, 1, do_mem_crc
,
1245 "crc32 - checksum calculation\n",
1246 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1249 #else /* CONFIG_CRC32_VERIFY */
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"
1258 #endif /* CONFIG_CRC32_VERIFY */
1261 base
, 2, 1, do_mem_base
,
1262 "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"
1268 loop
, 3, 1, do_mem_loop
,
1269 "loop - infinite loop on address range\n",
1270 "[.b, .w, .l] address number_of_objects\n"
1271 " - loop on a set of addresses\n"
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"
1281 #endif /* CONFIG_LOOPW */
1284 mtest
, 4, 1, do_mem_mtest
,
1285 "mtest - simple RAM test\n",
1286 "[start [end [pattern]]]\n"
1287 " - simple RAM read/write test\n"
1290 #ifdef CONFIG_MX_CYCLIC
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"
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"
1302 #endif /* CONFIG_MX_CYCLIC */