]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/cmd_mem.c
video: ipu: initialize g_ipu_clk, g_ldb_clk statically
[karo-tx-uboot.git] / common / cmd_mem.c
index 5b03c2d5b10b97777ef972a365262eae71fe0c9a..43c3fb62bffec59d3e36adab0b25535918be4b18 100644 (file)
  */
 
 #include <common.h>
+#include <bootretry.h>
+#include <cli.h>
 #include <command.h>
 #ifdef CONFIG_HAS_DATAFLASH
 #include <dataflash.h>
 #endif
 #include <hash.h>
+#include <inttypes.h>
+#include <mapmem.h>
 #include <watchdog.h>
 #include <asm/io.h>
 #include <linux/compiler.h>
@@ -32,9 +36,9 @@ static int mod_mem(cmd_tbl_t *, int, int, int, char * const []);
 /* Display values from last command.
  * Memory modify remembered values are different from display memory.
  */
-static uint    dp_last_addr, dp_last_size;
-static uint    dp_last_length = 0x40;
-static uint    mm_last_addr, mm_last_size;
+static ulong   dp_last_addr, dp_last_size;
+static ulong   dp_last_length = 0x40;
+static ulong   mm_last_addr, mm_last_size;
 
 static ulong   base_address = 0;
 
@@ -162,7 +166,7 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 #endif
        ulong   addr, count;
        int     size;
-       void *buf;
+       void *buf, *start;
        ulong bytes;
 
        if ((argc < 3) || (argc > 4))
@@ -194,7 +198,8 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        }
 
        bytes = size * count;
-       buf = map_sysmem(addr, bytes);
+       start = map_sysmem(addr, bytes);
+       buf = start;
        while (count-- > 0) {
                if (size == 4)
                        *((u32 *)buf) = (u32)writeval;
@@ -208,12 +213,12 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        *((u8 *)buf) = (u8)writeval;
                buf += size;
        }
-       unmap_sysmem(buf);
+       unmap_sysmem(start);
        return 0;
 }
 
 #ifdef CONFIG_MX_CYCLIC
-int do_mem_mdc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_mdc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        int i;
        ulong count;
@@ -240,7 +245,7 @@ int do_mem_mdc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        return 0;
 }
 
-int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_mwc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        int i;
        ulong count;
@@ -336,7 +341,8 @@ static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                if (word1 != word2) {
                        ulong offset = buf1 - base;
 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
-                       printf("%s at 0x%p (%#0*llx) != %s at 0x%p (%#0*llx)\n",
+                       printf("%s at 0x%p (%#0*"PRIx64") != %s at 0x%p (%#0*"
+                              PRIx64 ")\n",
                               type, (void *)(addr1 + offset), size, word1,
                               type, (void *)(addr2 + offset), size, word2);
 #else
@@ -478,6 +484,9 @@ static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                if ((count % (64 << 10)) == 0)
                        WATCHDOG_RESET();
        }
+       unmap_sysmem(buf);
+       unmap_sysmem(src);
+
        return 0;
 }
 
@@ -593,7 +602,8 @@ static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
 }
 
 #ifdef CONFIG_LOOPW
