diff --git a/src/memory.rs b/src/memory.rs index c64b72d4..844d3d54 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -1,9 +1,9 @@ use bootloader::bootinfo::{MemoryMap, MemoryRegionType}; use x86_64::{ + PhysAddr, VirtAddr, structures::paging::{ FrameAllocator, Mapper, OffsetPageTable, Page, PageTable, PhysFrame, Size4KiB, }, - PhysAddr, VirtAddr, }; /// Initialize a new OffsetPageTable. @@ -13,8 +13,10 @@ use x86_64::{ /// `physical_memory_offset`. Also, this function must be only called once /// to avoid aliasing `&mut` references (which is undefined behavior). pub unsafe fn init(physical_memory_offset: VirtAddr) -> OffsetPageTable<'static> { - let level_4_table = active_level_4_table(physical_memory_offset); - OffsetPageTable::new(level_4_table, physical_memory_offset) + unsafe { + let level_4_table = active_level_4_table(physical_memory_offset); + OffsetPageTable::new(level_4_table, physical_memory_offset) + } } /// Returns a mutable reference to the active level 4 table. @@ -32,7 +34,7 @@ unsafe fn active_level_4_table(physical_memory_offset: VirtAddr) -> &'static mut let virt = physical_memory_offset + phys.as_u64(); let page_table_ptr: *mut PageTable = virt.as_mut_ptr(); - &mut *page_table_ptr // unsafe + unsafe { &mut *page_table_ptr } } /// Creates an example mapping for the given page to frame `0xb8000`.