Files
ViperOS/abi/linux.vp
T

207 lines
6.1 KiB
Plaintext

# Linux x86-64 ABI constants and structures shared by the kernel and vpsdk.
#
# The byte layouts must match Linux exactly: glibc reads these structs
# directly and never goes through any ViperOS wrapper.
#
# This module is imported by both sides:
# VKernel/Kernel/intr/syscall.vp (kernel project gains "../.." include)
# vpsdk/syscall.vp / vpsdk/fs.vp (apps already include the repo root)
# ---------------------------------------------------------------- errno ----
define EPERM = 1
define ENOENT = 2
define ESRCH = 3
define EINTR = 4
define EIO = 5
define ENXIO = 6
define E2BIG = 7
define ENOEXEC = 8
define EBADF = 9
define ECHILD = 10
define EAGAIN = 11
define ENOMEM = 12
define EACCES = 13
define EFAULT = 14
define ENOTBLK = 15
define EBUSY = 16
define EEXIST = 17
define EXDEV = 18
define ENODEV = 19
define ENOTDIR = 20
define EISDIR = 21
define EINVAL = 22
define ENFILE = 23
define EMFILE = 24
define ENOTTY = 25
define ETXTBSY = 26
define EFBIG = 27
define ENOSPC = 28
define ESPIPE = 29
define EROFS = 30
define EMLINK = 31
define EPIPE = 32
define EDOM = 33
define ERANGE = 34
define EDEADLK = 35
define ENAMETOOLONG = 36
define ENOLCK = 37
define ENOSYS = 38
define ENOTEMPTY = 39
define ELOOP = 40
define EOVERFLOW = 75
define ENOTSUP = 95
define EOPNOTSUPP = 95
define ETIMEDOUT = 110
# ------------------------------------------------------------ open flags ----
# Values are the Linux x86-64 ones (octal in the man page).
define O_RDONLY = 0
define O_WRONLY = 1
define O_RDWR = 2
define O_ACCMODE = 3
define O_CREAT = 64
define O_EXCL = 128
define O_NOCTTY = 256
define O_TRUNC = 512
define O_APPEND = 1024
define O_NONBLOCK = 2048
define O_DSYNC = 4096
define O_DIRECT = 16384
define O_DIRECTORY = 65536
define O_NOFOLLOW = 131072
define O_CLOEXEC = 524288
# --------------------------------------------------------------- fcntl ----
define F_DUPFD = 0
define F_GETFD = 1
define F_SETFD = 2
define F_GETFL = 3
define F_SETFL = 4
define F_DUPFD_CLOEXEC = 1030
define FD_CLOEXEC = 1
# ----------------------------------------------------------- at / dirent ----
define AT_FDCWD = -100
define AT_SYMLINK_NOFOLLOW = 256
define AT_REMOVEDIR = 512
define AT_EACCESS = 512
define AT_EMPTY_PATH = 4096
define DT_UNKNOWN = 0
define DT_FIFO = 1
define DT_CHR = 2
define DT_DIR = 4
define DT_BLK = 6
define DT_REG = 8
define DT_LNK = 10
define DT_SOCK = 12
# ------------------------------------------------------------ mmap/mprot ----
define PROT_NONE = 0
define PROT_READ = 1
define PROT_WRITE = 2
define PROT_EXEC = 4
define MAP_SHARED = 1
define MAP_PRIVATE = 2
define MAP_FIXED = 16
define MAP_ANONYMOUS = 32
define MAP_GROWSDOWN = 256
define MAP_NORESERVE = 16384
define MAP_POPULATE = 32768
define MAP_FAILED: uint64 = 0xFFFFFFFFFFFFFFFF
# ---------------------------------------------------------------- mremap ----
define MREMAP_MAYMOVE = 1
define MREMAP_FIXED = 2
# ------------------------------------------------------------- arch_prctl ----
define ARCH_SET_GS = 0x1001
define ARCH_SET_FS = 0x1002
define ARCH_GET_FS = 0x1003
define ARCH_GET_GS = 0x1004
# ---------------------------------------------------------------- rlimit ----
define RLIMIT_CPU = 0
define RLIMIT_FSIZE = 1
define RLIMIT_DATA = 2
define RLIMIT_STACK = 3
define RLIMIT_CORE = 4
define RLIMIT_NOFILE = 7
define RLIM_INFINITY: uint64 = 0xFFFFFFFFFFFFFFFF
# ------------------------------------------------------------- file modes ----
define S_IFMT = 61440
define S_IFDIR = 16384
define S_IFCHR = 8192
define S_IFIFO = 4096
define S_IFREG = 32768
define MODE_FILE = 33188 # 0100644
define MODE_DIR = 16877 # 040755
define MODE_CHAR = 8630 # 020666
define MODE_FIFO = 4534 # 010666
define SEEK_SET = 0
define SEEK_CUR = 1
define SEEK_END = 2
define PATH_MAX = 256
define SIZEOF_LINUX_STAT = 144
define SIZEOF_UTSNAME = 390
define SIZEOF_DIRENT64 = 19
# ---------------------------------------------------------------- structs ----
# struct stat, x86-64 Linux layout (144 bytes).
@__attribute__(packed)
class linux_stat:
st_dev: uint64
st_ino: uint64
st_nlink: uint64
st_mode: uint32
st_uid: uint32
st_gid: uint32
pad0: uint32
st_rdev: uint64
st_size: uint64
st_blksize: uint64
st_blocks: uint64
st_atime_sec: uint64
st_atime_nsec: uint64
st_mtime_sec: uint64
st_mtime_nsec: uint64
st_ctime_sec: uint64
st_ctime_nsec: uint64
res0: uint64
res1: uint64
res2: uint64
# struct linux_dirent64 header; the NUL-terminated name follows immediately.
@__attribute__(packed)
class linux_dirent64:
d_ino: uint64
d_off: uint64
d_reclen: uint16
d_type: uint8
@__attribute__(packed)
class linux_timespec:
tv_sec: uint64
tv_nsec: uint64
@__attribute__(packed)
class linux_utsname:
sysname: [65]char
nodename: [65]char
release: [65]char
version: [65]char
machine: [65]char
domainname: [65]char
@__attribute__(packed)
class linux_rlimit:
cur: uint64
max: uint64
class iovec:
base: rawptr
len: uint64