Event based ethernetd
This commit is contained in:
parent
d208f6aa11
commit
eb5ee5edc9
7 changed files with 255 additions and 129 deletions
|
@ -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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue