mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Remove test_paging function
This commit is contained in:
@@ -67,8 +67,6 @@ pub extern "C" fn rust_main(multiboot_information_address: usize) {
|
|||||||
multiboot_end,
|
multiboot_end,
|
||||||
memory_map_tag.memory_areas());
|
memory_map_tag.memory_areas());
|
||||||
|
|
||||||
memory::test_paging(&mut frame_allocator);
|
|
||||||
|
|
||||||
enable_nxe_bit();
|
enable_nxe_bit();
|
||||||
enable_write_protect_bit();
|
enable_write_protect_bit();
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
pub use self::area_frame_allocator::AreaFrameAllocator;
|
pub use self::area_frame_allocator::AreaFrameAllocator;
|
||||||
pub use self::paging::test_paging;
|
|
||||||
pub use self::paging::remap_the_kernel;
|
pub use self::paging::remap_the_kernel;
|
||||||
use self::paging::PhysicalAddress;
|
use self::paging::PhysicalAddress;
|
||||||
|
|
||||||
|
|||||||
@@ -141,37 +141,6 @@ impl InactivePageTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn test_paging<A>(allocator: &mut A)
|
|
||||||
where A: FrameAllocator
|
|
||||||
{
|
|
||||||
let mut page_table = unsafe { ActivePageTable::new() };
|
|
||||||
|
|
||||||
// test translate
|
|
||||||
println!("Some = {:?}", page_table.translate(0));
|
|
||||||
println!("Some = {:?}", page_table.translate(4096)); // second P1 entry
|
|
||||||
println!("Some = {:?}", page_table.translate(512 * 4096)); // second P2 entry
|
|
||||||
println!("Some = {:?}", page_table.translate(300 * 512 * 4096)); // 300th P2 entry
|
|
||||||
println!("None = {:?}", page_table.translate(512 * 512 * 4096)); // second P3 entry
|
|
||||||
println!("Some = {:?}", page_table.translate(512 * 512 * 4096 - 1)); // last mapped byte
|
|
||||||
|
|
||||||
// test map_to
|
|
||||||
let addr = 42 * 512 * 512 * 4096; // 42th P3 entry
|
|
||||||
let page = Page::containing_address(addr);
|
|
||||||
let frame = allocator.allocate_frame().expect("no more frames");
|
|
||||||
println!("None = {:?}, map to {:?}",
|
|
||||||
page_table.translate(addr),
|
|
||||||
frame);
|
|
||||||
page_table.map_to(page, frame, EntryFlags::empty(), allocator);
|
|
||||||
println!("Some = {:?}", page_table.translate(addr));
|
|
||||||
println!("next free frame: {:?}", allocator.allocate_frame());
|
|
||||||
|
|
||||||
// test unmap
|
|
||||||
println!("{:#x}",
|
|
||||||
unsafe { *(Page::containing_address(addr).start_address() as *const u64) });
|
|
||||||
page_table.unmap(Page::containing_address(addr), allocator);
|
|
||||||
println!("None = {:?}", page_table.translate(addr));
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn remap_the_kernel<A>(allocator: &mut A, boot_info: &BootInformation)
|
pub fn remap_the_kernel<A>(allocator: &mut A, boot_info: &BootInformation)
|
||||||
where A: FrameAllocator
|
where A: FrameAllocator
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user