mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 06:17:49 +00:00
Also show non-empty level 3 table entries
This commit is contained in:
14
src/main.rs
14
src/main.rs
@@ -12,6 +12,7 @@ entry_point!(kernel_main);
|
||||
fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
||||
use blog_os::interrupts::PICS;
|
||||
use blog_os::memory::active_level_4_table;
|
||||
use x86_64::{structures::paging::PageTable, VirtAddr};
|
||||
|
||||
println!("Hello World{}", "!");
|
||||
|
||||
@@ -24,6 +25,19 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
||||
for (i, entry) in l4_table.iter().enumerate() {
|
||||
if !entry.is_unused() {
|
||||
println!("L4 Entry {}: {:?}", i, entry);
|
||||
|
||||
// get the physical address from the entry and convert it
|
||||
let phys = entry.frame().unwrap().start_address();
|
||||
let virt = phys.as_u64() + boot_info.physical_memory_offset;
|
||||
let ptr = VirtAddr::new(virt).as_mut_ptr();
|
||||
let l3_table: &PageTable = unsafe { &*ptr };
|
||||
|
||||
// print non-empty entries of the level 3 table
|
||||
for (i, entry) in l3_table.iter().enumerate() {
|
||||
if !entry.is_unused() {
|
||||
println!(" L3 Entry {}: {:?}", i, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user