* Port previous ethernet scheme

* Add ipd

* Fix initfs rebuilds, use QEMU user networking addresses in ipd

* Add tcp/udp, netutils, dns, and network config

* Add fsync to network driver

* Add dns, router, subnet by default

* Fix e1000 driver. Make ethernet and IP non-blocking to avoid deadlocks

* Add orbital server, WIP

* Add futex

* Add orbutils and orbital

* Update libstd, orbutils, and orbital
Move ANSI key encoding to vesad

* Add orbital assets

* Update orbital

* Update to add login manager

* Add blocking primitives, block for most things except waitpid, update orbital

* Wait in waitpid and IRQ, improvements for other waits

* Fevent in root scheme

* WIP: Switch to using fevent

* Reorganize

* Event based e1000d driver

* Superuser-only access to some network schemes, display, and disk

* Superuser root and irq schemes

* Fix orbital
This commit is contained in:
Jeremy Soller 2016-10-13 17:21:42 -06:00 • committed by GitHub
commit 224c43f761

View file

@ -1,17 +1,18 @@
use alloc::arc::{Arc, Weak};
use collections::{BTreeMap, VecDeque};
use core::mem;
use collections::BTreeMap;
use core::{mem, slice};
use core::sync::atomic::{AtomicUsize, Ordering};
use spin::{Mutex, RwLock};
use spin::RwLock;
use context;
use sync::WaitQueue;
use syscall::data::Event;
use syscall::error::*;
use syscall::scheme::Scheme;
pub struct EventScheme {
next_id: AtomicUsize,
handles: RwLock<BTreeMap<usize, Weak<Mutex<VecDeque<Event>>>>>
handles: RwLock<BTreeMap<usize, Weak<WaitQueue<Event>>>>
}
impl EventScheme {
@ -57,29 +58,8 @@ impl Scheme for EventScheme {
handle_weak.upgrade().ok_or(Error::new(EBADF))?
};
let event_size = mem::size_of::<Event>();
let len = buf.len()/event_size;
if len > 0 {
loop {
let mut i = 0;
{
let mut events = handle.lock();
while ! events.is_empty() && i < len {
let event = events.pop_front().unwrap();
unsafe { *(buf.as_mut_ptr() as *mut Event).offset(i as isize) = event; }
i += 1;
}
}
if i > 0 {
return Ok(i * event_size);
} else {
unsafe { context::switch(); } //TODO: Block
}
}
} else {
Ok(0)
}
let event_buf = unsafe { slice::from_raw_parts_mut(buf.as_mut_ptr() as *mut Event, buf.len()/mem::size_of::<Event>()) };
Ok(handle.receive_into(event_buf) * mem::size_of::<Event>())
}
fn fsync(&self, id: usize) -> Result<usize> {