[new uImage] Add memmove_wd() common routine
authorMarian Balakowicz <m8@semihalf.com>
Tue, 8 Jan 2008 17:11:45 +0000 (18:11 +0100)
committerWolfgang Denk <wd@denx.de>
Thu, 7 Feb 2008 00:12:56 +0000 (01:12 +0100)
Move common, watchdog sensible memmove code to a helper memmmove_wd() routine.

Signed-off-by: Marian Balakowicz <m8@semihalf.com>
common/cmd_bootm.c
common/image.c
include/image.h
lib_m68k/m68k_linux.c
lib_ppc/ppc_linux.c

index aa7c0f5b777f9f0490cb036b2531a53e4c52b1e5..b059336ca599fa4bc475644368a7a2065fb3fbe4 100644 (file)
@@ -250,24 +250,12 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                if (image_get_load (hdr) == addr) {
                        printf ("   XIP %s ... ", name);
                } else {
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
-                       size_t l = len;
-                       void *to = (void *)image_get_load (hdr);
-                       void *from = (void *)data;
-
                        printf ("   Loading %s ... ", name);
 
-                       while (l > 0) {
-                               size_t tail = (l > CHUNKSZ) ? CHUNKSZ : l;
-                               WATCHDOG_RESET();
-                               memmove (to, from, tail);
-                               to += tail;
-                               from += tail;
-                               l -= tail;
-                       }
-#else  /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
-                       memmove ((void *)image_get_load (hdr), (uchar *)data, len);
-#endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
+                       memmove_wd ((void *)image_get_load (hdr),
+                                  (void *)data, len, CHUNKSZ);
+
+                       puts("OK\n");
                }
                break;
        case IH_COMP_GZIP:
index 7a0a3d2a90a184d3310109215bf5691a91a257e2..048b866ce65e29a3e74615339866e98878e5dcb4 100644 (file)
@@ -57,6 +57,7 @@ int image_check_dcrc (image_header_t *hdr)
        return (dcrc == image_get_dcrc (hdr));
 }
 
+#ifndef USE_HOSTCC
 int image_check_dcrc_wd (image_header_t *hdr, ulong chunksz)
 {
        ulong dcrc = 0;
@@ -89,3 +90,20 @@ int getenv_verify (void)
        char *s = getenv ("verify");
        return (s && (*s == 'n')) ? 0 : 1;
 }
+
+void memmove_wd (void *to, void *from, size_t len, ulong chunksz)
+{
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+       while (len > 0) {
+               size_t tail = (len > chunksz) ? chunksz : len;
+               WATCHDOG_RESET ();
+               memmove (to, from, tail);
+               to += tail;
+               from += tail;
+               len -= tail;
+       }
+#else  /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
+       memmove (to, from, len);
+#endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
+}
+#endif /* USE_HOSTCC */
index aab3f44ccbfb0c97859227368abd7784411dd841..9dc0343586ee6482c0218cccb5a973057ccf714c 100644 (file)
@@ -250,8 +250,11 @@ static inline void image_set_name (image_header_t *hdr, const char *name)
 
 int image_check_hcrc (image_header_t *hdr);
 int image_check_dcrc (image_header_t *hdr);
+#ifndef USE_HOSTCC
 int image_check_dcrc_wd (image_header_t *hdr, ulong chunksize);
 int getenv_verify (void);
+void memmove_wd (void *to, void *from, size_t len, ulong chunksz);
+#endif
 
 static inline int image_check_magic (image_header_t *hdr)
 {
index f865c0c6a5a837420f0b8bb92c72961a0f68f8c1..0af2eae56889441b824f1de313b9472b950bf1aa 100644 (file)
@@ -266,25 +266,10 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
                        initrd_end = initrd_start + len;
                        printf("   Loading Ramdisk to %08lx, end %08lx ... ",
                               initrd_start, initrd_end);
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
-                       {
-                               size_t l = len;
-                               void *to = (void *)initrd_start;
-                               void *from = (void *)data;
-
-                               while (l > 0) {
-                                       size_t tail =
-                                           (l > CHUNKSZ) ? CHUNKSZ : l;
-                                       WATCHDOG_RESET();
-                                       memmove(to, from, tail);
-                                       to += tail;
-                                       from += tail;
-                                       l -= tail;
-                               }
-                       }
-#else                          /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
-                       memmove((void *)initrd_start, (void *)data, len);
-#endif                         /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
+
+                       memmove_wd((void *)initrd_start,
+                                  (void *)data, len, CHUNKSZ);
+
                        puts("OK\n");
                }
        } else {
index 671673fcb87afbb0e8adfc00da583a46783e02c0..6e2afed9b058f147c388ddefe7868991e338669b 100644 (file)
@@ -426,24 +426,10 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
                initrd_end    = initrd_start + len;
                printf ("   Loading Ramdisk to %08lx, end %08lx ... ",
                        initrd_start, initrd_end);
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
-               {
-                       size_t l = len;
-                       void *to = (void *)initrd_start;
-                       void *from = (void *)data;
-
-                       while (l > 0) {
-                               size_t tail = (l > CHUNKSZ) ? CHUNKSZ : l;
-                               WATCHDOG_RESET();
-                               memmove (to, from, tail);
-                               to += tail;
-                               from += tail;
-                               l -= tail;
-                       }
-               }
-#else  /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
-               memmove ((void *)initrd_start, (void *)data, len);
-#endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
+
+               memmove_wd((void *)initrd_start,
+                          (void *)data, len, CHUNKSZ);
+
                puts ("OK\n");
            }
        } else {