mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Add a P4 constant and a Table::next_table_address method
This commit is contained in:
@@ -2,6 +2,8 @@ use core::ops::{Index, IndexMut};
|
||||
use memory::paging::entry::*;
|
||||
use memory::paging::ENTRY_COUNT;
|
||||
|
||||
pub const P4: *mut Table = 0xffffffff_fffff000 as *mut _;
|
||||
|
||||
pub struct Table {
|
||||
entries: [Entry; ENTRY_COUNT],
|
||||
}
|
||||
@@ -12,6 +14,16 @@ impl Table {
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user