MYNEWT-518 boot - Allow test+confirm as single act

Currently, to permanently run the alternate image, the boot loader
requires the following sequence:

1. image test <slot-01-hash>
2. reboot
3. image confirm

The new feature is to remove the need for the third step. The user
should be able to permanently switch images with this sequence:

1. image confirm <slot-01-hash>
2. reboot
diff --git a/boot/bootutil/src/bootutil_misc.c b/boot/bootutil/src/bootutil_misc.c
index f3ab9d5..1119bc2 100644
--- a/boot/bootutil/src/bootutil_misc.c
+++ b/boot/bootutil/src/bootutil_misc.c
@@ -74,9 +74,11 @@
          *----------+------------+------------|
          *    magic | Any        | Good       |
          * image-ok | Any        | N/A        |
-         * ---------+------------+------------'
-         * swap: test                         |
-         * -----------------------------------'
+         * ---------+------------+------------+---------------------------'
+         * swap: test                                                     |
+         * note: slot-1 image-ok val indicates whether swap is permanent; |
+         *       (0xff=temporary; 0x01=permanent)                         |
+         * ---------------------------------------------------------------'
          */
         .bsw_magic_slot0 =      0,
         .bsw_magic_slot1 =      BOOT_MAGIC_GOOD,
@@ -357,10 +359,15 @@
  * Marks the image in slot 1 as pending.  On the next reboot, the system will
  * perform a one-time boot of the slot 1 image.
  *
+ * @param permanent         Whether the image should be used permanently or
+ *                              only tested once:
+ *                                  0=run image once, then confirm or revert.
+ *                                  1=run image forever.
+ *
  * @return                  0 on success; nonzero on failure.
  */
 int
-boot_set_pending(void)
+boot_set_pending(int permanent)
 {
     const struct flash_area *fap;
     struct boot_swap_state state_slot1;
@@ -386,6 +393,10 @@
             rc = boot_write_magic(fap);
         }
 
+        if (rc == 0 && permanent) {
+            rc = boot_write_image_ok(fap);
+        }
+
         flash_area_close(fap);
         return rc;