2024-11-17 23:32:07 +02:00
|
|
|
// vi:syntax=yggdrasil-abi:
|
2024-03-12 13:37:40 +02:00
|
|
|
|
|
|
|
extern {
|
|
|
|
type Duration = core::time::Duration;
|
|
|
|
type AtomicU32 = core::sync::atomic::AtomicU32;
|
|
|
|
|
2024-12-02 10:19:48 +02:00
|
|
|
type SystemTime = yggdrasil_abi::time::SystemTime;
|
|
|
|
#[thin]
|
|
|
|
type ClockType = yggdrasil_abi::time::ClockType;
|
|
|
|
|
2024-03-13 14:25:02 +02:00
|
|
|
// TODO "tagged union" enums are not yet implemented
|
2024-03-12 13:37:40 +02:00
|
|
|
type MappingSource;
|
|
|
|
|
|
|
|
type SystemInfo = yggdrasil_abi::system::SystemInfo;
|
|
|
|
|
|
|
|
type SignalEntryData = yggdrasil_abi::process::SignalEntryData;
|
|
|
|
type MutexOperation = yggdrasil_abi::process::MutexOperation;
|
|
|
|
#[thin]
|
|
|
|
type ExitCode = yggdrasil_abi::process::ExitCode;
|
2024-11-17 23:32:07 +02:00
|
|
|
type ThreadOption = yggdrasil_abi::process::ThreadOption;
|
2024-11-28 11:30:09 +02:00
|
|
|
type ProcessOption = yggdrasil_abi::process::ProcessOption;
|
2024-11-28 22:28:32 +02:00
|
|
|
type ProcessWait = yggdrasil_abi::process::ProcessWait;
|
2024-03-12 13:37:40 +02:00
|
|
|
|
2024-11-01 11:44:57 +02:00
|
|
|
type SocketAddr = core::net::SocketAddr;
|
2024-03-12 13:37:40 +02:00
|
|
|
type SocketOption = yggdrasil_abi::net::SocketOption;
|
2024-11-01 11:44:57 +02:00
|
|
|
type SocketConnect = yggdrasil_abi::net::SocketConnect;
|
2024-03-12 13:37:40 +02:00
|
|
|
|
|
|
|
type SentMessage = yggdrasil_abi::io::SentMessage;
|
|
|
|
type ReceivedMessageMetadata = yggdrasil_abi::io::ReceivedMessageMetadata;
|
|
|
|
type DeviceRequest = yggdrasil_abi::io::DeviceRequest;
|
|
|
|
type FileMetadataUpdate = yggdrasil_abi::io::FileMetadataUpdate;
|
2024-03-13 13:11:46 +02:00
|
|
|
|
2024-03-19 23:11:03 +02:00
|
|
|
type DebugOperation = yggdrasil_abi::debug::DebugOperation;
|
|
|
|
type DebugFrame = yggdrasil_abi::debug::DebugFrame;
|
|
|
|
|
2024-03-12 13:37:40 +02:00
|
|
|
#[thin]
|
|
|
|
type SeekFrom = yggdrasil_abi::io::SeekFrom;
|
|
|
|
#[thin]
|
|
|
|
type MessageDestination = yggdrasil_abi::io::MessageDestination;
|
|
|
|
}
|
|
|
|
|
|
|
|
// abi::net
|
|
|
|
|
|
|
|
enum SocketType(u32) {
|
|
|
|
/// Raw packet socket
|
|
|
|
RawPacket = 0,
|
|
|
|
/// TCP stream socket
|
|
|
|
TcpStream = 1,
|
|
|
|
/// UDP packet socket
|
|
|
|
UdpPacket = 2,
|
|
|
|
}
|
|
|
|
|
2024-11-14 16:24:45 +02:00
|
|
|
// abi::mem
|
|
|
|
|
|
|
|
bitfield MappingFlags(u32) {
|
|
|
|
/// Process write access
|
|
|
|
WRITE: 0,
|
|
|
|
/// Executable access
|
|
|
|
EXEC: 1,
|
|
|
|
}
|
|
|
|
|
2024-03-12 13:37:40 +02:00
|
|
|
// TODO allow splitting types into separate modules
|
|
|
|
|
|
|
|
syscall get_random(buffer: &mut [u8]);
|
2024-12-02 10:19:48 +02:00
|
|
|
syscall get_clock(clock: ClockType, out: &mut MaybeUninit<SystemTime>) -> Result<()>;
|
2024-03-12 13:37:40 +02:00
|
|
|
syscall get_system_info(info: &mut SystemInfo) -> Result<()>;
|
|
|
|
syscall mount(opts: &MountOptions<'_>) -> Result<()>;
|
|
|
|
syscall unmount(opts: &UnmountOptions) -> Result<()>;
|
2024-04-01 17:23:12 +03:00
|
|
|
syscall load_module(path: &str) -> Result<()>;
|
2024-03-12 13:37:40 +02:00
|
|
|
|
|
|
|
// Memory management
|
2024-11-14 16:24:45 +02:00
|
|
|
syscall map_memory(
|
|
|
|
hint: Option<NonZeroUsize>,
|
|
|
|
len: usize,
|
|
|
|
flags: MappingFlags,
|
|
|
|
source: &MappingSource
|
|
|
|
) -> Result<usize>;
|
2024-03-12 13:37:40 +02:00
|
|
|
syscall unmap_memory(address: usize, len: usize) -> Result<()>;
|
|
|
|
|
|
|
|
// Process/thread management
|
2024-03-13 17:55:14 +02:00
|
|
|
syscall create_process_group() -> ProcessGroupId;
|
|
|
|
syscall get_process_group_id() -> ProcessGroupId;
|
|
|
|
|
2024-03-12 13:37:40 +02:00
|
|
|
syscall exit_process(code: ExitCode) -> !;
|
2024-03-12 14:47:30 +02:00
|
|
|
syscall spawn_process(options: &SpawnOptions<'_>) -> Result<ProcessId>;
|
2024-11-28 22:28:32 +02:00
|
|
|
syscall wait_process(wait: &ProcessWait, status: &mut ExitCode, flags: WaitFlags) -> Result<ProcessId>;
|
2024-03-12 14:47:30 +02:00
|
|
|
syscall get_pid() -> ProcessId;
|
2024-11-28 11:30:09 +02:00
|
|
|
syscall get_tid() -> u32;
|
2024-03-12 13:37:40 +02:00
|
|
|
|
2024-04-25 16:02:00 +03:00
|
|
|
// TODO use ThreadId
|
|
|
|
syscall spawn_thread(options: &ThreadSpawnOptions) -> Result<u32>;
|
|
|
|
syscall exit_thread() -> !;
|
|
|
|
syscall wait_thread(tid: u32) -> Result<()>;
|
2024-11-20 17:55:57 +02:00
|
|
|
syscall get_thread_option(option: &mut ThreadOption<'_>) -> Result<()>;
|
2024-11-28 11:30:09 +02:00
|
|
|
syscall set_thread_option(option: &mut ThreadOption<'_>) -> Result<()>;
|
|
|
|
syscall get_process_option(option: &mut ProcessOption) -> Result<()>;
|
|
|
|
syscall set_process_option(option: &mut ProcessOption) -> Result<()>;
|
2024-04-25 16:02:00 +03:00
|
|
|
|
2024-11-20 15:39:10 +02:00
|
|
|
syscall nanosleep(duration: &Duration, remaining: &mut MaybeUninit<Duration>) -> Result<()>;
|
2024-03-12 13:37:40 +02:00
|
|
|
|
|
|
|
syscall exit_signal(frame: &SignalEntryData) -> !;
|
2024-03-12 14:47:30 +02:00
|
|
|
syscall send_signal(target: ProcessId, signal: Signal) -> Result<()>;
|
2024-03-12 13:37:40 +02:00
|
|
|
|
|
|
|
syscall mutex(mutex: &AtomicU32, op: &MutexOperation) -> Result<()>;
|
|
|
|
|
|
|
|
syscall start_session() -> Result<()>;
|
|
|
|
|
|
|
|
// I/O
|
|
|
|
syscall open(at: Option<RawFd>, path: &str, opts: OpenOptions, mode: FileMode) -> Result<RawFd>;
|
|
|
|
syscall close(fd: RawFd) -> Result<()>;
|
|
|
|
syscall write(fd: RawFd, data: &[u8]) -> Result<usize>;
|
|
|
|
syscall read(fd: RawFd, data: &mut [u8]) -> Result<usize>;
|
2024-10-11 17:24:20 +03:00
|
|
|
syscall seek(fd: RawFd, pos: SeekFrom, output: &mut u64) -> Result<()>;
|
2024-03-12 13:37:40 +02:00
|
|
|
|
|
|
|
syscall open_directory(at: Option<RawFd>, path: &str) -> Result<RawFd>;
|
|
|
|
syscall read_directory_entries(fd: RawFd, entries: &mut [MaybeUninit<DirectoryEntry>]) -> Result<usize>;
|
|
|
|
syscall create_directory(at: Option<RawFd>, path: &str, mode: FileMode) -> Result<()>;
|
|
|
|
syscall remove_directory(at: Option<RawFd>, path: &str) -> Result<()>;
|
|
|
|
|
2024-08-02 17:04:47 +03:00
|
|
|
syscall read_link(at: Option<RawFd>, path: &str, buf: &mut [u8]) -> Result<usize>;
|
2024-03-12 13:37:40 +02:00
|
|
|
syscall remove(at: Option<RawFd>, path: &str) -> Result<()>;
|
|
|
|
syscall clone_fd(source: RawFd, target: Option<RawFd>) -> Result<RawFd>;
|
|
|
|
syscall update_metadata(at: Option<RawFd>, path: &str, update: &FileMetadataUpdate) -> Result<()>;
|
|
|
|
syscall get_metadata(at: Option<RawFd>, path: &str, metadata: &mut MaybeUninit<FileAttr>, follow: bool) -> Result<()>;
|
|
|
|
syscall device_request(fd: RawFd, req: &mut DeviceRequest) -> Result<()>;
|
|
|
|
|
|
|
|
// Misc I/O
|
|
|
|
syscall open_channel(name: &str, subscribe: bool) -> Result<RawFd>;
|
2024-10-31 13:14:07 +02:00
|
|
|
syscall create_timer(options: TimerOptions) -> Result<RawFd>;
|
2024-11-29 19:40:17 +02:00
|
|
|
syscall create_pid(target: &ProcessWait, flags: WaitFlags) -> Result<RawFd>;
|
2024-03-12 13:37:40 +02:00
|
|
|
syscall create_pty(opts: &TerminalOptions, size: &TerminalSize, fds: &mut [MaybeUninit<RawFd>; 2]) -> Result<()>;
|
|
|
|
syscall create_shared_memory(size: usize) -> Result<RawFd>;
|
|
|
|
syscall create_poll_channel() -> Result<RawFd>;
|
2024-11-06 19:40:27 +02:00
|
|
|
syscall create_pipe(fds: &mut [MaybeUninit<RawFd>; 2], options: PipeOptions) -> Result<()>;
|
2024-03-12 13:37:40 +02:00
|
|
|
|
|
|
|
syscall poll_channel_wait(
|
|
|
|
poll_fd: RawFd,
|
|
|
|
timeout: &Option<Duration>,
|
2024-08-07 19:20:39 +03:00
|
|
|
retain: bool,
|
2024-03-12 13:37:40 +02:00
|
|
|
output: &mut Option<(RawFd, Result<()>)>
|
|
|
|
) -> Result<()>;
|
|
|
|
syscall poll_channel_control(poll_fd: RawFd, ctl: PollControl, fd: RawFd) -> Result<()>;
|
|
|
|
|
|
|
|
syscall send_message(fd: RawFd, msg: &SentMessage<'_>, dst: MessageDestination) -> Result<()>;
|
|
|
|
syscall receive_message(
|
|
|
|
fd: RawFd,
|
|
|
|
meta: &mut MaybeUninit<ReceivedMessageMetadata>,
|
|
|
|
data: &mut [u8],
|
2024-03-12 14:47:30 +02:00
|
|
|
from: &mut MaybeUninit<ChannelPublisherId>
|
2024-03-12 13:37:40 +02:00
|
|
|
) -> Result<()>;
|
|
|
|
|
|
|
|
// Network
|
2024-11-01 11:44:57 +02:00
|
|
|
syscall connect_socket(connect: &mut SocketConnect, local: &mut MaybeUninit<SocketAddr>) -> Result<RawFd>;
|
2024-03-12 13:37:40 +02:00
|
|
|
syscall bind_socket(address: &SocketAddr, ty: SocketType) -> Result<RawFd>;
|
|
|
|
syscall accept(sock_fd: RawFd, remote: &mut MaybeUninit<SocketAddr>) -> Result<RawFd>;
|
|
|
|
|
|
|
|
syscall send_to(sock_fd: RawFd, data: &[u8], remote: &Option<SocketAddr>) -> Result<usize>;
|
|
|
|
syscall receive_from(sock_fd: RawFd, data: &mut [u8], remote: &mut MaybeUninit<SocketAddr>) -> Result<usize>;
|
|
|
|
|
|
|
|
syscall get_socket_option(sock_fd: RawFd, option: &mut SocketOption<'_>) -> Result<()>;
|
|
|
|
syscall set_socket_option(sock_fd: RawFd, option: &SocketOption<'_>) -> Result<()>;
|
|
|
|
|
|
|
|
// C compat
|
2024-03-12 14:47:30 +02:00
|
|
|
syscall fork() -> Result<ProcessId>;
|
2024-03-12 13:37:40 +02:00
|
|
|
syscall execve(options: &ExecveOptions<'_>) -> Result<()>;
|
2024-03-19 23:11:03 +02:00
|
|
|
|
|
|
|
// Debugging
|
|
|
|
syscall debug_trace(message: &str);
|
2024-10-27 06:46:25 +02:00
|
|
|
syscall debug_control(pid: ProcessId, op: &mut DebugOperation<'_>) -> Result<()>;
|