Memory map dump

This commit is contained in:
guillaume didier 2020-02-20 09:19:40 +01:00
parent 5e4025493b
commit f3f7aad23c
2 changed files with 6 additions and 2 deletions

View File

@ -64,6 +64,8 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
use x86_64::structures::paging::MapperAllSizes;
use x86_64::VirtAddr;
serial_println!("Memory map: {:#?}", boot_info.memory_map);
let phys_mem_offset = VirtAddr::new(boot_info.physical_memory_offset);
// new: initialize a mapper
let mut frame_allocator =

View File

@ -79,12 +79,14 @@ impl BootInfoFrameAllocator {
// map each region to its address range
let addr_ranges = usable_regions.map(|r| r.range.start_addr()..r.range.end_addr());
// transform to an iterator of frame start addresses
let frame_addresses = addr_ranges.flat_map(|r| r.step_by(4096));
let frame_addresses = addr_ranges.flat_map(|r| r.step_by(4096)); // TODO Magic number, this is where 4k pages are enforced
// create `PhysFrame` types from the start addresses
let frames = frame_addresses.map(|addr| PhysFrame::containing_address(PhysAddr::new(addr)));
frames
}
}
// We only allocate 4k pages
unsafe impl FrameAllocator<Size4KiB> for BootInfoFrameAllocator {
fn allocate_frame(&mut self) -> Option<UnusedPhysFrame> {
let frame = self.usable_frames().nth(self.next);