2016-08-14 23:58:35 +02:00
|
|
|
///! Syscall handlers
|
|
|
|
|
2016-09-21 00:23:28 +02:00
|
|
|
extern crate syscall;
|
|
|
|
|
2016-09-21 00:57:45 +02:00
|
|
|
pub use self::syscall::{data, error, flag, number, scheme};
|
2016-09-21 00:23:28 +02:00
|
|
|
|
2016-08-14 23:58:35 +02:00
|
|
|
pub use self::fs::*;
|
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
|
|
|
pub use self::futex::futex;
|
2016-08-14 23:58:35 +02:00
|
|
|
pub use self::process::*;
|
2016-10-07 04:50:14 +02:00
|
|
|
pub use self::time::*;
|
2016-09-17 02:50:47 +02:00
|
|
|
pub use self::validate::*;
|
2016-08-14 23:58:35 +02:00
|
|
|
|
2016-10-07 04:50:14 +02:00
|
|
|
use self::data::TimeSpec;
|
2016-09-21 00:57:45 +02:00
|
|
|
use self::error::{Error, Result, ENOSYS};
|
|
|
|
use self::number::*;
|
|
|
|
|
2016-09-17 02:50:47 +02:00
|
|
|
/// Filesystem syscalls
|
2016-09-21 00:23:28 +02:00
|
|
|
pub mod fs;
|
2016-08-14 23:58: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
|
|
|
/// Fast userspace mutex
|
|
|
|
pub mod futex;
|
|
|
|
|
2016-09-17 02:50:47 +02:00
|
|
|
/// Process syscalls
|
2016-09-21 00:23:28 +02:00
|
|
|
pub mod process;
|
2016-08-14 23:58:35 +02:00
|
|
|
|
2016-10-07 04:50:14 +02:00
|
|
|
/// Time syscalls
|
|
|
|
pub mod time;
|
|
|
|
|
2016-09-17 02:50:47 +02:00
|
|
|
/// Validate input
|
2016-09-21 00:23:28 +02:00
|
|
|
pub mod validate;
|
2016-08-14 23:58:35 +02:00
|
|
|
|
2016-09-14 04:06:39 +02:00
|
|
|
#[no_mangle]
|
|
|
|
pub extern fn syscall(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize, stack: usize) -> usize {
|
|
|
|
#[inline(always)]
|
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
|
|
|
fn inner(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize, stack: usize) -> Result<usize> {
|
2016-09-25 19:20:59 +02:00
|
|
|
match a & SYS_CLASS {
|
|
|
|
SYS_CLASS_FILE => match a & SYS_ARG {
|
|
|
|
SYS_ARG_SLICE => file_op_slice(a, b, validate_slice(c as *const u8, d)?),
|
|
|
|
SYS_ARG_MSLICE => file_op_mut_slice(a, b, validate_slice_mut(c as *mut u8, d)?),
|
|
|
|
_ => match a {
|
|
|
|
SYS_CLOSE => close(b),
|
|
|
|
SYS_DUP => dup(b),
|
|
|
|
SYS_FEVENT => fevent(b, c),
|
|
|
|
_ => file_op(a, b, c, d)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
SYS_CLASS_PATH => match a {
|
|
|
|
SYS_OPEN => open(validate_slice(b as *const u8, c)?, d),
|
2016-10-06 02:01:05 +02:00
|
|
|
SYS_MKDIR => mkdir(validate_slice(b as *const u8, c)?, d as u16),
|
|
|
|
SYS_RMDIR => rmdir(validate_slice(b as *const u8, c)?),
|
|
|
|
SYS_UNLINK => unlink(validate_slice(b as *const u8, c)?),
|
2016-09-25 19:20:59 +02:00
|
|
|
_ => unreachable!()
|
|
|
|
},
|
|
|
|
_ => match a {
|
|
|
|
SYS_EXIT => exit(b),
|
|
|
|
SYS_WAITPID => waitpid(b, c, d),
|
|
|
|
SYS_EXECVE => exec(validate_slice(b as *const u8, c)?, validate_slice(d as *const [usize; 2], e)?),
|
|
|
|
SYS_CHDIR => chdir(validate_slice(b as *const u8, c)?),
|
|
|
|
SYS_GETPID => getpid(),
|
|
|
|
SYS_BRK => brk(b),
|
|
|
|
SYS_IOPL => iopl(b),
|
|
|
|
SYS_CLONE => clone(b, stack),
|
|
|
|
SYS_YIELD => sched_yield(),
|
2016-10-07 04:50:14 +02:00
|
|
|
SYS_NANOSLEEP => nanosleep(validate_slice(b as *const TimeSpec, 1).map(|req| &req[0])?, validate_slice_mut(c as *mut TimeSpec, 1).ok().map(|rem| &mut rem[0])),
|
2016-09-25 19:20:59 +02:00
|
|
|
SYS_GETCWD => getcwd(validate_slice_mut(b as *mut u8, c)?),
|
2016-10-05 23:43:35 +02:00
|
|
|
SYS_GETUID => getuid(),
|
|
|
|
SYS_GETGID => getgid(),
|
2016-10-06 04:31:59 +02:00
|
|
|
SYS_GETEUID => geteuid(),
|
|
|
|
SYS_GETEGID => getegid(),
|
2016-10-05 23:43:35 +02:00
|
|
|
SYS_SETUID => setuid(b as u32),
|
|
|
|
SYS_SETGID => setgid(b as u32),
|
2016-10-07 04:50:14 +02:00
|
|
|
SYS_CLOCK_GETTIME => clock_gettime(b, validate_slice_mut(c as *mut TimeSpec, 1).map(|time| &mut time[0])?),
|
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
|
|
|
SYS_FUTEX => futex(validate_slice_mut(b as *mut i32, 1).map(|uaddr| &mut uaddr[0])?, c, d as i32, e, f as *mut i32),
|
2016-10-07 02:46:24 +02:00
|
|
|
SYS_PIPE2 => pipe2(validate_slice_mut(b as *mut usize, 2)?, c),
|
2016-10-05 23:43:35 +02:00
|
|
|
SYS_PHYSALLOC => physalloc(b),
|
|
|
|
SYS_PHYSFREE => physfree(b, c),
|
2016-09-25 19:20:59 +02:00
|
|
|
SYS_PHYSMAP => physmap(b, c, d),
|
|
|
|
SYS_PHYSUNMAP => physunmap(b),
|
2016-10-05 23:43:35 +02:00
|
|
|
SYS_VIRTTOPHYS => virttophys(b),
|
2016-09-25 19:20:59 +02:00
|
|
|
_ => Err(Error::new(ENOSYS))
|
2016-09-14 04:06:39 +02:00
|
|
|
}
|
2016-09-12 00:48:58 +02:00
|
|
|
}
|
2016-08-20 21:43:35 +02:00
|
|
|
}
|
2016-08-19 03:44:31 +02:00
|
|
|
|
2016-09-28 19:18:28 +02:00
|
|
|
let result = inner(a, b, c, d, e, f, stack);
|
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
|
|
|
/*
|
2016-09-28 19:18:28 +02:00
|
|
|
if let Err(ref err) = result {
|
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
|
|
|
println!("{}, {}, {}, {}: {}", a, b, c, d, err);
|
2016-09-28 19:18:28 +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
|
|
|
*/
|
2016-09-28 19:18:28 +02:00
|
|
|
Error::mux(result)
|
2016-08-19 03:44:31 +02:00
|
|
|
}
|