Memory map dump
This commit is contained in:
parent
5e4025493b
commit
f3f7aad23c
@ -64,6 +64,8 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
|||||||
use x86_64::structures::paging::MapperAllSizes;
|
use x86_64::structures::paging::MapperAllSizes;
|
||||||
use x86_64::VirtAddr;
|
use x86_64::VirtAddr;
|
||||||
|
|
||||||
|
serial_println!("Memory map: {:#?}", boot_info.memory_map);
|
||||||
|
|
||||||
let phys_mem_offset = VirtAddr::new(boot_info.physical_memory_offset);
|
let phys_mem_offset = VirtAddr::new(boot_info.physical_memory_offset);
|
||||||
// new: initialize a mapper
|
// new: initialize a mapper
|
||||||
let mut frame_allocator =
|
let mut frame_allocator =
|
||||||
|
@ -79,12 +79,14 @@ impl BootInfoFrameAllocator {
|
|||||||
// map each region to its address range
|
// map each region to its address range
|
||||||
let addr_ranges = usable_regions.map(|r| r.range.start_addr()..r.range.end_addr());
|
let addr_ranges = usable_regions.map(|r| r.range.start_addr()..r.range.end_addr());
|
||||||
// transform to an iterator of frame start addresses
|
// 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
|
// create `PhysFrame` types from the start addresses
|
||||||
let frames = frame_addresses.map(|addr| PhysFrame::containing_address(PhysAddr::new(addr)));
|
let frames = frame_addresses.map(|addr| PhysFrame::containing_address(PhysAddr::new(addr)));
|
||||||
frames
|
frames
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We only allocate 4k pages
|
||||||
unsafe impl FrameAllocator<Size4KiB> for BootInfoFrameAllocator {
|
unsafe impl FrameAllocator<Size4KiB> for BootInfoFrameAllocator {
|
||||||
fn allocate_frame(&mut self) -> Option<UnusedPhysFrame> {
|
fn allocate_frame(&mut self) -> Option<UnusedPhysFrame> {
|
||||||
let frame = self.usable_frames().nth(self.next);
|
let frame = self.usable_frames().nth(self.next);
|
||||||
|
Loading…
Reference in New Issue
Block a user