mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 06:17:49 +00:00
Update kernel_main to use MapperAllSizes::translate_addr
This commit is contained in:
@@ -11,8 +11,8 @@ entry_point!(kernel_main);
|
||||
#[cfg(not(test))]
|
||||
fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
||||
use blog_os::interrupts::PICS;
|
||||
use blog_os::memory::translate_addr;
|
||||
use x86_64::VirtAddr;
|
||||
use blog_os::memory;
|
||||
use x86_64::{structures::paging::MapperAllSizes, VirtAddr};
|
||||
|
||||
println!("Hello World{}", "!");
|
||||
|
||||
@@ -21,6 +21,8 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
||||
unsafe { PICS.lock().initialize() };
|
||||
x86_64::instructions::interrupts::enable();
|
||||
|
||||
let mapper = unsafe { memory::init(boot_info.physical_memory_offset) };
|
||||
|
||||
let addresses = [
|
||||
// the identity-mapped vga buffer page
|
||||
0xb8000,
|
||||
@@ -34,7 +36,7 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
||||
|
||||
for &address in &addresses {
|
||||
let virt = VirtAddr::new(address);
|
||||
let phys = unsafe { translate_addr(virt, boot_info.physical_memory_offset) };
|
||||
let phys = mapper.translate_addr(virt);
|
||||
println!("{:?} -> {:?}", virt, phys);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user