diff --git a/kernel/src/drivers/bus/pci.rs b/kernel/src/drivers/bus/pci.rs index bf4d163..6a143c8 100644 --- a/kernel/src/drivers/bus/pci.rs +++ b/kernel/src/drivers/bus/pci.rs @@ -125,10 +125,15 @@ pub fn init_driver(dev: &PCIDevice) { // 82599ES 10-Gigabit SFI/SFP+ Network Connection if let Some(BAR::Memory(addr, len, _, _)) = dev.bars[0] { let irq = unsafe { enable(dev.loc) }; - PCI_DRIVERS.lock().insert( - dev.loc, - ixgbe::ixgbe_init(name, irq, addr as usize, len as usize), - ); + let vaddr = KERNEL_OFFSET + addr as usize; + let mut current_addr = addr as usize; + while current_addr < addr as usize + len as usize { + active_table().map_if_not_exists(KERNEL_OFFSET + current_addr, current_addr); + current_addr = current_addr + PAGE_SIZE; + } + PCI_DRIVERS + .lock() + .insert(dev.loc, ixgbe::ixgbe_init(name, irq, vaddr, len as usize)); } } (0x8086, 0x2922) => { diff --git a/kernel/src/drivers/net/ixgbe.rs b/kernel/src/drivers/net/ixgbe.rs index 556739b..7e289f7 100644 --- a/kernel/src/drivers/net/ixgbe.rs +++ b/kernel/src/drivers/net/ixgbe.rs @@ -32,21 +32,6 @@ struct IXGBEDriver { mtu: usize, } -impl Drop for IXGBEDriver { - fn drop(&mut self) { - let _ = FlagsGuard::no_irq_region(); - let header = self.header; - let size = self.size; - if let None = active_table().get_entry(header) { - let mut current_addr = header; - while current_addr < header + size { - active_table().map_if_not_exists(current_addr, current_addr); - current_addr = current_addr + PAGE_SIZE; - } - } - } -} - pub struct IXGBEInterface { iface: Mutex>, driver: IXGBEDriver, @@ -64,16 +49,6 @@ impl Driver for IXGBEInterface { let handled = { let _ = FlagsGuard::no_irq_region(); - let header = self.driver.header; - let size = self.driver.size; - if let None = active_table().get_entry(header) { - let mut current_addr = header; - while current_addr < header + size { - active_table().map_if_not_exists(current_addr, current_addr); - current_addr = current_addr + PAGE_SIZE; - } - } - self.driver.inner.try_handle_interrupt() }; @@ -135,15 +110,6 @@ impl<'a> phy::Device<'a> for IXGBEDriver { fn receive(&'a mut self) -> Option<(Self::RxToken, Self::TxToken)> { let _ = FlagsGuard::no_irq_region(); - let header = self.header; - let size = self.size; - if let None = active_table().get_entry(header) { - let mut current_addr = header; - while current_addr < header + size { - active_table().map_if_not_exists(current_addr, current_addr); - current_addr = current_addr + PAGE_SIZE; - } - } if self.inner.can_send() { if let Some(data) = self.inner.recv() { Some((IXGBERxToken(data), IXGBETxToken(self.clone()))) @@ -157,15 +123,6 @@ impl<'a> phy::Device<'a> for IXGBEDriver { fn transmit(&'a mut self) -> Option { let _ = FlagsGuard::no_irq_region(); - let header = self.header; - let size = self.size; - if let None = active_table().get_entry(header) { - let mut current_addr = header; - while current_addr < header + size { - active_table().map_if_not_exists(current_addr, current_addr); - current_addr = current_addr + PAGE_SIZE; - } - } if self.inner.can_send() { Some(IXGBETxToken(self.clone())) } else { @@ -200,15 +157,6 @@ impl phy::TxToken for IXGBETxToken { F: FnOnce(&mut [u8]) -> Result, { let _ = FlagsGuard::no_irq_region(); - let header = self.0.header; - let size = self.0.size; - if let None = active_table().get_entry(header) { - let mut current_addr = header; - while current_addr < header + size { - active_table().map_if_not_exists(current_addr, current_addr); - current_addr = current_addr + PAGE_SIZE; - } - } let mut buffer = [0u8; ixgbe::IXGBEDriver::get_mtu()]; let result = f(&mut buffer[..len]); if result.is_ok() { @@ -225,13 +173,6 @@ pub fn ixgbe_init( size: usize, ) -> Arc { let _ = FlagsGuard::no_irq_region(); - if let None = active_table().get_entry(header) { - let mut current_addr = header; - while current_addr < header + size { - active_table().map_if_not_exists(current_addr, current_addr); - current_addr = current_addr + PAGE_SIZE; - } - } let ixgbe = ixgbe::IXGBEDriver::init(Provider::new(), header, size); ixgbe.enable_irq();