syscalls(2)


NAME
    syscalls - overview of MontaukOS system calls

DESCRIPTION
    MontaukOS provides 150 system calls (numbers 0-149, sparsely
    assigned -- not every number in the range is in use) for
    userspace programs. Syscalls use the x86-64 SYSCALL instruction
    with the following register convention:

        RAX   Syscall number (in) / return value (out)
        RDI   Argument 1
        RSI   Argument 2
        RDX   Argument 3
        R10   Argument 4
        R8    Argument 5
        R9    Argument 6

    Include <Api/Syscall.hpp> for the numeric SYS_* constants and
    ABI structs, and <montauk/syscall.h> for typed wrappers in the
    montauk:: namespace. This page groups syscalls the same way the
    kernel source does (one subsystem header per group).

PROCESS MANAGEMENT
SYS_EXIT (0)
    Terminate the calling process.
        [[noreturn]] void montauk::exit(int code = 0);

SYS_YIELD (1)
    Yield the remainder of the time slice.
        void montauk::yield();

SYS_SLEEP_MS (2)
    Sleep for at least the given number of milliseconds.
        void montauk::sleep_ms(uint64_t ms);

SYS_GETPID (3)
    Return the PID of the calling process.
        int montauk::getpid();

SYS_SPAWN (20)
    Spawn a new process from an ELF binary on the VFS.
        int montauk::spawn(const char* path, const char* args = nullptr);

SYS_WAITPID (23)
    Block until the given process has exited.
        void montauk::waitpid(int pid);

SYS_GETARGS (25)
    Get the argument string passed to this process at spawn time.
        int montauk::getargs(char* buf, uint64_t maxLen);

SYS_PROCLIST (61)
    List running processes (pid, parent, state, name, heap usage,
    accumulated CPU time).
        int montauk::proclist(montauk::abi::ProcInfo* buf, int max);

SYS_KILL (62)
    Terminate another process by PID.
        int montauk::kill(int pid);

SYS_CHDIR (96)
    Change the calling process's current working directory.
        int montauk::chdir(const char* path);

SYS_GETCWD (95)
    Get the calling process's current working directory.
        int montauk::getcwd(char* buf, uint64_t maxLen);

SYS_SETUSER (92)
    Associate a process with a logged-in user name (used by login/session
    management).
        int montauk::setuser(int pid, const char* name);

SYS_GETUSER (93)
    Get the user name associated with the calling process.
        int montauk::getuser(char* buf, uint64_t maxLen);

THREADING
    Threads share the spawning process's address space and heap
    (see montauk/heap.h for the heap lock). Declared in
    montauk/thread.h.

SYS_THREAD_SPAWN (130)
    Spawn a new thread in the calling process. Returns a positive
    TID on success, -1 on failure.
        int montauk::thread_spawn(ThreadEntry entry, void* arg,
                                  uint64_t stack_bytes = 0);

SYS_THREAD_EXIT (131)
    Terminate only the calling thread. If it is the main thread,
    the whole process exits.
        [[noreturn]] void montauk::thread_exit(int code = 0);

SYS_THREAD_JOIN (132)
    Block until the given TID exits, then reclaim its kernel state.
        int montauk::thread_join(int tid, int* out_code = nullptr);

SYS_THREAD_SELF (133)
    Return the calling thread's TID (equals getpid() for the main
    thread).
        int montauk::thread_self();

CONSOLE I/O
SYS_PRINT (4)
    Write a null-terminated string to the terminal.
        void montauk::print(const char* text);

SYS_PUTCHAR (5)
    Write a single character to the terminal.
        void montauk::putchar(char c);

FILE I/O
SYS_OPEN (6)
    Open a file. Returns a handle or negative on error.
        int montauk::open(const char* path);

SYS_READ (7)
    Read bytes from a file at a given offset.
        int montauk::read(int h, uint8_t* buf, uint64_t off, uint64_t sz);

SYS_GETSIZE (8)
    Get the size of an open file in bytes.
        uint64_t montauk::getsize(int handle);

SYS_CLOSE (9)
    Close a file handle.
        void montauk::close(int handle);

SYS_READDIR (10)
    List directory entries (max 256 per call for VFS directories,
    128 for driver-backed listings such as 0:/os/). For larger
    directories use SYS_READDIR_AT.
        int montauk::readdir(const char* path, const char** names, int max);

