opentitanlib/ownership/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

use std::sync::atomic::{AtomicBool, Ordering};

mod application_key;
mod flash;
mod flash_info;
mod misc;
pub mod owner;
mod rescue;

pub use application_key::{ApplicationKeyDomain, OwnerApplicationKey};
pub use flash::{FlashFlags, OwnerFlashConfig, OwnerFlashRegion};
pub use flash_info::{OwnerFlashInfoConfig, OwnerInfoPage};
pub use misc::{KeyMaterial, OwnershipKeyAlg, TlvHeader, TlvTag};
pub use owner::{OwnerBlock, OwnerConfigItem, SramExecMode};
pub use rescue::{CommandTag, OwnerRescueConfig, RescueType};

pub struct GlobalFlags;

static DEBUG: AtomicBool = AtomicBool::new(false);

impl GlobalFlags {
    /// Set the value of the ownership debug flag.  This controls the serialization
    /// of header and reserved fields in the ownership structs.
    pub fn set_debug(v: bool) {
        DEBUG.store(v, Ordering::Relaxed);
    }

    // Used by the serde serializer to query whether or not a field should be serialized.
    pub fn not_debug<T>(_: &T) -> bool {
        !DEBUG.load(Ordering::Relaxed)
    }
}