Update bootutil to reduce amount of global state

The boot loader state currently exists as global variable (boot_data)
which is accessed by all routines; this updates all routines that
require access to the state to receive it by parameter.

Variables that are declared as "static" (globals) were #ifdef'ed to
only use static when building a native bootloader, to avoid stack
allocation. When bootutil is built to run in the simulator they are
stack allocated to avoid thread share.

Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/boot/boot_serial/src/boot_serial.c b/boot/boot_serial/src/boot_serial.c
index bdf3749..6f964d4 100644
--- a/boot/boot_serial/src/boot_serial.c
+++ b/boot/boot_serial/src/boot_serial.c
@@ -178,7 +178,7 @@
         flash_area_read(fap, 0, &hdr, sizeof(hdr));
 
         if (hdr.ih_magic != IMAGE_MAGIC ||
-          bootutil_img_validate(0, &hdr, fap, tmpbuf, sizeof(tmpbuf),
+          bootutil_img_validate(NULL, 0, &hdr, fap, tmpbuf, sizeof(tmpbuf),
                                 NULL, 0, NULL)) {
             flash_area_close(fap);
             continue;