Commit 0a9b1593 authored by Jeremy Soller's avatar Jeremy Soller

Update to new event

parent 287fdde1
This diff is collapsed.
......@@ -8,7 +8,7 @@ extern crate byteorder;
use std::{env, usize};
use std::fs::File;
use std::io::{Read, Write};
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::os::unix::io::FromRawFd;
use syscall::{EVENT_READ, MAP_WRITE, Event, Packet, Scheme};
use scheme::DiskScheme;
......@@ -40,14 +40,27 @@ fn main() {
syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK
).expect("ahcid: failed to create disk scheme");
let mut socket = unsafe { File::from_raw_fd(socket_fd) };
syscall::fevent(socket_fd, EVENT_READ).expect("ahcid: failed to fevent disk scheme");
let mut irq_file = File::open(&format!("irq:{}", irq)).expect("ahcid: failed to open irq file");
let irq_fd = irq_file.as_raw_fd();
syscall::fevent(irq_fd, EVENT_READ).expect("ahcid: failed to fevent irq file");
let irq_fd = syscall::open(
&format!("irq:{}", irq),
syscall::O_RDWR | syscall::O_NONBLOCK
).expect("ahcid: failed to open irq file");
let mut irq_file = unsafe { File::from_raw_fd(irq_fd) };
let mut event_file = File::open("event:").expect("ahcid: failed to open event file");
event_file.write(&Event {
id: socket_fd,
flags: EVENT_READ,
data: 0
}).expect("ahcid: failed to event disk scheme");
event_file.write(&Event {
id: irq_fd,
flags: EVENT_READ,
data: 0
}).expect("ahcid: failed to event irq scheme");
let scheme = DiskScheme::new(scheme_name, ahci::disks(address, &name));
syscall::setrens(0, 0).expect("ahcid: failed to enter null namespace");
......
......@@ -56,7 +56,7 @@ fn main() {
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<Option<usize>> {
event_queue.add(irq_file.as_raw_fd(), move |_event| -> Result<Option<usize>> {
let mut irq = [0; 8];
irq_file.read(&mut irq)?;
if unsafe { device_irq.borrow_mut().intr_legacy() } {
......@@ -85,7 +85,7 @@ fn main() {
}).expect("alxd: failed to catch events on IRQ file");
let socket_packet = socket.clone();
event_queue.add(socket_fd, move |_count: usize| -> Result<Option<usize>> {
event_queue.add(socket_fd, move |_event| -> Result<Option<usize>> {
loop {
let mut packet = Packet::default();
if socket_packet.borrow_mut().read(&mut packet)? == 0 {
......@@ -110,7 +110,10 @@ fn main() {
Ok(None)
}).expect("alxd: failed to catch events on IRQ file");
for event_count in event_queue.trigger_all(0).expect("alxd: failed to trigger events") {
for event_count in event_queue.trigger_all(event::Event {
fd: 0,
flags: 0,
}).expect("alxd: failed to trigger events") {
socket.borrow_mut().write(&Packet {
id: 0,
pid: 0,
......
......@@ -51,7 +51,7 @@ fn main() {
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<Option<usize>> {
event_queue.add(irq_file.as_raw_fd(), move |_event| -> Result<Option<usize>> {
let mut irq = [0; 8];
irq_file.read(&mut irq)?;
if unsafe { device_irq.irq() } {
......@@ -80,7 +80,7 @@ fn main() {
}).expect("e1000d: failed to catch events on IRQ file");
let socket_packet = socket.clone();
event_queue.add(socket_fd, move |_count: usize| -> Result<Option<usize>> {
event_queue.add(socket_fd, move |_event| -> Result<Option<usize>> {
loop {
let mut packet = Packet::default();
if socket_packet.borrow_mut().read(&mut packet)? == 0 {
......@@ -105,7 +105,10 @@ fn main() {
Ok(None)
}).expect("e1000d: failed to catch events on scheme file");
for event_count in event_queue.trigger_all(0).expect("e1000d: failed to trigger events") {
for event_count in event_queue.trigger_all(event::Event {
fd: 0,
flags: 0,
}).expect("e1000d: failed to trigger events") {
socket.borrow_mut().write(&Packet {
id: 0,
pid: 0,
......
......@@ -23,11 +23,6 @@ pub mod HDA;
use HDA::IntelHDA;
/*
VEND:PROD
Virtualbox 8086:2668
......@@ -78,7 +73,7 @@ fn main() {
let socket_irq = socket.clone();
let device_loop = device.clone();
event_queue.add(irq_file.as_raw_fd(), move |_count: usize| -> Result<Option<usize>> {
event_queue.add(irq_file.as_raw_fd(), move |_event| -> Result<Option<usize>> {
let mut irq = [0; 8];
irq_file.read(&mut irq)?;
......@@ -110,7 +105,7 @@ fn main() {
}).expect("IHDA: failed to catch events on IRQ file");
let socket_fd = socket.borrow().as_raw_fd();
let socket_packet = socket.clone();
event_queue.add(socket_fd, move |_count: usize| -> Result<Option<usize>> {
event_queue.add(socket_fd, move |_event| -> Result<Option<usize>> {
loop {
let mut packet = Packet::default();
if socket_packet.borrow_mut().read(&mut packet)? == 0 {
......@@ -137,7 +132,10 @@ fn main() {
Ok(None)
}).expect("IHDA: failed to catch events on IRQ file");
for event_count in event_queue.trigger_all(0).expect("IHDA: failed to trigger events") {
for event_count in event_queue.trigger_all(event::Event {
fd: 0,
flags: 0,
}).expect("IHDA: failed to trigger events") {
socket.borrow_mut().write(&Packet {
id: 0,
pid: 0,
......
......@@ -52,7 +52,7 @@ fn daemon(input: File) {
syscall::setrens(0, 0).expect("ps2d: failed to enter null namespace");
let key_ps2d = ps2d.clone();
event_queue.add(key_irq.as_raw_fd(), move |_count: usize| -> Result<Option<()>> {
event_queue.add(key_irq.as_raw_fd(), move |_event| -> Result<Option<()>> {
let mut irq = [0; 8];
if key_irq.read(&mut irq)? >= irq.len() {
key_ps2d.borrow_mut().irq();
......@@ -62,7 +62,7 @@ fn daemon(input: File) {
}).expect("ps2d: failed to poll irq:1");
let mouse_ps2d = ps2d;
event_queue.add(mouse_irq.as_raw_fd(), move |_count: usize| -> Result<Option<()>> {
event_queue.add(mouse_irq.as_raw_fd(), move |_event| -> Result<Option<()>> {
let mut irq = [0; 8];
if mouse_irq.read(&mut irq)? >= irq.len() {
mouse_ps2d.borrow_mut().irq();
......@@ -71,7 +71,10 @@ fn daemon(input: File) {
Ok(None)
}).expect("ps2d: failed to poll irq:12");
event_queue.trigger_all(0).expect("ps2d: failed to trigger events");
event_queue.trigger_all(event::Event {
fd: 0,
flags: 0,
}).expect("ps2d: failed to trigger events");
event_queue.run().expect("ps2d: failed to handle events");
}
......
......@@ -51,7 +51,7 @@ fn main() {
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<Option<usize>> {
event_queue.add(irq_file.as_raw_fd(), move |_event| -> Result<Option<usize>> {
let mut irq = [0; 8];
irq_file.read(&mut irq)?;
......@@ -83,7 +83,7 @@ fn main() {
let socket_fd = socket.borrow().as_raw_fd();
let socket_packet = socket.clone();
event_queue.add(socket_fd, move |_count: usize| -> Result<Option<usize>> {
event_queue.add(socket_fd, move |_event| -> Result<Option<usize>> {
loop {
let mut packet = Packet::default();
if socket_packet.borrow_mut().read(&mut packet)? == 0 {
......@@ -108,7 +108,10 @@ fn main() {
Ok(None)
}).expect("rtl8168d: failed to catch events on scheme file");
for event_count in event_queue.trigger_all(0).expect("rtl8168d: failed to trigger events") {
for event_count in event_queue.trigger_all(event::Event {
fd: 0,
flags: 0,
}).expect("rtl8168d: failed to trigger events") {
socket.borrow_mut().write(&Packet {
id: 0,
pid: 0,
......
......@@ -5,7 +5,7 @@ extern crate orbclient;
extern crate syscall;
use event::EventQueue;
use std::{env, mem, slice};
use std::{env, mem};
use std::os::unix::io::AsRawFd;
use std::fs::File;
use std::io::{Result, Read, Write};
......@@ -219,7 +219,7 @@ fn main() {
let mut port = Pio::<u32>::new(bar0 as u16);
let address = unsafe { syscall::physmap(bar1, 4096, MAP_WRITE).expect("vboxd: failed to map address") };
{
let mut vmmdev = unsafe { &mut *(address as *mut VboxVmmDev) };
let vmmdev = unsafe { &mut *(address as *mut VboxVmmDev) };
let mut guest_info = VboxGuestInfo::new().expect("vboxd: failed to map GuestInfo");
guest_info.version.write(VBOX_VMMDEV_VERSION);
......@@ -244,7 +244,7 @@ fn main() {
let get_mouse = VboxGetMouse::new().expect("vboxd: failed to map GetMouse");
let display_change = VboxDisplayChange::new().expect("vboxd: failed to map DisplayChange");
let ack_events = VboxAckEvents::new().expect("vboxd: failed to map AckEvents");
event_queue.add(irq_file.as_raw_fd(), move |_count: usize| -> Result<Option<()>> {
event_queue.add(irq_file.as_raw_fd(), move |_event| -> Result<Option<()>> {
let mut irq = [0; 8];
if irq_file.read(&mut irq)? >= irq.len() {
let host_events = vmmdev.host_events.read();
......@@ -286,7 +286,10 @@ fn main() {
Ok(None)
}).expect("vboxd: failed to poll irq");
event_queue.trigger_all(0).expect("vboxd: failed to trigger events");
event_queue.trigger_all(event::Event {
fd: 0,
flags: 0
}).expect("vboxd: failed to trigger events");
event_queue.run().expect("vboxd: failed to run event loop");
}
......
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