Skip to content
Snippets Groups Projects
Commit 9371120f authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Flush TLB correctly when remapping

Seperate mouse and keyboard structs in PS/2 driver
parent 9b17495d
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,6 @@ use goblin::elf64::{header, program_header};
use arch::externs::{memcpy, memset};
use arch::paging::{entry, ActivePageTable, Page, VirtualAddress};
use arch::start::usermode;
use arch::x86::tlb;
/// An ELF executable
pub struct Elf<'a> {
......@@ -63,11 +62,9 @@ impl<'a> Elf<'a> {
for page in Page::range_inclusive(start_page, end_page) {
active_table.map(page, entry::NO_EXECUTE | entry::WRITABLE);
}
active_table.flush_all();
unsafe {
// Update the page table
tlb::flush_all();
// Copy file data
memcpy(segment.p_vaddr as *mut u8,
(self.data.as_ptr() as usize + segment.p_offset as usize) as *const u8,
......@@ -94,26 +91,20 @@ impl<'a> Elf<'a> {
for page in Page::range_inclusive(start_page, end_page) {
active_table.remap(page, flags);
}
unsafe {
// Update the page table
tlb::flush_all();
}
active_table.flush_all();
}
}
unsafe {
// Map stack
let start_page = Page::containing_address(VirtualAddress::new(0x80000000));
let end_page = Page::containing_address(VirtualAddress::new(0x80000000 + 64*1024 - 1));
// Map stack
let start_page = Page::containing_address(VirtualAddress::new(0x80000000));
let end_page = Page::containing_address(VirtualAddress::new(0x80000000 + 64*1024 - 1));
for page in Page::range_inclusive(start_page, end_page) {
active_table.map(page, entry::NO_EXECUTE | entry::WRITABLE | entry::USER_ACCESSIBLE);
}
// Update the page table
tlb::flush_all();
for page in Page::range_inclusive(start_page, end_page) {
active_table.map(page, entry::NO_EXECUTE | entry::WRITABLE | entry::USER_ACCESSIBLE);
}
active_table.flush_all();
unsafe {
// Clear stack
memset(0x80000000 as *mut u8, 0, 64 * 1024);
......
......@@ -34,6 +34,7 @@ pub fn brk(address: usize) -> Result<usize> {
if active_table.translate_page(page).is_none() {
//println!("Not found - mapping");
active_table.map(page, entry::PRESENT | entry::WRITABLE | entry::NO_EXECUTE | entry::USER_ACCESSIBLE);
active_table.flush(page);
} else {
//println!("Found - skipping");
}
......@@ -49,6 +50,7 @@ pub fn brk(address: usize) -> Result<usize> {
if active_table.translate_page(page).is_some() {
//println!("Found - unmapping");
active_table.unmap(page);
active_table.flush(page);
} else {
//println!("Not found - skipping");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment