2024-03-13 14:25:02 +02:00
|
|
|
// vi:syntax=yggdrasil_abi:
|
|
|
|
|
|
|
|
enum Signal(u32) {
|
|
|
|
/// Process has tried to perform an illegal memory operation
|
|
|
|
MemoryAccessViolation = 1,
|
|
|
|
/// Process has hit a breakpoint or was aborted
|
|
|
|
Aborted = 2,
|
|
|
|
/// Process was killed
|
|
|
|
Killed = 3,
|
|
|
|
/// Process was interrupted
|
|
|
|
Interrupted = 4,
|
2024-03-12 13:48:09 +02:00
|
|
|
}
|
|
|
|
|
2024-03-13 14:25:02 +02:00
|
|
|
newtype ProcessId(u32);
|
|
|
|
newtype ProcessGroupId(u32);
|
|
|
|
newtype ThreadId(u32);
|
|
|
|
|
|
|
|
// Spawn
|
|
|
|
|
2024-03-12 13:48:09 +02:00
|
|
|
/// Controls how processes are created
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
#[repr(C)]
|
2024-03-13 14:25:02 +02:00
|
|
|
struct SpawnOptions<'a> {
|
2024-03-12 13:48:09 +02:00
|
|
|
/// Creator-relative path to the binary to execute
|
|
|
|
pub program: &'a str,
|
|
|
|
/// Arguments to the child process
|
|
|
|
pub arguments: &'a [&'a str],
|
|
|
|
/// Environment for the child process
|
|
|
|
pub environment: &'a [&'a str],
|
|
|
|
/// Optional arguments to specify details of the creation
|
|
|
|
pub optional: &'a [SpawnOption],
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Legacy execve(2) arguments
|
|
|
|
#[allow(missing_docs)]
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
#[repr(C)]
|
2024-03-13 14:25:02 +02:00
|
|
|
struct ExecveOptions<'a> {
|
2024-03-12 13:48:09 +02:00
|
|
|
pub program: &'a str,
|
|
|
|
pub arguments: &'a [&'a str],
|
|
|
|
pub environment: &'a [&'a str],
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Controls how threads are spawned within a process
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
#[repr(C)]
|
2024-03-13 14:25:02 +02:00
|
|
|
struct ThreadSpawnOptions {
|
2024-03-12 13:48:09 +02:00
|
|
|
/// Thread entry function
|
|
|
|
pub entry: extern "C" fn(u64) -> !,
|
|
|
|
/// Thread argument value
|
|
|
|
pub argument: u64,
|
|
|
|
/// Thread stack pointer. NOTE: it's the caller's responsibility to allocate a proper stack for
|
|
|
|
/// the thread.
|
|
|
|
pub stack_top: usize,
|
|
|
|
}
|
2024-03-13 14:25:02 +02:00
|
|
|
|
|
|
|
// Signal
|
|
|
|
|
|
|
|
/// Data provided by the kernel to signal entry function
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
#[repr(C)]
|
|
|
|
struct SignalEntryData {
|
|
|
|
/// Which signal was issued
|
|
|
|
pub signal: Signal,
|
|
|
|
/// Saved frame of the context that was interrupted
|
|
|
|
pub frame: SavedFrame,
|
|
|
|
}
|