twizzler_security/
gates.rs

1#[derive(Clone, Copy, PartialEq, Eq, Debug)]
2/// Gates are a range into an object that a
3/// `Cap` / `Del` provides access to.
4/// Typically Gates are set to the entire
5/// object, but can be defined to the byte-level.
6/// This primitive is used to support Secure API Calls
7/// TODO: link more info about secure api calls
8pub struct Gate {
9    /// The offset into the object that we provide permissions for
10    pub offset: u64,
11    /// How far that area should strech, from the offset
12    pub length: u64,
13    /// The alignment
14    pub align: u64,
15}
16
17/// The maximum length of an object.
18static MAX_LEN: u64 = 1e9 as u64;
19
20impl Gate {
21    /// Create a new Gate
22    pub fn new(offset: u64, length: u64, align: u64) -> Self {
23        Gate {
24            offset,
25            length,
26            align,
27        }
28    }
29}
30
31impl Default for Gate {
32    fn default() -> Self {
33        //NOTE: verify with daniel that these are the default values for gates
34        Gate {
35            offset: 0,
36            length: MAX_LEN,
37            align: 1,
38        }
39    }
40}