diff --git a/posts/DRAFT-paging.md b/posts/DRAFT-paging.md index 04461493..345abda6 100644 --- a/posts/DRAFT-paging.md +++ b/posts/DRAFT-paging.md @@ -498,7 +498,7 @@ TODO imports Let's add a function that maps a `Page` to some `Frame`: ```rust -pub fn map_to(page: &Page, frame: Frame, flags: EntryFlags, allocator: &mut A) +pub fn map_to(page: Page, frame: Frame, flags: EntryFlags, allocator: &mut A) where A: FrameAllocator { let p4 = unsafe { &mut *P4 }; @@ -603,7 +603,7 @@ impl RecursivePageTable { } pub fn map_to(&mut self, - page: &Page, + page: Page, frame: Frame, flags: EntryFlags, allocator: &mut A) @@ -621,7 +621,7 @@ Now the `p4()` and `p4_mut()` methods should be the only methods containing an ` For convenience, we add a `map` method that just picks a free frame for us: ```rust -pub fn map(&mut self, page: &Page, flags: EntryFlags, allocator: &mut A) +pub fn map(&mut self, page: Page, flags: EntryFlags, allocator: &mut A) where A: FrameAllocator { let frame = allocator.allocate_frame().expect("out of memory"); @@ -639,7 +639,7 @@ pub fn identity_map(&mut self, where A: FrameAllocator { let page = Page::containing_address(frame.start_address()); - self.map_to(&page, frame, flags, allocator) + self.map_to(page, frame, flags, allocator) } ``` @@ -648,7 +648,7 @@ pub fn identity_map(&mut self, TODO ```rust -fn unmap(&mut self, page: &Page, allocator: &mut A) +fn unmap(&mut self, page: Page, allocator: &mut A) where A: FrameAllocator { assert!(self.translate(page.start_address()).is_some()); diff --git a/src/memory/paging/mod.rs b/src/memory/paging/mod.rs index 10548a50..dfe817d3 100644 --- a/src/memory/paging/mod.rs +++ b/src/memory/paging/mod.rs @@ -129,14 +129,14 @@ impl RecursivePageTable { .or_else(huge_page) } - pub fn map(&mut self, page: &Page, flags: EntryFlags, allocator: &mut A) + pub fn map(&mut self, page: Page, flags: EntryFlags, allocator: &mut A) where A: FrameAllocator { let frame = allocator.allocate_frame().expect("out of memory"); self.map_to(page, frame, flags, allocator) } - pub fn map_to(&mut self, page: &Page, frame: Frame, flags: EntryFlags, allocator: &mut A) + pub fn map_to(&mut self, page: Page, frame: Frame, flags: EntryFlags, allocator: &mut A) where A: FrameAllocator { let mut p3 = self.p4_mut().next_table_create(page.p4_index(), allocator); @@ -151,11 +151,11 @@ impl RecursivePageTable { where A: FrameAllocator { let page = Page::containing_address(frame.start_address()); - self.map_to(&page, frame, flags, allocator) + self.map_to(page, frame, flags, allocator) } - fn unmap(&mut self, page: &Page, allocator: &mut A) + fn unmap(&mut self, page: Page, allocator: &mut A) where A: FrameAllocator { use x86::tlb;