mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Formatting: Run rustfmt
This commit is contained in:
@@ -85,6 +85,6 @@ extern "C" fn panic_fmt(fmt: core::fmt::Arguments, file: &str, line: u32) -> ! {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn _Unwind_Resume() -> ! {
|
||||
pub extern "C" fn _Unwind_Resume() -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
@@ -20,15 +20,18 @@ pub const PAGE_SIZE: usize = 4096;
|
||||
pub fn init(boot_info: &BootInformation) {
|
||||
assert_has_not_been_called!("memory::init must be called only once");
|
||||
|
||||
let memory_map_tag = boot_info.memory_map_tag().expect(
|
||||
"Memory map tag required");
|
||||
let elf_sections_tag = boot_info.elf_sections_tag().expect(
|
||||
"Elf sections tag required");
|
||||
let memory_map_tag = boot_info.memory_map_tag().expect("Memory map tag required");
|
||||
let elf_sections_tag = boot_info.elf_sections_tag().expect("Elf sections tag required");
|
||||
|
||||
let kernel_start = elf_sections_tag.sections()
|
||||
.filter(|s| s.is_allocated()).map(|s| s.addr).min().unwrap();
|
||||
.filter(|s| s.is_allocated())
|
||||
.map(|s| s.addr)
|
||||
.min()
|
||||
.unwrap();
|
||||
let kernel_end = elf_sections_tag.sections()
|
||||
.filter(|s| s.is_allocated()).map(|s| s.addr + s.size).max()
|
||||
.filter(|s| s.is_allocated())
|
||||
.map(|s| s.addr + s.size)
|
||||
.max()
|
||||
.unwrap();
|
||||
|
||||
println!("kernel start: {:#x}, kernel end: {:#x}",
|
||||
@@ -38,13 +41,13 @@ pub fn init(boot_info: &BootInformation) {
|
||||
boot_info.start_address(),
|
||||
boot_info.end_address());
|
||||
|
||||
let mut frame_allocator = AreaFrameAllocator::new(
|
||||
kernel_start as usize, kernel_end as usize,
|
||||
boot_info.start_address(), boot_info.end_address(),
|
||||
let mut frame_allocator = AreaFrameAllocator::new(kernel_start as usize,
|
||||
kernel_end as usize,
|
||||
boot_info.start_address(),
|
||||
boot_info.end_address(),
|
||||
memory_map_tag.memory_areas());
|
||||
|
||||
let mut active_table = paging::remap_the_kernel(&mut frame_allocator,
|
||||
boot_info);
|
||||
let mut active_table = paging::remap_the_kernel(&mut frame_allocator, boot_info);
|
||||
|
||||
use self::paging::Page;
|
||||
use hole_list_allocator::{HEAP_START, HEAP_SIZE};
|
||||
|
||||
@@ -167,8 +167,7 @@ impl InactivePageTable {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remap_the_kernel<A>(allocator: &mut A, boot_info: &BootInformation)
|
||||
-> ActivePageTable
|
||||
pub fn remap_the_kernel<A>(allocator: &mut A, boot_info: &BootInformation) -> ActivePageTable
|
||||
where A: FrameAllocator
|
||||
{
|
||||
let mut temporary_page = TemporaryPage::new(Page { number: 0xcafebabe }, allocator);
|
||||
|
||||
@@ -20,7 +20,8 @@ pub struct Table<L: TableLevel> {
|
||||
level: PhantomData<L>,
|
||||
}
|
||||
|
||||
impl<L> Table<L> where L: TableLevel
|
||||
impl<L> Table<L>
|
||||
where L: TableLevel
|
||||
{
|
||||
pub fn zero(&mut self) {
|
||||
for entry in self.entries.iter_mut() {
|
||||
@@ -29,7 +30,8 @@ impl<L> Table<L> where L: TableLevel
|
||||
}
|
||||
}
|
||||
|
||||
impl<L> Table<L> where L: HierarchicalLevel
|
||||
impl<L> Table<L>
|
||||
where L: HierarchicalLevel
|
||||
{
|
||||
fn next_table_address(&self, index: usize) -> Option<usize> {
|
||||
let entry_flags = self[index].flags();
|
||||
@@ -68,7 +70,8 @@ impl<L> Table<L> where L: HierarchicalLevel
|
||||
}
|
||||
}
|
||||
|
||||
impl<L> Index<usize> for Table<L> where L: TableLevel
|
||||
impl<L> Index<usize> for Table<L>
|
||||
where L: TableLevel
|
||||
{
|
||||
type Output = Entry;
|
||||
|
||||
@@ -77,7 +80,8 @@ impl<L> Index<usize> for Table<L> where L: TableLevel
|
||||
}
|
||||
}
|
||||
|
||||
impl<L> IndexMut<usize> for Table<L> where L: TableLevel
|
||||
impl<L> IndexMut<usize> for Table<L>
|
||||
where L: TableLevel
|
||||
{
|
||||
fn index_mut(&mut self, index: usize) -> &mut Entry {
|
||||
&mut self.entries[index]
|
||||
|
||||
Reference in New Issue
Block a user