pub fn new(frame: PhysFrame) -> InactivePageTable {
        let physical_memory_offset = *PHYSICAL_MEMORY_OFFSET.r#try()
            .expect("PHYSICAL_MEMORY_OFFSET not initialized");
        let inactive_table = unsafe { get_level_4_table(frame) };
        let active_table = unsafe { active_level_4_table() };

        let phys_mapped_entry_index = VirtAddr::new(physical_memory_offset).p4_index();
        let old_entry = &active_table[phys_mapped_entry_index];
        let new_entry = &mut inactive_table[phys_mapped_entry_index];
        new_entry.set_addr(old_entry.addr(), old_entry.flags());
        InactivePageTable { p4_frame: frame }
    }
/// We use the 'map_physical_memory' feature of 'bootloader' crate.
/// That is we map the whole physical memory in out virtual address space with an offset.
/// When we want to create a new level 4 page table,we need to do that again.
/// But as an optimization we link the level 3 page table from current address space to the new address space instead of copying them.
/// Inspired by this [post](https://os.phil-opp.com/paging-implementation/)
We use the 'map_physical_memory' feature of 'bootloader' crate.
That is we map the whole physical memory in out virtual address space with an offset.
When we want to create a new level 4 page table,we need to do that again.
But as an optimization we link the level 3 page table from current address space to the new address space instead of copying them.
Inspired by this [post]
We use the ' map_physical_memory ' feature of ' bootloader ' crate . That is we map the whole physical memory in out virtual address space with an offset . When we want to create a new level 4 page table we need to do that again . But as an optimization we link the level 3 page table from current address space to the new address space instead of copying them . Inspired by this [ post ]
pub fn new(frame: PhysFrame) -> InactivePageTable {
        let physical_memory_offset = *PHYSICAL_MEMORY_OFFSET.r#try()
            .expect("PHYSICAL_MEMORY_OFFSET not initialized");
        let inactive_table = unsafe { get_level_4_table(frame) };
        let active_table = unsafe { active_level_4_table() };
        let phys_mapped_entry_index = VirtAddr::new(physical_memory_offset).p4_index();
        let old_entry = &active_table[phys_mapped_entry_index];
        let new_entry = &mut inactive_table[phys_mapped_entry_index];
        new_entry.set_addr(old_entry.addr(), old_entry.flags());
        InactivePageTable { p4_frame: frame }
    }
pub fn new ( frame : PhysFrame ) -> InactivePageTable { let physical_memory_offset = * PHYSICAL_MEMORY_OFFSET . r#try ( ) . expect ( " " ) ; let inactive_table = unsafe { get_level_4_table ( frame ) } ; let active_table = unsafe { active_level_4_table ( ) } ; let phys_mapped_entry_index = VirtAddr :: new ( physical_memory_offset ) . p4_index ( ) ; let old_entry = & active_table [ phys_mapped_entry_index ] ; let new_entry = & mut inactive_table [ phys_mapped_entry_index ] ; new_entry . set_addr ( old_entry . addr ( ) , old_entry . flags ( ) ) ; InactivePageTable { p4_frame : frame } }
We use the 'map_physical_memory' feature of 'bootloader' crate.
We use the ' map_physical_memory ' feature of ' bootloader ' crate .
frame
PhysFrame
frame
PhysFrame