Run rustfmt

This commit is contained in:
Philipp Oppermann
2017-03-09 17:50:44 +01:00
parent 844d739379
commit 68dc7447f4
6 changed files with 28 additions and 27 deletions

View File

@@ -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();

View File

@@ -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 {

View File

@@ -32,8 +32,11 @@ impl Mapper {
pub fn translate(&self, virtual_address: VirtualAddress) -> Option<PhysicalAddress> {
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<Frame> {
@@ -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()) {

View File

@@ -188,8 +188,7 @@ pub fn remap_the_kernel<A>(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() {

View File

@@ -44,13 +44,11 @@ impl<L> Table<L>
}
pub fn next_table(&self, index: usize) -> Option<&Table<L::NextLevel>> {
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<L::NextLevel>> {
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<A>(&mut self,

View File

@@ -16,10 +16,11 @@ const BUFFER_HEIGHT: usize = 25;
const BUFFER_WIDTH: usize = 80;
pub static WRITER: Mutex<Writer> = 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;
}
}