SYS_READDIR_AT (136)
    Paginated directory read. Returns entries starting at
    startIndex; call repeatedly with startIndex advanced by the
    returned count until it returns 0 to enumerate directories of
    any size.
        int montauk::readdir_at(const char* path, const char** names,
                               int max, int startIndex);

SYS_FWRITE (41)
    Write bytes to a file at a given offset.
        int montauk::fwrite(int handle, const uint8_t* buf,
                           uint64_t offset, uint64_t size);

SYS_FCREATE (42)
    Create a new file on the target volume. Returns a handle or
    negative on error.
        int montauk::fcreate(const char* path);

SYS_FDELETE (77)
    Delete a file.
        int montauk::fdelete(const char* path);

SYS_FMKDIR (78)
    Create a directory.
        int montauk::fmkdir(const char* path);

SYS_FRENAME (94)
    Rename or move a file/directory (used as the basis for file
    manager move operations).
        int montauk::frename(const char* oldPath, const char* newPath);

SYS_DRIVELIST (79)
    List mounted drive numbers.
        int montauk::drivelist(int* outDrives, int max);

SYS_DRIVELABEL (124)
    Get the volume label of a drive.
        int montauk::drivelabel(int drive, char* outLabel, int maxLen);

SYS_DRIVEKIND (127)
    Get the block device kind backing a drive: 0=unknown/ramdisk,
    1=SATA, 2=SATAPI, 3=NVMe, 4=USB mass storage.
        int montauk::drivekind(int drive);

MEMORY
SYS_ALLOC (11)
    Map zeroed pages into the process address space.
        void* montauk::alloc(uint64_t size);

SYS_FREE (12)
    Reserved (currently a no-op).
        void montauk::free(void* ptr);

SYS_MEMSTATS (67)
    Get kernel-wide physical memory usage (total/free/used bytes,
    page size).
        void montauk::memstats(montauk::abi::MemStats* out);

TIMEKEEPING
SYS_GETTICKS (13)
    Get APIC timer ticks since boot.
        uint64_t montauk::get_ticks();

SYS_GETMILLISECONDS (14)
    Get milliseconds elapsed since boot.
        uint64_t montauk::get_milliseconds();

SYS_GETTIME (28)
    Get the current wall-clock date and time (UTC).
    Fills a montauk::abi::DateTime struct with Year, Month, Day,
    Hour, Minute, and Second fields.
        void montauk::gettime(montauk::abi::DateTime* out);

SYS_SETTZ (90)
    Set the process/system timezone offset, in minutes from UTC.
        void montauk::settz(int offset_minutes);

SYS_GETTZ (91)
    Get the current timezone offset, in minutes from UTC.
        int montauk::gettz();

SYSTEM
SYS_GETINFO (15)
    Get OS name, version string, API version, max process count,
    and the monotonic kernel build number.
        void montauk::get_info(montauk::abi::SysInfo* info);

KEYBOARD
SYS_ISKEYAVAILABLE (16)
    Check if a key event is pending (non-blocking).
        bool montauk::is_key_available();

SYS_GETKEY (17)
    Get the next key event (press or release).
        void montauk::getkey(montauk::abi::KeyEvent* out);

SYS_GETCHAR (18)
    Block until a printable character is typed.
        char montauk::getchar();

SYS_INPUT_WAIT (123)
    Block until the input serial number differs from
    observedSerial or the timeout elapses; used to sleep
    efficiently between input-driven redraws.
        uint64_t montauk::input_wait(uint64_t observedSerial, uint64_t timeoutMs);

MOUSE
SYS_MOUSESTATE (47)
    Get the current mouse position, scroll delta, and button mask.
        void montauk::mouse_state(montauk::abi::MouseState* out);

SYS_SETMOUSEBOUNDS (48)
    Set the maximum X/Y the mouse cursor may reach (e.g. framebuffer
    dimensions).
        void montauk::set_mouse_bounds(int32_t maxX, int32_t maxY);

NETWORKING
SYS_PING (19)
    Send an ICMP echo request and wait for reply.
        int32_t montauk::ping(uint32_t ip, uint32_t timeoutMs = 3000);

SYS_RESOLVE (44)
    Resolve a hostname to an IPv4 address via DNS. Sends a UDP
    query to the configured DNS server and waits up to 5 seconds
    for a reply. Returns the IP in network byte order, or 0 on
    failure. IP address strings (e.g. "10.0.0.1") are detected
    and returned directly without a DNS query.
        uint32_t montauk::resolve(const char* hostname);

SYS_GETNETCFG (37)
    Get the current network configuration (IP, mask, gateway, MAC,
    DNS server).
        void montauk::get_netcfg(montauk::abi::NetCfg* out);

SYS_SETNETCFG (38)
    Set the network configuration (IP, mask, gateway, DNS server).
        int montauk::set_netcfg(const montauk::abi::NetCfg* cfg);

SYS_NETSTATUS (125)
    Get adapter status including driver name, link state, polling mode,
    and RX/TX packet counters.
        int montauk::net_status(montauk::abi::NetStatus* out);

SOCKETS
SYS_SOCKET (29)
    Create a socket. type=SOCK_TCP (1) or SOCK_UDP (2).
    Returns fd or -1.
        int montauk::socket(int type);

SYS_CONNECT (30)
    Connect a TCP socket to a remote host.
        int montauk::connect(int fd, uint32_t ip, uint16_t port);

SYS_BIND (31)
    Bind a socket to a local port for listening.
        int montauk::bind(int fd, uint16_t port);

SYS_LISTEN (32)
    Start listening for incoming TCP connections.
        int montauk::listen(int fd);

SYS_ACCEPT (33)
    Accept an incoming connection on a listening socket.
    Returns a new socket fd for the client connection.
        int montauk::accept(int fd);

SYS_SEND (34)
    Send data on a connected socket. Returns bytes sent.
        int montauk::send(int fd, const void* data, uint32_t len);

SYS_RECV (35)
    Receive data from a connected socket. Returns bytes
    received, 0 if no data available, or -1 on close/error.
        int montauk::recv(int fd, void* buf, uint32_t maxLen);

SYS_CLOSESOCK (36)
    Close a socket and release its resources.
        int montauk::closesocket(int fd);

SYS_SENDTO (39)
    Send a UDP datagram to a specific destination.
        int montauk::sendto(int fd, const void* data, uint32_t len,
                           uint32_t destIp, uint16_t destPort);

SYS_RECVFROM (40)
    Receive a UDP datagram. Returns the source address.
        int montauk::recvfrom(int fd, void* buf, uint32_t maxLen,
                             uint32_t* srcIp, uint16_t* srcPort);

FRAMEBUFFER
SYS_FBINFO (21)
    Get framebuffer dimensions and format.
        void montauk::fb_info(montauk::abi::FbInfo* info);

SYS_FBMAP (22)
    Map the framebuffer into process memory.
        void* montauk::fb_map();

TERMINAL
SYS_TERMSIZE (24)
    Get terminal dimensions (columns and rows).
        void montauk::termsize(int* cols, int* rows);

SYS_TERMSCALE (43)
    Get or set the terminal font scale factor. When scale_x is 0,
    returns the current scale as (scale_y << 32 | scale_x). When
    scale_x is non-zero, sets the font scale and returns the new
    terminal dimensions as (rows << 32 | cols).
        void montauk::termscale(int scale_x, int scale_y);
        void montauk::get_termscale(int* scale_x, int* scale_y);

RANDOM
SYS_GETRANDOM (45)
    Fill a buffer with random bytes using RDTSC-seeded entropy.
    Returns the number of bytes written.
        int64_t montauk::getrandom(void* buf, uint32_t len);

POWER MANAGEMENT
SYS_RESET (26)
    Reboot the system.
        [[noreturn]] void montauk::reset();

SYS_SHUTDOWN (27)
    Shut down the system.
        [[noreturn]] void montauk::shutdown();

SYS_SUSPEND (89)
    Enter ACPI S3 sleep. Returns after wake, 0 on success.
        int montauk::suspend();

SYS_POWER_REQUEST (135)
    Cross-process graceful power-off request channel. The desktop
    posts a pending action (POWER_REQ_SHUTDOWN / POWER_REQ_REBOOT)
    then exits; login.elf reads it with POWER_REQ_QUERY
    (read-and-clear), runs the shutdown stages, and finally calls
    shutdown()/reset(). See montauk::abi::PowerRequestAction.
        int montauk::power_request(int action);

