137 lines
7.6 KiB
C
137 lines
7.6 KiB
C
#pragma once
|
|
// syscall_nr.h - system call numbers
|
|
// Shared between kernel (ke_syscall.c) and user mode (syscall.dll).
|
|
// Keep in sync with gSyscallTable in ke_syscall.c and SYS_MAX below.
|
|
//
|
|
// Calling convention (INT 0x40, MS x64):
|
|
// RAX = syscall number
|
|
// RCX, RDX, R8, R9 = args 0-3
|
|
// R10, R11 = args 4-5 (loaded by SYSCALL_STUB6 in syscall_stubs.asm)
|
|
// Return value in RAX (KSTATUS or data).
|
|
//
|
|
// Handle semantics:
|
|
// Every kernel object (file, mutex, semaphore, event, queue) is reference-
|
|
// counted. SYS_CLOSE_HANDLE is the ONE way to close any handle regardless
|
|
// of the object type behind it. KeCloseHandle calls ObDereferenceObject,
|
|
// which fires the type-specific Destroy callback (e.g. FileDestroy)
|
|
// automatically when the refcount reaches zero. There is no separate
|
|
// SYS_CLOSE_FILE - that was redundant.
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Process & Thread
|
|
// ---------------------------------------------------------------------------
|
|
#define SYS_EXIT_PROCESS 0 // (int exitCode) -> void
|
|
#define SYS_EXIT_THREAD 1 // (int exitCode) -> void
|
|
#define SYS_CREATE_THREAD 2 // (uint64_t entry, uint64_t arg, uint32_t priority, uint32_t* tidOut) -> KSTATUS
|
|
#define SYS_GET_CURRENT_TID 3 // () -> uint32_t
|
|
#define SYS_GET_CURRENT_PID 4 // () -> uint32_t
|
|
#define SYS_YIELD 5 // () -> void
|
|
#define SYS_SLEEP 6 // (uint32_t ms) -> void
|
|
#define SYS_SET_THREAD_PRIORITY 7 // (uint32_t priority) -> KSTATUS
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Memory
|
|
// ---------------------------------------------------------------------------
|
|
#define SYS_ALLOC 8 // (size_t size) -> void* (NULL on failure)
|
|
#define SYS_FREE 9 // (void* ptr, size_t size) -> void
|
|
#define SYS_REALLOC 10 // (void* ptr, size_t newSize) -> void*
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Synchronisation Objects
|
|
// ---------------------------------------------------------------------------
|
|
#define SYS_MUTEX_CREATE 11 // (uint32_t* handleOut) -> KSTATUS
|
|
#define SYS_MUTEX_ACQUIRE 12 // (uint32_t handle) -> KSTATUS
|
|
#define SYS_MUTEX_TRY_ACQUIRE 13 // (uint32_t handle) -> KSTATUS
|
|
#define SYS_MUTEX_RELEASE 14 // (uint32_t handle) -> KSTATUS
|
|
|
|
#define SYS_SEM_CREATE 15 // (int32_t initial, int32_t max, uint32_t* handleOut) -> KSTATUS
|
|
#define SYS_SEM_WAIT 16 // (uint32_t handle) -> KSTATUS
|
|
#define SYS_SEM_TRY_WAIT 17 // (uint32_t handle) -> KSTATUS
|
|
#define SYS_SEM_SIGNAL 18 // (uint32_t handle) -> void
|
|
|
|
#define SYS_EVENT_CREATE 19 // (uint32_t type, uint32_t initialState, uint32_t* handleOut) -> KSTATUS
|
|
#define SYS_EVENT_SIGNAL 20 // (uint32_t handle) -> void
|
|
#define SYS_EVENT_CLEAR 21 // (uint32_t handle) -> void
|
|
#define SYS_EVENT_WAIT 22 // (uint32_t handle) -> KSTATUS
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Message Queues
|
|
// ---------------------------------------------------------------------------
|
|
#define SYS_QUEUE_CREATE 23 // (uint32_t* handleOut) -> KSTATUS
|
|
#define SYS_QUEUE_SEND 24 // (uint32_t handle, const QUEUE_MESSAGE* msg, uint32_t blocking) -> KSTATUS
|
|
#define SYS_QUEUE_RECV 25 // (uint32_t handle, QUEUE_MESSAGE* msg, uint32_t blocking) -> KSTATUS
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Handle Management
|
|
// ---------------------------------------------------------------------------
|
|
#define SYS_CLOSE_HANDLE 26 // (uint32_t handle) -> void
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// File I/O
|
|
// (Close a file handle via SYS_CLOSE_HANDLE, same as any other object.)
|
|
// ---------------------------------------------------------------------------
|
|
#define SYS_OPEN_FILE 27 // (const char* path, uint32_t* handleOut) -> KSTATUS
|
|
#define SYS_READ_FILE 28 // (uint32_t handle, void* buf, size_t size, size_t* bytesReadOut) -> KSTATUS
|
|
#define SYS_SEEK_FILE 29 // (uint32_t handle, uint64_t offset) -> KSTATUS
|
|
#define SYS_GET_FILE_SIZE 30 // (uint32_t handle) -> uint64_t
|
|
#define SYS_WRITE_FILE 43
|
|
#define SYS_CREATE_FILE 44
|
|
#define SYS_DELETE_FILE 45
|
|
#define SYS_TRUNCATE_FILE 46
|
|
#define SYS_GET_FILE_POS 47
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Screen / Graphics
|
|
// ---------------------------------------------------------------------------
|
|
#define SYS_SCREEN_BLIT 31 // (int x, int y, int w, int h, const uint32_t* pixels) -> void
|
|
#define SYS_SCREEN_CLEAR 32 // (uint32_t color) -> void
|
|
#define SYS_SCREEN_GET_SIZE 33 // (int* widthOut, int* heightOut) -> void
|
|
#define SYS_SCREEN_PUT_CHAR 34 // (char c, int x, int y, uint32_t fg, uint32_t bg) -> void
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Keyboard
|
|
// ---------------------------------------------------------------------------
|
|
#define SYS_KB_POLL 35 // () -> uint32_t (1 if key available, 0 otherwise)
|
|
#define SYS_KB_READ_CHAR 36 // () -> char (blocks, yields while waiting)
|
|
#define SYS_KB_READ_SCANCODE 37 // () -> uint8_t (blocks, yields while waiting)
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Timer
|
|
// ---------------------------------------------------------------------------
|
|
#define SYS_GET_TICK 38 // () -> uint64_t (milliseconds since boot)
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Debug
|
|
// ---------------------------------------------------------------------------
|
|
#define SYS_DEBUG_PRINT 39 // (const char* str) -> void
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Process launch & lifecycle
|
|
// ---------------------------------------------------------------------------
|
|
#define SYS_CREATE_PROCESS 40 // (const char* path, uint32_t* handleOut) -> KSTATUS
|
|
#define SYS_WAIT_FOR_PROCESS 41 // (uint32_t handle) -> KSTATUS
|
|
#define SYS_GET_PROCESS_EXIT_CODE 42 // (uint32_t handle, int* exitCodeOut) -> KSTATUS
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Console output (white text, distinct from green SYS_DEBUG_PRINT)
|
|
// ---------------------------------------------------------------------------
|
|
#define SYS_WRITE_CONSOLE 48 // (const char* buf, size_t len) -> void
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Directory enumeration
|
|
// (Close the handle via SYS_CLOSE_HANDLE like any other object.)
|
|
// ---------------------------------------------------------------------------
|
|
#define SYS_OPEN_DIR 49 // (const char* dirPath, uint32_t* handleOut) -> KSTATUS
|
|
#define SYS_READ_DIR 50 // (uint32_t handle, KDIR_ENTRY* entryOut) -> KSTATUS
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Current Working Directory
|
|
// ---------------------------------------------------------------------------
|
|
#define SYS_SET_CWD 51 // (const char* path) -> KSTATUS
|
|
#define SYS_GET_CWD 52 // (char* buf, size_t size) -> KSTATUS
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Sentinel
|
|
// ---------------------------------------------------------------------------
|
|
#define SYS_MAX 53
|