Impl Debug for page table

master
WangRunji 7 years ago
parent b954aef696
commit eb9a5e9241

@ -40,6 +40,8 @@ pub fn init(boot_info: &BootInformation) -> MemoryController {
let mut active_table = paging::remap_the_kernel(&mut frame_allocator,
boot_info);
println!("{:?}", active_table);
use self::paging::Page;
use {HEAP_START, HEAP_SIZE};

@ -69,3 +69,13 @@ impl EntryFlags {
flags
}
}
use core::fmt;
use core::fmt::Debug;
impl Debug for Entry {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "{:#014X} {:?}", self.0 & 0x000fffff_fffff000, self.flags());
Ok(())
}
}

@ -116,3 +116,12 @@ impl Mapper {
//allocator.deallocate_frame(frame);
}
}
use core::fmt;
use core::fmt::Debug;
impl Debug for Mapper {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "{:?}", self.p4())
}
}

@ -243,3 +243,13 @@ pub fn remap_the_kernel<A>(allocator: &mut A, boot_info: &BootInformation)
active_table
}
use core::fmt;
use core::fmt::Debug;
impl Debug for ActivePageTable {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "ActivePageTable:\n")?;
write!(f, "{:?}", &self.mapper)
}
}

@ -98,3 +98,51 @@ impl HierarchicalLevel for Level3 {
impl HierarchicalLevel for Level2 {
type NextLevel = Level1;
}
use core::fmt;
use core::fmt::Debug;
impl Debug for Table<Level4> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
// Ignore the 511th recursive entry
let entries = self.entries.iter().enumerate().filter(|(i, e)| !e.is_unused() && *i != 511usize);
for (i, e) in entries {
write!(f, "{:3}: {:?}\n", i, e)?;
write!(f, "{:?}", self.next_table(i).unwrap())?;
}
Ok(())
}
}
impl Debug for Table<Level3> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
let entries = self.entries.iter().enumerate().filter(|(i, e)| !e.is_unused());
for (i, e) in entries {
write!(f, " {:3}: {:?}\n", i, e)?;
write!(f, "{:?}", self.next_table(i).unwrap())?;
}
Ok(())
}
}
impl Debug for Table<Level2> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
let entries = self.entries.iter().enumerate().filter(|(i, e)| !e.is_unused());
for (i, e) in entries {
write!(f, " {:3}: {:?}\n", i, e)?;
write!(f, "{:?}", self.next_table(i).unwrap())?;
}
Ok(())
}
}
impl Debug for Table<Level1> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
let entries = self.entries.iter().enumerate().filter(|(i, e)| !e.is_unused());
for (i, e) in entries {
write!(f, " {:3}: {:?}\n", i, e)?;
}
Ok(())
}
}
Loading…
Cancel
Save