|
|
|
@ -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<EthernetInterface<'static, 'static, 'static, IXGBEDriver>>,
|
|
|
|
|
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<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() {
|
|
|
|
|
Some(IXGBETxToken(self.clone()))
|
|
|
|
|
} else {
|
|
|
|
@ -200,15 +157,6 @@ impl phy::TxToken for IXGBETxToken {
|
|
|
|
|
F: FnOnce(&mut [u8]) -> Result<R>,
|
|
|
|
|
{
|
|
|
|
|
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<IXGBEInterface> {
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|