Commit 4c9883b0 authored by David Brown's avatar David Brown Committed by David Brown
Browse files

Add a capability query for image number

In addition to the binary capability flags, add a query function that
returns the number of images MCUboot has been configured to support.

Signed-off-by: default avatarDavid Brown <david.brown@linaro.org>
parent 74b161ea
Loading
Loading
Loading
Loading
+6
Changes for boot/bootutil/include/bootutil/caps.h: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -41,6 +41,12 @@ uint32_t bootutil_get_caps(void);
#define BOOTUTIL_CAP_ENC_KW                 (1<<6)
#define BOOTUTIL_CAP_VALIDATE_PRIMARY_SLOT  (1<<7)

/*
 * Query the number of images this bootloader is configured for.  This
 * is also primarily used for testing.
 */
uint32_t bootutil_get_num_images(void);

#ifdef __cplusplus
}
#endif
+9
Changes for boot/bootutil/src/caps.c: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -47,3 +47,12 @@ uint32_t bootutil_get_caps(void)

    return res;
}

uint32_t bootutil_get_num_images(void)
{
#if defined(MCUBOOT_IMAGE_NUMBER)
    return MCUBOOT_IMAGE_NUMBER;
#else
    return 1;
#endif
}
+7
Changes for sim/src/caps.rs: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -19,8 +19,15 @@ impl Caps {
        let caps = unsafe { bootutil_get_caps() };
        (caps as u32) & (self as u32) != 0
    }

    /// Query for the number of images that have been configured into this
    /// MCUboot build.
    pub fn get_num_images() -> usize {
        (unsafe { bootutil_get_num_images() }) as usize
    }
}

extern "C" {
    fn bootutil_get_caps() -> Caps;
    fn bootutil_get_num_images() -> u32;
}