Skip to content

Commit

Permalink
Cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
64 committed Jul 9, 2019
1 parent 40db4fa commit 701b53a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/frame_allocator.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{frame_range, phys_frame_range};
use bootloader::bootinfo::{MemoryMap, MemoryRegion, MemoryRegionType};
use x86_64::structures::paging::{PhysFrame, frame::PhysFrameRange};
use x86_64::structures::paging::{frame::PhysFrameRange, PhysFrame};

pub(crate) struct FrameAllocator<'a> {
pub memory_map: &'a mut MemoryMap,
Expand Down
9 changes: 6 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use core::{mem, slice};
use fixedvec::alloc_stack;
use usize_conversions::usize_from;
use x86_64::structures::paging::{
Page, PageTableFlags, Size2MiB, Size4KiB, PhysFrame, frame::PhysFrameRange, Mapper, RecursivePageTable
frame::PhysFrameRange, Mapper, Page, PageTableFlags, PhysFrame, RecursivePageTable, Size2MiB,
Size4KiB,
};
use x86_64::ux::u9;
use x86_64::{PhysAddr, VirtAddr};
Expand Down Expand Up @@ -234,7 +235,8 @@ fn load_elf(
&mut rec_page_table,
&mut frame_allocator,
)
}.expect("Mapping of bootinfo page failed")
}
.expect("Mapping of bootinfo page failed")
.flush();
page
};
Expand All @@ -257,7 +259,8 @@ fn load_elf(
&mut rec_page_table,
&mut frame_allocator,
)
}.expect("Mapping of bootinfo page failed")
}
.expect("Mapping of bootinfo page failed")
.flush();
}
}
Expand Down
18 changes: 12 additions & 6 deletions src/page_table.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::frame_allocator::FrameAllocator;
use bootloader::bootinfo::MemoryRegionType;
use fixedvec::FixedVec;
use x86_64::structures::paging::mapper::{MapToError, MapperFlush, UnmapError};
use x86_64::structures::paging::{
Mapper, Page, PageSize, PageTableFlags, PhysFrame, Size4KiB, self, RecursivePageTable,
self, Mapper, Page, PageSize, PageTableFlags, PhysFrame, RecursivePageTable, Size4KiB,
};
use x86_64::structures::paging::mapper::{UnmapError, MapToError, MapperFlush};
use x86_64::{align_up, PhysAddr, VirtAddr};
use xmas_elf::program::{self, ProgramHeader64};

Expand Down Expand Up @@ -68,7 +68,8 @@ pub(crate) fn map_segment(
for frame in PhysFrame::range_inclusive(start_frame, end_frame) {
let offset = frame - start_frame;
let page = start_page + offset;
unsafe { map_page(page, frame, page_table_flags, page_table, frame_allocator)? }.flush();
unsafe { map_page(page, frame, page_table_flags, page_table, frame_allocator)? }
.flush();
}

if mem_size > file_size {
Expand All @@ -93,7 +94,8 @@ pub(crate) fn map_segment(
page_table,
frame_allocator,
)?
}.flush();
}
.flush();

type PageArray = [u64; Size4KiB::SIZE as usize / 8];

Expand Down Expand Up @@ -123,7 +125,8 @@ pub(crate) fn map_segment(
page_table,
frame_allocator,
)?
}.flush();
}
.flush();
}

// Map additional frames.
Expand All @@ -136,7 +139,10 @@ pub(crate) fn map_segment(
let frame = frame_allocator
.allocate_frame(MemoryRegionType::Kernel)
.ok_or(MapToError::FrameAllocationFailed)?;
unsafe { map_page(page, frame, page_table_flags, page_table, frame_allocator)? }.flush();
unsafe {
map_page(page, frame, page_table_flags, page_table, frame_allocator)?
}
.flush();
}

// zero
Expand Down

0 comments on commit 701b53a

Please sign in to comment.