Take page by value in mapping functions

(there is no reason to borrow it at the moment)
This commit is contained in:
Philipp Oppermann
2015-12-07 11:01:22 +01:00
parent b314d4827f
commit 15427b363a
2 changed files with 9 additions and 9 deletions

View File

@@ -498,7 +498,7 @@ TODO imports
Let's add a function that maps a `Page` to some `Frame`: Let's add a function that maps a `Page` to some `Frame`:
```rust ```rust
pub fn map_to<A>(page: &Page, frame: Frame, flags: EntryFlags, allocator: &mut A) pub fn map_to<A>(page: Page, frame: Frame, flags: EntryFlags, allocator: &mut A)
where A: FrameAllocator where A: FrameAllocator
{ {
let p4 = unsafe { &mut *P4 }; let p4 = unsafe { &mut *P4 };
@@ -603,7 +603,7 @@ impl RecursivePageTable {
} }
pub fn map_to<A>(&mut self, pub fn map_to<A>(&mut self,
page: &Page, page: Page,
frame: Frame, frame: Frame,
flags: EntryFlags, flags: EntryFlags,
allocator: &mut A) 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: For convenience, we add a `map` method that just picks a free frame for us:
```rust ```rust
pub fn map<A>(&mut self, page: &Page, flags: EntryFlags, allocator: &mut A) pub fn map<A>(&mut self, page: Page, flags: EntryFlags, allocator: &mut A)
where A: FrameAllocator where A: FrameAllocator
{ {
let frame = allocator.allocate_frame().expect("out of memory"); let frame = allocator.allocate_frame().expect("out of memory");
@@ -639,7 +639,7 @@ pub fn identity_map<A>(&mut self,
where A: FrameAllocator where A: FrameAllocator
{ {
let page = Page::containing_address(frame.start_address()); 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<A>(&mut self,
TODO TODO
```rust ```rust
fn unmap<A>(&mut self, page: &Page, allocator: &mut A) fn unmap<A>(&mut self, page: Page, allocator: &mut A)
where A: FrameAllocator where A: FrameAllocator
{ {
assert!(self.translate(page.start_address()).is_some()); assert!(self.translate(page.start_address()).is_some());

View File

@@ -129,14 +129,14 @@ impl RecursivePageTable {
.or_else(huge_page) .or_else(huge_page)
} }
pub fn map<A>(&mut self, page: &Page, flags: EntryFlags, allocator: &mut A) pub fn map<A>(&mut self, page: Page, flags: EntryFlags, allocator: &mut A)
where A: FrameAllocator where A: FrameAllocator
{ {
let frame = allocator.allocate_frame().expect("out of memory"); let frame = allocator.allocate_frame().expect("out of memory");
self.map_to(page, frame, flags, allocator) self.map_to(page, frame, flags, allocator)
} }
pub fn map_to<A>(&mut self, page: &Page, frame: Frame, flags: EntryFlags, allocator: &mut A) pub fn map_to<A>(&mut self, page: Page, frame: Frame, flags: EntryFlags, allocator: &mut A)
where A: FrameAllocator where A: FrameAllocator
{ {
let mut p3 = self.p4_mut().next_table_create(page.p4_index(), allocator); let mut p3 = self.p4_mut().next_table_create(page.p4_index(), allocator);
@@ -151,11 +151,11 @@ impl RecursivePageTable {
where A: FrameAllocator where A: FrameAllocator
{ {
let page = Page::containing_address(frame.start_address()); let page = Page::containing_address(frame.start_address());
self.map_to(&page, frame, flags, allocator) self.map_to(page, frame, flags, allocator)
} }
fn unmap<A>(&mut self, page: &Page, allocator: &mut A) fn unmap<A>(&mut self, page: Page, allocator: &mut A)
where A: FrameAllocator where A: FrameAllocator
{ {
use x86::tlb; use x86::tlb;