2016-08-15 05:38:32 +02:00
|
|
|
use core::str;
|
2016-09-24 01:54:39 +02:00
|
|
|
use core::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
|
Orbital (#16)
* 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
2016-10-14 01:21:42 +02:00
|
|
|
use spin::Once;
|
2016-08-26 01:03:01 +02:00
|
|
|
|
2016-09-19 01:55:35 +02:00
|
|
|
use context;
|
Orbital (#16)
* 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
2016-10-14 01:21:42 +02:00
|
|
|
use sync::WaitQueue;
|
2016-09-21 00:23:28 +02:00
|
|
|
use syscall::error::*;
|
2016-09-24 01:54:39 +02:00
|
|
|
use syscall::flag::EVENT_READ;
|
2016-09-21 00:23:28 +02:00
|
|
|
use syscall::scheme::Scheme;
|
2016-08-15 05:38:32 +02:00
|
|
|
|
2016-09-24 01:54:39 +02:00
|
|
|
pub static DEBUG_SCHEME_ID: AtomicUsize = ATOMIC_USIZE_INIT;
|
|
|
|
|
Orbital (#16)
* 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
2016-10-14 01:21:42 +02:00
|
|
|
/// Input queue
|
|
|
|
static INPUT: Once<WaitQueue<u8>> = Once::new();
|
2016-09-19 01:55:35 +02:00
|
|
|
|
Orbital (#16)
* 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
2016-10-14 01:21:42 +02:00
|
|
|
/// Initialize input queue, called if needed
|
|
|
|
fn init_input() -> WaitQueue<u8> {
|
|
|
|
WaitQueue::new()
|
2016-09-19 01:55:35 +02:00
|
|
|
}
|
|
|
|
|
Orbital (#16)
* 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
2016-10-14 01:21:42 +02:00
|
|
|
/// Add to the input queue
|
2016-09-19 01:55:35 +02:00
|
|
|
#[no_mangle]
|
|
|
|
pub extern fn debug_input(b: u8) {
|
Orbital (#16)
* 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
2016-10-14 01:21:42 +02:00
|
|
|
let len = INPUT.call_once(init_input).send(b);
|
2016-09-24 01:54:39 +02:00
|
|
|
|
|
|
|
context::event::trigger(DEBUG_SCHEME_ID.load(Ordering::SeqCst), 0, EVENT_READ, len);
|
2016-09-19 01:55:35 +02:00
|
|
|
}
|
|
|
|
|
2016-08-15 05:38:32 +02:00
|
|
|
pub struct DebugScheme;
|
|
|
|
|
|
|
|
impl Scheme for DebugScheme {
|
2016-10-06 02:01:05 +02:00
|
|
|
fn open(&self, _path: &[u8], _flags: usize, _uid: u32, _gid: u32) -> Result<usize> {
|
2016-08-15 05:38:32 +02:00
|
|
|
Ok(0)
|
|
|
|
}
|
|
|
|
|
2016-10-26 21:19:56 +02:00
|
|
|
fn dup(&self, _file: usize, _buf: &[u8]) -> Result<usize> {
|
2016-09-12 01:31:21 +02:00
|
|
|
Ok(0)
|
|
|
|
}
|
|
|
|
|
2016-08-15 05:38:32 +02:00
|
|
|
/// Read the file `number` into the `buffer`
|
|
|
|
///
|
|
|
|
/// Returns the number of bytes read
|
2016-09-20 02:29:28 +02:00
|
|
|
fn read(&self, _file: usize, buf: &mut [u8]) -> Result<usize> {
|
2016-10-20 20:31:39 +02:00
|
|
|
Ok(INPUT.call_once(init_input).receive_into(buf, true))
|
2016-08-15 05:38:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Write the `buffer` to the `file`
|
|
|
|
///
|
|
|
|
/// Returns the number of bytes written
|
2016-09-20 02:29:28 +02:00
|
|
|
fn write(&self, _file: usize, buffer: &[u8]) -> Result<usize> {
|
2016-08-15 05:38:32 +02:00
|
|
|
//TODO: Write bytes, do not convert to str
|
|
|
|
print!("{}", unsafe { str::from_utf8_unchecked(buffer) });
|
|
|
|
Ok(buffer.len())
|
|
|
|
}
|
|
|
|
|
2016-09-27 01:00:06 +02:00
|
|
|
fn fevent(&self, _file: usize, _flags: usize) -> Result<usize> {
|
2016-09-24 01:54:39 +02:00
|
|
|
Ok(0)
|
|
|
|
}
|
|
|
|
|
2016-09-21 00:23:28 +02:00
|
|
|
fn fsync(&self, _file: usize) -> Result<usize> {
|
|
|
|
Ok(0)
|
2016-09-19 01:55:35 +02:00
|
|
|
}
|
|
|
|
|
2016-08-15 05:38:32 +02:00
|
|
|
/// Close the file `number`
|
2016-09-21 00:23:28 +02:00
|
|
|
fn close(&self, _file: usize) -> Result<usize> {
|
|
|
|
Ok(0)
|
2016-08-15 05:38:32 +02:00
|
|
|
}
|
|
|
|
}
|