diff --git a/arch/x86_64/src/device/display.rs b/arch/x86_64/src/device/display.rs index f6714757bc06333033aad496ad14075a86011740..6716250dd2b15616142b5358386501f3d3ad4e22 100644 --- a/arch/x86_64/src/device/display.rs +++ b/arch/x86_64/src/device/display.rs @@ -95,14 +95,15 @@ pub unsafe fn init(active_table: &mut ActivePageTable) { if mode_info.physbaseptr > 0 { let width = mode_info.xresolution as usize; let height = mode_info.yresolution as usize; - let onscreen = mode_info.physbaseptr as usize; + let onscreen = mode_info.physbaseptr as usize + ::KERNEL_OFFSET; let size = width * height; { - let start_frame = Frame::containing_address(PhysicalAddress::new(onscreen)); - let end_frame = Frame::containing_address(PhysicalAddress::new(onscreen + size * 4 - 1)); - for frame in Frame::range_inclusive(start_frame, end_frame) { - active_table.identity_map(frame, /*actually sets PAT for write combining*/ entry::HUGE_PAGE | entry::PRESENT | entry::WRITABLE | entry::NO_EXECUTE); + let start_page = Page::containing_address(VirtualAddress::new(onscreen)); + let end_page = Page::containing_address(VirtualAddress::new(onscreen + size * 4 - 1)); + for page in Page::range_inclusive(start_page, end_page) { + let frame = Frame::containing_address(PhysicalAddress::new(page.start_address().get() - ::KERNEL_OFFSET)); + active_table.map_to(page, frame, /*actually sets PAT for write combining*/ entry::HUGE_PAGE | entry::PRESENT | entry::WRITABLE | entry::NO_EXECUTE); } } @@ -121,28 +122,6 @@ pub unsafe fn init(active_table: &mut ActivePageTable) { active_table.unmap(Page::containing_address(VirtualAddress::new(0x5200))); } -pub unsafe fn init_ap(active_table: &mut ActivePageTable) { - active_table.identity_map(Frame::containing_address(PhysicalAddress::new(0x5200)), entry::PRESENT | entry::NO_EXECUTE); - - let mode_info = &*(0x5200 as *const VBEModeInfo); - if mode_info.physbaseptr > 0 { - let width = mode_info.xresolution as usize; - let height = mode_info.yresolution as usize; - let start = mode_info.physbaseptr as usize; - let size = width * height; - - { - let start_frame = Frame::containing_address(PhysicalAddress::new(start)); - let end_frame = Frame::containing_address(PhysicalAddress::new(start + size * 4 - 1)); - for frame in Frame::range_inclusive(start_frame, end_frame) { - active_table.identity_map(frame, /*actually sets PAT for write combining*/ entry::HUGE_PAGE | entry::PRESENT | entry::WRITABLE | entry::NO_EXECUTE); - } - } - } - - active_table.unmap(Page::containing_address(VirtualAddress::new(0x5200))); -} - /// A display pub struct Display { pub width: usize, diff --git a/arch/x86_64/src/device/mod.rs b/arch/x86_64/src/device/mod.rs index 8a58e0a49e1d2bb43cbdc6b899678897b37094d7..02fe70dd11e69d00b70628e0b56fd8c866a2aec9 100644 --- a/arch/x86_64/src/device/mod.rs +++ b/arch/x86_64/src/device/mod.rs @@ -9,7 +9,3 @@ pub unsafe fn init(active_table: &mut ActivePageTable){ display::init(active_table); ps2::init(); } - -pub unsafe fn init_ap(active_table: &mut ActivePageTable) { - display::init_ap(active_table); -} diff --git a/arch/x86_64/src/start.rs b/arch/x86_64/src/start.rs index 213ff4ac4859ffd942ddda11141dc954222bb59c..7748a003c11d16bf977dc5a77358329bf985f3e4 100644 --- a/arch/x86_64/src/start.rs +++ b/arch/x86_64/src/start.rs @@ -166,9 +166,6 @@ pub unsafe extern fn kstart_ap(cpu_id: usize, page_table: usize, stack_start: us assert_eq!(TDATA_TEST_NONZERO, 0xFFFFFFFFFFFFFFFE); } - // Init devices for AP - device::init_ap(&mut active_table); - AP_READY.store(true, Ordering::SeqCst); }