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-11-17 20:12:02 +01:00
|
|
|
pub use self::driver::*;
|
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-11-17 20:12:02 +01:00
|
|
|
pub use self::privilege::*;
|
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-11-13 15:36:52 +01:00
|
|
|
use context::ContextId;
|
2016-11-25 20:09:54 +01:00
|
|
|
use scheme::{FileHandle, SchemeNamespace};
|
2016-11-13 15:36:52 +01:00
|
|
|
|
2016-11-17 20:12:02 +01:00
|
|
|
/// Driver syscalls
|
|
|
|
pub mod driver;
|
|
|
|
|
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-11-17 20:12:02 +01:00
|
|
|
/// Privilege syscalls
|
|
|
|
pub mod privilege;
|
|
|
|
|
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 {
|
2016-11-13 21:47:04 +01:00
|
|
|
SYS_CLASS_FILE => {
|
|
|
|
let fd = FileHandle::from(b);
|
|
|
|
match a & SYS_ARG {
|
|
|
|
SYS_ARG_SLICE => file_op_slice(a, fd, validate_slice(c as *const u8, d)?),
|
|
|
|
SYS_ARG_MSLICE => file_op_mut_slice(a, fd, validate_slice_mut(c as *mut u8, d)?),
|
|
|
|
_ => match a {
|
|
|
|
SYS_CLOSE => close(fd),
|
|
|
|
SYS_DUP => dup(fd, validate_slice(c as *const u8, d)?).map(FileHandle::into),
|
|
|
|
SYS_FEVENT => fevent(fd, c),
|
|
|
|
SYS_FUNMAP => funmap(b),
|
|
|
|
_ => file_op(a, fd, c, d)
|
|
|
|
}
|
2016-09-25 19:20:59 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
SYS_CLASS_PATH => match a {
|
2016-11-13 21:47:04 +01:00
|
|
|
SYS_OPEN => open(validate_slice(b as *const u8, c)?, d).map(FileHandle::into),
|
2016-11-16 01:08:14 +01:00
|
|
|
SYS_CHMOD => chmod(validate_slice(b as *const u8, c)?, d as u16),
|
2016-10-06 02:01:05 +02:00
|
|
|
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 {
|
2016-11-17 06:14:02 +01:00
|
|
|
SYS_YIELD => sched_yield(),
|
|
|
|
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])),
|
|
|
|
SYS_CLOCK_GETTIME => clock_gettime(b, validate_slice_mut(c as *mut TimeSpec, 1).map(|time| &mut time[0])?),
|
|
|
|
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),
|
|
|
|
SYS_BRK => brk(b),
|
2016-11-13 15:36:52 +01:00
|
|
|
SYS_GETPID => getpid().map(ContextId::into),
|
|
|
|
SYS_CLONE => clone(b, stack).map(ContextId::into),
|
2016-11-17 20:12:02 +01:00
|
|
|
SYS_EXIT => exit((b & 0xFF) << 8),
|
|
|
|
SYS_KILL => kill(ContextId::from(b), c),
|
|
|
|
SYS_WAITPID => waitpid(ContextId::from(b), c, d).map(ContextId::into),
|
|
|
|
SYS_CHDIR => chdir(validate_slice(b as *const u8, c)?),
|
|
|
|
SYS_EXECVE => exec(validate_slice(b as *const u8, c)?, validate_slice(d as *const [usize; 2], e)?),
|
|
|
|
SYS_IOPL => iopl(b, stack),
|
2016-09-25 19:20:59 +02:00
|
|
|
SYS_GETCWD => getcwd(validate_slice_mut(b as *mut u8, c)?),
|
2016-10-06 04:31:59 +02:00
|
|
|
SYS_GETEGID => getegid(),
|
2016-11-25 20:09:54 +01:00
|
|
|
SYS_GETENS => getens(),
|
|
|
|
SYS_GETEUID => geteuid(),
|
|
|
|
SYS_GETGID => getgid(),
|
|
|
|
SYS_GETNS => getns(),
|
|
|
|
SYS_GETUID => getuid(),
|
|
|
|
SYS_MKNS => mkns(validate_slice(b as *const [usize; 2], c)?),
|
2016-11-17 22:16:39 +01:00
|
|
|
SYS_SETREUID => setreuid(b as u32, c as u32),
|
2016-11-25 20:09:54 +01:00
|
|
|
SYS_SETRENS => setrens(SchemeNamespace::from(b), SchemeNamespace::from(c)),
|
2016-11-17 22:16:39 +01:00
|
|
|
SYS_SETREGID => setregid(b as u32, c as u32),
|
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
|
|
|
}
|