From aa7e38882bf35a01d2da31e7a7ae6b5a59ff42fc Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 15 Sep 2016 08:50:29 -0600 Subject: [PATCH] Map display in kernel shared memory --- arch/x86_64/src/device/display.rs | 33 ++++++------------------------- arch/x86_64/src/device/mod.rs | 4 ---- arch/x86_64/src/start.rs | 3 --- 3 files changed, 6 insertions(+), 34 deletions(-) diff --git a/arch/x86_64/src/device/display.rs b/arch/x86_64/src/device/display.rs index f671475..6716250 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 8a58e0a..02fe70d 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 213ff4a..7748a00 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); }