fix DelayHandler & MemoryAttr

toolchain_update
WangRunji 6 years ago
parent 704af94211
commit 557f021c08

@ -21,8 +21,8 @@ impl<T: FrameAllocator> MemoryHandler for Delay<T> {
let entry = pt.get_entry(addr).expect("failed to get entry");
if entry.present() {
self.allocator.dealloc(entry.target());
pt.unmap(addr);
}
pt.unmap(addr);
}
fn page_fault_handler(&self, pt: &mut PageTable, addr: VirtAddr) -> bool {
@ -33,8 +33,7 @@ impl<T: FrameAllocator> MemoryHandler for Delay<T> {
}
let frame = self.allocator.alloc().expect("failed to alloc frame");
entry.set_target(frame);
entry.set_present(true);
entry.update();
self.flags.apply(entry);
true
}
}

@ -83,7 +83,6 @@ pub struct MemoryAttr {
readonly: bool,
execute: bool,
mmio: bool,
hide: bool,
}
impl MemoryAttr {
@ -116,26 +115,18 @@ impl MemoryAttr {
self
}
/*
** @brief set the memory attribute's hide bit
** @retval MemoryAttr the memory attribute itself
*/
pub fn hide(mut self) -> Self {
self.hide = true;
self
}
/*
** @brief apply the memory attribute to a page table entry
** @param entry: &mut impl Entry
** the page table entry to apply the attribute
** @retval none
*/
fn apply(&self, entry: &mut Entry) {
if self.user { entry.set_user(true); }
if self.readonly { entry.set_writable(false); }
if self.execute { entry.set_execute(true); }
if self.mmio { entry.set_mmio(true); }
if self.hide { entry.set_present(false); }
if self.user || self.readonly || self.execute || self.mmio || self.hide { entry.update(); }
pub fn apply(&self, entry: &mut Entry) {
entry.set_present(true);
entry.set_user(self.user);
entry.set_writable(!self.readonly);
entry.set_execute(self.execute);
entry.set_mmio(self.mmio);
entry.update();
}
}

@ -116,8 +116,8 @@ impl Entry for PageEntry {
}
fn execute(&self) -> bool { !self.0.flags().contains(EF::NO_EXECUTE) }
fn set_execute(&mut self, value: bool) { self.as_flags().set(EF::NO_EXECUTE, !value); }
fn mmio(&self) -> bool { unimplemented!() }
fn set_mmio(&mut self, value: bool) { unimplemented!() }
fn mmio(&self) -> bool { false }
fn set_mmio(&mut self, value: bool) { }
}
fn get_entry_ptr(addr: usize, level: u8) -> *mut PageEntry {

Loading…
Cancel
Save