742 lines
30 KiB
C++
742 lines
30 KiB
C++
/*
|
|
* Syscall.hpp
|
|
* MontaukOS syscall definitions for userspace programs
|
|
* Copyright (c) 2025 Daniel Hammer
|
|
*/
|
|
|
|
#pragma once
|
|
#include <cstdint>
|
|
#include <cstddef>
|
|
|
|
namespace montauk::abi {
|
|
|
|
// Syscall numbers
|
|
static constexpr uint64_t SYS_EXIT = 0;
|
|
static constexpr uint64_t SYS_YIELD = 1;
|
|
static constexpr uint64_t SYS_SLEEP_MS = 2;
|
|
static constexpr uint64_t SYS_GETPID = 3;
|
|
static constexpr uint64_t SYS_PRINT = 4;
|
|
static constexpr uint64_t SYS_PUTCHAR = 5;
|
|
static constexpr uint64_t SYS_OPEN = 6;
|
|
static constexpr uint64_t SYS_READ = 7;
|
|
static constexpr uint64_t SYS_GETSIZE = 8;
|
|
static constexpr uint64_t SYS_CLOSE = 9;
|
|
static constexpr uint64_t SYS_READDIR = 10;
|
|
static constexpr uint64_t SYS_ALLOC = 11;
|
|
static constexpr uint64_t SYS_FREE = 12;
|
|
static constexpr uint64_t SYS_GETTICKS = 13;
|
|
static constexpr uint64_t SYS_GETMILLISECONDS = 14;
|
|
static constexpr uint64_t SYS_GETINFO = 15;
|
|
static constexpr uint64_t SYS_ISKEYAVAILABLE = 16;
|
|
static constexpr uint64_t SYS_GETKEY = 17;
|
|
static constexpr uint64_t SYS_GETCHAR = 18;
|
|
static constexpr uint64_t SYS_PING = 19;
|
|
static constexpr uint64_t SYS_SPAWN = 20;
|
|
static constexpr uint64_t SYS_FBINFO = 21;
|
|
static constexpr uint64_t SYS_FBMAP = 22;
|
|
static constexpr uint64_t SYS_WAITPID = 23;
|
|
static constexpr uint64_t SYS_TERMSIZE = 24;
|
|
static constexpr uint64_t SYS_GETARGS = 25;
|
|
static constexpr uint64_t SYS_RESET = 26;
|
|
static constexpr uint64_t SYS_SHUTDOWN = 27;
|
|
static constexpr uint64_t SYS_GETTIME = 28;
|
|
static constexpr uint64_t SYS_SOCKET = 29;
|
|
static constexpr uint64_t SYS_CONNECT = 30;
|
|
static constexpr uint64_t SYS_BIND = 31;
|
|
static constexpr uint64_t SYS_LISTEN = 32;
|
|
static constexpr uint64_t SYS_ACCEPT = 33;
|
|
static constexpr uint64_t SYS_SEND = 34;
|
|
static constexpr uint64_t SYS_RECV = 35;
|
|
static constexpr uint64_t SYS_CLOSESOCK = 36;
|
|
static constexpr uint64_t SYS_GETNETCFG = 37;
|
|
static constexpr uint64_t SYS_SETNETCFG = 38;
|
|
static constexpr uint64_t SYS_SENDTO = 39;
|
|
static constexpr uint64_t SYS_RECVFROM = 40;
|
|
static constexpr uint64_t SYS_FWRITE = 41;
|
|
static constexpr uint64_t SYS_FCREATE = 42;
|
|
static constexpr uint64_t SYS_FDELETE = 77;
|
|
static constexpr uint64_t SYS_FMKDIR = 78;
|
|
static constexpr uint64_t SYS_DRIVELIST = 79;
|
|
static constexpr uint64_t SYS_TERMSCALE = 43;
|
|
static constexpr uint64_t SYS_RESOLVE = 44;
|
|
static constexpr uint64_t SYS_GETRANDOM = 45;
|
|
static constexpr uint64_t SYS_KLOG = 46;
|
|
static constexpr uint64_t SYS_MOUSESTATE = 47;
|
|
static constexpr uint64_t SYS_SETMOUSEBOUNDS = 48;
|
|
static constexpr uint64_t SYS_SPAWN_REDIR = 49;
|
|
static constexpr uint64_t SYS_CHILDIO_READ = 50;
|
|
static constexpr uint64_t SYS_CHILDIO_WRITE = 51;
|
|
static constexpr uint64_t SYS_CHILDIO_WRITEKEY = 52;
|
|
static constexpr uint64_t SYS_CHILDIO_SETTERMSZ = 53;
|
|
|
|
// Window server syscalls
|
|
static constexpr uint64_t SYS_WINCREATE = 54;
|
|
static constexpr uint64_t SYS_WINDESTROY = 55;
|
|
static constexpr uint64_t SYS_WINPRESENT = 56;
|
|
static constexpr uint64_t SYS_WINPOLL = 57;
|
|
static constexpr uint64_t SYS_WINENUM = 58;
|
|
static constexpr uint64_t SYS_WINMAP = 59;
|
|
static constexpr uint64_t SYS_WINUNMAP = 97;
|
|
static constexpr uint64_t SYS_WINSENDEVENT = 60;
|
|
static constexpr uint64_t SYS_WINRESIZE = 64;
|
|
static constexpr uint64_t SYS_WINSETSCALE = 65;
|
|
static constexpr uint64_t SYS_WINGETSCALE = 66;
|
|
static constexpr uint64_t SYS_WINSETCURSOR = 68;
|
|
static constexpr uint64_t SYS_WINSETFLAGS = 126;
|
|
|
|
// Process management syscalls
|
|
static constexpr uint64_t SYS_PROCLIST = 61;
|
|
static constexpr uint64_t SYS_KILL = 62;
|
|
static constexpr uint64_t SYS_DEVLIST = 63;
|
|
static constexpr uint64_t SYS_DISKINFO = 69;
|
|
|
|
// Kernel introspection syscalls
|
|
static constexpr uint64_t SYS_MEMSTATS = 67;
|
|
|
|
// Storage / partition syscalls
|
|
static constexpr uint64_t SYS_PARTLIST = 70;
|
|
static constexpr uint64_t SYS_DISKREAD = 71;
|
|
static constexpr uint64_t SYS_DISKWRITE = 72;
|
|
static constexpr uint64_t SYS_GPTINIT = 73;
|
|
static constexpr uint64_t SYS_GPTADD = 74;
|
|
static constexpr uint64_t SYS_FSMOUNT = 75;
|
|
static constexpr uint64_t SYS_FSFORMAT = 76;
|
|
|
|
// Audio syscalls
|
|
static constexpr uint64_t SYS_AUDIOOPEN = 80;
|
|
static constexpr uint64_t SYS_AUDIOCLOSE = 81;
|
|
static constexpr uint64_t SYS_AUDIOWRITE = 82;
|
|
static constexpr uint64_t SYS_AUDIOCTL = 83;
|
|
|
|
// Bluetooth syscalls
|
|
static constexpr uint64_t SYS_BTSCAN = 84;
|
|
static constexpr uint64_t SYS_BTCONNECT = 85;
|
|
static constexpr uint64_t SYS_BTDISCONNECT = 86;
|
|
static constexpr uint64_t SYS_BTLIST = 87;
|
|
static constexpr uint64_t SYS_BTINFO = 88;
|
|
|
|
// Power management
|
|
static constexpr uint64_t SYS_SUSPEND = 89;
|
|
|
|
// Timezone
|
|
static constexpr uint64_t SYS_SETTZ = 90;
|
|
static constexpr uint64_t SYS_GETTZ = 91;
|
|
|
|
// User management
|
|
static constexpr uint64_t SYS_SETUSER = 92;
|
|
static constexpr uint64_t SYS_GETUSER = 93;
|
|
static constexpr uint64_t SYS_FRENAME = 94;
|
|
static constexpr uint64_t SYS_GETCWD = 95;
|
|
static constexpr uint64_t SYS_CHDIR = 96;
|
|
static constexpr uint64_t SYS_DUPHANDLE = 98;
|
|
static constexpr uint64_t SYS_WAIT_HANDLE = 99;
|
|
static constexpr uint64_t SYS_STREAM_CREATE = 100;
|
|
static constexpr uint64_t SYS_STREAM_READ = 101;
|
|
static constexpr uint64_t SYS_STREAM_WRITE = 102;
|
|
static constexpr uint64_t SYS_MAILBOX_CREATE = 103;
|
|
static constexpr uint64_t SYS_MAILBOX_SEND = 104;
|
|
static constexpr uint64_t SYS_MAILBOX_RECV = 105;
|
|
static constexpr uint64_t SYS_WAITSET_CREATE = 106;
|
|
static constexpr uint64_t SYS_WAITSET_ADD = 107;
|
|
static constexpr uint64_t SYS_WAITSET_REMOVE = 108;
|
|
static constexpr uint64_t SYS_WAITSET_WAIT = 109;
|
|
static constexpr uint64_t SYS_PROC_OPEN = 110;
|
|
static constexpr uint64_t SYS_SURFACE_CREATE = 111;
|
|
static constexpr uint64_t SYS_SURFACE_MAP = 112;
|
|
static constexpr uint64_t SYS_SURFACE_RESIZE = 113;
|
|
|
|
// Shared library syscalls
|
|
static constexpr uint64_t SYS_LOAD_LIB = 114;
|
|
static constexpr uint64_t SYS_UNLOAD_LIB = 115;
|
|
static constexpr uint64_t SYS_DLSYM = 116;
|
|
static constexpr uint64_t SYS_GETLIBBASE = 117;
|
|
|
|
/* CrashReport */
|
|
static constexpr uint64_t SYS_CRASH_REPORT = 118;
|
|
static constexpr uint64_t SYS_CLIPBOARD_SET_TEXT = 119;
|
|
static constexpr uint64_t SYS_CLIPBOARD_GET_INFO = 120;
|
|
static constexpr uint64_t SYS_CLIPBOARD_GET_TEXT = 121;
|
|
static constexpr uint64_t SYS_CLIPBOARD_CLEAR = 122;
|
|
static constexpr uint64_t SYS_INPUT_WAIT = 123;
|
|
static constexpr uint64_t SYS_DRIVELABEL = 124;
|
|
static constexpr uint64_t SYS_NETSTATUS = 125;
|
|
static constexpr uint64_t SYS_DRIVEKIND = 127;
|
|
|
|
// Audio mixer enumeration
|
|
static constexpr uint64_t SYS_AUDIOLIST = 128;
|
|
// Block until the mixer state serial differs from the caller's snapshot.
|
|
static constexpr uint64_t SYS_AUDIOWAIT = 129;
|
|
|
|
// Threading
|
|
static constexpr uint64_t SYS_THREAD_SPAWN = 130;
|
|
static constexpr uint64_t SYS_THREAD_EXIT = 131;
|
|
static constexpr uint64_t SYS_THREAD_JOIN = 132;
|
|
static constexpr uint64_t SYS_THREAD_SELF = 133;
|
|
|
|
// Flush + unmount persistent volumes for power-off
|
|
static constexpr uint64_t SYS_FS_SYNC = 134;
|
|
|
|
// Cross-process graceful power-off request channel
|
|
static constexpr uint64_t SYS_POWER_REQUEST = 135;
|
|
|
|
// Paginated directory read (path, names, max, startIndex)
|
|
static constexpr uint64_t SYS_READDIR_AT = 136;
|
|
|
|
// Set adapter BD_ADDR (6-byte buffer, addr[0] = LSB)
|
|
static constexpr uint64_t SYS_BTSETADDR = 137;
|
|
|
|
// List bonded (paired) devices / forget a bond
|
|
static constexpr uint64_t SYS_BTBONDS = 138;
|
|
static constexpr uint64_t SYS_BTFORGET = 139;
|
|
|
|
/* Sdr.hpp -- software-defined radio receive API */
|
|
static constexpr uint64_t SYS_SDR_COUNT = 140; // number of receivers
|
|
static constexpr uint64_t SYS_SDR_INFO = 141; // (index, SdrDeviceInfo*)
|
|
static constexpr uint64_t SYS_SDR_OPEN = 142; // (index) -> handle
|
|
static constexpr uint64_t SYS_SDR_CLOSE = 143; // (handle)
|
|
static constexpr uint64_t SYS_SDR_START = 144; // (handle) begin streaming
|
|
static constexpr uint64_t SYS_SDR_STOP = 145; // (handle) stop streaming
|
|
static constexpr uint64_t SYS_SDR_READ = 146; // (handle, buf, len) -> bytes
|
|
static constexpr uint64_t SYS_SDR_SETPARAM = 147; // (handle, param, value)
|
|
static constexpr uint64_t SYS_SDR_GETPARAM = 148; // (handle, param) -> value
|
|
|
|
// CPU power/thermal status
|
|
static constexpr uint64_t SYS_POWERINFO = 149; // (PowerInfo*) -> 0, -1 unsupported
|
|
|
|
// Framebuffer page flip (double-buffered scanout)
|
|
static constexpr uint64_t SYS_FBFLIP = 150;
|
|
|
|
// Absolute path of the running executable (for argv[0]).
|
|
static constexpr uint64_t SYS_GETEXECPATH = 151; // (index, flags) -> new front index; index=-1 queries support (1/0); flags bit0 = wait vsync
|
|
|
|
// Path metadata (size, timestamps, mode). (const char* path, FileStat* out) -> 0, -1 on error/unsupported.
|
|
static constexpr uint64_t SYS_STAT = 152;
|
|
static constexpr uint64_t SYS_SETUNIXTIME = 153;
|
|
|
|
// Display/modesetting control
|
|
static constexpr uint64_t SYS_DISPLAYINFO = 154;
|
|
static constexpr uint64_t SYS_DISPLAYMODES = 155;
|
|
static constexpr uint64_t SYS_DISPLAYSETMODE = 156;
|
|
static constexpr uint64_t SYS_DISPLAYBRIGHTNESS = 157;
|
|
|
|
// Wi-Fi adapter control
|
|
static constexpr uint64_t SYS_WIFI_SCAN = 158; // (WifiNetwork*, maxCount, timeoutMs) -> count
|
|
static constexpr uint64_t SYS_WIFI_INFO = 159; // (WifiInfo*) -> 0, -1 if absent
|
|
static constexpr uint64_t SYS_WIFI_CONNECT = 160; // (ssid, password) -> 0, <0 on error
|
|
static constexpr uint64_t SYS_WIFI_DISCONNECT = 161; // () -> 0
|
|
static constexpr uint64_t SYS_WIFI_SCAN_START = 162; // (timeoutMs) -> 0 started, 1 busy, -1 no adapter
|
|
static constexpr uint64_t SYS_WIFI_RESULTS = 163; // (WifiNetwork*, maxCount) -> count, no radio work
|
|
static constexpr uint64_t SYS_WIFI_CONNECT_ASYNC = 164; // (ssid, password) -> 0 accepted, <0 on error
|
|
static constexpr uint64_t SYS_NETIFS = 165; // (NetIfInfo*, maxCount) -> count
|
|
static constexpr uint64_t SYS_GETCHAR_NB = 166; // () -> ascii, 0 if nothing pending; never blocks
|
|
static constexpr uint64_t SYS_UTIME = 167;
|
|
static constexpr uint64_t SYS_MMAP_ANON = 168;
|
|
static constexpr uint64_t SYS_MUNMAP = 169;
|
|
static constexpr uint64_t SYS_MPROTECT = 170;
|
|
static constexpr uint64_t SYS_GETENVIRON = 171;
|
|
static constexpr uint64_t SYS_SETENVIRON = 172;
|
|
static constexpr uint64_t SYS_SPAWN_ENV = 173;
|
|
|
|
// Tunable parameters (for SYS_SDR_SETPARAM / SYS_SDR_GETPARAM).
|
|
static constexpr int SDR_PARAM_FREQ = 0; // center frequency, Hz
|
|
static constexpr int SDR_PARAM_SAMPLE_RATE = 1; // sample rate, Hz
|
|
static constexpr int SDR_PARAM_GAIN_MODE = 2; // 0 = auto/AGC, 1 = manual
|
|
static constexpr int SDR_PARAM_GAIN = 3; // tuner gain, tenths of dB
|
|
static constexpr int SDR_PARAM_FREQ_CORR = 4; // frequency correction, ppm
|
|
static constexpr int SDR_PARAM_AGC = 5; // demod digital AGC, 0/1
|
|
static constexpr int SDR_PARAM_DIRECT_SAMP = 6; // direct sampling: 0=off,1=I,2=Q
|
|
|
|
// Sample formats reported in SdrDeviceInfo.sampleFormat.
|
|
static constexpr uint8_t SDR_FORMAT_CU8 = 0; // 8-bit unsigned interleaved I/Q
|
|
|
|
// Graceful power-off request actions (SYS_POWER_REQUEST). The desktop posts
|
|
// a pending action and exits; login.elf reads it, runs the shutdown stages,
|
|
// then issues the matching SYS_SHUTDOWN / SYS_RESET.
|
|
enum PowerRequestAction : int {
|
|
POWER_REQ_QUERY = 0, // read-and-clear the pending action
|
|
POWER_REQ_SHUTDOWN = 1,
|
|
POWER_REQ_REBOOT = 2,
|
|
};
|
|
|
|
static constexpr uint32_t CLIPBOARD_MAX_TEXT_BYTES = 256 * 1024;
|
|
|
|
static constexpr uint32_t IPC_SIGNAL_READABLE = 1u << 0;
|
|
static constexpr uint32_t IPC_SIGNAL_WRITABLE = 1u << 1;
|
|
static constexpr uint32_t IPC_SIGNAL_PEER_CLOSED = 1u << 2;
|
|
static constexpr uint32_t IPC_SIGNAL_EXITED = 1u << 3;
|
|
static constexpr uint32_t IPC_SIGNAL_READY = 1u << 4;
|
|
|
|
// Audio control commands (for SYS_AUDIOCTL).
|
|
//
|
|
// Commands 0..3 act on the stream named by the handle argument.
|
|
// Commands 7..12 act on the global master and ignore the handle.
|
|
static constexpr int AUDIO_CTL_SET_VOLUME = 0;
|
|
static constexpr int AUDIO_CTL_GET_VOLUME = 1;
|
|
static constexpr int AUDIO_CTL_GET_POS = 2;
|
|
static constexpr int AUDIO_CTL_PAUSE = 3;
|
|
static constexpr int AUDIO_CTL_GET_OUTPUT = 4; // 0=HDA, 1=Bluetooth
|
|
static constexpr int AUDIO_CTL_SET_OUTPUT = 5; // Switch audio output
|
|
static constexpr int AUDIO_CTL_BT_STATUS = 6; // 0=unavailable, 1=setup, 2=ready
|
|
static constexpr int AUDIO_CTL_SET_MASTER_VOLUME = 7; // 0-100
|
|
static constexpr int AUDIO_CTL_GET_MASTER_VOLUME = 8;
|
|
static constexpr int AUDIO_CTL_SET_MUTE = 9; // 0/1, per-stream
|
|
static constexpr int AUDIO_CTL_GET_MUTE = 10;
|
|
static constexpr int AUDIO_CTL_SET_MASTER_MUTE = 11;
|
|
static constexpr int AUDIO_CTL_GET_MASTER_MUTE = 12;
|
|
static constexpr int AUDIO_OUTPUT_HDA = 0;
|
|
static constexpr int AUDIO_OUTPUT_BLUETOOTH = 1;
|
|
|
|
static constexpr int SOCK_TCP = 1;
|
|
static constexpr int SOCK_UDP = 2;
|
|
|
|
struct NetCfg {
|
|
uint32_t ipAddress; // network byte order
|
|
uint32_t subnetMask; // network byte order
|
|
uint32_t gateway; // network byte order
|
|
uint8_t macAddress[6];
|
|
uint8_t _pad[2];
|
|
uint32_t dnsServer; // network byte order
|
|
};
|
|
|
|
struct NetStatus {
|
|
uint8_t initialized;
|
|
uint8_t linkUp;
|
|
uint8_t polling;
|
|
uint8_t _pad0;
|
|
char driver[32];
|
|
uint64_t rxPackets;
|
|
uint64_t txPackets;
|
|
};
|
|
|
|
struct DateTime {
|
|
uint16_t Year;
|
|
uint8_t Month;
|
|
uint8_t Day;
|
|
uint8_t Hour;
|
|
uint8_t Minute;
|
|
uint8_t Second;
|
|
};
|
|
|
|
// Path metadata returned by SYS_STAT. Timestamps are UTC unix seconds;
|
|
// a filesystem that does not record a given time reports it as 0.
|
|
struct FileStat {
|
|
uint64_t size; // file size in bytes
|
|
int64_t mtime; // last data modification time
|
|
int64_t ctime; // last inode (metadata) change time
|
|
int64_t atime; // last access time
|
|
uint32_t mode; // ext2/POSIX mode bits (type + permissions)
|
|
uint32_t isDir; // 1 if the entry is a directory, else 0
|
|
};
|
|
|
|
struct FbInfo {
|
|
uint64_t width;
|
|
uint64_t height;
|
|
uint64_t pitch; // bytes per scanline
|
|
uint64_t bpp; // bits per pixel (32)
|
|
uint64_t userAddr; // filled by SYS_FBMAP (0 until mapped)
|
|
};
|
|
|
|
enum DisplayConnectorType : uint8_t {
|
|
DISPLAY_CONNECTOR_UNKNOWN = 0,
|
|
DISPLAY_CONNECTOR_EDP = 1,
|
|
DISPLAY_CONNECTOR_DP = 2,
|
|
DISPLAY_CONNECTOR_HDMI = 3,
|
|
DISPLAY_CONNECTOR_DVI = 4,
|
|
DISPLAY_CONNECTOR_VGA = 5,
|
|
DISPLAY_CONNECTOR_LVDS = 6,
|
|
};
|
|
|
|
static constexpr uint32_t DISPLAY_CAP_MODESET = 1u << 0;
|
|
static constexpr uint32_t DISPLAY_CAP_EDID = 1u << 1;
|
|
static constexpr uint32_t DISPLAY_CAP_BRIGHTNESS = 1u << 2;
|
|
static constexpr uint32_t DISPLAY_CAP_PAGE_FLIP = 1u << 3;
|
|
static constexpr uint32_t DISPLAY_CAP_VBLANK_IRQ = 1u << 4;
|
|
static constexpr uint32_t DISPLAY_CAP_SAFE_SWITCH = 1u << 5;
|
|
|
|
static constexpr uint32_t DISPLAY_MODE_PREFERRED = 1u << 0;
|
|
static constexpr uint32_t DISPLAY_MODE_CURRENT = 1u << 1;
|
|
static constexpr uint32_t DISPLAY_MODE_DRIVER_VALID = 1u << 2;
|
|
|
|
struct DisplayModeInfo {
|
|
uint32_t width;
|
|
uint32_t height;
|
|
uint32_t refreshMilliHz;
|
|
uint32_t pixelClockKHz;
|
|
uint32_t flags;
|
|
uint32_t _pad;
|
|
};
|
|
|
|
struct DisplayInfo {
|
|
uint32_t capabilities;
|
|
uint32_t modeCount;
|
|
int32_t currentMode;
|
|
int32_t brightness; // 0..100, or -1 when unavailable
|
|
uint16_t deviceId;
|
|
uint8_t generation;
|
|
uint8_t connectorType;
|
|
uint8_t connected;
|
|
uint8_t _pad0[3];
|
|
char gpuName[64];
|
|
char connectorName[32];
|
|
char monitorName[64];
|
|
};
|
|
|
|
struct SysInfo {
|
|
char osName[32];
|
|
char osVersion[32];
|
|
uint32_t apiVersion;
|
|
uint32_t maxProcesses;
|
|
uint32_t buildNumber; // monotonic kernel build number
|
|
};
|
|
|
|
struct KeyEvent {
|
|
uint8_t scancode;
|
|
char ascii;
|
|
bool pressed;
|
|
bool shift;
|
|
bool ctrl;
|
|
bool alt;
|
|
bool capslock;
|
|
// Right Alt held, reported separately from alt so keyboard layouts can
|
|
// use it as AltGr without swallowing left-Alt shortcuts.
|
|
bool altgr;
|
|
// Key came from an E0-prefixed scancode (keypad "/" and Enter share a
|
|
// scancode with the main-block keys). Layout translation must skip it.
|
|
bool extended;
|
|
};
|
|
|
|
struct MouseState {
|
|
int32_t x;
|
|
int32_t y;
|
|
int32_t scrollDelta;
|
|
uint8_t buttons;
|
|
};
|
|
|
|
struct IpcWaitResult {
|
|
int32_t index;
|
|
uint32_t signals;
|
|
};
|
|
|
|
struct ClipboardInfo {
|
|
uint32_t textBytes;
|
|
uint32_t _pad;
|
|
uint64_t serial;
|
|
};
|
|
|
|
// One entry per active mixer stream; returned by SYS_AUDIOLIST.
|
|
struct AudioStreamInfo {
|
|
int32_t handle;
|
|
int32_t ownerPid;
|
|
char name[64];
|
|
uint32_t sampleRate;
|
|
uint8_t channels;
|
|
uint8_t bitsPerSample;
|
|
uint8_t volume; // 0-100
|
|
uint8_t muted; // 0/1
|
|
uint8_t paused; // 0/1
|
|
uint8_t _pad[7];
|
|
};
|
|
|
|
// Window server shared types
|
|
struct WinEvent {
|
|
uint8_t type; // 0=key, 1=mouse, 2=resize, 3=close, 4=scale
|
|
uint8_t _pad[3];
|
|
union {
|
|
KeyEvent key;
|
|
struct { int32_t x, y, scroll; uint8_t buttons, prev_buttons; } mouse;
|
|
struct { int32_t w, h; } resize;
|
|
struct { int32_t scale; } scale;
|
|
};
|
|
};
|
|
|
|
struct WinInfo {
|
|
int32_t id;
|
|
int32_t ownerPid;
|
|
char title[64];
|
|
int32_t width, height;
|
|
uint8_t dirty;
|
|
uint8_t cursor; // 0=arrow, 1=resize_h, 2=resize_v
|
|
uint8_t _pad2[2];
|
|
uint32_t flags;
|
|
};
|
|
|
|
static constexpr uint32_t WIN_FLAG_FULLSCREEN = 1u << 0;
|
|
|
|
struct WinCreateResult {
|
|
int32_t id; // -1 on failure
|
|
uint32_t _pad;
|
|
uint64_t pixelVa; // VA of pixel buffer in caller's address space
|
|
};
|
|
|
|
struct DevInfo {
|
|
uint8_t category; // 0=CPU, 1=Interrupt, 2=Timer, 3=Input, 4=USB, 5=Network, 6=Display, 7=Storage, 8=PCI, 9=Audio, 10=ACPI
|
|
uint8_t _pad[3];
|
|
char name[48];
|
|
char detail[48];
|
|
};
|
|
|
|
struct DiskInfo {
|
|
uint8_t port; // block device index
|
|
uint8_t type; // 0=none, 1=SATA, 2=SATAPI, 3=NVMe, 4=USB mass storage
|
|
uint8_t sataGen; // SATA gen (1/2/3)
|
|
uint8_t _pad0;
|
|
uint64_t sectorCount; // Total user-addressable sectors
|
|
uint16_t sectorSizeLog; // Logical sector size (bytes)
|
|
uint16_t sectorSizePhys; // Physical sector size (bytes)
|
|
uint16_t rpm; // 0=unknown, 1=SSD, else RPM
|
|
uint16_t ncqDepth; // 0 if no NCQ
|
|
uint8_t supportsLba48;
|
|
uint8_t supportsNcq;
|
|
uint8_t supportsTrim;
|
|
uint8_t supportsSmart;
|
|
uint8_t supportsWriteCache;
|
|
uint8_t supportsReadAhead;
|
|
uint8_t _pad1[2];
|
|
char model[41];
|
|
char serial[21];
|
|
char firmware[9];
|
|
char _pad2[1];
|
|
};
|
|
|
|
struct PartGuid {
|
|
uint32_t Data1;
|
|
uint16_t Data2;
|
|
uint16_t Data3;
|
|
uint8_t Data4[8];
|
|
};
|
|
|
|
struct PartInfo {
|
|
int32_t blockDev; // block device index
|
|
uint32_t _pad0;
|
|
uint64_t startLba;
|
|
uint64_t endLba;
|
|
uint64_t sectorCount;
|
|
PartGuid typeGuid;
|
|
PartGuid uniqueGuid;
|
|
uint64_t attributes;
|
|
char name[72]; // ASCII partition name
|
|
char typeName[24]; // human-readable type name
|
|
};
|
|
|
|
struct GptAddParams {
|
|
int32_t blockDev;
|
|
uint32_t _pad0;
|
|
uint64_t startLba; // 0 = auto (fill largest free region)
|
|
uint64_t endLba; // 0 = auto
|
|
PartGuid typeGuid;
|
|
char name[72];
|
|
};
|
|
|
|
// Filesystem type IDs for SYS_FSFORMAT
|
|
static constexpr int FS_TYPE_FAT32 = 1;
|
|
static constexpr int FS_TYPE_EXT2 = 2;
|
|
|
|
struct FsFormatParams {
|
|
int32_t partIndex; // global partition index
|
|
int32_t fsType; // FS_TYPE_FAT32, etc.
|
|
char label[32]; // volume label
|
|
};
|
|
|
|
// Bluetooth scan result (returned by SYS_BTSCAN)
|
|
struct BtScanResult {
|
|
uint8_t bdAddr[6];
|
|
uint8_t _pad[2];
|
|
uint32_t classOfDevice;
|
|
int8_t rssi;
|
|
uint8_t _pad2[3];
|
|
char name[64];
|
|
};
|
|
|
|
// Bluetooth connected device info (returned by SYS_BTLIST)
|
|
struct BtDevInfo {
|
|
uint8_t bdAddr[6];
|
|
uint8_t connected;
|
|
uint8_t encrypted;
|
|
uint16_t handle;
|
|
uint8_t linkType;
|
|
uint8_t _pad;
|
|
};
|
|
|
|
// Bluetooth adapter info (returned by SYS_BTINFO)
|
|
struct BtAdapterInfo {
|
|
uint8_t bdAddr[6];
|
|
uint8_t initialized;
|
|
uint8_t scanning;
|
|
char name[64];
|
|
};
|
|
|
|
// Bluetooth bonded (paired) device (returned by SYS_BTBONDS)
|
|
struct BtBondInfo {
|
|
uint8_t bdAddr[6];
|
|
uint8_t _pad[2];
|
|
};
|
|
|
|
// Software-defined radio receiver description (returned by SYS_SDR_INFO).
|
|
struct SdrDeviceInfo {
|
|
char name[64]; // e.g. "Realtek RTL2832U"
|
|
char tuner[32]; // e.g. "Rafael Micro R820T2"
|
|
char serial[32]; // device serial / bus location
|
|
uint64_t freqMin; // minimum tunable center frequency, Hz
|
|
uint64_t freqMax; // maximum tunable center frequency, Hz
|
|
uint32_t sampleRateMin; // minimum sample rate, Hz
|
|
uint32_t sampleRateMax; // maximum sample rate, Hz
|
|
uint32_t numGains; // number of discrete tuner gain steps
|
|
int32_t gains[32]; // available gains, tenths of dB
|
|
uint8_t sampleFormat; // SDR_FORMAT_*
|
|
uint8_t present; // 1 if the underlying hardware is connected
|
|
uint8_t streaming; // 1 if currently delivering samples
|
|
uint8_t _pad;
|
|
uint32_t _pad2;
|
|
};
|
|
|
|
// Wi-Fi security suites reported in WifiNetwork.security.
|
|
static constexpr uint8_t WIFI_SEC_OPEN = 0;
|
|
static constexpr uint8_t WIFI_SEC_WEP = 1;
|
|
static constexpr uint8_t WIFI_SEC_WPA = 2;
|
|
static constexpr uint8_t WIFI_SEC_WPA2 = 3;
|
|
static constexpr uint8_t WIFI_SEC_WPA3 = 4;
|
|
|
|
// Adapter states reported in WifiInfo.state.
|
|
static constexpr uint8_t WIFI_STATE_ABSENT = 0; // no device
|
|
static constexpr uint8_t WIFI_STATE_DETECTED = 1; // waiting for firmware load
|
|
static constexpr uint8_t WIFI_STATE_BOOTING = 2;
|
|
static constexpr uint8_t WIFI_STATE_RUNNING = 3;
|
|
static constexpr uint8_t WIFI_STATE_ERROR = 4;
|
|
static constexpr uint8_t WIFI_STATE_RFKILL = 5; // radio disabled in hardware
|
|
|
|
// One scanned network (returned by SYS_WIFI_SCAN).
|
|
struct WifiNetwork {
|
|
char ssid[36]; // NUL-terminated; empty for hidden networks
|
|
uint8_t bssid[6];
|
|
uint8_t channel;
|
|
int8_t rssi; // dBm
|
|
uint8_t band; // 0 = 2.4 GHz, 1 = 5 GHz
|
|
uint8_t security; // WIFI_SEC_*
|
|
uint16_t beaconInterval; // TU
|
|
};
|
|
|
|
// Association progress reported in WifiInfo.connState.
|
|
static constexpr uint32_t WIFI_CONN_IDLE = 0;
|
|
static constexpr uint32_t WIFI_CONN_CONTEXTS_UP = 1;
|
|
static constexpr uint32_t WIFI_CONN_AUTHENTICATING = 2;
|
|
static constexpr uint32_t WIFI_CONN_AUTHENTICATED = 3;
|
|
static constexpr uint32_t WIFI_CONN_ASSOCIATING = 4;
|
|
static constexpr uint32_t WIFI_CONN_ASSOCIATED = 5;
|
|
static constexpr uint32_t WIFI_CONN_HANDSHAKING = 6;
|
|
static constexpr uint32_t WIFI_CONN_CONNECTED = 7;
|
|
static constexpr uint32_t WIFI_CONN_FAILED = 8;
|
|
|
|
// Negative results from SYS_WIFI_CONNECT.
|
|
static constexpr int WIFI_ERR_NO_ADAPTER = -1; // no adapter, or not ready
|
|
static constexpr int WIFI_ERR_NOT_FOUND = -2; // SSID absent from the scan
|
|
static constexpr int WIFI_ERR_NEED_KEY = -3; // encrypted, no passphrase
|
|
static constexpr int WIFI_ERR_UNSUPPORTED = -4; // WPA3-SAE, WEP, enterprise
|
|
static constexpr int WIFI_ERR_AUTH = -5; // key exchange rejected
|
|
static constexpr int WIFI_ERR_TIMEOUT = -6; // AP never answered
|
|
static constexpr int WIFI_ERR_FAILED = -7; // anything else
|
|
|
|
// Adapter status (returned by SYS_WIFI_INFO).
|
|
struct WifiInfo {
|
|
uint8_t mac[6];
|
|
uint8_t present; // 1 if a supported device was found
|
|
uint8_t state; // WIFI_STATE_*
|
|
uint8_t scanning;
|
|
uint8_t bands; // bit0 = 2.4 GHz, bit1 = 5 GHz
|
|
uint16_t channels; // usable channels after regulatory filtering
|
|
char fwVersion[32];
|
|
uint64_t rxPackets;
|
|
uint32_t fwErrors;
|
|
uint32_t connState; // WIFI_CONN_*
|
|
uint64_t txPackets;
|
|
char ssid[36]; // network joined, empty when disconnected
|
|
uint8_t bssid[6];
|
|
uint8_t connected; // 1 once the link can carry IP traffic
|
|
uint8_t channel;
|
|
int32_t lastError; // WIFI_ERR_* from the last async join, 0 = none
|
|
uint32_t scanGeneration; // bumped every time a scan finishes
|
|
uint8_t joining; // 1 while an async join is in flight
|
|
uint8_t _pad[3];
|
|
};
|
|
|
|
// Link-layer interface kinds reported in NetIfInfo.kind.
|
|
static constexpr uint8_t NETIF_KIND_ETHERNET = 0;
|
|
static constexpr uint8_t NETIF_KIND_WIRELESS = 1;
|
|
|
|
// One registered link-layer interface (returned by SYS_NETIFS). The IP
|
|
// configuration is global to the stack, so it belongs to whichever
|
|
// interface reports active = 1.
|
|
struct NetIfInfo {
|
|
char name[16]; // "eth0", "wlan0"
|
|
uint8_t mac[6];
|
|
uint8_t kind; // NETIF_KIND_*
|
|
uint8_t linkUp;
|
|
uint8_t active; // 1 if this is the interface carrying traffic
|
|
uint8_t _pad[3];
|
|
};
|
|
|
|
struct ThermalInfo {
|
|
char name[32]; // short zone name (e.g. "THRM", "TZ00")
|
|
int32_t temperature; // tenths of degrees Celsius, or -1 if unavailable
|
|
uint32_t _pad;
|
|
};
|
|
|
|
// CPU power/thermal snapshot (returned by SYS_POWERINFO)
|
|
struct PowerInfo {
|
|
uint8_t hwpActive; // hardware P-state scaling enabled
|
|
uint8_t throttling; // thermal governor currently limiting frequency
|
|
uint8_t tempC; // package temperature, degrees C (0 = unknown)
|
|
uint8_t tjMaxC; // hardware throttle temperature
|
|
uint8_t highestPerf; // HWP performance range (ratio units)
|
|
uint8_t lowestPerf;
|
|
uint8_t curMaxPerf; // thermal governor's current ceiling
|
|
uint8_t epp; // energy/perf preference (0=perf, 255=power)
|
|
uint32_t baseMHz; // nominal base frequency (0 = unknown)
|
|
uint32_t maxMHz; // max turbo frequency
|
|
uint32_t effMHz; // measured average active frequency
|
|
uint32_t apIdleHint; // MWAIT hint used for AP deep idle
|
|
};
|
|
|
|
struct ProcInfo {
|
|
int32_t pid;
|
|
int32_t parentPid;
|
|
uint8_t state; // 0=Free, 1=Ready, 2=Running, 3=Blocked, 4=Terminated
|
|
uint8_t _pad[3];
|
|
char name[64];
|
|
uint64_t heapUsed; // heapNext - UserHeapBase (bytes)
|
|
uint64_t cpuTimeMs; // accumulated scheduler runtime
|
|
};
|
|
|
|
struct MemStats {
|
|
uint64_t totalBytes;
|
|
uint64_t freeBytes;
|
|
uint64_t usedBytes;
|
|
uint64_t pageSize;
|
|
};
|
|
|
|
// Crash report (filled by kernel on process fault, returned via SYS_CRASH_REPORT)
|
|
struct CrashReportInfo {
|
|
int pid;
|
|
char processName[64];
|
|
uint8_t exceptionVector;
|
|
char exceptionName[32];
|
|
uint64_t faultingAddress;
|
|
uint64_t instructionPointer;
|
|
uint64_t stackPointer;
|
|
uint64_t codeSegment;
|
|
uint64_t flags;
|
|
uint64_t stackSegment;
|
|
uint64_t stackWords[8];
|
|
uint8_t stackWordCount;
|
|
uint8_t pfPresent : 1;
|
|
uint8_t pfWrite : 1;
|
|
uint8_t pfUser : 1;
|
|
uint8_t pfReservedWrite : 1;
|
|
uint8_t pfInstructionFetch : 1;
|
|
uint8_t pfProtectionKey : 1;
|
|
uint8_t pfShadowStack : 1;
|
|
uint8_t pfSGX : 1;
|
|
uint64_t timestampTick;
|
|
};
|
|
|
|
}
|