Add watchdog feeding macro

When HW / OS provides an always enabled watchdog, this macro can
optionally be implemented to avoid resets which are expected to
occur under normal conditions when swapping very large images or
running on slower devices.

Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/boot/bootutil/src/loader.c b/boot/bootutil/src/loader.c
index d748439..c6ec34f 100644
--- a/boot/bootutil/src/loader.c
+++ b/boot/bootutil/src/loader.c
@@ -954,6 +954,8 @@
         }
 
         bytes_copied += chunk_sz;
+
+        MCUBOOT_WATCHDOG_FEED();
     }
 
     return 0;
diff --git a/boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h b/boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h
index b539e48..f04eebc 100644
--- a/boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h
+++ b/boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h
@@ -73,4 +73,14 @@
 
 #define MCUBOOT_MAX_IMG_SECTORS       MYNEWT_VAL(BOOTUTIL_MAX_IMG_SECTORS)
 
+#if MYNEWT_VAL(WATCHDOG_INTERVAL)
+#include <hal/hal_watchdog.h>
+#define MCUBOOT_WATCHDOG_FEED()    \
+    do {                           \
+        hal_watchdog_tickle();     \
+    } while (0)
+#else
+#define MCUBOOT_WATCHDOG_FEED()    do {} while (0)
+#endif
+
 #endif /* __MCUBOOT_CONFIG_H__ */
diff --git a/boot/zephyr/include/mcuboot_config/mcuboot_config.h b/boot/zephyr/include/mcuboot_config/mcuboot_config.h
index 4365ed2..d79d556 100644
--- a/boot/zephyr/include/mcuboot_config/mcuboot_config.h
+++ b/boot/zephyr/include/mcuboot_config/mcuboot_config.h
@@ -78,4 +78,9 @@
 
 #endif /* !__BOOTSIM__ */
 
+#define MCUBOOT_WATCHDOG_FEED()         \
+    do {                                \
+        /* TODO: to be implemented */   \
+    } while (0)
+
 #endif /* __MCUBOOT_CONFIG_H__ */