Add a P4 constant and a Table::next_table_address method

master
Philipp Oppermann 8 years ago
parent 8fcea7951b
commit 3706331a43

@ -2,6 +2,8 @@ use core::ops::{Index, IndexMut};
use memory::paging::entry::*; use memory::paging::entry::*;
use memory::paging::ENTRY_COUNT; use memory::paging::ENTRY_COUNT;
pub const P4: *mut Table = 0xffffffff_fffff000 as *mut _;
pub struct Table { pub struct Table {
entries: [Entry; ENTRY_COUNT], entries: [Entry; ENTRY_COUNT],
} }
@ -12,6 +14,16 @@ impl Table {
entry.set_unused(); entry.set_unused();
} }
} }
fn next_table_address(&self, index: usize) -> Option<usize> {
let entry_flags = self[index].flags();
if entry_flags.contains(PRESENT) && !entry_flags.contains(HUGE_PAGE) {
let table_address = self as *const _ as usize;
Some((table_address << 9) | (index << 12))
} else {
None
}
}
} }
impl Index<usize> for Table { impl Index<usize> for Table {

Loading…
Cancel
Save