diff --git a/drivers/e1000d/src/device.rs b/drivers/e1000d/src/device.rs index 6674c7c..257369c 100644 --- a/drivers/e1000d/src/device.rs +++ b/drivers/e1000d/src/device.rs @@ -186,6 +186,10 @@ impl Scheme for Intel8254x { } } + fn fevent(&self, _id: usize, _flags: usize) -> Result { + Ok(0) + } + fn fsync(&self, _id: usize) -> Result { Ok(0) } diff --git a/drivers/e1000d/src/main.rs b/drivers/e1000d/src/main.rs index fcc7d6b..fbec102 100644 --- a/drivers/e1000d/src/main.rs +++ b/drivers/e1000d/src/main.rs @@ -39,7 +39,7 @@ fn main() { { let device = Arc::new(unsafe { device::Intel8254x::new(address, irq).expect("e1000d: failed to allocate device") }); - let mut event_queue = EventQueue::<()>::new().expect("e1000d: failed to create event queue"); + let mut event_queue = EventQueue::::new().expect("e1000d: failed to create event queue"); let todo = Arc::new(RefCell::new(Vec::::new())); @@ -47,7 +47,7 @@ fn main() { let socket_irq = socket.clone(); let todo_irq = todo.clone(); let mut irq_file = File::open(format!("irq:{}", irq)).expect("e1000d: failed to open IRQ file"); - event_queue.add(irq_file.as_raw_fd(), move |_count: usize| -> Result> { + event_queue.add(irq_file.as_raw_fd(), move |_count: usize| -> Result> { let mut irq = [0; 8]; irq_file.read(&mut irq)?; if unsafe { device_irq.irq() } { @@ -70,9 +70,10 @@ fn main() { Ok(None) }).expect("e1000d: failed to catch events on IRQ file"); - event_queue.add(socket_fd, move |_count: usize| -> Result> { + let socket_packet = socket.clone(); + event_queue.add(socket_fd, move |_count: usize| -> Result> { let mut packet = Packet::default(); - socket.borrow_mut().read(&mut packet)?; + socket_packet.borrow_mut().read(&mut packet)?; let a = packet.a; device.handle(&mut packet); @@ -80,13 +81,28 @@ fn main() { packet.a = a; todo.borrow_mut().push(packet); } else { - socket.borrow_mut().write(&mut packet)?; + socket_packet.borrow_mut().write(&mut packet)?; } Ok(None) }).expect("e1000d: failed to catch events on IRQ file"); - event_queue.run().expect("e1000d: failed to handle events"); + loop { + let event_count = event_queue.run().expect("e1000d: failed to handle events"); + + let event_packet = Packet { + id: 0, + pid: 0, + uid: 0, + gid: 0, + a: syscall::number::SYS_FEVENT, + b: 0, + c: syscall::flag::EVENT_READ, + d: event_count + }; + + socket.borrow_mut().write(&event_packet).expect("vesad: failed to write display event"); + } } unsafe { let _ = syscall::physunmap(address); } }); diff --git a/drivers/rtl8168d/src/device.rs b/drivers/rtl8168d/src/device.rs index 0c563a8..4e8f53c 100644 --- a/drivers/rtl8168d/src/device.rs +++ b/drivers/rtl8168d/src/device.rs @@ -151,6 +151,10 @@ impl SchemeMut for Rtl8168 { } } + fn fevent(&mut self, _id: usize, _flags: usize) -> Result { + Ok(0) + } + fn fsync(&mut self, _id: usize) -> Result { Ok(0) } diff --git a/drivers/rtl8168d/src/main.rs b/drivers/rtl8168d/src/main.rs index 41dd4f3..4460903 100644 --- a/drivers/rtl8168d/src/main.rs +++ b/drivers/rtl8168d/src/main.rs @@ -42,14 +42,14 @@ fn main() { { let device = Arc::new(RefCell::new(unsafe { device::Rtl8168::new(address, irq).expect("rtl8168d: failed to allocate device") })); - let mut event_queue = EventQueue::<()>::new().expect("rtl8168d: failed to create event queue"); + let mut event_queue = EventQueue::::new().expect("rtl8168d: failed to create event queue"); let todo = Arc::new(RefCell::new(Vec::::new())); let device_irq = device.clone(); let socket_irq = socket.clone(); let todo_irq = todo.clone(); - event_queue.add(irq_file.as_raw_fd(), move |_count: usize| -> Result> { + event_queue.add(irq_file.as_raw_fd(), move |_count: usize| -> Result> { let mut irq = [0; 8]; irq_file.read(&mut irq)?; @@ -77,9 +77,10 @@ fn main() { }).expect("rtl8168d: failed to catch events on IRQ file"); let socket_fd = socket.borrow().as_raw_fd(); - event_queue.add(socket_fd, move |_count: usize| -> Result> { + let socket_packet = socket.clone(); + event_queue.add(socket_fd, move |_count: usize| -> Result> { let mut packet = Packet::default(); - socket.borrow_mut().read(&mut packet)?; + socket_packet.borrow_mut().read(&mut packet)?; let a = packet.a; device.borrow_mut().handle(&mut packet); @@ -87,13 +88,28 @@ fn main() { packet.a = a; todo.borrow_mut().push(packet); } else { - socket.borrow_mut().write(&mut packet)?; + socket_packet.borrow_mut().write(&mut packet)?; } Ok(None) }).expect("rtl8168d: failed to catch events on IRQ file"); - event_queue.run().expect("rtl8168d: failed to handle events"); + loop { + let event_count = event_queue.run().expect("rtl8168d: failed to handle events"); + + let event_packet = Packet { + id: 0, + pid: 0, + uid: 0, + gid: 0, + a: syscall::number::SYS_FEVENT, + b: 0, + c: syscall::flag::EVENT_READ, + d: event_count + }; + + socket.borrow_mut().write(&event_packet).expect("vesad: failed to write display event"); + } } unsafe { let _ = syscall::physunmap(address); } });