SYS_POWERINFO (149)
    Get the CPU power/thermal snapshot (HWP state, throttling,
    package temperature, base/max/effective frequency). Returns 0
    on success, -1 if unsupported by the running hardware.
        int montauk::syscall1(SYS_POWERINFO, (uint64_t)&out);
        // out: montauk::abi::PowerInfo*

KERNEL LOG
SYS_KLOG (46)
    Read from the kernel ring log buffer.
        int64_t montauk::read_klog(char* buf, uint64_t size);

I/O REDIRECTION
    Used by the terminal app and similar programs to run a child
    process with its console I/O captured instead of going directly
    to the framebuffer console.

SYS_SPAWN_REDIR (49)
    Spawn a process with its console I/O redirected to the caller.
        int montauk::spawn_redir(const char* path, const char* args = nullptr);

SYS_CHILDIO_READ (50)
    Read buffered output produced by a redirected child.
        int montauk::childio_read(int childPid, char* buf, int maxLen);

SYS_CHILDIO_WRITE (51)
    Write text input to a redirected child's stdin.
        int montauk::childio_write(int childPid, const char* data, int len);

SYS_CHILDIO_WRITEKEY (52)
    Forward a raw key event to a redirected child.
        int montauk::childio_writekey(int childPid, const montauk::abi::KeyEvent* key);

SYS_CHILDIO_SETTERMSZ (53)
    Tell a redirected child its terminal dimensions changed.
        int montauk::childio_settermsz(int childPid, int cols, int rows);

WINDOW SERVER
    Window server syscalls are used by GUI programs to create and
    drive an on-screen window (see montauk/Window.hpp for the
    higher-level win_create/win_poll/win_present wrappers built on
    top of these).

SYS_WINCREATE (54)
    Create a window and get its pixel buffer.
        int montauk::win_create(const char* title, int w, int h,
                               montauk::abi::WinCreateResult* result);

SYS_WINDESTROY (55)
    Destroy a window.
        int montauk::win_destroy(int id);

SYS_WINPRESENT (56)
    Flush the pixel buffer to the screen.
        uint64_t montauk::win_present(int id);

SYS_WINPOLL (57)
    Poll the next event (key, mouse, resize, close, scale) for a
    window.
        int montauk::win_poll(int id, montauk::abi::WinEvent* event);

SYS_WINENUM (58)
    Enumerate all windows currently managed by the window server.
        int montauk::win_enumerate(montauk::abi::WinInfo* info, int max);

SYS_WINMAP (59)
    Map (or re-map) a window's pixel buffer into the caller's
    address space.
        uint64_t montauk::win_map(int id);

SYS_WINUNMAP (97)
    Unmap a window's pixel buffer from the caller's address space.
        int montauk::win_unmap(int id);

SYS_WINSENDEVENT (60)
    Inject an event into a window's event queue.
        int montauk::win_sendevent(int id, const montauk::abi::WinEvent* event);

SYS_WINRESIZE (64)
    Resize a window and its pixel buffer.
        uint64_t montauk::win_resize(int id, int w, int h);

SYS_WINSETSCALE (65)
    Set the desktop-wide UI scale factor.
        int montauk::win_setscale(int scale);

SYS_WINGETSCALE (66)
    Get the desktop-wide UI scale factor.
        int montauk::win_getscale();

SYS_WINSETCURSOR (68)
    Set the mouse cursor shown while over a window (0=arrow,
    1=resize_h, 2=resize_v).
        int montauk::win_setcursor(int id, int cursor);

SYS_WINSETFLAGS (126)
    Set window flags (e.g. WIN_FLAG_FULLSCREEN).
        int montauk::win_setflags(int id, uint32_t flags);

DEVICES
SYS_DEVLIST (63)
    Enumerate detected devices (CPU, interrupts, timers, input,
    USB, network, display, storage, PCI, audio, ACPI) for the
    device explorer app.
        int montauk::devlist(montauk::abi::DevInfo* buf, int max);

SYS_DISKINFO (69)
    Get detailed info for one block device (model, serial, sector
    size, NCQ/TRIM/SMART support, etc.).
        int montauk::diskinfo(montauk::abi::DiskInfo* buf, int port);

STORAGE
SYS_PARTLIST (70)
    Enumerate GPT partitions across all block devices.
        int montauk::partlist(montauk::abi::PartInfo* buf, int max);

SYS_DISKREAD (71)
    Raw, driver-agnostic sector read from a block device.
        int64_t montauk::disk_read(int blockDev, uint64_t lba,
                                  uint32_t sectorCount, void* buf);

SYS_DISKWRITE (72)
    Raw, driver-agnostic sector write to a block device.
        int64_t montauk::disk_write(int blockDev, uint64_t lba,
                                   uint32_t sectorCount, const void* buf);

SYS_GPTINIT (73)
    Initialize a fresh GPT partition table on a block device.
        int montauk::gpt_init(int blockDev);

SYS_GPTADD (74)
    Add a partition to an existing GPT table.
        int montauk::gpt_add(const montauk::abi::GptAddParams* params);

SYS_FSMOUNT (75)
    Mount a partition's filesystem onto a drive number.
        int montauk::fs_mount(int partIndex, int driveNum);

SYS_FSFORMAT (76)
    Format a partition with a filesystem (FS_TYPE_FAT32 or
    FS_TYPE_EXT2).
        int montauk::fs_format(const montauk::abi::FsFormatParams* params);

SYS_FS_SYNC (134)
    Flush all block-device write caches and cleanly unmount
    disk-backed volumes ahead of power-off. Returns the number of
    volumes unmounted. Part of the graceful shutdown sequence
    (see SYS_POWER_REQUEST).
        int montauk::fs_sync();

AUDIO
SYS_AUDIOOPEN (80)
    Open a mixer output stream at the given sample rate, channel
    count, and bit depth. Returns a stream handle.
        int montauk::audio_open(uint32_t sampleRate, uint8_t channels,
                               uint8_t bitsPerSample);

SYS_AUDIOCLOSE (81)
    Close an audio stream.
        void montauk::audio_close(int handle);

SYS_AUDIOWRITE (82)
    Write PCM samples to an audio stream.
        int montauk::audio_write(int handle, const void* data, uint32_t size);

SYS_AUDIOCTL (83)
    Control an audio stream or the global mixer. Commands 0-3 act
    on the stream named by the handle argument; commands 4-12 act
    on that stream's routing/mute state or the global master and
    ignore or reuse the handle as documented below.
        int montauk::audio_ctl(int handle, int cmd, int value);

    Convenience wrappers (all thin calls onto audio_ctl):
        audio_set_volume, audio_get_volume     AUDIO_CTL_{SET,GET}_VOLUME (0/1)
        audio_get_pos                          AUDIO_CTL_GET_POS (2)
        audio_pause, audio_resume              AUDIO_CTL_PAUSE (3)
        audio_get_output                       AUDIO_CTL_GET_OUTPUT (4): 0=HDA, 1=Bluetooth
        (SET_OUTPUT, 5)                        switch a stream's output route
        audio_bt_status                        AUDIO_CTL_BT_STATUS (6)
        audio_set_master_volume, _get_          AUDIO_CTL_{SET,GET}_MASTER_VOLUME (7/8), 0-100
        audio_set_mute, audio_get_mute         AUDIO_CTL_{SET,GET}_MUTE (9/10), per-stream
        audio_set_master_mute, _get_           AUDIO_CTL_{SET,GET}_MASTER_MUTE (11/12)

SYS_AUDIOLIST (128)
    Enumerate active mixer streams (owner PID, name, format,
    volume, mute/pause state).
        int montauk::audio_list(montauk::abi::AudioStreamInfo* buf, int maxCount);

SYS_AUDIOWAIT (129)
    Return the current mixer state serial. With timeoutMs > 0,
    blocks until the serial differs from prevSerial or the timeout
    elapses; with timeoutMs == 0 it returns immediately.
        uint64_t montauk::audio_wait(uint64_t prevSerial, uint64_t timeoutMs);

BLUETOOTH
SYS_BTSCAN (84)
    Scan for discoverable Bluetooth devices for up to timeoutMs.
        int montauk::bt_scan(montauk::abi::BtScanResult* buf, int maxCount,
                            uint32_t timeoutMs);

SYS_BTCONNECT (85)
    Connect (and pair/bond if needed) to a device by BD_ADDR.
        int montauk::bt_connect(const uint8_t* bdAddr);

SYS_BTDISCONNECT (86)
    Disconnect from a device by BD_ADDR.
        int montauk::bt_disconnect(const uint8_t* bdAddr);

