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 {
|
impl Page {
|
||||||
fn containing_address(address: VirtualAddress) -> Page {
|
fn containing_address(address: VirtualAddress) -> Page {
|
||||||
match address {
|
assert!(address < 0x0000_8000_0000_0000 || address >= 0xffff_8000_0000_0000,
|
||||||
addr if addr < 0o_400_000_000_000_0000 => Page { number: addr / PAGE_SIZE },
|
"invalid address: 0x{:x}", address);
|
||||||
addr if addr >= 0o177777_400_000_000_000_0000 => {
|
Page { number: address / PAGE_SIZE }
|
||||||
Page { number: (address / PAGE_SIZE) & 0o_777_777_777_777 }
|
|
||||||
}
|
|
||||||
_ => panic!("invalid address: 0x{:x}", address),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_address(&self) -> VirtualAddress {
|
fn start_address(&self) -> VirtualAddress {
|
||||||
if self.number >= 0x800000000 {
|
self.number * PAGE_SIZE
|
||||||
// sign extension necessary
|
|
||||||
(self.number << 12) | 0xffff_000000000000
|
|
||||||
} else {
|
|
||||||
self.number << 12
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn p4_index(&self) -> usize {
|
fn p4_index(&self) -> usize {
|
||||||
|
|||||||
Reference in New Issue
Block a user