mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Calculate next_table_address through directly through addresses
This commit is contained in:
@@ -47,16 +47,10 @@ impl<L> Table<L> where L: HierachicalLevel
|
||||
}
|
||||
|
||||
fn next_table_address(&self, index: usize) -> Option<usize> {
|
||||
use memory::paging::Page;
|
||||
|
||||
let entry_flags = self[index].flags();
|
||||
if entry_flags.contains(PRESENT) && !entry_flags.contains(HUGE_PAGE) {
|
||||
let table_page = Page::containing_address(self as *const _ as usize);
|
||||
assert!(table_page.number >= 0o_777_000_000_000);
|
||||
let next_table_page = Page {
|
||||
number: ((table_page.number << 9) & 0o_777_777_777_777) | index,
|
||||
};
|
||||
Some(next_table_page.start_address())
|
||||
let table_address = self as *const _ as usize;
|
||||
Some((table_address << 9) | (index << 12))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user