Only remap device memory region lazily

master
Jiajie Chen 6 years ago
parent af63d937d6
commit 02a40b359b

@ -72,10 +72,13 @@ impl Driver for E1000Interface {
fn try_handle_interrupt(&self) -> bool { fn try_handle_interrupt(&self) -> bool {
let irq = { let irq = {
let driver = self.driver.0.lock(); let driver = self.driver.0.lock();
let mut current_addr = driver.header;
while current_addr < driver.header + driver.size { if let None = active_table().get_entry(driver.header) {
active_table().map_if_not_exists(current_addr, current_addr); let mut current_addr = driver.header;
current_addr = current_addr + PAGE_SIZE; while current_addr < driver.header + driver.size {
active_table().map_if_not_exists(current_addr, current_addr);
current_addr = current_addr + PAGE_SIZE;
}
} }
let e1000 = unsafe { let e1000 = unsafe {
@ -115,11 +118,12 @@ impl Driver for E1000Interface {
impl E1000 { impl E1000 {
fn transmit_available(&self) -> bool { fn transmit_available(&self) -> bool {
// TODO map it in all cpu if let None = active_table().get_entry(self.header) {
let mut current_addr = self.header; let mut current_addr = self.header;
while current_addr < self.header + self.size { while current_addr < self.header + self.size {
active_table().map_if_not_exists(current_addr, current_addr); active_table().map_if_not_exists(current_addr, current_addr);
current_addr = current_addr + PAGE_SIZE; current_addr = current_addr + PAGE_SIZE;
}
} }
let e1000 = let e1000 =
@ -136,11 +140,12 @@ impl E1000 {
} }
fn receive_available(&self) -> bool { fn receive_available(&self) -> bool {
// TODO map it in all cpu if let None = active_table().get_entry(self.header) {
let mut current_addr = self.header; let mut current_addr = self.header;
while current_addr < self.header + self.size { while current_addr < self.header + self.size {
active_table().map_if_not_exists(current_addr, current_addr); active_table().map_if_not_exists(current_addr, current_addr);
current_addr = current_addr + PAGE_SIZE; current_addr = current_addr + PAGE_SIZE;
}
} }
let e1000 = let e1000 =

@ -878,7 +878,6 @@ impl IoVecs {
fn write_all_from_slice(&mut self, buf: &[u8]) { fn write_all_from_slice(&mut self, buf: &[u8]) {
let mut copied_len = 0; let mut copied_len = 0;
debug!("copy {:?}", buf);
for slice in self.0.iter_mut() { for slice in self.0.iter_mut() {
let copy_len = min(slice.len(), buf.len() - copied_len); let copy_len = min(slice.len(), buf.len() - copied_len);
if copy_len == 0 { if copy_len == 0 {
@ -886,7 +885,6 @@ impl IoVecs {
} }
slice[..copy_len].copy_from_slice(&buf[copied_len..copied_len + copy_len]); slice[..copy_len].copy_from_slice(&buf[copied_len..copied_len + copy_len]);
debug!("copy to {:?}", slice);
copied_len += copy_len; copied_len += copy_len;
} }
} }

Loading…
Cancel
Save