#![cfg_attr(not(test), no_std)]
#![cfg_attr(doc, feature(doc_cfg))]
#![doc = include_str!("../README.md")]
use core::fmt;
use memory_addr::PhysAddr;
mod arch;
pub use self::arch::*;
bitflags::bitflags! {
#[derive(Clone, Copy, PartialEq)]
pub struct MappingFlags: usize {
const READ = 1 << 0;
const WRITE = 1 << 1;
const EXECUTE = 1 << 2;
const USER = 1 << 3;
const DEVICE = 1 << 4;
const UNCACHED = 1 << 5;
}
}
impl fmt::Debug for MappingFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.0, f)
}
}
pub trait GenericPTE: fmt::Debug + Clone + Copy + Sync + Send + Sized {
fn new_page(paddr: PhysAddr, flags: MappingFlags, is_huge: bool) -> Self;
fn new_table(paddr: PhysAddr) -> Self;
fn paddr(&self) -> PhysAddr;
fn flags(&self) -> MappingFlags;
fn set_paddr(&mut self, paddr: PhysAddr);
fn set_flags(&mut self, flags: MappingFlags, is_huge: bool);
fn bits(self) -> usize;
fn is_unused(&self) -> bool;
fn is_present(&self) -> bool;
fn is_huge(&self) -> bool;
fn clear(&mut self);
}