Trait kcore::vm::PageTable[][src]

pub trait PageTable: Sized {
    const USERTOP: usize;
    const PAGE_LAYOUT: Layout;
    const PAGE_SIZE: usize;

    fn new() -> Result<Self>;
fn switch(&self);
fn map(&mut self, va: usize, vpa: usize) -> Result<()>;
fn unmap(&mut self, va: usize) -> bool;
fn protect(&mut self, va: usize, read_only: bool); }
Expand description

Page table.

Associated Constants

const USERTOP: usize[src]

Request map to the page table will be always lower than USERTOP. This must be page aligned.

const PAGE_LAYOUT: Layout[src]

Layout used to alloc and dealloc physical pages from global allocator.

const PAGE_SIZE: usize[src]

Page size derived from [PAGE_LAYOUT]. Donot overwrite this.

Required methods

fn new() -> Result<Self>[src]

Create a new page table.

fn switch(&self)[src]

Switch to this page table.

SAFETY: All pages mapped before switching should be accessiable after that.

That means the implementation can batch the map and unmap requests.

fn map(&mut self, va: usize, vpa: usize) -> Result<()>[src]

Map virtual address [va, va+PAGE_SIZE) to physical page at vpa with write permission.

It’s guaranteed that va is page-aligned. Overwrite the old mapping if exists. The implementation is required to be atomic, i.e., undo the mapping if failed.

fn unmap(&mut self, va: usize) -> bool[src]

Unmap the pages in [va, va+PAGE_SIZE) in this page table.

Returns false if there is no such page. It’s guaranteed that va is page-aligned.

fn protect(&mut self, va: usize, read_only: bool)[src]

Protect the page in [va, va+PAGE_SIZE) as read-only or read-write.

It’s guaranteed that va is page-aligned.

Implementors