From 68dc7447f41c72e78c8b1ad55d2002606439a6e5 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 9 Mar 2017 17:50:44 +0100 Subject: [PATCH] Run rustfmt --- src/interrupts/mod.rs | 12 ++++++------ src/memory/area_frame_allocator.rs | 6 +++--- src/memory/paging/mapper.rs | 13 ++++++++----- src/memory/paging/mod.rs | 3 +-- src/memory/paging/table.rs | 6 ++---- src/vga_buffer.rs | 15 ++++++++------- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/interrupts/mod.rs b/src/interrupts/mod.rs index 3d4fc5b9..b5a5d131 100644 --- a/src/interrupts/mod.rs +++ b/src/interrupts/mod.rs @@ -115,14 +115,14 @@ pub fn init(memory_controller: &mut MemoryController) { use x86::shared::segmentation::{SegmentSelector, set_cs}; use x86::shared::task::load_tr; - let double_fault_stack = memory_controller.alloc_stack(1) - .expect("could not allocate double fault stack"); + let double_fault_stack = + memory_controller.alloc_stack(1).expect("could not allocate double fault stack"); let tss = TSS.call_once(|| { - let mut tss = TaskStateSegment::new(); - tss.ist[DOUBLE_FAULT_IST_INDEX] = double_fault_stack.top() as u64; - tss - }); + let mut tss = TaskStateSegment::new(); + tss.ist[DOUBLE_FAULT_IST_INDEX] = double_fault_stack.top() as u64; + tss + }); let mut code_selector = SegmentSelector::empty(); let mut tss_selector = SegmentSelector::empty(); diff --git a/src/memory/area_frame_allocator.rs b/src/memory/area_frame_allocator.rs index 2859a43f..60269c1f 100644 --- a/src/memory/area_frame_allocator.rs +++ b/src/memory/area_frame_allocator.rs @@ -49,9 +49,9 @@ impl AreaFrameAllocator { self.current_area = self.areas .clone() .filter(|area| { - let address = area.base_addr + area.length - 1; - Frame::containing_address(address as usize) >= self.next_free_frame - }) + let address = area.base_addr + area.length - 1; + Frame::containing_address(address as usize) >= self.next_free_frame + }) .min_by_key(|area| area.base_addr); if let Some(area) = self.current_area { diff --git a/src/memory/paging/mapper.rs b/src/memory/paging/mapper.rs index d85a6bfc..d6b2500e 100644 --- a/src/memory/paging/mapper.rs +++ b/src/memory/paging/mapper.rs @@ -32,8 +32,11 @@ impl Mapper { pub fn translate(&self, virtual_address: VirtualAddress) -> Option { let offset = virtual_address % PAGE_SIZE; - self.translate_page(Page::containing_address(virtual_address)) - .map(|frame| frame.number * PAGE_SIZE + offset) + self.translate_page(Page::containing_address(virtual_address)).map(|frame| { + frame.number * + PAGE_SIZE + + offset + }) } pub fn translate_page(&self, page: Page) -> Option { @@ -48,9 +51,9 @@ impl Mapper { // address must be 1GiB aligned assert!(start_frame.number % (ENTRY_COUNT * ENTRY_COUNT) == 0); return Some(Frame { - number: start_frame.number + page.p2_index() * ENTRY_COUNT + - page.p1_index(), - }); + number: start_frame.number + page.p2_index() * ENTRY_COUNT + + page.p1_index(), + }); } } if let Some(p2) = p3.next_table(page.p3_index()) { diff --git a/src/memory/paging/mod.rs b/src/memory/paging/mod.rs index bd6dd6b2..276a0d27 100644 --- a/src/memory/paging/mod.rs +++ b/src/memory/paging/mod.rs @@ -188,8 +188,7 @@ pub fn remap_the_kernel(allocator: &mut A, boot_info: &BootInformation) -> Ac }; active_table.with(&mut new_table, &mut temporary_page, |mapper| { - let elf_sections_tag = boot_info.elf_sections_tag() - .expect("Memory map tag required"); + let elf_sections_tag = boot_info.elf_sections_tag().expect("Memory map tag required"); // identity map the allocated kernel sections for section in elf_sections_tag.sections() { diff --git a/src/memory/paging/table.rs b/src/memory/paging/table.rs index 5dd94e9d..fdab3efc 100644 --- a/src/memory/paging/table.rs +++ b/src/memory/paging/table.rs @@ -44,13 +44,11 @@ impl Table } pub fn next_table(&self, index: usize) -> Option<&Table> { - self.next_table_address(index) - .map(|address| unsafe { &*(address as *const _) }) + self.next_table_address(index).map(|address| unsafe { &*(address as *const _) }) } pub fn next_table_mut(&mut self, index: usize) -> Option<&mut Table> { - self.next_table_address(index) - .map(|address| unsafe { &mut *(address as *mut _) }) + self.next_table_address(index).map(|address| unsafe { &mut *(address as *mut _) }) } pub fn next_table_create(&mut self, diff --git a/src/vga_buffer.rs b/src/vga_buffer.rs index e3cc06cc..74b85d2e 100644 --- a/src/vga_buffer.rs +++ b/src/vga_buffer.rs @@ -16,10 +16,11 @@ const BUFFER_HEIGHT: usize = 25; const BUFFER_WIDTH: usize = 80; pub static WRITER: Mutex = Mutex::new(Writer { - column_position: 0, - color_code: ColorCode::new(Color::LightGreen, Color::Black), - buffer: unsafe { Unique::new(0xb8000 as *mut _) }, -}); + column_position: 0, + color_code: ColorCode::new(Color::LightGreen, + Color::Black), + buffer: unsafe { Unique::new(0xb8000 as *mut _) }, + }); macro_rules! println { ($fmt:expr) => (print!(concat!($fmt, "\n"))); @@ -85,9 +86,9 @@ impl Writer { let color_code = self.color_code; self.buffer().chars[row][col].write(ScreenChar { - ascii_character: byte, - color_code: color_code, - }); + ascii_character: byte, + color_code: color_code, + }); self.column_position += 1; } }