]> git.sur5r.net Git - u-boot/blobdiff - common/cmd_mem.c
onenand: rename 16 bit memory copy into memcpy_16() to avoid conflicts
[u-boot] / common / cmd_mem.c
index 000107f726e9b31bec51ad6186232a4fb19e4ea2..51aa71fca84999b17fd451eb0607925732a22baa 100644 (file)
@@ -35,6 +35,7 @@
 #ifdef CONFIG_HAS_DATAFLASH
 #include <dataflash.h>
 #endif
+#include <watchdog.h>
 
 #if defined(CONFIG_CMD_MEMORY)         \
     || defined(CONFIG_CMD_I2C)         \
@@ -417,7 +418,7 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        /* check if we are copying to Flash */
        if ( (addr2info(dest) != NULL)
 #ifdef CONFIG_HAS_DATAFLASH
-          && (!addr_dataflash(addr))
+          && (!addr_dataflash(dest))
 #endif
           ) {
                int rc;
@@ -492,7 +493,11 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        }
 
        /* Check if we are copying from DataFlash to RAM */
-       if (addr_dataflash(addr) && !addr_dataflash(dest) && (addr2info(dest)==NULL) ){
+       if (addr_dataflash(addr) && !addr_dataflash(dest)
+#ifndef CFG_NO_FLASH
+                                && (addr2info(dest) == NULL)
+#endif
+          ){
                int rc;
                rc = read_dataflash(addr, count * size, (char *) dest);
                if (rc != 1) {
@@ -700,7 +705,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        int     rcode = 0;
 
 #if defined(CFG_ALT_MEMTEST)
-       vu_long addr_mask;
+       vu_long len;
        vu_long offset;
        vu_long test_offset;
        vu_long pattern;
@@ -836,26 +841,19 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                 *              all possible.
                 *
                 * Returns:     0 if the test succeeds, 1 if the test fails.
-                *
-                * ## NOTE ##   Be sure to specify start and end
-                *              addresses such that addr_mask has
-                *              lots of bits set. For example an
-                *              address range of 01000000 02000000 is
-                *              bad while a range of 01000000
-                *              01ffffff is perfect.
                 */
-               addr_mask = ((ulong)end - (ulong)start)/sizeof(vu_long);
+               len = ((ulong)end - (ulong)start)/sizeof(vu_long);
                pattern = (vu_long) 0xaaaaaaaa;
                anti_pattern = (vu_long) 0x55555555;
 
-               PRINTF("%s:%d: addr mask = 0x%.8lx\n",
+               PRINTF("%s:%d: length = 0x%.8lx\n",
                        __FUNCTION__, __LINE__,
-                       addr_mask);
+                       len);
                /*
                 * Write the default pattern at each of the
                 * power-of-two offsets.
                 */
-               for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) {
+               for (offset = 1; offset < len; offset <<= 1) {
                        start[offset] = pattern;
                }
 
@@ -865,7 +863,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                test_offset = 0;
                start[test_offset] = anti_pattern;
 
-               for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) {
+               for (offset = 1; offset < len; offset <<= 1) {
                    temp = start[offset];
                    if (temp != pattern) {
                        printf ("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
@@ -875,14 +873,15 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                    }
                }
                start[test_offset] = pattern;
+               WATCHDOG_RESET();
 
                /*
                 * Check for addr bits stuck low or shorted.
                 */
-               for (test_offset = 1; (test_offset & addr_mask) != 0; test_offset <<= 1) {
+               for (test_offset = 1; test_offset < len; test_offset <<= 1) {
                    start[test_offset] = anti_pattern;
 
-                   for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) {
+                   for (offset = 1; offset < len; offset <<= 1) {
                        temp = start[offset];
                        if ((temp != pattern) && (offset != test_offset)) {
                            printf ("\nFAILURE: Address bit stuck low or shorted @"
@@ -912,6 +911,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                 * Fill memory with a known pattern.
                 */
                for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
+                       WATCHDOG_RESET();
                        start[offset] = pattern;
                }
 
@@ -919,6 +919,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                 * Check each location and invert it for the second pass.
                 */
                for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
+                   WATCHDOG_RESET();
                    temp = start[offset];
                    if (temp != pattern) {
                        printf ("\nFAILURE (read/write) @ 0x%.8lx:"
@@ -935,6 +936,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                 * Check each location for the inverted pattern and zero it.
                 */
                for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
+                   WATCHDOG_RESET();
                    anti_pattern = ~pattern;
                    temp = start[offset];
                    if (temp != anti_pattern) {
@@ -961,6 +963,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                        pattern, "");
 
                for (addr=start,val=pattern; addr<end; addr++) {
+                       WATCHDOG_RESET();
                        *addr = val;
                        val  += incr;
                }
@@ -968,6 +971,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                puts ("Reading...");
 
                for (addr=start,val=pattern; addr<end; addr++) {
+                       WATCHDOG_RESET();
                        readback = *addr;
                        if (readback != val) {
                                printf ("\nMem error @ 0x%08X: "