mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-24 18:36:24 +04:00
Now PageTable::unmap calls PageTable::find_pte instead of PageTable::find_pte_create.
This commit is contained in:
parent
2793aa60e5
commit
9ff45a2e7a
@ -102,12 +102,12 @@ impl PageTable {
|
|||||||
}
|
}
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
fn find_pte(&self, vpn: VirtPageNum) -> Option<&PageTableEntry> {
|
fn find_pte(&self, vpn: VirtPageNum) -> Option<&mut PageTableEntry> {
|
||||||
let idxs = vpn.indexes();
|
let idxs = vpn.indexes();
|
||||||
let mut ppn = self.root_ppn;
|
let mut ppn = self.root_ppn;
|
||||||
let mut result: Option<&PageTableEntry> = None;
|
let mut result: Option<&mut PageTableEntry> = None;
|
||||||
for i in 0..3 {
|
for i in 0..3 {
|
||||||
let pte = &ppn.get_pte_array()[idxs[i]];
|
let pte = &mut ppn.get_pte_array()[idxs[i]];
|
||||||
if i == 2 {
|
if i == 2 {
|
||||||
result = Some(pte);
|
result = Some(pte);
|
||||||
break;
|
break;
|
||||||
@ -127,7 +127,7 @@ impl PageTable {
|
|||||||
}
|
}
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn unmap(&mut self, vpn: VirtPageNum) {
|
pub fn unmap(&mut self, vpn: VirtPageNum) {
|
||||||
let pte = self.find_pte_create(vpn).unwrap();
|
let pte = self.find_pte(vpn).unwrap();
|
||||||
assert!(pte.is_valid(), "vpn {:?} is invalid before unmapping", vpn);
|
assert!(pte.is_valid(), "vpn {:?} is invalid before unmapping", vpn);
|
||||||
*pte = PageTableEntry::empty();
|
*pte = PageTableEntry::empty();
|
||||||
}
|
}
|
||||||
@ -199,3 +199,4 @@ pub fn translated_refmut<T>(token: usize, ptr: *mut T) -> &'static mut T {
|
|||||||
//println!("translated_refmut: before translate_va");
|
//println!("translated_refmut: before translate_va");
|
||||||
page_table.translate_va(VirtAddr::from(va)).unwrap().get_mut()
|
page_table.translate_va(VirtAddr::from(va)).unwrap().get_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user