rust/kernel/iommu/pgtable.rs

Source file repositories/reference/linux-study-clean/rust/kernel/iommu/pgtable.rs

File Facts

System
Linux kernel
Corpus path
rust/kernel/iommu/pgtable.rs
Extension
.rs
Size
9758 bytes
Lines
280
Domain
Rust Kernel Layer
Bucket
Rust API Membrane
Inferred role
Rust Kernel Layer: implementation source
Status
source implementation candidate

Why This File Exists

Rust-side wrappers and abstractions around kernel C APIs, ownership contracts, allocation, synchronization, and module integration.

Dependency Surface

Detected Declarations

Annotated Snippet

fn drop(&mut self) {
        // SAFETY: The caller of `Self::ttbr()` promised that the page table is not live when this
        // destructor runs.
        unsafe { bindings::free_io_pgtable_ops(self.raw_ops()) };
    }
}

/// The `ARM_64_LPAE_S1` page table format.
pub enum ARM64LPAES1 {}

impl IoPageTableFmt for ARM64LPAES1 {
    const FORMAT: io_pgtable_fmt = bindings::io_pgtable_fmt_ARM_64_LPAE_S1 as io_pgtable_fmt;
}

impl IoPageTable<ARM64LPAES1> {
    /// Access the `ttbr` field of the configuration.
    ///
    /// This is the physical address of the page table, which may be passed to the device that
    /// needs to use it.
    ///
    /// # Safety
    ///
    /// The caller must ensure that the device stops using the page table before dropping it.
    #[inline]
    pub unsafe fn ttbr(&self) -> u64 {
        // SAFETY: `arm_lpae_s1_cfg` is the right cfg type for `ARM64LPAES1`.
        unsafe { (*self.raw_cfg()).__bindgen_anon_1.arm_lpae_s1_cfg.ttbr }
    }

    /// Access the `mair` field of the configuration.
    #[inline]
    pub fn mair(&self) -> u64 {
        // SAFETY: `arm_lpae_s1_cfg` is the right cfg type for `ARM64LPAES1`.
        unsafe { (*self.raw_cfg()).__bindgen_anon_1.arm_lpae_s1_cfg.mair }
    }
}

Annotation

Implementation Notes