SYS_BTLIST (87)
    List currently connected devices.
        int montauk::bt_list(montauk::abi::BtDevInfo* buf, int maxCount);

SYS_BTINFO (88)
    Get local adapter info (BD_ADDR, name, init/scanning state).
        int montauk::bt_info(montauk::abi::BtAdapterInfo* buf);

SYS_BTSETADDR (137)
    Change the adapter's BD_ADDR (6-byte buffer, byte 0 is the
    least-significant octet). Volatile -- apply after the last
    controller reset and persist separately to bluetooth.toml.
        int montauk::bt_set_addr(const uint8_t* bdAddr);

SYS_BTBONDS (138)
    List bonded (paired) devices.
        int montauk::bt_bonds(montauk::abi::BtBondInfo* buf, int maxCount);

SYS_BTFORGET (139)
    Forget a paired device; it must re-pair next time.
        int montauk::bt_forget(const uint8_t* bdAddr);

SOFTWARE-DEFINED RADIO
    Receive-only SDR API. Receivers are enumerated by index in
    [0, SYS_SDR_COUNT); SYS_SDR_OPEN returns a handle used by the
    rest of the calls. Samples are delivered as interleaved 8-bit
    unsigned I/Q (CU8, SDR_FORMAT_CU8) from the device's ring
    buffer. Backed by an RTL-SDR (RTL2832U + R820T2) driver.

SYS_SDR_COUNT (140)
    Number of available SDR receivers.
        int montauk::sdr_count();

SYS_SDR_INFO (141)
    Get static/dynamic info for one receiver by index (name, tuner,
    frequency/sample-rate ranges, gain steps, present/streaming
    flags).
        int montauk::sdr_info(int index, montauk::abi::SdrDeviceInfo* out);

SYS_SDR_OPEN (142)
    Open a receiver by index. Returns a handle.
        int montauk::sdr_open(int index);

SYS_SDR_CLOSE (143)
    Close a receiver handle.
        int montauk::sdr_close(int handle);

SYS_SDR_START (144)
    Begin streaming samples.
        int montauk::sdr_start(int handle);

SYS_SDR_STOP (145)
    Stop streaming samples.
        int montauk::sdr_stop(int handle);

SYS_SDR_READ (146)
    Non-blocking read of queued I/Q samples. Returns bytes copied.
        int montauk::sdr_read(int handle, void* buf, uint32_t len);

SYS_SDR_SETPARAM (147)
    Set a tunable parameter (see SDR_PARAM_* below).
        int montauk::sdr_set_param(int handle, int param, uint64_t value);

SYS_SDR_GETPARAM (148)
    Get a tunable parameter's current value.
        int64_t montauk::sdr_get_param(int handle, int param);

    Parameters (montauk::abi::SDR_PARAM_*): FREQ (center frequency,
    Hz), SAMPLE_RATE (Hz), GAIN_MODE (0=auto/AGC, 1=manual), GAIN
    (tenths of dB), FREQ_CORR (ppm), AGC (demod digital AGC, 0/1),
    DIRECT_SAMP (0=off, 1=I, 2=Q). Convenience wrappers exist for
    each: sdr_set_freq/sdr_get_freq, sdr_set_sample_rate/
    sdr_get_sample_rate, sdr_set_gain_mode, sdr_set_gain,
    sdr_set_freq_correction, sdr_set_agc.

CLIPBOARD
SYS_CLIPBOARD_SET_TEXT (119)
    Set the system clipboard's text contents (max
    CLIPBOARD_MAX_TEXT_BYTES, 256 KiB).
        int montauk::clipboard_set_text(const char* data, uint32_t len);

SYS_CLIPBOARD_GET_INFO (120)
    Get the clipboard's current size and serial number (for
    change detection).
        int montauk::clipboard_get_info(montauk::abi::ClipboardInfo* out);

SYS_CLIPBOARD_GET_TEXT (121)
    Read the clipboard's text contents.
        int montauk::clipboard_get_text(char* buf, uint32_t bufLen,
                                       uint32_t* outLen, uint64_t* outSerial = nullptr);

SYS_CLIPBOARD_CLEAR (122)
    Clear the clipboard.
        int montauk::clipboard_clear();