-int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_loopw(cmd_tbl_t *cmdtp, int flag, int argc,
+                       char * const argv[])
 {
        ulong   addr, length, i, bytes;
        int     size;
@@ -991,10 +1001,10 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
 {
        ulong start, end;
        vu_long *buf, *dummy;
-       int iteration_limit;
+       ulong iteration_limit = 0;
        int ret;
        ulong errs = 0; /* number of errors, or -1 if interrupted */
-       ulong pattern;
+       ulong pattern = 0;
        int iteration;
 #if defined(CONFIG_SYS_ALT_MEMTEST)
        const int alt_test = 1;
@@ -1002,25 +1012,29 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
        const int alt_test = 0;
 #endif
 
+       start = CONFIG_SYS_MEMTEST_START;
+       end = CONFIG_SYS_MEMTEST_END;
+
        if (argc > 1)
-               start = simple_strtoul(argv[1], NULL, 16);
-       else
-               start = CONFIG_SYS_MEMTEST_START;
+               if (strict_strtoul(argv[1], 16, &start) < 0)
+                       return CMD_RET_USAGE;
 
        if (argc > 2)
-               end = simple_strtoul(argv[2], NULL, 16);
-       else
-               end = CONFIG_SYS_MEMTEST_END;
+               if (strict_strtoul(argv[2], 16, &end) < 0)
+                       return CMD_RET_USAGE;
 
        if (argc > 3)
-               pattern = (ulong)simple_strtoul(argv[3], NULL, 16);
-       else
-               pattern = 0;
+               if (strict_strtoul(argv[3], 16, &pattern) < 0)
+                       return CMD_RET_USAGE;
 
        if (argc > 4)
-               iteration_limit = (ulong)simple_strtoul(argv[4], NULL, 16);
-       else
-               iteration_limit = 0;
+               if (strict_strtoul(argv[4], 16, &iteration_limit) < 0)
+                       return CMD_RET_USAGE;
+
+       if (end < start) {
+               printf("Refusing to do empty test\n");
+               return -1;
+       }
 
        printf("Testing %08x ... %08x:\n", (uint)start, (uint)end);
        debug("%s:%d: start %#08lx end %#08lx\n", __func__, __LINE__,
@@ -1071,7 +1085,7 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
                ret = errs != 0;
        }
 
-       return ret;     /* not reached */
+       return ret;
 }
 #endif /* CONFIG_CMD_MEMTEST */
 
@@ -1096,9 +1110,7 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
        if (argc != 2)
                return CMD_RET_USAGE;
 
-#ifdef CONFIG_BOOT_RETRY_TIME
-       reset_cmd_timeout();    /* got a good command to get here */
-#endif
+       bootretry_reset_cmd_timeout();  /* got a good command to get here */
        /* We use the last specified parameters, unless new ones are
         * entered.
         */
@@ -1142,14 +1154,14 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
                        printf(" %08x", *((u32 *)ptr));
 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
                else if (size == 8)
-                       printf(" %016llx", *((u64 *)ptr));
+                       printf(" %016" PRIx64, *((u64 *)ptr));
 #endif
                else if (size == 2)
                        printf(" %04x", *((u16 *)ptr));
                else
                        printf(" %02x", *((u8 *)ptr));
 
-               nbytes = readline (" ? ");
+               nbytes = cli_readline(" ? ");
                if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
                        /* <CR> pressed as only input, don't modify current
                         * location and move to next. "-" pressed will go back.
@@ -1157,9 +1169,8 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
                        if (incrflag)
                                addr += nbytes ? -size : size;
                        nbytes = 1;
-#ifdef CONFIG_BOOT_RETRY_TIME
-                       reset_cmd_timeout(); /* good enough to not time out */
-#endif
+                       /* good enough to not time out */
+                       bootretry_reset_cmd_timeout();
                }
 #ifdef CONFIG_BOOT_RETRY_TIME
                else if (nbytes == -2) {
@@ -1175,11 +1186,9 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
 #endif
                        nbytes = endp - console_buffer;
                        if (nbytes) {
-#ifdef CONFIG_BOOT_RETRY_TIME
                                /* good enough to not time out
                                 */
-                               reset_cmd_timeout();
-#endif
+                               bootretry_reset_cmd_timeout();
                                if (size == 4)
                                        *((u32 *)ptr) = i;
 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
@@ -1218,7 +1227,7 @@ static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        ac = argc - 1;
 #ifdef CONFIG_HASH_VERIFY
        if (strcmp(*av, "-v") == 0) {
-               flags |= HASH_FLAG_VERIFY;
+               flags |= HASH_FLAG_VERIFY | HASH_FLAG_ENV;
                av++;
                ac--;
        }
@@ -1294,7 +1303,7 @@ U_BOOT_CMD(
 
 #ifdef CONFIG_CMD_CRC32
 
-#ifndef CONFIG_CRC32_VERIFY
+#ifndef CONFIG_HASH_VERIFY
 
 U_BOOT_CMD(
        crc32,  4,      1,      do_mem_crc,
@@ -1302,7 +1311,7 @@ U_BOOT_CMD(
        "address count [addr]\n    - compute CRC32 checksum [save at addr]"
 );
 
-#else  /* CONFIG_CRC32_VERIFY */
+#else  /* CONFIG_HASH_VERIFY */
 
 U_BOOT_CMD(
        crc32,  5,      1,      do_mem_crc,
@@ -1311,12 +1320,12 @@ U_BOOT_CMD(
        "-v address count crc\n    - verify crc of memory area"
 );
 
-#endif /* CONFIG_CRC32_VERIFY */
+#endif /* CONFIG_HASH_VERIFY */
 
 #endif
 
 #ifdef CONFIG_CMD_MEMINFO
-__weak void board_show_dram(ulong size)
+__weak void board_show_dram(phys_size_t size)
 {
        puts("DRAM:  ");
        print_size(size, "\n");