[][src]Trait sunrise_kernel::paging::hierarchical_table::TableHierarchy

pub trait TableHierarchy {
    type TopLevelTableType: HierarchicalTable;
    fn get_top_level_table(
        &mut self
    ) -> SmartHierarchicalTable<Self::TopLevelTableType>; fn map_to_from_iterator<I>(
        &mut self,
        frames_iterator: I,
        start_address: VirtualAddress,
        flags: MappingAccessRights
    )
    where
        I: Iterator<Item = PhysicalAddress>
, { ... }
fn guard(&mut self, address: VirtualAddress, length: usize) { ... }
fn unmap<C>(&mut self, address: VirtualAddress, length: usize, callback: C)
    where
        C: FnMut(PhysicalAddress)
, { ... }
fn for_every_entry<C>(
        &mut self,
        address: VirtualAddress,
        length: usize,
        callback: C
    )
    where
        C: FnMut(PageState<PhysicalAddress>, usize)
, { ... }
fn find_available_virtual_space_aligned(
        &mut self,
        length: usize,
        start_addr: VirtualAddress,
        end_addr: VirtualAddress,
        alignment: usize
    ) -> Option<VirtualAddress> { ... } }

A trait operating on a whole hierarchy of tables.

Implementer only has to provide a function to map the top level table, and the trait does the rest.

Thanks to this we can have the same api for every kind of page tables, the only difference is the way we access the page directory :

Associated Types

type TopLevelTableType: HierarchicalTable

The type of the top level table.

Loading content...

Required methods

fn get_top_level_table(
    &mut self
) -> SmartHierarchicalTable<Self::TopLevelTableType>

Gets a reference to the top level table, either through recursive mapping, or by temporarily mapping it in the currently active page tables.

Loading content...

Provided methods

fn map_to_from_iterator<I>(
    &mut self,
    frames_iterator: I,
    start_address: VirtualAddress,
    flags: MappingAccessRights
) where
    I: Iterator<Item = PhysicalAddress>, 

Creates a mapping in the page tables with the given flags.

The physical frames to map are passed as an iterator that yields physical addresses. The mapping begins at start_address, and advances by PAGE_SIZE steps, consuming frames_iterator every time. When frames_iterator is depleted, the mapping stops.

Panics

Panics if address is not page-aligned. Panics if any encountered entry was already in use

fn guard(&mut self, address: VirtualAddress, length: usize)

Creates a span of guard pages

This function will avoid creating child tables filled only with guarded entry, and instead guard a single entry in the parent. This is called a HUGE guard.

Panics

Panics if any encountered entry was already in use Panics if address is not page-aligned. Panics if length is not page-aligned.

fn unmap<C>(&mut self, address: VirtualAddress, length: usize, callback: C) where
    C: FnMut(PhysicalAddress), 

Unmaps a range of virtual address. On every frames mapped by a level 0 table, the closure passed as parameter will be called after having deleted the entry. If unmap encounters a guard page, it is unmapped, and the closure is not called. If unmap encounters a HUGE guard page, it decides if it must split it and might create a child table which is only partly guarded. If unmap encounters a non-mapped entry, it panics, as this is probably a bug.

If a table is left empty after an unmap, it is never deallocated, and left as is.

Panics

Panics if encounters any entry that was not mapped. Panics if address is not page-aligned. Panics if length is not page-aligned.

fn for_every_entry<C>(
    &mut self,
    address: VirtualAddress,
    length: usize,
    callback: C
) where
    C: FnMut(PageState<PhysicalAddress>, usize), 

Iters in the page tables, applying closure on every mapping. On every entry, the closure will be called with its state and the length it maps.

Panics

Panics if address is not page-aligned. Panics if length is not page-aligned.

fn find_available_virtual_space_aligned(
    &mut self,
    length: usize,
    start_addr: VirtualAddress,
    end_addr: VirtualAddress,
    alignment: usize
) -> Option<VirtualAddress>

Finds a virtual space hole that is at least length long, between start_addr and end_addr.

Panics

Panics if start_addr is not page-aligned. Panics if length is not page-aligned. Panics if alignment is not page-aligned. Panics if start_addr > end_addr. Panics if length is zero.

Loading content...

Implementors

impl TableHierarchy for ActiveHierarchy[src]

type TopLevelTableType = ActivePageDirectory

fn get_top_level_table(&mut self) -> SmartHierarchicalTable<ActivePageDirectory>[src]

Gets the ActivePageDirectory through recursive mapping.

Panics

Panics if paging is not enabled.

impl TableHierarchy for InactiveHierarchy[src]

impl<'b> TableHierarchy for DynamicHierarchy<'b>[src]

type TopLevelTableType = ()

Loading content...