GENERIC IPC
    Handle-based IPC primitives underlying streams, mailboxes,
    waitsets, and shared-memory surfaces (see kernel/src/Ipc/Ipc.hpp).
    All are accessed via numeric handles with rights-based security
    and can be waited on with SYS_WAIT_HANDLE or a waitset.

SYS_DUPHANDLE (98)
    Duplicate a handle (e.g. to hand a copy to a child process).
        int montauk::dup_handle(int handle);

SYS_WAIT_HANDLE (99)
    Block until a handle's signals intersect wantedSignals, or
    timeoutMs elapses. See IPC_SIGNAL_* (READABLE, WRITABLE,
    PEER_CLOSED, EXITED, READY).
        uint32_t montauk::wait_handle(int handle, uint32_t wantedSignals,
                                     uint64_t timeoutMs = ~0ULL);

SYS_STREAM_CREATE (100)
    Create a byte-pipe stream, returning a read handle and a write
    handle.
        int montauk::stream_create(int* outReadHandle, int* outWriteHandle,
                                  uint32_t capacity = 0);

SYS_STREAM_READ (101)
    Read bytes from a stream handle.
        int montauk::stream_read(int handle, void* buf, int maxLen);

SYS_STREAM_WRITE (102)
    Write bytes to a stream handle.
        int montauk::stream_write(int handle, const void* data, int len);

SYS_MAILBOX_CREATE (103)
    Create a message-queue mailbox, returning a send handle and a
    receive handle.
        int montauk::mailbox_create(int* outSendHandle, int* outRecvHandle);

SYS_MAILBOX_SEND (104)
    Send a typed message, optionally attaching a handle to
    transfer to the receiver.
        int montauk::mailbox_send(int handle, uint32_t msgType, const void* data,
                                 uint16_t len, int attachHandle = -1);

SYS_MAILBOX_RECV (105)
    Receive a message.
        int montauk::mailbox_recv(int handle, uint32_t* outMsgType, void* data,
                                 uint16_t* inOutLen, int* outAttachHandle = nullptr);

SYS_WAITSET_CREATE (106)
    Create a waitset for multiplexing waits across many handles.
        int montauk::waitset_create();

SYS_WAITSET_ADD (107)
    Add a handle and its signal mask to a waitset.
        int montauk::waitset_add(int waitsetHandle, int targetHandle,
                                uint32_t signals);

SYS_WAITSET_REMOVE (108)
    Remove an entry from a waitset by index.
        int montauk::waitset_remove(int waitsetHandle, int index);

SYS_WAITSET_WAIT (109)
    Block until any member handle's watched signals fire, or
    timeoutMs elapses.
        int montauk::waitset_wait(int waitsetHandle, montauk::abi::IpcWaitResult* outReady,
                                 uint64_t timeoutMs = ~0ULL);

SYS_PROC_OPEN (110)
    Open a handle to another process by PID (for waiting on its
    exit via IPC_SIGNAL_EXITED, etc.).
        int montauk::proc_open(int pid);

SYS_SURFACE_CREATE (111)
    Create a shared pixel-buffer surface of byteSize bytes.
        int montauk::surface_create(uint64_t byteSize);

SYS_SURFACE_MAP (112)
    Map a surface into the caller's address space.
        void* montauk::surface_map(int handle);

SYS_SURFACE_RESIZE (113)
    Resize a surface.
        int montauk::surface_resize(int handle, uint64_t newSize);

SHARED LIBRARIES
SYS_LOAD_LIB (114)
    Load a shared library ELF (.lib) into the caller's address
    space.
        int montauk::load_lib(const char* path);

SYS_UNLOAD_LIB (115)
    Unload a previously loaded library.
        int montauk::unload_lib(int handle);

SYS_DLSYM (116)
    Resolve a symbol offset within a loaded library to a callable
    address.
        void* montauk::dlsym(int handle, uint64_t symbolOffset);

SYS_GETLIBBASE (117)
    Get the base virtual address a loaded library was mapped at.
        uint64_t montauk::get_libbase(int handle);

CRASH REPORTING
SYS_CRASH_REPORT (118)
    Retrieve the kernel-filled crash report for the last faulting
    process (exception vector/name, faulting address, register
    state, page-fault error bits). Used by the crashpad app.
        int montauk::crash_report(montauk::abi::CrashReportInfo* out);

SEE ALSO
    spawn(2), file(2), framebuffer(2), malloc(3), intro(1)

Back to Documentation Index