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 #ifdef CONFIG_HAS_DATAFLASH
33 #include <dataflash.h>
37 #include <u-boot/md5.h>
41 #define PRINTF(fmt,args...) printf (fmt ,##args)
43 #define PRINTF(fmt,args...)
46 static int mod_mem(cmd_tbl_t *, int, int, int, char * const []);
48 /* Display values from last command.
49 * Memory modify remembered values are different from display memory.
51 uint dp_last_addr, dp_last_size;
52 uint dp_last_length = 0x40;
53 uint mm_last_addr, mm_last_size;
55 static ulong base_address = 0;
60 * md{.b, .w, .l} {addr} {len}
62 #define DISP_LINE_LEN 16
63 int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
66 #if defined(CONFIG_HAS_DATAFLASH)
67 ulong nbytes, linebytes;
72 /* We use the last specified parameters, unless new ones are
77 length = dp_last_length;
80 return cmd_usage(cmdtp);
82 if ((flag & CMD_FLAG_REPEAT) == 0) {
83 /* New command specified. Check for a size specification.
84 * Defaults to long if no or incorrect specification.
86 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
89 /* Address is specified since argc > 1
91 addr = simple_strtoul(argv[1], NULL, 16);
94 /* If another parameter, it is the length to display.
95 * Length is the number of objects, not number of bytes.
98 length = simple_strtoul(argv[2], NULL, 16);
101 #if defined(CONFIG_HAS_DATAFLASH)
104 * We buffer all read data, so we can make sure data is read only
105 * once, and all accesses are with the specified bus width.
107 nbytes = length * size;
109 char linebuf[DISP_LINE_LEN];
111 linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes;
113 rc = read_dataflash(addr, (linebytes/size)*size, linebuf);
114 p = (rc == DATAFLASH_OK) ? linebuf : (void*)addr;
115 print_buffer(addr, p, size, linebytes/size, DISP_LINE_LEN/size);
123 } while (nbytes > 0);
126 # if defined(CONFIG_BLACKFIN)
127 /* See if we're trying to display L1 inst */
128 if (addr_bfin_on_chip_mem(addr)) {
129 char linebuf[DISP_LINE_LEN];
130 ulong linebytes, nbytes = length * size;
132 linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes;
133 memcpy(linebuf, (void *)addr, linebytes);
134 print_buffer(addr, linebuf, size, linebytes/size, DISP_LINE_LEN/size);
142 } while (nbytes > 0);
147 /* Print the lines. */
148 print_buffer(addr, (void*)addr, size, length, DISP_LINE_LEN/size);
154 dp_last_length = length;
159 int do_mem_mm ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
161 return mod_mem (cmdtp, 1, flag, argc, argv);
163 int do_mem_nm ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
165 return mod_mem (cmdtp, 0, flag, argc, argv);
168 int do_mem_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
170 ulong addr, writeval, count;
173 if ((argc < 3) || (argc > 4))
174 return cmd_usage(cmdtp);
176 /* Check for size specification.
178 if ((size = cmd_get_data_size(argv[0], 4)) < 1)
181 /* Address is specified since argc > 1
183 addr = simple_strtoul(argv[1], NULL, 16);
184 addr += base_address;
186 /* Get the value to write.
188 writeval = simple_strtoul(argv[2], NULL, 16);
192 count = simple_strtoul(argv[3], NULL, 16);
197 while (count-- > 0) {
199 *((ulong *)addr) = (ulong )writeval;
201 *((ushort *)addr) = (ushort)writeval;
203 *((u_char *)addr) = (u_char)writeval;
209 #ifdef CONFIG_MX_CYCLIC
210 int do_mem_mdc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
216 return cmd_usage(cmdtp);
218 count = simple_strtoul(argv[3], NULL, 10);
221 do_mem_md (NULL, 0, 3, argv);
223 /* delay for <count> ms... */
224 for (i=0; i<count; i++)
227 /* check for ctrl-c to abort... */
237 int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
243 return cmd_usage(cmdtp);
245 count = simple_strtoul(argv[3], NULL, 10);
248 do_mem_mw (NULL, 0, 3, argv);
250 /* delay for <count> ms... */
251 for (i=0; i<count; i++)
254 /* check for ctrl-c to abort... */
263 #endif /* CONFIG_MX_CYCLIC */
265 int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
267 ulong addr1, addr2, count, ngood;
272 return cmd_usage(cmdtp);
274 /* Check for size specification.
276 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
279 addr1 = simple_strtoul(argv[1], NULL, 16);
280 addr1 += base_address;
282 addr2 = simple_strtoul(argv[2], NULL, 16);
283 addr2 += base_address;
285 count = simple_strtoul(argv[3], NULL, 16);
287 #ifdef CONFIG_HAS_DATAFLASH
288 if (addr_dataflash(addr1) | addr_dataflash(addr2)){
289 puts ("Comparison with DataFlash space not supported.\n\r");
294 #ifdef CONFIG_BLACKFIN
295 if (addr_bfin_on_chip_mem(addr1) || addr_bfin_on_chip_mem(addr2)) {
296 puts ("Comparison with L1 instruction memory not supported.\n\r");
303 while (count-- > 0) {
305 ulong word1 = *(ulong *)addr1;
306 ulong word2 = *(ulong *)addr2;
307 if (word1 != word2) {
308 printf("word at 0x%08lx (0x%08lx) "
309 "!= word at 0x%08lx (0x%08lx)\n",
310 addr1, word1, addr2, word2);
315 else if (size == 2) {
316 ushort hword1 = *(ushort *)addr1;
317 ushort hword2 = *(ushort *)addr2;
318 if (hword1 != hword2) {
319 printf("halfword at 0x%08lx (0x%04x) "
320 "!= halfword at 0x%08lx (0x%04x)\n",
321 addr1, hword1, addr2, hword2);
327 u_char byte1 = *(u_char *)addr1;
328 u_char byte2 = *(u_char *)addr2;
329 if (byte1 != byte2) {
330 printf("byte at 0x%08lx (0x%02x) "
331 "!= byte at 0x%08lx (0x%02x)\n",
332 addr1, byte1, addr2, byte2);
342 printf("Total of %ld %s%s were the same\n",
343 ngood, size == 4 ? "word" : size == 2 ? "halfword" : "byte",
344 ngood == 1 ? "" : "s");
348 int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
350 ulong addr, dest, count;
354 return cmd_usage(cmdtp);
356 /* Check for size specification.
358 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
361 addr = simple_strtoul(argv[1], NULL, 16);
362 addr += base_address;
364 dest = simple_strtoul(argv[2], NULL, 16);
365 dest += base_address;
367 count = simple_strtoul(argv[3], NULL, 16);
370 puts ("Zero length ???\n");
374 #ifndef CONFIG_SYS_NO_FLASH
375 /* check if we are copying to Flash */
376 if ( (addr2info(dest) != NULL)
377 #ifdef CONFIG_HAS_DATAFLASH
378 && (!addr_dataflash(dest))
383 puts ("Copy to Flash... ");
385 rc = flash_write ((char *)addr, dest, count*size);
395 #ifdef CONFIG_HAS_DATAFLASH
396 /* Check if we are copying from RAM or Flash to DataFlash */
397 if (addr_dataflash(dest) && !addr_dataflash(addr)){
400 puts ("Copy to DataFlash... ");
402 rc = write_dataflash (dest, addr, count*size);
405 dataflash_perror (rc);
412 /* Check if we are copying from DataFlash to RAM */
413 if (addr_dataflash(addr) && !addr_dataflash(dest)
414 #ifndef CONFIG_SYS_NO_FLASH
415 && (addr2info(dest) == NULL)
419 rc = read_dataflash(addr, count * size, (char *) dest);
421 dataflash_perror (rc);
427 if (addr_dataflash(addr) && addr_dataflash(dest)){
428 puts ("Unsupported combination of source/destination.\n\r");
433 #ifdef CONFIG_BLACKFIN
434 /* See if we're copying to/from L1 inst */
435 if (addr_bfin_on_chip_mem(dest) || addr_bfin_on_chip_mem(addr)) {
436 memcpy((void *)dest, (void *)addr, count * size);
441 while (count-- > 0) {
443 *((ulong *)dest) = *((ulong *)addr);
445 *((ushort *)dest) = *((ushort *)addr);
447 *((u_char *)dest) = *((u_char *)addr);
454 int do_mem_base (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
457 /* Set new base address.
459 base_address = simple_strtoul(argv[1], NULL, 16);
461 /* Print the current base address.
463 printf("Base Address: 0x%08lx\n", base_address);
467 int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
469 ulong addr, length, i, junk;
471 volatile uint *longp;
472 volatile ushort *shortp;
476 return cmd_usage(cmdtp);
478 /* Check for a size spefication.
479 * Defaults to long if no or incorrect specification.
481 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
484 /* Address is always specified.
486 addr = simple_strtoul(argv[1], NULL, 16);
488 /* Length is the number of objects, not number of bytes.
490 length = simple_strtoul(argv[2], NULL, 16);
492 /* We want to optimize the loops to run as fast as possible.
493 * If we have only one object, just run infinite loops.
497 longp = (uint *)addr;
502 shortp = (ushort *)addr;
513 longp = (uint *)addr;
521 shortp = (ushort *)addr;
536 int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
538 ulong addr, length, i, data;
540 volatile uint *longp;
541 volatile ushort *shortp;
545 return cmd_usage(cmdtp);
547 /* Check for a size spefication.
548 * Defaults to long if no or incorrect specification.
550 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
553 /* Address is always specified.
555 addr = simple_strtoul(argv[1], NULL, 16);
557 /* Length is the number of objects, not number of bytes.
559 length = simple_strtoul(argv[2], NULL, 16);
562 data = simple_strtoul(argv[3], NULL, 16);
564 /* We want to optimize the loops to run as fast as possible.
565 * If we have only one object, just run infinite loops.
569 longp = (uint *)addr;
574 shortp = (ushort *)addr;
585 longp = (uint *)addr;
593 shortp = (ushort *)addr;
606 #endif /* CONFIG_LOOPW */
609 * Perform a memory test. A more complete alternative test can be
610 * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
611 * interrupted by ctrl-c or by a failure of one of the sub-tests.
613 int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
615 vu_long *addr, *start, *end;
622 #if defined(CONFIG_SYS_ALT_MEMTEST)
628 vu_long anti_pattern;
630 #if defined(CONFIG_SYS_MEMTEST_SCRATCH)
631 vu_long *dummy = (vu_long*)CONFIG_SYS_MEMTEST_SCRATCH;
633 vu_long *dummy = 0; /* yes, this is address 0x0, not NULL */
637 static const ulong bitpattern[] = {
638 0x00000001, /* single bit */
639 0x00000003, /* two adjacent bits */
640 0x00000007, /* three adjacent bits */
641 0x0000000F, /* four adjacent bits */
642 0x00000005, /* two non-adjacent bits */
643 0x00000015, /* three non-adjacent bits */
644 0x00000055, /* four non-adjacent bits */
645 0xaaaaaaaa, /* alternating 1/0 */
653 start = (ulong *)simple_strtoul(argv[1], NULL, 16);
655 start = (ulong *)CONFIG_SYS_MEMTEST_START;
658 end = (ulong *)simple_strtoul(argv[2], NULL, 16);
660 end = (ulong *)(CONFIG_SYS_MEMTEST_END);
663 pattern = (ulong)simple_strtoul(argv[3], NULL, 16);
668 iteration_limit = (ulong)simple_strtoul(argv[4], NULL, 16);
672 #if defined(CONFIG_SYS_ALT_MEMTEST)
673 printf ("Testing %08x ... %08x:\n", (uint)start, (uint)end);
674 PRINTF("%s:%d: start 0x%p end 0x%p\n",
675 __FUNCTION__, __LINE__, start, end);
684 if (iteration_limit && iterations > iteration_limit) {
685 printf("Tested %d iteration(s) with %lu errors.\n",
690 printf("Iteration: %6d\r", iterations);
695 * Data line test: write a pattern to the first
696 * location, write the 1's complement to a 'parking'
697 * address (changes the state of the data bus so a
698 * floating bus doen't give a false OK), and then
699 * read the value back. Note that we read it back
700 * into a variable because the next time we read it,
701 * it might be right (been there, tough to explain to
702 * the quality guys why it prints a failure when the
703 * "is" and "should be" are obviously the same in the
706 * Rather than exhaustively testing, we test some
707 * patterns by shifting '1' bits through a field of
708 * '0's and '0' bits through a field of '1's (i.e.
709 * pattern and ~pattern).
712 for (j = 0; j < sizeof(bitpattern)/sizeof(bitpattern[0]); j++) {
714 for(; val != 0; val <<= 1) {
716 *dummy = ~val; /* clear the test data off of the bus */
718 if(readback != val) {
719 printf ("FAILURE (data line): "
720 "expected %08lx, actual %08lx\n",
731 if(readback != ~val) {
732 printf ("FAILURE (data line): "
733 "Is %08lx, should be %08lx\n",
745 * Based on code whose Original Author and Copyright
746 * information follows: Copyright (c) 1998 by Michael
747 * Barr. This software is placed into the public
748 * domain and may be used for any purpose. However,
749 * this notice must not be changed or removed and no
750 * warranty is either expressed or implied by its
751 * publication or distribution.
757 * Description: Test the address bus wiring in a
758 * memory region by performing a walking
759 * 1's test on the relevant bits of the
760 * address and checking for aliasing.
761 * This test will find single-bit
762 * address failures such as stuck -high,
763 * stuck-low, and shorted pins. The base
764 * address and size of the region are
765 * selected by the caller.
767 * Notes: For best results, the selected base
768 * address should have enough LSB 0's to
769 * guarantee single address bit changes.
770 * For example, to test a 64-Kbyte
771 * region, select a base address on a
772 * 64-Kbyte boundary. Also, select the
773 * region size as a power-of-two if at
776 * Returns: 0 if the test succeeds, 1 if the test fails.
778 len = ((ulong)end - (ulong)start)/sizeof(vu_long);
779 pattern = (vu_long) 0xaaaaaaaa;
780 anti_pattern = (vu_long) 0x55555555;
782 PRINTF("%s:%d: length = 0x%.8lx\n",
783 __FUNCTION__, __LINE__,
786 * Write the default pattern at each of the
787 * power-of-two offsets.
789 for (offset = 1; offset < len; offset <<= 1) {
790 start[offset] = pattern;
794 * Check for address bits stuck high.
797 start[test_offset] = anti_pattern;
799 for (offset = 1; offset < len; offset <<= 1) {
800 temp = start[offset];
801 if (temp != pattern) {
802 printf ("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
803 " expected 0x%.8lx, actual 0x%.8lx\n",
804 (ulong)&start[offset], pattern, temp);
812 start[test_offset] = pattern;
816 * Check for addr bits stuck low or shorted.
818 for (test_offset = 1; test_offset < len; test_offset <<= 1) {
819 start[test_offset] = anti_pattern;
821 for (offset = 1; offset < len; offset <<= 1) {
822 temp = start[offset];
823 if ((temp != pattern) && (offset != test_offset)) {
824 printf ("\nFAILURE: Address bit stuck low or shorted @"
825 " 0x%.8lx: expected 0x%.8lx, actual 0x%.8lx\n",
826 (ulong)&start[offset], pattern, temp);
834 start[test_offset] = pattern;
838 * Description: Test the integrity of a physical
839 * memory device by performing an
840 * increment/decrement test over the
841 * entire region. In the process every
842 * storage bit in the device is tested
843 * as a zero and a one. The base address
844 * and the size of the region are
845 * selected by the caller.
847 * Returns: 0 if the test succeeds, 1 if the test fails.
849 num_words = ((ulong)end - (ulong)start)/sizeof(vu_long) + 1;
852 * Fill memory with a known pattern.
854 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
856 start[offset] = pattern;
860 * Check each location and invert it for the second pass.
862 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
864 temp = start[offset];
865 if (temp != pattern) {
866 printf ("\nFAILURE (read/write) @ 0x%.8lx:"
867 " expected 0x%.8lx, actual 0x%.8lx)\n",
868 (ulong)&start[offset], pattern, temp);
876 anti_pattern = ~pattern;
877 start[offset] = anti_pattern;
881 * Check each location for the inverted pattern and zero it.
883 for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
885 anti_pattern = ~pattern;
886 temp = start[offset];
887 if (temp != anti_pattern) {
888 printf ("\nFAILURE (read/write): @ 0x%.8lx:"
889 " expected 0x%.8lx, actual 0x%.8lx)\n",
890 (ulong)&start[offset], anti_pattern, temp);
901 #else /* The original, quickie test */
909 if (iteration_limit && iterations > iteration_limit) {
910 printf("Tested %d iteration(s) with %lu errors.\n",
916 printf ("\rPattern %08lX Writing..."
918 "\b\b\b\b\b\b\b\b\b\b",
921 for (addr=start,val=pattern; addr<end; addr++) {
929 for (addr=start,val=pattern; addr<end; addr++) {
932 if (readback != val) {
933 printf ("\nMem error @ 0x%08X: "
934 "found %08lX, expected %08lX\n",
935 (uint)addr, readback, val);
946 * Flip the pattern each time to make lots of zeros and
947 * then, the next time, lots of ones. We decrement
948 * the "negative" patterns and increment the "positive"
949 * patterns to preserve this feature.
951 if(pattern & 0x80000000) {
952 pattern = -pattern; /* complement & increment */
960 return 0; /* not reached */
967 * mm{.b, .w, .l} {addr}
968 * nm{.b, .w, .l} {addr}
971 mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
975 extern char console_buffer[];
978 return cmd_usage(cmdtp);
980 #ifdef CONFIG_BOOT_RETRY_TIME
981 reset_cmd_timeout(); /* got a good command to get here */
983 /* We use the last specified parameters, unless new ones are
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.
993 if ((size = cmd_get_data_size(argv[0], 4)) < 0)
996 /* Address is specified since argc > 1
998 addr = simple_strtoul(argv[1], NULL, 16);
999 addr += base_address;
1002 #ifdef CONFIG_HAS_DATAFLASH
1003 if (addr_dataflash(addr)){
1004 puts ("Can't modify DataFlash in place. Use cp instead.\n\r");
1009 #ifdef CONFIG_BLACKFIN
1010 if (addr_bfin_on_chip_mem(addr)) {
1011 puts ("Can't modify L1 instruction in place. Use cp instead.\n\r");
1016 /* Print the address, followed by value. Then accept input for
1017 * the next value. A non-converted value exits.
1020 printf("%08lx:", addr);
1022 printf(" %08x", *((uint *)addr));
1024 printf(" %04x", *((ushort *)addr));
1026 printf(" %02x", *((u_char *)addr));
1028 nbytes = readline (" ? ");
1029 if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
1030 /* <CR> pressed as only input, don't modify current
1031 * location and move to next. "-" pressed will go back.
1034 addr += nbytes ? -size : size;
1036 #ifdef CONFIG_BOOT_RETRY_TIME
1037 reset_cmd_timeout(); /* good enough to not time out */
1040 #ifdef CONFIG_BOOT_RETRY_TIME
1041 else if (nbytes == -2) {
1042 break; /* timed out, exit the command */
1047 i = simple_strtoul(console_buffer, &endp, 16);
1048 nbytes = endp - console_buffer;
1050 #ifdef CONFIG_BOOT_RETRY_TIME
1051 /* good enough to not time out
1053 reset_cmd_timeout();
1056 *((uint *)addr) = i;
1058 *((ushort *)addr) = i;
1060 *((u_char *)addr) = i;
1067 mm_last_addr = addr;
1068 mm_last_size = size;
1072 #ifndef CONFIG_CRC32_VERIFY
1074 int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1081 return cmd_usage(cmdtp);
1083 addr = simple_strtoul (argv[1], NULL, 16);
1084 addr += base_address;
1086 length = simple_strtoul (argv[2], NULL, 16);
1088 crc = crc32 (0, (const uchar *) addr, length);
1090 printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
1091 addr, addr + length - 1, crc);
1094 ptr = (ulong *) simple_strtoul (argv[3], NULL, 16);
1101 #else /* CONFIG_CRC32_VERIFY */
1103 int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1115 return cmd_usage(cmdtp);
1120 if (strcmp(*av, "-v") == 0) {
1129 addr = simple_strtoul(*av++, NULL, 16);
1130 addr += base_address;
1131 length = simple_strtoul(*av++, NULL, 16);
1133 crc = crc32(0, (const uchar *) addr, length);
1136 printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
1137 addr, addr + length - 1, crc);
1139 ptr = (ulong *) simple_strtoul (*av++, NULL, 16);
1143 vcrc = simple_strtoul(*av++, NULL, 16);
1145 printf ("CRC32 for %08lx ... %08lx ==> %08lx != %08lx ** ERROR **\n",
1146 addr, addr + length - 1, crc, vcrc);
1154 #endif /* CONFIG_CRC32_VERIFY */
1156 #ifdef CONFIG_CMD_MD5SUM
1157 int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1159 unsigned long addr, len;
1164 return cmd_usage(cmdtp);
1166 addr = simple_strtoul(argv[1], NULL, 16);
1167 len = simple_strtoul(argv[2], NULL, 16);
1169 md5((unsigned char *) addr, len, output);
1170 printf("md5 for %08lx ... %08lx ==> ", addr, addr + len - 1);
1171 for (i = 0; i < 16; i++)
1172 printf("%02x", output[i]);
1179 #ifdef CONFIG_CMD_SHA1
1180 int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1182 unsigned long addr, len;
1187 return cmd_usage(cmdtp);
1189 addr = simple_strtoul(argv[1], NULL, 16);
1190 len = simple_strtoul(argv[2], NULL, 16);
1192 sha1_csum((unsigned char *) addr, len, output);
1193 printf("SHA1 for %08lx ... %08lx ==> ", addr, addr + len - 1);
1194 for (i = 0; i < 20; i++)
1195 printf("%02x", output[i]);
1202 #ifdef CONFIG_CMD_UNZIP
1203 int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1205 unsigned long src, dst;
1206 unsigned long src_len = ~0UL, dst_len = ~0UL;
1210 dst_len = simple_strtoul(argv[3], NULL, 16);
1213 src = simple_strtoul(argv[1], NULL, 16);
1214 dst = simple_strtoul(argv[2], NULL, 16);
1217 return cmd_usage(cmdtp);
1220 return !!gunzip((void *) dst, dst_len, (void *) src, &src_len);
1222 #endif /* CONFIG_CMD_UNZIP */
1225 /**************************************************/
1227 md, 3, 1, do_mem_md,
1229 "[.b, .w, .l] address [# of objects]"
1234 mm, 2, 1, do_mem_mm,
1235 "memory modify (auto-incrementing address)",
1236 "[.b, .w, .l] address"
1241 nm, 2, 1, do_mem_nm,
1242 "memory modify (constant address)",
1243 "[.b, .w, .l] address"
1247 mw, 4, 1, do_mem_mw,
1248 "memory write (fill)",
1249 "[.b, .w, .l] address value [count]"
1253 cp, 4, 1, do_mem_cp,
1255 "[.b, .w, .l] source target count"
1259 cmp, 4, 1, do_mem_cmp,
1261 "[.b, .w, .l] addr1 addr2 count"
1264 #ifndef CONFIG_CRC32_VERIFY
1267 crc32, 4, 1, do_mem_crc,
1268 "checksum calculation",
1269 "address count [addr]\n - compute CRC32 checksum [save at addr]"
1272 #else /* CONFIG_CRC32_VERIFY */
1275 crc32, 5, 1, do_mem_crc,
1276 "checksum calculation",
1277 "address count [addr]\n - compute CRC32 checksum [save at addr]\n"
1278 "-v address count crc\n - verify crc of memory area"
1281 #endif /* CONFIG_CRC32_VERIFY */
1284 base, 2, 1, do_mem_base,
1285 "print or set address offset",
1286 "\n - print address offset for memory commands\n"
1287 "base off\n - set address offset for memory commands to 'off'"
1291 loop, 3, 1, do_mem_loop,
1292 "infinite loop on address range",
1293 "[.b, .w, .l] address number_of_objects"
1298 loopw, 4, 1, do_mem_loopw,
1299 "infinite write loop on address range",
1300 "[.b, .w, .l] address number_of_objects data_to_write"
1302 #endif /* CONFIG_LOOPW */
1305 mtest, 5, 1, do_mem_mtest,
1306 "simple RAM read/write test",
1307 "[start [end [pattern [iterations]]]]"
1310 #ifdef CONFIG_MX_CYCLIC
1312 mdc, 4, 1, do_mem_mdc,
1313 "memory display cyclic",
1314 "[.b, .w, .l] address count delay(ms)"
1318 mwc, 4, 1, do_mem_mwc,
1319 "memory write cyclic",
1320 "[.b, .w, .l] address value delay(ms)"
1322 #endif /* CONFIG_MX_CYCLIC */
1324 #ifdef CONFIG_CMD_MD5SUM
1326 md5sum, 3, 1, do_md5sum,
1327 "compute MD5 message digest",
1332 #ifdef CONFIG_CMD_SHA1SUM
1334 sha1sum, 3, 1, do_sha1sum,
1335 "compute SHA1 message digest",
1338 #endif /* CONFIG_CMD_SHA1 */
1340 #ifdef CONFIG_CMD_UNZIP
1342 unzip, 4, 1, do_unzip,
1343 "unzip a memory region",
1344 "srcaddr dstaddr [dstsize]"
1346 #endif /* CONFIG_CMD_UNZIP */