You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
741 B
33 lines
741 B
use super::*;
|
|
|
|
#[derive(Debug, Eq, PartialEq, Clone)]
|
|
pub struct Linear {
|
|
offset: isize,
|
|
}
|
|
|
|
impl MemoryHandler for Linear {
|
|
fn box_clone(&self) -> Box<MemoryHandler> {
|
|
Box::new(self.clone())
|
|
}
|
|
|
|
fn map(&self, pt: &mut PageTable, addr: VirtAddr, attr: &MemoryAttr) {
|
|
let target = (addr as isize + self.offset) as PhysAddr;
|
|
let entry = pt.map(addr, target);
|
|
entry.set_present(true);
|
|
attr.apply(entry);
|
|
}
|
|
|
|
fn unmap(&self, pt: &mut PageTable, addr: VirtAddr) {
|
|
pt.unmap(addr);
|
|
}
|
|
|
|
fn handle_page_fault(&self, _pt: &mut PageTable, _addr: VirtAddr) -> bool {
|
|
false
|
|
}
|
|
}
|
|
|
|
impl Linear {
|
|
pub fn new(offset: isize) -> Self {
|
|
Linear { offset }
|
|
}
|
|
} |