Run rustfmt

This commit is contained in:
Philipp Oppermann
2016-06-25 17:08:26 +02:00
parent 2f9e6cc0d0
commit c9d8afe434
4 changed files with 22 additions and 23 deletions

View File

@@ -47,13 +47,12 @@ impl AreaFrameAllocator {
fn choose_next_area(&mut self) { fn choose_next_area(&mut self) {
self.current_area = self.areas self.current_area = self.areas
.clone() .clone()
.filter(|area| { .filter(|area| {
let address = area.base_addr + area.length - 1; let address = area.base_addr + area.length - 1;
Frame::containing_address(address as usize) >= Frame::containing_address(address as usize) >= self.next_free_frame
self.next_free_frame })
}) .min_by_key(|area| area.base_addr);
.min_by_key(|area| area.base_addr);
if let Some(area) = self.current_area { if let Some(area) = self.current_area {
let start_frame = Frame::containing_address(area.base_addr as usize); let start_frame = Frame::containing_address(area.base_addr as usize);

View File

@@ -24,15 +24,15 @@ pub fn init(boot_info: &BootInformation) {
let elf_sections_tag = boot_info.elf_sections_tag().expect("Elf sections tag required"); let elf_sections_tag = boot_info.elf_sections_tag().expect("Elf sections tag required");
let kernel_start = elf_sections_tag.sections() let kernel_start = elf_sections_tag.sections()
.filter(|s| s.is_allocated()) .filter(|s| s.is_allocated())
.map(|s| s.addr) .map(|s| s.addr)
.min() .min()
.unwrap(); .unwrap();
let kernel_end = elf_sections_tag.sections() let kernel_end = elf_sections_tag.sections()
.filter(|s| s.is_allocated()) .filter(|s| s.is_allocated())
.map(|s| s.addr + s.size) .map(|s| s.addr + s.size)
.max() .max()
.unwrap(); .unwrap();
println!("kernel start: {:#x}, kernel end: {:#x}", println!("kernel start: {:#x}, kernel end: {:#x}",
kernel_start, kernel_start,

View File

@@ -69,9 +69,9 @@ impl Mapper {
}; };
p3.and_then(|p3| p3.next_table(page.p3_index())) p3.and_then(|p3| p3.next_table(page.p3_index()))
.and_then(|p2| p2.next_table(page.p2_index())) .and_then(|p2| p2.next_table(page.p2_index()))
.and_then(|p1| p1[page.p1_index()].pointed_frame()) .and_then(|p1| p1[page.p1_index()].pointed_frame())
.or_else(huge_page) .or_else(huge_page)
} }
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)
@@ -105,10 +105,10 @@ impl Mapper {
assert!(self.translate(page.start_address()).is_some()); assert!(self.translate(page.start_address()).is_some());
let p1 = self.p4_mut() let p1 = self.p4_mut()
.next_table_mut(page.p4_index()) .next_table_mut(page.p4_index())
.and_then(|p3| p3.next_table_mut(page.p3_index())) .and_then(|p3| p3.next_table_mut(page.p3_index()))
.and_then(|p2| p2.next_table_mut(page.p2_index())) .and_then(|p2| p2.next_table_mut(page.p2_index()))
.expect("mapping code does not support huge pages"); .expect("mapping code does not support huge pages");
let frame = p1[page.p1_index()].pointed_frame().unwrap(); let frame = p1[page.p1_index()].pointed_frame().unwrap();
p1[page.p1_index()].set_unused(); p1[page.p1_index()].set_unused();
unsafe { ::x86::tlb::flush(page.start_address()) }; unsafe { ::x86::tlb::flush(page.start_address()) };

View File

@@ -180,7 +180,7 @@ pub fn remap_the_kernel<A>(allocator: &mut A, boot_info: &BootInformation) -> Ac
active_table.with(&mut new_table, &mut temporary_page, |mapper| { active_table.with(&mut new_table, &mut temporary_page, |mapper| {
let elf_sections_tag = boot_info.elf_sections_tag() let elf_sections_tag = boot_info.elf_sections_tag()
.expect("Memory map tag required"); .expect("Memory map tag required");
// identity map the allocated kernel sections // identity map the allocated kernel sections
for section in elf_sections_tag.sections() { for section in elf_sections_tag.sections() {