Commit 9c94a5cd authored by Jeremy Soller's avatar Jeremy Soller

Event based ethernetd

parent a1acadd3
......@@ -140,7 +140,8 @@ impl Scheme for Intel8254x {
}
}
Err(Error::new(EWOULDBLOCK))
//Err(Error::new(EWOULDBLOCK))
Ok(0)
}
fn write(&self, _id: usize, buf: &[u8]) -> Result<usize> {
......@@ -225,6 +226,25 @@ impl Intel8254x {
icr != 0
}
pub fn next_read(&self) -> usize {
let head = unsafe { self.read(RDH) };
let mut tail = unsafe { self.read(RDT) };
tail += 1;
if tail >= self.receive_ring.len() as u32 {
tail = 0;
}
if tail != head {
let rd = unsafe { &* (self.receive_ring.as_ptr().offset(tail as isize) as *const Rd) };
if rd.status & RD_DD == RD_DD {
return rd.length as usize;
}
}
0
}
pub unsafe fn read(&self, register: u32) -> u32 {
ptr::read_volatile((self.base + register as usize) as *mut u32)
}
......
......@@ -69,6 +69,11 @@ fn main() {
todo.remove(i);
}
}
let next_read = device_irq.next_read();
if next_read > 0 {
return Ok(Some(next_read));
}
}
Ok(None)
}).expect("e1000d: failed to catch events on IRQ file");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment