feat: rename 'ZenithOS' => 'MontaukOS' and fix build system issues
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* heap.h
|
||||
* Userspace heap allocator for MontaukOS programs
|
||||
* Free-list allocator backed by SYS_ALLOC page requests.
|
||||
* Adapted from the kernel HeapAllocator.
|
||||
* Copyright (c) 2025 Daniel Hammer
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <montauk/syscall.h>
|
||||
|
||||
namespace montauk {
|
||||
namespace heap_detail {
|
||||
|
||||
static constexpr uint64_t HEADER_MAGIC = 0x5A484541; // "ZHEA"
|
||||
|
||||
struct Header {
|
||||
uint64_t magic;
|
||||
uint64_t size; // user-requested size
|
||||
} __attribute__((packed));
|
||||
|
||||
struct FreeNode {
|
||||
uint64_t size; // total size of this free block (including node)
|
||||
FreeNode* next;
|
||||
};
|
||||
|
||||
// Per-process heap state (single TU per program, so static is fine)
|
||||
static FreeNode g_head{0, nullptr};
|
||||
static bool g_initialized = false;
|
||||
|
||||
static inline Header* get_header(void* block) {
|
||||
return (Header*)((uint8_t*)block - sizeof(Header));
|
||||
}
|
||||
|
||||
static inline void insert_free(void* ptr, uint64_t size) {
|
||||
auto* node = (FreeNode*)ptr;
|
||||
node->size = size;
|
||||
node->next = g_head.next;
|
||||
g_head.next = node;
|
||||
}
|
||||
|
||||
static inline bool grow(uint64_t bytes) {
|
||||
uint64_t pages = (bytes + 0xFFF) / 0x1000;
|
||||
if (pages < 4) pages = 4; // grow at least 16 KiB at a time
|
||||
|
||||
void* mem = montauk::alloc(pages * 0x1000);
|
||||
if (mem == nullptr) return false;
|
||||
insert_free(mem, pages * 0x1000);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace heap_detail
|
||||
|
||||
// ---- Public API ----
|
||||
|
||||
inline void* malloc(uint64_t size) {
|
||||
using namespace heap_detail;
|
||||
|
||||
if (!g_initialized) {
|
||||
grow(16 * 0x1000); // seed with 64 KiB
|
||||
g_initialized = true;
|
||||
}
|
||||
|
||||
uint64_t needed = size + sizeof(Header);
|
||||
needed = (needed + 15) & ~15ULL; // 16-byte alignment
|
||||
|
||||
FreeNode* prev = &g_head;
|
||||
FreeNode* current = g_head.next;
|
||||
|
||||
while (current != nullptr) {
|
||||
if (current->size >= needed) {
|
||||
uint64_t blockSize = current->size;
|
||||
|
||||
// Unlink
|
||||
prev->next = current->next;
|
||||
|
||||
// Split if worthwhile
|
||||
if (blockSize > needed + sizeof(FreeNode) + 16) {
|
||||
void* rest = (void*)((uint8_t*)current + needed);
|
||||
uint64_t restSize = blockSize - needed;
|
||||
insert_free(rest, restSize);
|
||||
}
|
||||
|
||||
// Write allocation header
|
||||
Header* header = (Header*)current;
|
||||
header->magic = HEADER_MAGIC;
|
||||
header->size = size;
|
||||
|
||||
return (void*)((uint8_t*)header + sizeof(Header));
|
||||
}
|
||||
|
||||
prev = current;
|
||||
current = current->next;
|
||||
}
|
||||
|
||||
// No fit — grow and retry
|
||||
if (!grow(needed))
|
||||
return nullptr;
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
inline void mfree(void* ptr) {
|
||||
using namespace heap_detail;
|
||||
|
||||
if (ptr == nullptr) return;
|
||||
|
||||
Header* header = get_header(ptr);
|
||||
|
||||
uint64_t blockSize = header->size + sizeof(Header);
|
||||
blockSize = (blockSize + 15) & ~15ULL;
|
||||
|
||||
insert_free((void*)header, blockSize);
|
||||
}
|
||||
|
||||
inline void* realloc(void* ptr, uint64_t size) {
|
||||
if (ptr == nullptr) return malloc(size);
|
||||
|
||||
auto* header = heap_detail::get_header(ptr);
|
||||
uint64_t old = header->size;
|
||||
|
||||
void* newBlock = malloc(size);
|
||||
if (newBlock == nullptr) return nullptr;
|
||||
|
||||
// Copy the smaller of old/new sizes
|
||||
uint64_t copySize = (old < size) ? old : size;
|
||||
uint8_t* dst = (uint8_t*)newBlock;
|
||||
uint8_t* src = (uint8_t*)ptr;
|
||||
for (uint64_t i = 0; i < copySize; i++)
|
||||
dst[i] = src[i];
|
||||
|
||||
mfree(ptr);
|
||||
return newBlock;
|
||||
}
|
||||
|
||||
} // namespace montauk
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* string.h
|
||||
* Common string and memory utility functions for MontaukOS programs
|
||||
* Copyright (c) 2025-2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
namespace montauk {
|
||||
|
||||
inline int slen(const char* s) {
|
||||
int n = 0;
|
||||
while (s[n]) n++;
|
||||
return n;
|
||||
}
|
||||
|
||||
inline bool streq(const char* a, const char* b) {
|
||||
while (*a && *b) {
|
||||
if (*a != *b) return false;
|
||||
a++; b++;
|
||||
}
|
||||
return *a == *b;
|
||||
}
|
||||
|
||||
inline bool starts_with(const char* str, const char* prefix) {
|
||||
while (*prefix) {
|
||||
if (*str != *prefix) return false;
|
||||
str++; prefix++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline const char* skip_spaces(const char* s) {
|
||||
while (*s == ' ') s++;
|
||||
return s;
|
||||
}
|
||||
|
||||
inline void memcpy(void* dst, const void* src, uint64_t n) {
|
||||
auto* d = (uint8_t*)dst;
|
||||
auto* s = (const uint8_t*)src;
|
||||
for (uint64_t i = 0; i < n; i++) d[i] = s[i];
|
||||
}
|
||||
|
||||
inline void memmove(void* dst, const void* src, uint64_t n) {
|
||||
auto* d = (uint8_t*)dst;
|
||||
auto* s = (const uint8_t*)src;
|
||||
if (d < s) {
|
||||
for (uint64_t i = 0; i < n; i++) d[i] = s[i];
|
||||
} else {
|
||||
for (uint64_t i = n; i > 0; i--) d[i-1] = s[i-1];
|
||||
}
|
||||
}
|
||||
|
||||
inline void memset(void* dst, int val, uint64_t n) {
|
||||
auto* d = (uint8_t*)dst;
|
||||
for (uint64_t i = 0; i < n; i++) d[i] = (uint8_t)val;
|
||||
}
|
||||
|
||||
inline void strcpy(char* dst, const char* src) {
|
||||
while (*src) *dst++ = *src++;
|
||||
*dst = '\0';
|
||||
}
|
||||
|
||||
inline void strncpy(char* dst, const char* src, int max) {
|
||||
int i = 0;
|
||||
while (src[i] && i < max - 1) { dst[i] = src[i]; i++; }
|
||||
dst[i] = '\0';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,333 @@
|
||||
/*
|
||||
* syscall.h
|
||||
* MontaukOS program-side syscall wrappers using SYSCALL instruction
|
||||
* Copyright (c) 2025 Daniel Hammer
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <Api/Syscall.hpp>
|
||||
|
||||
namespace montauk {
|
||||
|
||||
// ---- Raw SYSCALL wrappers ----
|
||||
|
||||
// The SYSCALL handler does not restore RDI, RSI, RDX, R10, R8, R9
|
||||
// (they are skipped on the return path). We move arguments into the
|
||||
// correct registers inside the asm block and list ALL argument
|
||||
// registers in the clobber list. This guarantees the compiler
|
||||
// reloads every argument on each call — GCC cannot optimise away
|
||||
// clobbers, unlike "+r" outputs whose dead values it may discard.
|
||||
|
||||
inline int64_t syscall0(uint64_t nr) {
|
||||
int64_t ret;
|
||||
asm volatile("syscall" : "=a"(ret) : "a"(nr)
|
||||
: "rcx", "r11", "rdi", "rsi", "rdx", "r8", "r9", "r10", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline int64_t syscall1(uint64_t nr, uint64_t a1) {
|
||||
int64_t ret;
|
||||
asm volatile(
|
||||
"mov %[a1], %%rdi\n\t"
|
||||
"syscall"
|
||||
: "=a"(ret)
|
||||
: "a"(nr), [a1] "r"(a1)
|
||||
: "rcx", "r11", "rdi", "rsi", "rdx", "r8", "r9", "r10", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline int64_t syscall2(uint64_t nr, uint64_t a1, uint64_t a2) {
|
||||
int64_t ret;
|
||||
asm volatile(
|
||||
"mov %[a1], %%rdi\n\t"
|
||||
"mov %[a2], %%rsi\n\t"
|
||||
"syscall"
|
||||
: "=a"(ret)
|
||||
: "a"(nr), [a1] "r"(a1), [a2] "r"(a2)
|
||||
: "rcx", "r11", "rdi", "rsi", "rdx", "r8", "r9", "r10", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline int64_t syscall3(uint64_t nr, uint64_t a1, uint64_t a2, uint64_t a3) {
|
||||
int64_t ret;
|
||||
asm volatile(
|
||||
"mov %[a1], %%rdi\n\t"
|
||||
"mov %[a2], %%rsi\n\t"
|
||||
"mov %[a3], %%rdx\n\t"
|
||||
"syscall"
|
||||
: "=a"(ret)
|
||||
: "a"(nr), [a1] "r"(a1), [a2] "r"(a2), [a3] "r"(a3)
|
||||
: "rcx", "r11", "rdi", "rsi", "rdx", "r8", "r9", "r10", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline int64_t syscall4(uint64_t nr, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4) {
|
||||
int64_t ret;
|
||||
asm volatile(
|
||||
"mov %[a1], %%rdi\n\t"
|
||||
"mov %[a2], %%rsi\n\t"
|
||||
"mov %[a3], %%rdx\n\t"
|
||||
"mov %[a4], %%r10\n\t"
|
||||
"syscall"
|
||||
: "=a"(ret)
|
||||
: "a"(nr), [a1] "r"(a1), [a2] "r"(a2), [a3] "r"(a3), [a4] "r"(a4)
|
||||
: "rcx", "r11", "rdi", "rsi", "rdx", "r8", "r9", "r10", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline int64_t syscall5(uint64_t nr, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
int64_t ret;
|
||||
asm volatile(
|
||||
"mov %[a1], %%rdi\n\t"
|
||||
"mov %[a2], %%rsi\n\t"
|
||||
"mov %[a3], %%rdx\n\t"
|
||||
"mov %[a4], %%r10\n\t"
|
||||
"mov %[a5], %%r8\n\t"
|
||||
"syscall"
|
||||
: "=a"(ret)
|
||||
: "a"(nr), [a1] "r"(a1), [a2] "r"(a2), [a3] "r"(a3), [a4] "r"(a4), [a5] "r"(a5)
|
||||
: "rcx", "r11", "rdi", "rsi", "rdx", "r8", "r9", "r10", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline int64_t syscall6(uint64_t nr, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a5, uint64_t a6) {
|
||||
int64_t ret;
|
||||
asm volatile(
|
||||
"mov %[a1], %%rdi\n\t"
|
||||
"mov %[a2], %%rsi\n\t"
|
||||
"mov %[a3], %%rdx\n\t"
|
||||
"mov %[a4], %%r10\n\t"
|
||||
"mov %[a5], %%r8\n\t"
|
||||
"mov %[a6], %%r9\n\t"
|
||||
"syscall"
|
||||
: "=a"(ret)
|
||||
: "a"(nr), [a1] "r"(a1), [a2] "r"(a2), [a3] "r"(a3), [a4] "r"(a4), [a5] "r"(a5), [a6] "r"(a6)
|
||||
: "rcx", "r11", "rdi", "rsi", "rdx", "r8", "r9", "r10", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ---- Typed wrappers ----
|
||||
|
||||
// Process
|
||||
[[noreturn]] inline void exit(int code = 0) {
|
||||
syscall1(Montauk::SYS_EXIT, (uint64_t)code);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
inline void yield() { syscall0(Montauk::SYS_YIELD); }
|
||||
inline void sleep_ms(uint64_t ms) { syscall1(Montauk::SYS_SLEEP_MS, ms); }
|
||||
inline int getpid() { return (int)syscall0(Montauk::SYS_GETPID); }
|
||||
inline int spawn(const char* path, const char* args = nullptr) {
|
||||
return (int)syscall2(Montauk::SYS_SPAWN, (uint64_t)path, (uint64_t)args);
|
||||
}
|
||||
|
||||
// Console
|
||||
inline void print(const char* text) { syscall1(Montauk::SYS_PRINT, (uint64_t)text); }
|
||||
inline void putchar(char c) { syscall1(Montauk::SYS_PUTCHAR, (uint64_t)c); }
|
||||
|
||||
// File I/O
|
||||
inline int open(const char* path) { return (int)syscall1(Montauk::SYS_OPEN, (uint64_t)path); }
|
||||
inline int read(int handle, uint8_t* buf, uint64_t off, uint64_t size) {
|
||||
return (int)syscall4(Montauk::SYS_READ, (uint64_t)handle, (uint64_t)buf, off, size);
|
||||
}
|
||||
inline uint64_t getsize(int handle) { return (uint64_t)syscall1(Montauk::SYS_GETSIZE, (uint64_t)handle); }
|
||||
inline void close(int handle) { syscall1(Montauk::SYS_CLOSE, (uint64_t)handle); }
|
||||
inline int readdir(const char* path, const char** names, int max) {
|
||||
return (int)syscall3(Montauk::SYS_READDIR, (uint64_t)path, (uint64_t)names, (uint64_t)max);
|
||||
}
|
||||
|
||||
// File write/create
|
||||
inline int fwrite(int handle, const uint8_t* buf, uint64_t off, uint64_t size) {
|
||||
return (int)syscall4(Montauk::SYS_FWRITE, (uint64_t)handle, (uint64_t)buf, off, size);
|
||||
}
|
||||
inline int fcreate(const char* path) {
|
||||
return (int)syscall1(Montauk::SYS_FCREATE, (uint64_t)path);
|
||||
}
|
||||
|
||||
// Memory
|
||||
inline void* alloc(uint64_t size) { return (void*)syscall1(Montauk::SYS_ALLOC, size); }
|
||||
inline void free(void* ptr) { syscall1(Montauk::SYS_FREE, (uint64_t)ptr); }
|
||||
|
||||
// Timekeeping
|
||||
inline uint64_t get_ticks() { return (uint64_t)syscall0(Montauk::SYS_GETTICKS); }
|
||||
inline uint64_t get_milliseconds() { return (uint64_t)syscall0(Montauk::SYS_GETMILLISECONDS); }
|
||||
|
||||
// System
|
||||
inline void get_info(Montauk::SysInfo* info) { syscall1(Montauk::SYS_GETINFO, (uint64_t)info); }
|
||||
|
||||
// Keyboard
|
||||
inline bool is_key_available() { return (bool)syscall0(Montauk::SYS_ISKEYAVAILABLE); }
|
||||
inline void getkey(Montauk::KeyEvent* out) { syscall1(Montauk::SYS_GETKEY, (uint64_t)out); }
|
||||
inline char getchar() { return (char)syscall0(Montauk::SYS_GETCHAR); }
|
||||
|
||||
// Networking
|
||||
inline int32_t ping(uint32_t ip, uint32_t timeoutMs = 3000) {
|
||||
return (int32_t)syscall2(Montauk::SYS_PING, (uint64_t)ip, (uint64_t)timeoutMs);
|
||||
}
|
||||
|
||||
// DNS resolve: returns IP in network byte order, or 0 on failure
|
||||
inline uint32_t resolve(const char* hostname) {
|
||||
return (uint32_t)syscall1(Montauk::SYS_RESOLVE, (uint64_t)hostname);
|
||||
}
|
||||
|
||||
// Network configuration
|
||||
inline void get_netcfg(Montauk::NetCfg* out) { syscall1(Montauk::SYS_GETNETCFG, (uint64_t)out); }
|
||||
inline int set_netcfg(const Montauk::NetCfg* cfg) { return (int)syscall1(Montauk::SYS_SETNETCFG, (uint64_t)cfg); }
|
||||
|
||||
// Sockets
|
||||
inline int socket(int type) {
|
||||
return (int)syscall1(Montauk::SYS_SOCKET, (uint64_t)type);
|
||||
}
|
||||
inline int connect(int fd, uint32_t ip, uint16_t port) {
|
||||
return (int)syscall3(Montauk::SYS_CONNECT, (uint64_t)fd, (uint64_t)ip, (uint64_t)port);
|
||||
}
|
||||
inline int bind(int fd, uint16_t port) {
|
||||
return (int)syscall2(Montauk::SYS_BIND, (uint64_t)fd, (uint64_t)port);
|
||||
}
|
||||
inline int listen(int fd) {
|
||||
return (int)syscall1(Montauk::SYS_LISTEN, (uint64_t)fd);
|
||||
}
|
||||
inline int accept(int fd) {
|
||||
return (int)syscall1(Montauk::SYS_ACCEPT, (uint64_t)fd);
|
||||
}
|
||||
inline int send(int fd, const void* data, uint32_t len) {
|
||||
return (int)syscall3(Montauk::SYS_SEND, (uint64_t)fd, (uint64_t)data, (uint64_t)len);
|
||||
}
|
||||
inline int recv(int fd, void* buf, uint32_t maxLen) {
|
||||
return (int)syscall3(Montauk::SYS_RECV, (uint64_t)fd, (uint64_t)buf, (uint64_t)maxLen);
|
||||
}
|
||||
inline int closesocket(int fd) {
|
||||
return (int)syscall1(Montauk::SYS_CLOSESOCK, (uint64_t)fd);
|
||||
}
|
||||
inline int sendto(int fd, const void* data, uint32_t len, uint32_t destIp, uint16_t destPort) {
|
||||
return (int)syscall5(Montauk::SYS_SENDTO, (uint64_t)fd, (uint64_t)data,
|
||||
(uint64_t)len, (uint64_t)destIp, (uint64_t)destPort);
|
||||
}
|
||||
inline int recvfrom(int fd, void* buf, uint32_t maxLen, uint32_t* srcIp, uint16_t* srcPort) {
|
||||
return (int)syscall5(Montauk::SYS_RECVFROM, (uint64_t)fd, (uint64_t)buf,
|
||||
(uint64_t)maxLen, (uint64_t)srcIp, (uint64_t)srcPort);
|
||||
}
|
||||
|
||||
// Process management
|
||||
inline void waitpid(int pid) { syscall1(Montauk::SYS_WAITPID, (uint64_t)pid); }
|
||||
|
||||
// Framebuffer
|
||||
inline void fb_info(Montauk::FbInfo* info) { syscall1(Montauk::SYS_FBINFO, (uint64_t)info); }
|
||||
inline void* fb_map() { return (void*)syscall0(Montauk::SYS_FBMAP); }
|
||||
|
||||
// Arguments
|
||||
inline int getargs(char* buf, uint64_t maxLen) {
|
||||
return (int)syscall2(Montauk::SYS_GETARGS, (uint64_t)buf, maxLen);
|
||||
}
|
||||
|
||||
// Terminal
|
||||
inline void termsize(int* cols, int* rows) {
|
||||
uint64_t r = (uint64_t)syscall0(Montauk::SYS_TERMSIZE);
|
||||
if (cols) *cols = (int)(r & 0xFFFFFFFF);
|
||||
if (rows) *rows = (int)(r >> 32);
|
||||
}
|
||||
|
||||
inline void termscale(int scale_x, int scale_y) {
|
||||
syscall2(Montauk::SYS_TERMSCALE, (uint64_t)scale_x, (uint64_t)scale_y);
|
||||
}
|
||||
|
||||
inline void get_termscale(int* scale_x, int* scale_y) {
|
||||
uint64_t r = (uint64_t)syscall2(Montauk::SYS_TERMSCALE, 0, 0);
|
||||
if (scale_x) *scale_x = (int)(r & 0xFFFFFFFF);
|
||||
if (scale_y) *scale_y = (int)(r >> 32);
|
||||
}
|
||||
|
||||
// Timekeeping (wall-clock)
|
||||
inline void gettime(Montauk::DateTime* out) { syscall1(Montauk::SYS_GETTIME, (uint64_t)out); }
|
||||
|
||||
// Random number generation
|
||||
inline int64_t getrandom(void* buf, uint32_t len) {
|
||||
return syscall2(Montauk::SYS_GETRANDOM, (uint64_t)buf, (uint64_t)len);
|
||||
}
|
||||
|
||||
// Power management
|
||||
[[noreturn]] inline void reset() {
|
||||
syscall0(Montauk::SYS_RESET);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
[[noreturn]] inline void shutdown() {
|
||||
syscall0(Montauk::SYS_SHUTDOWN);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
// Mouse
|
||||
inline void mouse_state(Montauk::MouseState* out) { syscall1(Montauk::SYS_MOUSESTATE, (uint64_t)out); }
|
||||
inline void set_mouse_bounds(int32_t maxX, int32_t maxY) {
|
||||
syscall2(Montauk::SYS_SETMOUSEBOUNDS, (uint64_t)maxX, (uint64_t)maxY);
|
||||
}
|
||||
|
||||
// Kernel log
|
||||
inline int64_t read_klog(char* buf, uint64_t size) {
|
||||
return syscall2(Montauk::SYS_KLOG, (uint64_t)buf, size);
|
||||
}
|
||||
|
||||
// I/O redirection
|
||||
inline int spawn_redir(const char* path, const char* args = nullptr) {
|
||||
return (int)syscall2(Montauk::SYS_SPAWN_REDIR, (uint64_t)path, (uint64_t)args);
|
||||
}
|
||||
inline int childio_read(int childPid, char* buf, int maxLen) {
|
||||
return (int)syscall3(Montauk::SYS_CHILDIO_READ, (uint64_t)childPid, (uint64_t)buf, (uint64_t)maxLen);
|
||||
}
|
||||
inline int childio_write(int childPid, const char* data, int len) {
|
||||
return (int)syscall3(Montauk::SYS_CHILDIO_WRITE, (uint64_t)childPid, (uint64_t)data, (uint64_t)len);
|
||||
}
|
||||
inline int childio_writekey(int childPid, const Montauk::KeyEvent* key) {
|
||||
return (int)syscall2(Montauk::SYS_CHILDIO_WRITEKEY, (uint64_t)childPid, (uint64_t)key);
|
||||
}
|
||||
inline int childio_settermsz(int childPid, int cols, int rows) {
|
||||
return (int)syscall3(Montauk::SYS_CHILDIO_SETTERMSZ, (uint64_t)childPid, (uint64_t)cols, (uint64_t)rows);
|
||||
}
|
||||
|
||||
// Process listing / kill
|
||||
inline int proclist(Montauk::ProcInfo* buf, int max) {
|
||||
return (int)syscall2(Montauk::SYS_PROCLIST, (uint64_t)buf, (uint64_t)max);
|
||||
}
|
||||
inline int kill(int pid) {
|
||||
return (int)syscall1(Montauk::SYS_KILL, (uint64_t)pid);
|
||||
}
|
||||
inline int devlist(Montauk::DevInfo* buf, int max) {
|
||||
return (int)syscall2(Montauk::SYS_DEVLIST, (uint64_t)buf, (uint64_t)max);
|
||||
}
|
||||
|
||||
// Kernel introspection
|
||||
inline void memstats(Montauk::MemStats* out) { syscall1(Montauk::SYS_MEMSTATS, (uint64_t)out); }
|
||||
|
||||
// Window server
|
||||
inline int win_create(const char* title, int w, int h, Montauk::WinCreateResult* result) {
|
||||
return (int)syscall4(Montauk::SYS_WINCREATE, (uint64_t)title, (uint64_t)w, (uint64_t)h, (uint64_t)result);
|
||||
}
|
||||
inline int win_destroy(int id) {
|
||||
return (int)syscall1(Montauk::SYS_WINDESTROY, (uint64_t)id);
|
||||
}
|
||||
inline uint64_t win_present(int id) {
|
||||
return (uint64_t)syscall1(Montauk::SYS_WINPRESENT, (uint64_t)id);
|
||||
}
|
||||
inline int win_poll(int id, Montauk::WinEvent* event) {
|
||||
return (int)syscall2(Montauk::SYS_WINPOLL, (uint64_t)id, (uint64_t)event);
|
||||
}
|
||||
inline int win_enumerate(Montauk::WinInfo* info, int max) {
|
||||
return (int)syscall2(Montauk::SYS_WINENUM, (uint64_t)info, (uint64_t)max);
|
||||
}
|
||||
inline uint64_t win_map(int id) {
|
||||
return (uint64_t)syscall1(Montauk::SYS_WINMAP, (uint64_t)id);
|
||||
}
|
||||
inline int win_sendevent(int id, const Montauk::WinEvent* event) {
|
||||
return (int)syscall2(Montauk::SYS_WINSENDEVENT, (uint64_t)id, (uint64_t)event);
|
||||
}
|
||||
inline uint64_t win_resize(int id, int w, int h) {
|
||||
return (uint64_t)syscall3(Montauk::SYS_WINRESIZE, (uint64_t)id, (uint64_t)w, (uint64_t)h);
|
||||
}
|
||||
inline int win_setscale(int scale) {
|
||||
return (int)syscall1(Montauk::SYS_WINSETSCALE, (uint64_t)scale);
|
||||
}
|
||||
inline int win_getscale() {
|
||||
return (int)syscall0(Montauk::SYS_WINGETSCALE);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user