blob: 77be9de110e1eb66c6443a07811abc412e387fb6 [file] [log] [blame]
David Brown902d6172017-05-05 09:37:41 -06001// Query the bootloader's capabilities.
2
3#[repr(u32)]
4#[derive(Copy, Clone, Eq, PartialEq)]
5#[allow(unused)]
6pub enum Caps {
7 RSA2048 = (1 << 0),
8 EcdsaP224 = (1 << 1),
9 EcdsaP256 = (1 << 2),
10 SwapUpgrade = (1 << 3),
11 OverwriteUpgrade = (1 << 4),
12}
13
14impl Caps {
15 pub fn present(self) -> bool {
16 let caps = unsafe { bootutil_get_caps() };
17 (caps as u32) & (self as u32) != 0
18 }
19}
20
21extern "C" {
22 fn bootutil_get_caps() -> Caps;
23}