Map display in kernel shared memory

This commit is contained in:
Jeremy Soller 2016-09-15 08:50:29 -06:00
parent 997e229f27
commit aa7e38882b
3 changed files with 6 additions and 34 deletions

View file

@ -95,14 +95,15 @@ pub unsafe fn init(active_table: &mut ActivePageTable) {
if mode_info.physbaseptr > 0 { if mode_info.physbaseptr > 0 {
let width = mode_info.xresolution as usize; let width = mode_info.xresolution as usize;
let height = mode_info.yresolution 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 size = width * height;
{ {
let start_frame = Frame::containing_address(PhysicalAddress::new(onscreen)); let start_page = Page::containing_address(VirtualAddress::new(onscreen));
let end_frame = Frame::containing_address(PhysicalAddress::new(onscreen + size * 4 - 1)); let end_page = Page::containing_address(VirtualAddress::new(onscreen + size * 4 - 1));
for frame in Frame::range_inclusive(start_frame, end_frame) { for page in Page::range_inclusive(start_page, end_page) {
active_table.identity_map(frame, /*actually sets PAT for write combining*/ entry::HUGE_PAGE | entry::PRESENT | entry::WRITABLE | entry::NO_EXECUTE); 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))); 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 /// A display
pub struct Display { pub struct Display {
pub width: usize, pub width: usize,

View file

@ -9,7 +9,3 @@ pub unsafe fn init(active_table: &mut ActivePageTable){
display::init(active_table); display::init(active_table);
ps2::init(); ps2::init();
} }
pub unsafe fn init_ap(active_table: &mut ActivePageTable) {
display::init_ap(active_table);
}

View file

@ -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); assert_eq!(TDATA_TEST_NONZERO, 0xFFFFFFFFFFFFFFFE);
} }
// Init devices for AP
device::init_ap(&mut active_table);
AP_READY.store(true, Ordering::SeqCst); AP_READY.store(true, Ordering::SeqCst);
} }