mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Change semantics of start_address and containing_address
The page numbers now respect the memory hole between higher and lower half.
This commit is contained in:
@@ -40,22 +40,13 @@ pub struct Page {
|
||||
|
||||
impl Page {
|
||||
fn containing_address(address: VirtualAddress) -> Page {
|
||||
match address {
|
||||
addr if addr < 0o_400_000_000_000_0000 => Page { number: addr / PAGE_SIZE },
|
||||
addr if addr >= 0o177777_400_000_000_000_0000 => {
|
||||
Page { number: (address / PAGE_SIZE) & 0o_777_777_777_777 }
|
||||
}
|
||||
_ => panic!("invalid address: 0x{:x}", address),
|
||||
}
|
||||
assert!(address < 0x0000_8000_0000_0000 || address >= 0xffff_8000_0000_0000,
|
||||
"invalid address: 0x{:x}", address);
|
||||
Page { number: address / PAGE_SIZE }
|
||||
}
|
||||
|
||||
pub fn start_address(&self) -> VirtualAddress {
|
||||
if self.number >= 0x800000000 {
|
||||
// sign extension necessary
|
||||
(self.number << 12) | 0xffff_000000000000
|
||||
} else {
|
||||
self.number << 12
|
||||
}
|
||||
fn start_address(&self) -> VirtualAddress {
|
||||
self.number * PAGE_SIZE
|
||||
}
|
||||
|
||||
fn p4_index(&self) -> usize {
|
||||
|
||||
Reference in New Issue
Block a user