Skip to main content

AccessPolicy

Struct AccessPolicy 

Source
pub struct AccessPolicy { /* private fields */ }
Expand description

The validated policy engine for one session.

Construction validates the entire allowlist against the resources and ceiling; a rejected allowlist creates no engine and therefore no session, and no hardware operation is performed.

Implementations§

Source§

impl AccessPolicy

Source

pub fn new( mode: SessionMode, resources: BTreeMap<ResourceId, MmioResource>, ceiling: BTreeMap<ResourceId, ResourceCeiling>, allowlist: impl IntoIterator<Item = AccessRule>, ) -> Result<Self, (AccessRule, Denial)>

Builds a policy engine, validating every allowlist rule structurally and against the ceiling. Returns the first offending rule and the reason on failure.

Source

pub fn mode(&self) -> SessionMode

The session mode (read-only or mutating).

Source

pub fn resource_ids(&self) -> impl Iterator<Item = ResourceId>

IDs of every resource this policy knows about.

Source

pub fn resource(&self, id: ResourceId) -> Option<&MmioResource>

Returns the descriptor for id, if known.

Source

pub fn check_read32( &self, resource: ResourceId, offset: u64, class: AccessClass, ) -> Result<(), Denial>

Immediately-before-access validation for a 32-bit read. This covers resource lookup, width, alignment, overflow, logical and mapped bounds, ceiling hard denies, unknown-read permission, and the exact allowlist match. Session/generation staleness is the session server’s job and the volatile read itself is the executor’s.

Source

pub fn check_write32( &self, resource: ResourceId, offset: u64, write_mask: u32, precondition: Option<&WritePrecondition>, ) -> Result<&WritableRegister, Denial>

Immediately-before-access validation for a 32-bit write.

Source

pub fn check_poll32( &self, resource: ResourceId, offset: u64, mask: u32, interval_ns: i64, timeout_ns: i64, ) -> Result<(), Denial>

Immediately-before-access validation for repeated polling reads.

Source

pub fn check_interrupt(&self, resource: ResourceId) -> Result<(), Denial>

Immediately-before-access validation for an interrupt observation.

Source

pub fn check_gpio_read(&self, resource: ResourceId) -> Result<(), Denial>

Immediately-before-access validation for a GPIO read.

Source

pub fn check_gpio_write(&self, resource: ResourceId) -> Result<(), Denial>

Immediately-before-access validation for a GPIO write. Requires mutation lease.

Source

pub fn check_i2c_transfer( &self, resource: ResourceId, write_len: usize, read_len: usize, ) -> Result<(), Denial>

Immediately-before-access validation for an I2C transfer.

Source

pub fn check_spi_transmit( &self, resource: ResourceId, tx_len: usize, ) -> Result<(), Denial>

Immediately-before-access validation for a SPI transmit. Requires mutation lease.

Source

pub fn check_clock_enable(&self, resource: ResourceId) -> Result<(), Denial>

Immediately-before-access validation for Clock enable. Requires mutation lease.

Source

pub fn check_clock_disable(&self, resource: ResourceId) -> Result<(), Denial>

Immediately-before-access validation for Clock disable. Requires mutation lease.

Source

pub fn check_clock_is_enabled(&self, resource: ResourceId) -> Result<(), Denial>

Immediately-before-access validation for Clock is_enabled query.

Source

pub fn check_clock_set_rate(&self, resource: ResourceId) -> Result<(), Denial>

Immediately-before-access validation for Clock set_rate. Requires mutation lease.

Source

pub fn check_clock_query_rate(&self, resource: ResourceId) -> Result<(), Denial>

Immediately-before-access validation for Clock query_rate.

Source

pub fn check_clock_get_rate(&self, resource: ResourceId) -> Result<(), Denial>

Immediately-before-access validation for Clock get_rate.

Source

pub fn check_reset_assert(&self, resource: ResourceId) -> Result<(), Denial>

Immediately-before-access validation for Reset assert. Requires mutation lease.

Source

pub fn check_reset_deassert(&self, resource: ResourceId) -> Result<(), Denial>

Immediately-before-access validation for Reset deassert. Requires mutation lease.

Source

pub fn check_reset_toggle(&self, resource: ResourceId) -> Result<(), Denial>

Immediately-before-access validation for Reset toggle. Requires mutation lease.

Source

pub fn check_reset_status(&self, resource: ResourceId) -> Result<(), Denial>

Immediately-before-access validation for Reset status query.

Source

pub fn check_serial_read(&self, resource: ResourceId) -> Result<(), Denial>

Immediately-before-access validation for Serial read.

Source

pub fn check_serial_write( &self, resource: ResourceId, tx_len: usize, ) -> Result<(), Denial>

Immediately-before-access validation for Serial write. Requires mutation lease.

Trait Implementations§

Source§

impl Debug for AccessPolicy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.