Skip to content

Commit

Permalink
#5: Some more progress
Browse files Browse the repository at this point in the history
  • Loading branch information
kennystrawnmusic committed Aug 29, 2022
1 parent a8f4fcb commit 3871978
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/cralloc/frames.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,17 @@ pub fn build_from_uefi(fa: &mut impl FrameAllocator<Size4KiB>) -> StubTables {
};

// shut up the borrow checker
let mut cloned_table = table.clone();
let cloned_table = table.clone();

let next_available = if let Some(_) = table.iter().find(|e| e.flags().contains(PageTableFlags::PRESENT | PageTableFlags::WRITABLE)) {
cloned_table.iter_mut().next()
let next_available = if let Some(entry) = cloned_table.iter().find(|e| e.flags().contains(PageTableFlags::PRESENT | PageTableFlags::WRITABLE)) {
let size = entry.frame().unwrap().size() as usize;
table.iter_mut().skip(size / 16).next()
} else {
panic!("Page table only contains one entry")
};

if let Some(entry) = next_available {
entry.set_flags(PageTableFlags::PRESENT | PageTableFlags::WRITABLE);
let frame = entry.frame().unwrap();
let frame = PhysFrame::<Size4KiB>::containing_address(entry.addr());
unsafe { (OffsetPageTable::new(&mut *table, offset), frame) }
} else {
panic!("Couldn't find any available page table entries")
Expand Down

0 comments on commit 3871978

Please sign in to comment.