Mark Poliakov d9b70439b8 Add 'tool/abi-generator/' from commit '635bf51bb1cde626d477df477604d58d107bc037'
git-subtree-dir: tool/abi-generator
git-subtree-mainline: 7a0d528cdabd0ff344911b64e447a21e40bcbeaa
git-subtree-split: 635bf51bb1cde626d477df477604d58d107bc037
2024-03-12 16:13:37 +02:00

202 lines
6.2 KiB
Plaintext

// vi:syntax=yggdrasil_abi:
extern {
type Duration = core::time::Duration;
type Mutex = core::sync::atomic::AtomicU32;
type SocketAddr = core::net::SocketAddr;
type SystemInfo;
type MappingSource;
type SpawnOptions;
type ThreadSpawnOptions;
type MutexOperation;
type SignalEntryData;
type ProcessInfoElement;
type ExecveOptions;
type MountOptions;
type UnmountOptions;
type DirectoryEntry;
type FileAttr;
type DeviceRequest;
type SentMessage;
type ReceivedMessageMetadata;
type TerminalOptions;
type TerminalSize;
type FileMetadataUpdate;
type SocketOption;
#[thin]
type ExitCode;
#[fat]
type SeekFrom;
}
newtype Fd(u32);
newtype ProcessId(u32);
newtype ThreadId(u32);
newtype ProcessGroupId(u32);
// TODO define these as enums
newtype MessageDestination(u32);
bitfield OpenOptions(u32) {
/// Open the file with read capability
READ: 0,
/// Open the file with write capability
WRITE: 1,
/// Position at the end of the opened file
APPEND: 2,
/// Truncate the file to zero bytes when opening
TRUNCATE: 3,
/// Create a new file if it does not exist
CREATE: 4,
}
bitfield FileMode(u32) {
/// Other user execute access
OTHER_EXEC: 0,
/// Other user write access
OTHER_WRITE: 1,
/// Other user read access
OTHER_READ: 2,
/// Group execute access
GROUP_EXEC: 0,
/// Group write access
GROUP_WRITE: 1,
/// Group read access
GROUP_READ: 2,
/// Owner execute access
USER_EXEC: 0,
/// Owner write access
USER_WRITE: 1,
/// Owner read access
USER_READ: 2,
}
enum Signal(u32) {
MemoryAccessViolation = 1,
Aborted = 2,
Killed = 3,
Interrupted = 4
}
enum PollControl(u32) {
AddFd = 1
}
enum SocketType(u32) {
RawPacket = 1,
TcpStream = 2,
UdpPacket = 3
}
enum Error(u32) {
Dummy = 1,
UndefinedSyscall = 2,
InvalidArgument = 3,
}
syscall test_syscall(a: &(u32, u64));
//
// // Misc
//
// syscall debug_trace(msg: &str);
// syscall get_random(buffer: &mut [u8]);
// syscall get_system_info(info: &mut SystemInfo) -> Result<Fd>;
//
// // Memory management
//
// syscall map_memory(hint: Option<NonZeroUsize>, len: usize, source: &MappingSource) -> Result<usize>;
// syscall unmap_memory(virt: usize, len: usize) -> Result<()>;
//
// // Process/thread management
//
// syscall spawn_process(options: &SpawnOptions<'_>) -> Result<ProcessId>;
// syscall spawn_thread(options: &ThreadSpawnOptions) -> Result<ThreadId>;
//
// syscall exit_thread(code: ExitCode) -> !;
// syscall exit_process(code: ExitCode) -> !;
// syscall wait_process(pid: ProcessId, status: &mut ExitCode) -> Result<()>;
// syscall send_signal(pid: ProcessId, signal: Signal) -> Result<()>;
// syscall nanosleep(duration: &Duration);
//
// syscall mutex(mutex: &Mutex, op: &MutexOperation) -> Result<()>;
//
// syscall set_signal_entry(entry: usize, stack: usize);
// syscall exit_signal(frame: &SignalEntryData) -> !;
//
// syscall get_pid() -> ProcessId;
//
// syscall start_session() -> Result<()>;
// syscall set_process_group_id(pid: ProcessId, pgid: Option<ProcessGroupId>) -> Result<ProcessGroupId>;
//
// syscall get_process_info(what: &mut ProcessInfoElement) -> Result<()>;
// syscall set_process_info(what: &ProcessInfoElement) -> Result<()>;
//
// // C compat
//
// syscall fork() -> Result<ProcessId>;
// syscall execve(opts: &ExecveOptions) -> Result<()>;
//
// // I/O
//
// syscall write(fd: Fd, data: &[u8]) -> Result<usize>;
// syscall read(fd: Fd, data: &mut [u8]) -> Result<usize>;
// syscall open(at: Option<Fd>, path: &str, opts: OpenOptions, mode: FileMode) -> Result<Fd>;
// syscall close(fd: Fd) -> Result<()>;
// syscall mount(options: &MountOptions) -> Result<()>;
// syscall unmount(options: &UnmountOptions) -> Result<()>;
// syscall open_directory(at: Option<Fd>, path: &str) -> Result<Fd>;
// syscall read_directory_entries(fd: Fd, buffer: &mut [MaybeUninit<DirectoryEntry>]) -> Result<usize>;
// syscall create_directory(at: Option<Fd>, path: &str, mode: FileMode) -> Result<()>;
// syscall remove(at: Option<Fd>, path: &str) -> Result<()>;
// syscall remove_directory(at: Option<Fd>, path: &str) -> Result<()>;
// syscall get_metadata(at: Option<Fd>, path: &str, metadata: &mut FileAttr, follow: bool) -> Result<()>;
// // TODO this one is broken
// syscall seek(fd: Fd, pos: SeekFrom) -> Result<usize>;
//
// syscall device_request(fd: Fd, req: &mut DeviceRequest) -> Result<()>;
//
// syscall create_pipe(ends: &mut [MaybeUninit<Fd>; 2]) -> Result<()>;
//
// syscall create_poll_channel() -> Result<Fd>;
// syscall poll_channel_control(poll_fd: Fd, ctl: PollControl, fd: Fd) -> Result<()>;
// syscall poll_channel_wait(poll_fd: Fd, timeout: &Option<Duration>, out: &mut Option<Fd>) -> Result<()>;
//
// syscall open_channel(name: &str, subscribe: bool) -> Result<Fd>;
// syscall send_message(fd: Fd, message: &SentMessage, destination: MessageDestination) -> Result<()>;
// syscall receive_message(
// fd: Fd,
// metadata: &mut MaybeUninit<ReceivedMessageMetadata>,
// buffer: &mut [u8],
// from: &mut MaybeUninit<u32>
// ) -> Result<usize>;
//
// syscall create_shared_memory(size: usize) -> Result<Fd>;
// syscall create_pty(options: &TerminalOptions, size: &TerminalSize, fds: &mut [MaybeUninit<Fd>; 2]) -> Result<()>;
//
// syscall clone_fd(source: Fd, target: Option<Fd>) -> Result<Fd>;
//
// syscall update_metadata(at: Option<Fd>, path: &str, update: &FileMetadataUpdate) -> Result<()>;
//
// syscall create_timer(repeat: bool) -> Result<Fd>;
//
// // Network
//
// syscall bind_socket(listen_address: &SocketAddr, ty: SocketType) -> Result<Fd>;
// syscall connect_socket(
// socket_fd: Option<Fd>,
// remote_address: &SocketAddr,
// ty: SocketType,
// local_address: &mut MaybeUninit<SocketAddr>
// ) -> Result<Fd>;
// syscall send_to(socket_fd: Fd, data: &[u8], recepient: &Option<SocketAddr>) -> Result<usize>;
// syscall receive_from(socket_fd: Fd, buffer: &mut [u8], sender: &mut MaybeUninit<SocketAddr>) -> Result<usize>;
// syscall get_socket_option(socket_fd: Fd, option: &mut SocketOption) -> Result<()>;
// syscall set_socket_option(socket_fd: Fd, option: &SocketOption) -> Result<()>;
// syscall accept(listener: Fd, address: &mut MaybeUninit<SocketAddr>) -> Result<Fd>;