isolate POSIX builds from the host UCRT, wire lwext4 and ntfs-3g as ext4.sys and ntfs.sys, split the FAT driver into directory/file/async/driver/mount units, add posixsrv and dwm plus input/console/desktop syscall clients and a pile of new smoke targets, rename serial.sys to cereal.sys, name HDA/USB/lwIP/AHCI workers, harden ATA probing/reset/removal around actual hardware deadlines, absent-channel detection, diagnostics and explicit worker lifetime, redo ACPI S5 shutdown around GAS/MMIO and HW-reduced firmware, scan SSDTs for _S5 and deal with Intel SMI sleep trapping, make serial and SMP timeouts use real monotonic deadlines, add thread names and fix terminal thread teardown, scheduler and APC prepare/commit races, make advisory file locks queryable and preserve split ranges and add mutable file append state, add shared-memory pipes with kernel-assisted wait/wake, introduce capability-scoped input and display managers, split surface map rights into read/write, add explicit unmap and replace present with commit/generation/damage tracking while keeping physical presentation under the display manager, decouple native exception classes from Win32 exception numbers and translate them in kernel32, add opaque process startup data, bump the resource protocol to v3 with namespace directories, symlinks and enumeration and service control to v2 with generic READY handle exports, add the new POSIX errno/status surface and rebuild fds around posixsrv-owned shared open descriptions, descriptor-local flags, exact inheritance snapshots, dup/fcntl/record locks and shared-ring pipes, add waitpid, POSIX credentials/groups/sessions/passwd/group lookups and move sockets onto stable open descriptions, port the shells and apps to the new console/input services and surface commit API, teach init to load services.ini and start/supervise RSSRV, DWM and generic services under restricted capabilities while publishing their endpoints through RSSRV, split RSSRV into namespace, volume, display, session, input, console and resource components and make /SystemRoot a real symlink to the independently published system volume, shift the syscall table again, expand lock/resource/surface/POSIX/service/thread smoke coverage, make docs scream ASK QUESTIONS and DISCUSS at LLMs, replace MIT No Attribution with WTFPL+.

This commit is contained in:
maksw committed 2026-09-16 10:33:20 +02:00
1 parent 3dacbd32c8
commit 73abd6f90d
441 files changed
+187073 -6549

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
// Minimal MSVC intrinsic declarations needed by nt-lite public/user headers.
#pragma once
unsigned __int64 __readgsqword(unsigned long offset);
long _InterlockedCompareExchange(long volatile* destination, long exchange, long comparand);
long _InterlockedExchange(long volatile* target, long value);
long _InterlockedIncrement(long volatile* addend);
long _InterlockedDecrement(long volatile* addend);
void _ReadWriteBarrier(void);
void _mm_pause(void);
#ifdef _MSC_VER
#pragma intrinsic(__readgsqword)
#pragma intrinsic(_InterlockedCompareExchange)
#pragma intrinsic(_InterlockedExchange)
#pragma intrinsic(_InterlockedIncrement)
#pragma intrinsic(_InterlockedDecrement)
#pragma intrinsic(_ReadWriteBarrier)
#pragma intrinsic(_mm_pause)
#endif
+21
View File
@@ -0,0 +1,21 @@
// Minimal freestanding variadic argument support for nt-lite target builds.
#pragma once
#ifdef _MSC_VER
#define va_list __crt_va_list
#define va_start __crt_va_start
#define va_arg __crt_va_arg
#define va_end __crt_va_end
#define va_copy(destination, source) ((destination) = (source))
typedef char* __crt_va_list;
#define __crt_va_start(ap, x) ((ap) = (char*)(&(x)) + ((sizeof(x) + 7u) & ~7u))
#define __crt_va_arg(ap, t) (*(t*)(((ap) += 8u) - 8u))
#define __crt_va_end(ap) ((ap) = (char*)0)
#else
#define va_list __builtin_va_list
#define va_start(ap, last) __builtin_va_start(ap, last)
#define va_arg(ap, type) __builtin_va_arg(ap, type)
#define va_end(ap) __builtin_va_end(ap)
#define va_copy(destination, source) __builtin_va_copy(destination, source)
#endif
+11
View File
@@ -0,0 +1,11 @@
// Freestanding Boolean declarations for nt-lite C target builds.
#pragma once
#ifndef __cplusplus
#define bool _Bool
#define true 1
#define false 0
#endif
#define __bool_true_false_are_defined 1
+14
View File
@@ -0,0 +1,14 @@
// Freestanding ISO C stddef subset for nt-lite target builds.
#pragma once
typedef unsigned __int64 size_t;
typedef __int64 ptrdiff_t;
#ifndef NULL
#define NULL ((void*)0)
#endif
#ifndef offsetof
#define offsetof(type, member) ((size_t)&(((type*)0)->member))
#endif
+51
View File
@@ -0,0 +1,51 @@
// Freestanding fixed-width integer declarations for nt-lite x86-64 targets.
#pragma once
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
typedef int8_t int_least8_t;
typedef uint8_t uint_least8_t;
typedef int16_t int_least16_t;
typedef uint16_t uint_least16_t;
typedef int32_t int_least32_t;
typedef uint32_t uint_least32_t;
typedef int64_t int_least64_t;
typedef uint64_t uint_least64_t;
typedef int8_t int_fast8_t;
typedef uint8_t uint_fast8_t;
typedef int16_t int_fast16_t;
typedef uint16_t uint_fast16_t;
typedef int32_t int_fast32_t;
typedef uint32_t uint_fast32_t;
typedef int64_t int_fast64_t;
typedef uint64_t uint_fast64_t;
typedef __int64 intptr_t;
typedef unsigned __int64 uintptr_t;
typedef __int64 intmax_t;
typedef unsigned __int64 uintmax_t;
#define INT8_MIN (-127 - 1)
#define INT16_MIN (-32767 - 1)
#define INT32_MIN (-2147483647 - 1)
#define INT64_MIN (-9223372036854775807LL - 1)
#define INT8_MAX 127
#define INT16_MAX 32767
#define INT32_MAX 2147483647
#define INT64_MAX 9223372036854775807LL
#define UINT8_MAX 0xffU
#define UINT16_MAX 0xffffU
#define UINT32_MAX 0xffffffffU
#define UINT64_MAX 0xffffffffffffffffULL
#define INTPTR_MIN INT64_MIN
#define INTPTR_MAX INT64_MAX
#define UINTPTR_MAX UINT64_MAX
+23
View File
@@ -0,0 +1,23 @@
// Freestanding string and memory declarations backed by nt-lite libc.
#pragma once
#include <stddef.h>
char* strcpy(char* destination, const char* source);
char* strncpy(char* destination, const char* source, size_t count);
char* strcat(char* destination, const char* source);
char* strncat(char* destination, const char* source, size_t count);
int strcmp(const char* left, const char* right);
int strncmp(const char* left, const char* right, size_t count);
int _stricmp(const char* left, const char* right);
size_t strlen(const char* string);
size_t strnlen(const char* string, size_t maximumLength);
char* strchr(const char* string, int character);
char* strrchr(const char* string, int character);
char* strstr(const char* haystack, const char* needle);
void* memchr(const void* buffer, int character, size_t count);
void* memset(void* destination, int value, size_t count);
void* memcpy(void* destination, const void* source, size_t count);
void* memmove(void* destination, const void* source, size_t count);
int memcmp(const void* left, const void* right, size_t count);
+121
View File
@@ -0,0 +1,121 @@
// Native console service protocol and client helpers.
#pragma once
#include <stddef.h>
#include <stdint.h>
#include <ntlite/handle.h>
#include <ntlite/input.h>
#include <ntlite/status.h>
#define NTL_CONSOLE_PROTOCOL_VERSION 1u
#define NTL_CONSOLE_SERVICE_PATH "/Services/Console"
#define NTL_CONSOLE_FLAG_NONE 0x00000000u
#define NTL_CONSOLE_WRITE_MAX 512u
#define NTL_CONSOLE_OP_WRITE 1u
#define NTL_CONSOLE_OP_QUERY_INFO 2u
#define NTL_CONSOLE_OP_SET_CURSOR 3u
#define NTL_CONSOLE_OP_FILL_CHARACTER 4u
#define NTL_CONSOLE_OP_FILL_ATTRIBUTE 5u
#define NTL_CONSOLE_OP_PUT_CHARACTER 6u
#define NTL_CONSOLE_OP_CLEAR 7u
#define NTL_CONSOLE_OP_READ_INPUT 8u
#define NTL_CONSOLE_OP_PEEK_INPUT 9u
#define NTL_CONSOLE_OP_FLUSH_INPUT 10u
typedef struct NTL_CONSOLE_INFO {
uint32_t Size;
uint32_t Flags;
uint32_t Columns;
uint32_t Rows;
uint32_t CursorX;
uint32_t CursorY;
uint16_t Attribute;
uint16_t Reserved;
uint32_t PixelWidth;
uint32_t PixelHeight;
uint64_t Generation;
} NTL_CONSOLE_INFO;
typedef struct NTL_CONSOLE_REQUEST {
uint32_t Size;
uint32_t Version;
uint32_t Operation;
uint32_t Flags;
uint64_t TimeoutMilliseconds;
union {
struct {
uint32_t Length;
char Data[NTL_CONSOLE_WRITE_MAX];
} Write;
struct {
int32_t X;
int32_t Y;
} Cursor;
struct {
char Character;
uint8_t Reserved[3];
int32_t X;
int32_t Y;
uint32_t Length;
} FillCharacter;
struct {
uint16_t Attribute;
uint16_t Reserved;
int32_t X;
int32_t Y;
uint32_t Length;
} FillAttribute;
struct {
char Character;
uint8_t Reserved[3];
int32_t X;
int32_t Y;
uint32_t Foreground;
uint32_t Background;
} PutCharacter;
struct {
uint32_t Color;
} Clear;
} Data;
} NTL_CONSOLE_REQUEST;
typedef struct NTL_CONSOLE_REPLY {
uint32_t Size;
uint32_t Version;
uint32_t Operation;
uint32_t Flags;
KSTATUS Status;
uint32_t Written;
INPUT_KEY_RECORD Input;
NTL_CONSOLE_INFO Info;
} NTL_CONSOLE_REPLY;
#if defined(NTL_SYSCALL_STATIC)
#define NTL_CONSOLE_API
#elif defined(NTL_SYSCALL_BUILD)
#define NTL_CONSOLE_API __declspec(dllexport)
#else
#define NTL_CONSOLE_API
#endif
NTL_CONSOLE_API KSTATUS NtlConsoleConnect(SYS_HANDLE* sessionOut);
NTL_CONSOLE_API KSTATUS NtlConsoleClose(SYS_HANDLE session);
NTL_CONSOLE_API KSTATUS NtlConsoleWrite(SYS_HANDLE session, const void* data, size_t length, size_t* writtenOut);
NTL_CONSOLE_API KSTATUS NtlConsoleQueryInfo(SYS_HANDLE session, NTL_CONSOLE_INFO* infoOut);
NTL_CONSOLE_API KSTATUS NtlConsoleSetCursor(SYS_HANDLE session, int x, int y);
NTL_CONSOLE_API KSTATUS NtlConsoleFillCharacter(SYS_HANDLE session, char character, int x, int y,
size_t length, size_t* writtenOut);
NTL_CONSOLE_API KSTATUS NtlConsoleFillAttribute(SYS_HANDLE session, uint16_t attribute, int x, int y,
size_t length, size_t* writtenOut);
NTL_CONSOLE_API KSTATUS NtlConsolePutCharacter(SYS_HANDLE session, char character, int x, int y,
uint32_t foreground, uint32_t background);
NTL_CONSOLE_API KSTATUS NtlConsoleClear(SYS_HANDLE session, uint32_t color);
NTL_CONSOLE_API KSTATUS NtlConsoleReadInput(SYS_HANDLE session, uint64_t timeoutMilliseconds,
INPUT_KEY_RECORD* recordOut);
NTL_CONSOLE_API KSTATUS NtlConsolePeekInput(SYS_HANDLE session, uint64_t timeoutMilliseconds,
INPUT_KEY_RECORD* recordOut);
NTL_CONSOLE_API KSTATUS NtlConsoleFlushInput(SYS_HANDLE session);
NTL_CONSOLE_API KSTATUS NtlConsoleReadCharacter(SYS_HANDLE session, char* characterOut);
+3
View File
@@ -34,6 +34,9 @@ typedef enum OBJECT_TYPE {
ObjectTypePort = 24,
ObjectTypeVolume = 25,
ObjectTypeVolumeManager = 26,
ObjectTypeInputManager = 27,
ObjectTypeDisplayManager = 28,
ObjectTypePipeEndpoint = 29,
} OBJECT_TYPE;
typedef enum OBJECT_LIFETIME_STATE {
+8 -2
View File
@@ -55,8 +55,12 @@ static __forceinline void KeReleaseSpinlock(SPINLOCK* sl, uintptr_t cookie) {
KIRQL oldIrql = KiSpinlockCookieIrql(cookie);
_InterlockedExchange(&sl->Locked, 0);
KeLowerIrql(oldIrql);
// Restore the caller's hardware interrupt state before dropping to an
// IRQL that can dispatch APCs. PASSIVE_LEVEL with IF still clear is not a
// valid APC execution context.
KeRestoreInterrupts(flags);
KeLowerIrql(oldIrql);
}
// Attempts to acquire a spinlock without blocking.
@@ -72,8 +76,10 @@ static __forceinline int KeTryAcquireSpinlock(SPINLOCK* sl, uintptr_t* outCookie
return 1;
}
KeLowerIrql(oldIrql);
// Keep the failed-acquire unwind consistent with normal release: restore
// IF before a PASSIVE transition can dispatch pending APCs.
KeRestoreInterrupts(flags);
KeLowerIrql(oldIrql);
return 0;
}
+14 -5
View File
@@ -4,6 +4,7 @@
#include <stdint.h>
#include <ntlite/status.h>
#include <ntlite/thread.h>
typedef struct THREAD THREAD;
@@ -34,21 +35,29 @@ typedef enum KE_SCHEDULING_CLASS {
// must retain the returned THREAD reference and call KeResumeThread().
#define KE_THREAD_CREATE_FLAG_SUSPENDED 0x00000001u
// Describes initial scheduling, execution state, and affinity for one new
// thread. Zero affinity selects the kernel default rather than an empty CPU
// set.
// Describes initial scheduling, execution state, affinity, and diagnostics for
// one new thread. Zero affinity selects the kernel default rather than an empty
// CPU set. Name may be NULL; otherwise it must be a NUL-terminated UTF-8 name
// shorter than NTL_THREAD_NAME_MAX bytes.
typedef struct KE_THREAD_CREATE_PARAMETERS {
KE_SCHEDULING_CLASS SchedulingClass;
uint32_t Priority;
uint32_t Flags;
uint64_t AffinityMask;
const char* Name;
} KE_THREAD_CREATE_PARAMETERS;
#define KE_THREAD_CREATE_NORMAL(priorityValue) \
{ KeSchedulingNormal, (uint32_t)(priorityValue), 0u, 0ULL }
{ KeSchedulingNormal, (uint32_t)(priorityValue), 0u, 0ULL, (const char*)0 }
#define KE_THREAD_CREATE_NAMED_NORMAL(priorityValue, nameValue) \
{ KeSchedulingNormal, (uint32_t)(priorityValue), 0u, 0ULL, (nameValue) }
#define KE_THREAD_CREATE_REALTIME(priorityValue) \
{ KeSchedulingRealtime, (uint32_t)(priorityValue), 0u, 0ULL }
{ KeSchedulingRealtime, (uint32_t)(priorityValue), 0u, 0ULL, (const char*)0 }
#define KE_THREAD_CREATE_NAMED_REALTIME(priorityValue, nameValue) \
{ KeSchedulingRealtime, (uint32_t)(priorityValue), 0u, 0ULL, (nameValue) }
// Creates a system-process kernel thread with explicit scheduling parameters.
__declspec(dllexport) KSTATUS KeCreateKernelThread(uintptr_t fn,
+138
View File
@@ -0,0 +1,138 @@
// Native desktop/window protocol and client helpers. DWM owns window policy while RSSRV retains Session 0 routing authority.
#pragma once
#include <stdint.h>
#include <ntlite/display.h>
#include <ntlite/handle.h>
#include <ntlite/input.h>
#include <ntlite/status.h>
#define NTL_DESKTOP_PROTOCOL_VERSION 1u
#define NTL_DESKTOP_SERVICE_PATH "/Sessions/0/Desktop"
#define NTL_DESKTOP_FLAG_NONE 0x00000000u
#define NTL_DESKTOP_OP_CREATE_WINDOW 1u
#define NTL_DESKTOP_OP_DESTROY_WINDOW 2u
#define NTL_DESKTOP_OP_SET_BOUNDS 3u
#define NTL_DESKTOP_OP_SET_VISIBLE 4u
#define NTL_DESKTOP_OP_RAISE_WINDOW 5u
#define NTL_DESKTOP_OP_LOWER_WINDOW 6u
#define NTL_DESKTOP_OP_REQUEST_FOCUS 7u
#define NTL_DESKTOP_OP_REQUEST_CAPTURE 8u
#define NTL_DESKTOP_OP_RELEASE_CAPTURE 9u
#define NTL_DESKTOP_OP_SET_POINTER_MODE 10u
#define NTL_DESKTOP_OP_ATTACH_SURFACE 11u
#define NTL_DESKTOP_OP_DETACH_SURFACE 12u
#define NTL_DESKTOP_OP_QUERY_WINDOW 13u
#define NTL_DESKTOP_EVENT_KEY 1u
#define NTL_DESKTOP_EVENT_MOUSE 2u
#define NTL_DESKTOP_POINTER_FREE 0u
#define NTL_DESKTOP_POINTER_CONFINED 1u
#define NTL_DESKTOP_POINTER_RELATIVE_LOCKED 2u
typedef uint64_t NTL_WINDOW_ID;
// One fixed desktop request. ATTACH_SURFACE carries exactly one surface capability.
typedef struct NTL_DESKTOP_REQUEST {
uint32_t Size;
uint32_t Version;
uint32_t Operation;
uint32_t Flags;
NTL_WINDOW_ID WindowId;
DISPLAY_RECT Bounds;
uint32_t Value;
uint32_t Reserved;
} NTL_DESKTOP_REQUEST;
// One fixed desktop reply. Query fields are meaningful after CREATE_WINDOW or QUERY_WINDOW.
typedef struct NTL_DESKTOP_REPLY {
uint32_t Size;
uint32_t Version;
uint32_t Operation;
uint32_t Flags;
KSTATUS Status;
uint32_t Reserved;
NTL_WINDOW_ID WindowId;
DISPLAY_RECT Bounds;
uint32_t Visible;
uint32_t Focused;
uint32_t Captured;
uint32_t HasSurface;
uint32_t SurfaceWidth;
uint32_t SurfaceHeight;
} NTL_DESKTOP_REPLY;
// One asynchronous input notification delivered to the owning window connection.
typedef struct NTL_DESKTOP_EVENT {
uint32_t Size;
uint32_t Version;
uint32_t Type;
uint32_t Flags;
NTL_WINDOW_ID WindowId;
int32_t PointerX;
int32_t PointerY;
INPUT_KEY_RECORD Key;
INPUT_MOUSE_EVENT Mouse;
} NTL_DESKTOP_EVENT;
#if defined(NTL_SYSCALL_STATIC)
#define NTL_DESKTOP_API
#elif defined(NTL_SYSCALL_BUILD)
#define NTL_DESKTOP_API __declspec(dllexport)
#else
#define NTL_DESKTOP_API
#endif
// Connects to the active Session 0 desktop endpoint through RSSRV.
NTL_DESKTOP_API KSTATUS NtlDesktopConnect(SYS_HANDLE* sessionOut);
// Creates one hidden client-owned top-level window.
NTL_DESKTOP_API KSTATUS NtlDesktopCreateWindow(SYS_HANDLE session, const DISPLAY_RECT* bounds, NTL_WINDOW_ID* windowOut);
// Destroys one window owned by this connection.
NTL_DESKTOP_API KSTATUS NtlDesktopDestroyWindow(SYS_HANDLE session, NTL_WINDOW_ID window);
// Changes one window's screen-space bounds.
NTL_DESKTOP_API KSTATUS NtlDesktopSetBounds(SYS_HANDLE session, NTL_WINDOW_ID window, const DISPLAY_RECT* bounds);
// Shows or hides one window without changing its z-order.
NTL_DESKTOP_API KSTATUS NtlDesktopSetVisible(SYS_HANDLE session, NTL_WINDOW_ID window, uint32_t visible);
// Moves one window to the top of the z-order.
NTL_DESKTOP_API KSTATUS NtlDesktopRaiseWindow(SYS_HANDLE session, NTL_WINDOW_ID window);
// Moves one window to the bottom of the z-order.
NTL_DESKTOP_API KSTATUS NtlDesktopLowerWindow(SYS_HANDLE session, NTL_WINDOW_ID window);
// Requests Session 0 keyboard focus for one visible window.
NTL_DESKTOP_API KSTATUS NtlDesktopRequestFocus(SYS_HANDLE session, NTL_WINDOW_ID window);
// Requests Session 0 pointer capture for one visible window.
NTL_DESKTOP_API KSTATUS NtlDesktopRequestCapture(SYS_HANDLE session, NTL_WINDOW_ID window);
// Releases pointer capture only when this window currently owns it.
NTL_DESKTOP_API KSTATUS NtlDesktopReleaseCapture(SYS_HANDLE session, NTL_WINDOW_ID window);
// Sets visible cursor policy for the focused/captured window.
NTL_DESKTOP_API KSTATUS NtlDesktopSetPointerMode(SYS_HANDLE session, NTL_WINDOW_ID window, uint32_t mode);
// Attaches a shared surface. DWM receives only QUERY, WAIT, and MAP_READ rights.
NTL_DESKTOP_API KSTATUS NtlDesktopAttachSurface(SYS_HANDLE session, NTL_WINDOW_ID window, SYS_HANDLE surface);
// Detaches the current shared surface from one window.
NTL_DESKTOP_API KSTATUS NtlDesktopDetachSurface(SYS_HANDLE session, NTL_WINDOW_ID window);
// Queries one connection-owned window.
NTL_DESKTOP_API KSTATUS NtlDesktopQueryWindow(SYS_HANDLE session, NTL_WINDOW_ID window, NTL_DESKTOP_REPLY* replyOut);
// Receives one asynchronous key or mouse event from DWM.
NTL_DESKTOP_API KSTATUS NtlDesktopReceiveEvent(SYS_HANDLE session, uint64_t timeoutMilliseconds, NTL_DESKTOP_EVENT* eventOut);
// Disconnects and closes one desktop session endpoint.
NTL_DESKTOP_API KSTATUS NtlDesktopClose(SYS_HANDLE session);
#undef NTL_DESKTOP_API
+19 -13
View File
@@ -35,22 +35,28 @@ typedef struct DISPLAY_RECT {
#define SYS_SURFACE_FORMAT_XRGB8888 1u
#define SYS_SURFACE_FLAG_NONE 0u
#define SYS_SURFACE_MAX_RECTS 64u
#define SYS_SURFACE_MAX_DIMENSION 16384u
#define SYS_SURFACE_MAX_BYTES (256ull * 1024ull * 1024ull)
#define SYS_SURFACE_MAP_READ 0x00000001u
#define SYS_SURFACE_MAP_WRITE 0x00000002u
typedef struct SYS_SURFACE_DESC {
uint32_t Width;
uint32_t Height;
uint32_t PitchBytes;
uint32_t Format;
void* Base;
uint64_t PayloadBytes;
uint64_t PageCount;
uint64_t MapCount;
uint64_t PresentCount;
uint64_t PresentRectCount;
uint64_t PresentClippedRectCount;
uint64_t PresentEmptyClipCount;
uint64_t PresentRowsCopied;
uint64_t PresentBytesCopied;
uint64_t ContentGeneration;
uint64_t CommitCount;
uint64_t CommitRectCount;
uint64_t CommitClippedRectCount;
uint64_t CommitEmptyClipCount;
DISPLAY_RECT LastDamageBounds;
uint32_t LastDamageValid;
uint32_t Reserved;
} SYS_SURFACE_DESC;
typedef struct SYS_SURFACE_STATS {
@@ -62,12 +68,12 @@ typedef struct SYS_SURFACE_STATS {
uint64_t LivePages;
uint64_t LiveBytes;
uint64_t MapCalls;
uint64_t PresentCalls;
uint64_t PresentRectInputs;
uint64_t PresentClippedRects;
uint64_t PresentEmptyClips;
uint64_t PresentRowsCopied;
uint64_t PresentBytesCopied;
uint64_t CommitCalls;
uint64_t CommitRectInputs;
uint64_t CommitClippedRects;
uint64_t CommitEmptyClips;
uint64_t PhysicalPresentCalls;
uint64_t PhysicalPresentBytesCopied;
} SYS_SURFACE_STATS;
typedef struct DISPLAY_STATS {
+21 -3
View File
@@ -26,7 +26,8 @@ typedef uint32_t SYS_RIGHTS;
#define SYS_PROCESS_RIGHT_BUILD 0x00000400u
// Thread-specific rights.
#define SYS_THREAD_RIGHT_RESUME 0x00000100u
#define SYS_THREAD_RIGHT_RESUME 0x00000100u
#define SYS_THREAD_RIGHT_SET_INFORMATION 0x00000200u
// Mutex-specific rights.
#define SYS_MUTEX_RIGHT_RELEASE 0x00000100u
@@ -58,6 +59,17 @@ typedef uint32_t SYS_RIGHTS;
#define SYS_VOLUME_MANAGER_RIGHT_OPEN 0x00000200u
#define SYS_VOLUME_MANAGER_RIGHT_WAIT 0x00000400u
// Input-manager rights. The bootstrap manager capability is delegated to RSSRV.
#define SYS_INPUT_MANAGER_RIGHT_READ 0x00000100u
#define SYS_INPUT_MANAGER_RIGHT_CONFIGURE 0x00000200u
// Display-manager rights. The bootstrap manager capability is delegated to RSSRV.
#define SYS_DISPLAY_MANAGER_RIGHT_ENUMERATE 0x00000100u
#define SYS_DISPLAY_MANAGER_RIGHT_MODESET 0x00000200u
#define SYS_DISPLAY_MANAGER_RIGHT_PRESENT 0x00000400u
#define SYS_DISPLAY_MANAGER_RIGHT_CURSOR 0x00000800u
#define SYS_DISPLAY_MANAGER_RIGHT_CONSOLE 0x00001000u
// Directory-specific rights.
#define SYS_DIR_RIGHT_ENUMERATE 0x00000100u
#define SYS_DIR_RIGHT_OPEN 0x00000200u
@@ -77,12 +89,18 @@ typedef uint32_t SYS_RIGHTS;
#define SYS_SOCKET_RIGHT_POLL 0x00008000u
#define SYS_SOCKET_RIGHT_SET_OPTION 0x00010000u
// Pipe-endpoint rights.
#define SYS_PIPE_RIGHT_READ 0x00000100u
#define SYS_PIPE_RIGHT_WRITE 0x00000200u
#define SYS_PIPE_RIGHT_POLL 0x00000400u
// File-mapping rights.
#define SYS_FILE_MAPPING_RIGHT_MAP 0x00000100u
// Surface rights.
#define SYS_SURFACE_RIGHT_MAP 0x00000100u
#define SYS_SURFACE_RIGHT_PRESENT 0x00000200u
#define SYS_SURFACE_RIGHT_MAP_READ 0x00000100u
#define SYS_SURFACE_RIGHT_MAP_WRITE 0x00000200u
#define SYS_SURFACE_RIGHT_COMMIT 0x00000400u
// Input-queue rights.
#define SYS_INPUT_QUEUE_RIGHT_READ 0x00000100u
+92
View File
@@ -0,0 +1,92 @@
// Native logical-input service protocol and client helpers.
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <ntlite/handle.h>
#include <ntlite/input.h>
#include <ntlite/status.h>
#define NTL_INPUT_PROTOCOL_VERSION 1u
#define NTL_INPUT_SERVICE_PATH "/Services/Input"
#define NTL_INPUT_FLAG_NONE 0x00000000u
#define NTL_INPUT_OP_READ_KEY 1u
#define NTL_INPUT_OP_PEEK_KEY 2u
#define NTL_INPUT_OP_READ_MOUSE 3u
#define NTL_INPUT_OP_PEEK_MOUSE 4u
#define NTL_INPUT_OP_QUERY_STATE 5u
#define NTL_INPUT_STATE_FLAG_NONE 0x00000000u
#define NTL_INPUT_KEY_BYTES 32u
// RSSRV-owned logical input state. This is distinct from the legacy kernel-global input snapshot.
typedef struct NTL_INPUT_STATE {
uint32_t Size;
uint32_t Flags;
uint64_t Generation;
uint32_t Modifiers;
uint8_t KeyDown[NTL_INPUT_KEY_BYTES];
int32_t MouseX;
int32_t MouseY;
int32_t MouseWheel;
uint32_t MouseButtons;
} NTL_INPUT_STATE;
// Request header for all logical-input service operations.
typedef struct NTL_INPUT_REQUEST {
uint32_t Size;
uint32_t Version;
uint32_t Operation;
uint32_t Flags;
uint64_t TimeoutMilliseconds;
} NTL_INPUT_REQUEST;
// Fixed reply. Only the field associated with Operation is meaningful on success.
typedef struct NTL_INPUT_REPLY {
uint32_t Size;
uint32_t Version;
uint32_t Operation;
uint32_t Flags;
KSTATUS Status;
uint32_t Reserved;
INPUT_KEY_RECORD Key;
INPUT_MOUSE_EVENT Mouse;
NTL_INPUT_STATE State;
} NTL_INPUT_REPLY;
#if defined(NTL_SYSCALL_STATIC)
#define NTL_INPUT_API
#elif defined(NTL_SYSCALL_BUILD)
#define NTL_INPUT_API __declspec(dllexport)
#else
#define NTL_INPUT_API
#endif
// Opens one session to RSSRV's logical-input service.
NTL_INPUT_API KSTATUS NtlInputConnect(SYS_HANDLE* sessionOut);
NTL_INPUT_API KSTATUS NtlInputClose(SYS_HANDLE session);
// Reads or peeks one logical keyboard record. SYS_HANDLE_INVALID selects the process-default session; a zero timeout is nonblocking.
NTL_INPUT_API KSTATUS NtlInputReadEvent(SYS_HANDLE session, uint64_t timeoutMilliseconds, INPUT_KEY_RECORD* recordOut);
NTL_INPUT_API KSTATUS NtlInputPeekEvent(SYS_HANDLE session, uint64_t timeoutMilliseconds, INPUT_KEY_RECORD* recordOut);
// Reads or peeks one logical mouse event. SYS_HANDLE_INVALID selects the process-default session; a zero timeout is nonblocking.
NTL_INPUT_API KSTATUS NtlInputReadMouse(SYS_HANDLE session, uint64_t timeoutMilliseconds, INPUT_MOUSE_EVENT* eventOut);
NTL_INPUT_API KSTATUS NtlInputPeekMouse(SYS_HANDLE session, uint64_t timeoutMilliseconds, INPUT_MOUSE_EVENT* eventOut);
// Snapshots RSSRV's logical key/modifier/pointer state.
NTL_INPUT_API KSTATUS NtlInputQueryState(SYS_HANDLE session, NTL_INPUT_STATE* stateOut);
// Process-local convenience wrappers backed by a lazily connected RSSRV session.
NTL_INPUT_API KSTATUS NtlInputPollKeyboard(INPUT_KEY* keyOut);
NTL_INPUT_API KSTATUS NtlInputIsKeyDown(INPUT_KEY key, bool* downOut);
NTL_INPUT_API KSTATUS NtlInputReadKeyboardChar(char* charOut);
NTL_INPUT_API KSTATUS NtlInputReadKey(INPUT_KEY* keyOut);
NTL_INPUT_API uint32_t NtlInputGetKeyModifiers(void);
NTL_INPUT_API KSTATUS NtlInputQueryDefaultState(NTL_INPUT_STATE* stateOut);
NTL_INPUT_API KSTATUS NtlInputGetMousePos(int* xOut, int* yOut);
#undef NTL_INPUT_API
+219
View File
@@ -0,0 +1,219 @@
// Native POSIX personality-server discovery, process identity, and shared-attribute protocol.
#pragma once
#include <stdint.h>
#include <ntlite/status.h>
#include <ntlite/syscall.h>
#define NTL_POSIX_SERVICE_PATH "/Services/posix"
#define NTL_POSIX_PROTOCOL_VERSION 6u
#define NTL_POSIX_REQUEST_FLAG_NONE 0u
#define NTL_POSIX_OP_QUERY 1u
#define NTL_POSIX_OP_BEGIN_TRANSACTION 2u
#define NTL_POSIX_OP_CANCEL_TRANSACTION 3u
#define NTL_POSIX_OP_REGISTER_PROCESS 4u
#define NTL_POSIX_OP_GET_PROCESS_ATTRIBUTES 5u
#define NTL_POSIX_OP_SET_CURRENT_DIRECTORY 6u
#define NTL_POSIX_OP_SET_UID 7u
#define NTL_POSIX_OP_SET_GID 8u
#define NTL_POSIX_OP_SET_PROCESS_GROUP 9u
#define NTL_POSIX_OP_CREATE_SESSION 10u
#define NTL_POSIX_OP_LOOKUP_USER 11u
#define NTL_POSIX_OP_LOOKUP_GROUP 12u
#define NTL_POSIX_OP_CREATE_OPEN_DESCRIPTION 13u
#define NTL_POSIX_OP_RELEASE_OPEN_DESCRIPTION 14u
#define NTL_POSIX_OP_SET_OPEN_STATUS 15u
#define NTL_POSIX_OP_CREATE_PIPE 16u
#define NTL_POSIX_OP_CREATE_FD_INHERITANCE 17u
#define NTL_POSIX_OP_IMPORT_FD_INHERITANCE 18u
#define NTL_POSIX_OP_CANCEL_FD_INHERITANCE 19u
#define NTL_POSIX_OP_ARM_FD_INHERITANCE 20u
#define NTL_POSIX_TRANSACTION_NONE 0u
#define NTL_POSIX_TRANSACTION_SPAWN 1u
#define NTL_POSIX_TRANSACTION_EXEC 2u
#define NTL_POSIX_PROCESS_STATE_NONE 0u
#define NTL_POSIX_PROCESS_STATE_RUNNING 1u
#define NTL_POSIX_PROCESS_STATE_EXITED 2u
#define NTL_POSIX_LOOKUP_NONE 0u
#define NTL_POSIX_LOOKUP_BY_ID 1u
#define NTL_POSIX_LOOKUP_BY_NAME 2u
#define NTL_POSIX_TRANSACTION_CAPACITY 8u
#define NTL_POSIX_SUPPLEMENTARY_GROUP_MAX 16u
#define NTL_POSIX_IDENTITY_NAME_MAX 63u
#define NTL_POSIX_IDENTITY_HOME_MAX 255u
#define NTL_POSIX_IDENTITY_SHELL_MAX 255u
// POSIX open-description kinds shared between posix.dll and posixsrv.
#define NTL_POSIX_OPEN_TYPE_FILE 1u
#define NTL_POSIX_OPEN_TYPE_CONSOLE_READ 2u
#define NTL_POSIX_OPEN_TYPE_CONSOLE_WRITE 3u
#define NTL_POSIX_OPEN_TYPE_DEV_NULL 4u
#define NTL_POSIX_OPEN_TYPE_DEV_ZERO 5u
#define NTL_POSIX_OPEN_TYPE_SOCKET 6u
#define NTL_POSIX_OPEN_TYPE_PIPE_READ 7u
#define NTL_POSIX_OPEN_TYPE_PIPE_WRITE 8u
// Values intentionally match the public POSIX fcntl ABI; posixsrv owns policy but
// does not include personality headers.
#define NTL_POSIX_OPEN_STATUS_RDONLY 0x0000u
#define NTL_POSIX_OPEN_STATUS_WRONLY 0x0001u
#define NTL_POSIX_OPEN_STATUS_RDWR 0x0002u
#define NTL_POSIX_OPEN_STATUS_ACCMODE 0x0003u
#define NTL_POSIX_OPEN_STATUS_APPEND 0x0400u
#define NTL_POSIX_OPEN_STATUS_NONBLOCK 0x0800u
#define NTL_POSIX_OPEN_STATUS_VALID_MASK \
(NTL_POSIX_OPEN_STATUS_ACCMODE | NTL_POSIX_OPEN_STATUS_APPEND | NTL_POSIX_OPEN_STATUS_NONBLOCK)
#define NTL_POSIX_SHARED_OPEN_MAGIC 0x31444F50u
#define NTL_POSIX_SHARED_OPEN_VERSION 2u
#define NTL_POSIX_FD_INHERIT_MAX 64u
#define NTL_POSIX_FD_IMPORT_BATCH_MAX SYS_PORT_MAX_TRANSFER_HANDLES
#define NTL_POSIX_FD_INHERIT_FLAG_NONE 0u
#define NTL_POSIX_FD_DESCRIPTOR_CLOEXEC 0x00000001u
#define NTL_POSIX_FD_HANDLE_NONE UINT32_MAX
typedef struct NTL_POSIX_FD_MANIFEST_ENTRY {
int32_t Descriptor;
uint32_t DescriptorFlags;
uint64_t OpenDescriptionId;
} NTL_POSIX_FD_MANIFEST_ENTRY;
typedef struct NTL_POSIX_FD_DESCRIPTION_ENTRY {
uint64_t OpenDescriptionId;
uint64_t SharedOpenDescription;
uint32_t OpenDescriptionType;
uint32_t OpenStatusFlags;
uint32_t HandleIndex;
uint32_t Reserved;
} NTL_POSIX_FD_DESCRIPTION_ENTRY;
// Hot open-description state lives in posixsrv-owned userspace memory. In the
// single-address-space model clients use this pointer directly; lifetime remains
// authoritative in posixsrv rather than in writable shared fields.
typedef struct NTL_POSIX_SHARED_OPEN_DESCRIPTION {
uint32_t Magic;
uint32_t Version;
uint32_t Type;
uint32_t Reserved;
uint64_t DescriptionId;
volatile long StatusFlags;
uint32_t Reserved2;
// Optional server-owned userspace data-plane pointer. Pipe endpoint
// descriptions use this for SYS_PIPE_SHARED_STATE; other types leave it zero.
uint64_t SharedObjectData;
} NTL_POSIX_SHARED_OPEN_DESCRIPTION;
// Future server-owned spawn/exec builders place this opaque personality payload
// in the generic userspace process-loader startup data. Zero token/PID/generation
// means an ordinary process is self-registering for the first time.
#define NTL_POSIX_BOOTSTRAP_MAGIC 0x3258504Eu
#define NTL_POSIX_BOOTSTRAP_VERSION 2u
typedef struct NTL_POSIX_BOOTSTRAP_DATA {
uint32_t Magic;
uint32_t Version;
uint32_t Size;
uint32_t Reserved;
uint64_t Token;
uint32_t PosixPid;
uint32_t Generation;
uint64_t FdInheritanceToken;
} NTL_POSIX_BOOTSTRAP_DATA;
// Requests remain fixed-size through P4 open-description control. Later spawn/exec
// transactions may layer bounded multi-message payloads over this header.
typedef struct NTL_POSIX_REQUEST {
uint32_t Size;
uint32_t Version;
uint32_t Operation;
uint32_t Flags;
uint32_t TransactionId;
uint32_t TransactionKind;
uint64_t BootstrapToken;
uint32_t BootstrapPosixPid;
uint32_t BootstrapGeneration;
uint32_t TargetPosixPid;
uint32_t UserId;
uint32_t GroupId;
uint32_t ProcessGroupId;
uint32_t LookupKind;
uint32_t OpenDescriptionType;
uint32_t OpenStatusFlags;
uint64_t OpenDescriptionId;
uint32_t NameLength;
uint32_t PathLength;
uint64_t FdInheritanceToken;
uint32_t FdInheritanceIndex;
uint32_t FdInheritanceCount;
uint32_t FdInheritanceFlags;
uint32_t Reserved[2];
NTL_POSIX_FD_MANIFEST_ENTRY FdManifest[NTL_POSIX_FD_INHERIT_MAX];
char Name[NTL_POSIX_IDENTITY_NAME_MAX + 1u];
char Path[SYS_PATH_MAX + 1u];
} NTL_POSIX_REQUEST;
// Replies expose stable POSIX identity and the server-owned shared process
// attributes. Lookup operations reuse the identity strings and ID fields.
typedef struct NTL_POSIX_REPLY {
uint32_t Size;
uint32_t Version;
uint32_t Operation;
uint32_t Flags;
KSTATUS Status;
uint32_t TransactionId;
uint32_t ClientProcessId;
uint32_t ClientSecurityId;
uint32_t ActiveTransactions;
uint32_t TransactionCapacity;
uint32_t PosixPid;
uint32_t NativeGeneration;
uint32_t ProcessState;
uint32_t RegisteredProcesses;
uint32_t RegisteredOpenDescriptions;
uint32_t OpenDescriptionType;
uint32_t OpenStatusFlags;
uint64_t OpenDescriptionId;
uint64_t SharedOpenDescription;
uint32_t OpenDescriptionType2;
uint32_t OpenStatusFlags2;
uint64_t OpenDescriptionId2;
uint64_t SharedOpenDescription2;
uint64_t FdInheritanceToken;
uint32_t FdInheritanceIndex;
uint32_t FdInheritanceCount;
uint32_t FdDescriptionIndex;
uint32_t FdDescriptionCount;
uint32_t FdDescriptionTotal;
NTL_POSIX_FD_MANIFEST_ENTRY FdManifest[NTL_POSIX_FD_INHERIT_MAX];
NTL_POSIX_FD_DESCRIPTION_ENTRY FdDescriptions[NTL_POSIX_FD_IMPORT_BATCH_MAX];
uint32_t ParentPosixPid;
uint32_t UserId;
uint32_t EffectiveUserId;
uint32_t GroupId;
uint32_t EffectiveGroupId;
uint32_t ProcessGroupId;
uint32_t SessionId;
uint32_t SupplementaryGroupCount;
uint32_t SupplementaryGroups[NTL_POSIX_SUPPLEMENTARY_GROUP_MAX];
uint32_t NameLength;
uint32_t HomeLength;
uint32_t ShellLength;
uint32_t CurrentDirectoryLength;
char Name[NTL_POSIX_IDENTITY_NAME_MAX + 1u];
char Home[NTL_POSIX_IDENTITY_HOME_MAX + 1u];
char Shell[NTL_POSIX_IDENTITY_SHELL_MAX + 1u];
char CurrentDirectory[SYS_PATH_MAX + 1u];
} NTL_POSIX_REPLY;
+12
View File
@@ -2,6 +2,7 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
#include <ntlite/handle.h>
#include <ntlite/status.h>
@@ -10,6 +11,7 @@
#include <ntlite/module_loader.h>
#define NTL_PROCESS_LOAD_FLAG_NONE 0x00000000u
#define NTL_PROCESS_STARTUP_DATA_MAX 1024u
// Describes one source capability to duplicate into a constructing child.
typedef struct NTL_PROCESS_STARTUP_CAPABILITY {
@@ -35,6 +37,9 @@ typedef struct NTL_CREATE_PROCESS_AT_REQUEST {
void* ResolveContext;
const NTL_PROCESS_STARTUP_CAPABILITY* StartupCapabilities;
uint32_t StartupCapabilityCount;
// Optional opaque userspace bootstrap data copied into the child's read-only loader block.
const void* StartupData;
size_t StartupDataSize;
SYS_HANDLE* ProcessHandleOut;
} NTL_CREATE_PROCESS_AT_REQUEST;
@@ -54,6 +59,9 @@ typedef struct NTL_CREATE_SYSTEM_PROCESS_REQUEST {
void* ResolveContext;
const NTL_PROCESS_STARTUP_CAPABILITY* StartupCapabilities;
uint32_t StartupCapabilityCount;
// Optional opaque userspace bootstrap data copied into the child's read-only loader block.
const void* StartupData;
size_t StartupDataSize;
SYS_HANDLE* ProcessHandleOut;
} NTL_CREATE_SYSTEM_PROCESS_REQUEST;
@@ -67,5 +75,9 @@ typedef struct NTL_CREATE_SYSTEM_PROCESS_REQUEST {
NTL_PROCESS_LOADER_API KSTATUS NtlCreateProcessAt(const NTL_CREATE_PROCESS_AT_REQUEST* request);
NTL_PROCESS_LOADER_API KSTATUS NtlCreateSystemProcess(const NTL_CREATE_SYSTEM_PROCESS_REQUEST* request);
// Copies the optional opaque startup data supplied by the userspace process builder.
NTL_PROCESS_LOADER_API KSTATUS NtlGetProcessStartupData(void* buffer,
size_t bufferSize,
size_t* sizeOut);
#undef NTL_PROCESS_LOADER_API
+49 -20
View File
@@ -7,25 +7,31 @@
#include <ntlite/status.h>
#include <ntlite/string_view.h>
#define NTL_RESOURCE_PROTOCOL_VERSION 2u
#define NTL_RESOURCE_PROTOCOL_VERSION 3u
#define NTL_RESOURCE_PATH_MAX 1024u
#define NTL_RESOURCE_NAME_MAX 255u
#define NTL_RESOURCE_FLAG_NONE 0x00000000u
#define NTL_RESOURCE_RESOLVE_FLAG_MODIFY 0x00000001u
#define NTL_RESOURCE_OP_LOOKUP 1u
#define NTL_RESOURCE_OP_QUERY 2u
#define NTL_RESOURCE_OP_BIND 3u
#define NTL_RESOURCE_OP_UNBIND 4u
#define NTL_RESOURCE_OP_RESOLVE 5u
#define NTL_RESOURCE_OP_LOOKUP 1u
#define NTL_RESOURCE_OP_QUERY 2u
#define NTL_RESOURCE_OP_BIND 3u
#define NTL_RESOURCE_OP_UNBIND 4u
#define NTL_RESOURCE_OP_RESOLVE 5u
#define NTL_RESOURCE_OP_ENUMERATE 6u
#define NTL_RESOURCE_OP_CREATE_DIRECTORY 7u
#define NTL_RESOURCE_OP_CREATE_SYMBOLIC_LINK 8u
#define NTL_RESOURCE_KIND_INVALID 0u
#define NTL_RESOURCE_KIND_CAPABILITY 1u
#define NTL_RESOURCE_KIND_VOLUME 2u
#define NTL_RESOURCE_KIND_DIRECTORY 3u
#define NTL_RESOURCE_KIND_DEVICE 4u
#define NTL_RESOURCE_KIND_INVALID 0u
#define NTL_RESOURCE_KIND_CAPABILITY 1u
#define NTL_RESOURCE_KIND_VOLUME 2u
#define NTL_RESOURCE_KIND_DIRECTORY 3u
#define NTL_RESOURCE_KIND_DEVICE 4u
#define NTL_RESOURCE_KIND_NAMESPACE_DIRECTORY 5u
#define NTL_RESOURCE_KIND_SYMBOLIC_LINK 6u
// Request header followed immediately by PathLength bytes of canonical native resource path.
// Request header followed by PathLength bytes of canonical native resource path and AuxLength operation-specific bytes.
typedef struct NTL_RESOURCE_REQUEST {
uint32_t Size;
uint32_t Version;
@@ -35,10 +41,10 @@ typedef struct NTL_RESOURCE_REQUEST {
SYS_RIGHTS ExportRights;
uint32_t Kind;
uint32_t PathLength;
uint32_t Reserved;
uint32_t AuxLength;
} NTL_RESOURCE_REQUEST;
// Every resource request receives one fixed-size reply. Successful lookup additionally transfers one handle.
// Every ordinary resource request receives one fixed-size reply. Enumeration appends NameLength bytes of one child name.
typedef struct NTL_RESOURCE_REPLY {
uint32_t Size;
uint32_t Version;
@@ -47,9 +53,21 @@ typedef struct NTL_RESOURCE_REPLY {
KSTATUS Status;
uint32_t Kind;
uint32_t ResolvedLength;
uint32_t Reserved;
uint32_t NameLength;
} NTL_RESOURCE_REPLY;
// Stateless lexicographic enumeration cursor. Callers zero-initialize it before the first request.
typedef struct NTL_RESOURCE_ENUM_CURSOR {
uint32_t NameLength;
char Name[NTL_RESOURCE_NAME_MAX + 1u];
} NTL_RESOURCE_ENUM_CURSOR;
// One immediate child of an RSSRV namespace directory.
typedef struct NTL_RESOURCE_ENUM_ENTRY {
uint32_t Kind;
char Name[NTL_RESOURCE_NAME_MAX + 1u];
} NTL_RESOURCE_ENUM_ENTRY;
#if defined(NTL_SYSCALL_STATIC)
#define NTL_RESOURCE_API
#elif defined(NTL_SYSCALL_BUILD)
@@ -63,17 +81,17 @@ NTL_RESOURCE_API KSTATUS NtlResourceConnect(SYS_HANDLE* sessionOut);
NTL_RESOURCE_API KSTATUS NtlResourceOpenSystemRoot(SYS_RIGHTS desiredRights, SYS_HANDLE* handleOut);
// Connects one session through an explicitly delegated resource-listener capability.
NTL_RESOURCE_API KSTATUS NtlResourceConnectListener(SYS_HANDLE listenerHandle, SYS_HANDLE* sessionOut);
// Resolves one canonical global resource name to an attenuated capability.
// Resolves one canonical global resource name to an attenuated capability. Symbolic links are followed.
NTL_RESOURCE_API KSTATUS NtlResourceLookup(SYS_HANDLE session,
SYS_STRING_VIEW path,
SYS_RIGHTS desiredRights,
SYS_HANDLE* handleOut);
// Queries resource metadata without transferring the resource capability.
// Queries the exact namespace node without following the final symbolic link.
NTL_RESOURCE_API KSTATUS NtlResourceQuery(SYS_HANDLE session,
SYS_STRING_VIEW path,
uint32_t* kindOut);
// Resolves the longest bound resource prefix of one canonical absolute path.
// ResolvedLength receives the byte length of the matched resource name; the remaining
// Resolves the longest bound resource prefix of one canonical absolute path, following namespace symbolic links.
// ResolvedLength receives the byte length consumed from the caller's original resource path; the remaining
// path, after one optional '/', is relative to the returned volume/directory capability.
NTL_RESOURCE_API KSTATUS NtlResourceResolve(SYS_HANDLE session,
SYS_STRING_VIEW path,
@@ -81,6 +99,17 @@ NTL_RESOURCE_API KSTATUS NtlResourceResolve(SYS_HANDLE session,
SYS_HANDLE* rootHandleOut,
uint32_t* kindOut,
uint32_t* resolvedLengthOut);
// Enumerates immediate children in stable bytewise-name order using a caller-owned stateless cursor.
NTL_RESOURCE_API KSTATUS NtlResourceEnumerate(SYS_HANDLE session,
SYS_STRING_VIEW directoryPath,
NTL_RESOURCE_ENUM_CURSOR* cursor,
NTL_RESOURCE_ENUM_ENTRY* entryOut);
// Creates one empty namespace directory through an administrative session.
NTL_RESOURCE_API KSTATUS NtlResourceCreateDirectory(SYS_HANDLE session, SYS_STRING_VIEW path);
// Creates one absolute namespace symbolic link through an administrative session.
NTL_RESOURCE_API KSTATUS NtlResourceCreateSymbolicLink(SYS_HANDLE session,
SYS_STRING_VIEW path,
SYS_STRING_VIEW target);
// Binds one capability into an administrative session with an explicit namespace-rights grant and export ceiling.
NTL_RESOURCE_API KSTATUS NtlResourceBind(SYS_HANDLE session,
SYS_STRING_VIEW path,
@@ -88,7 +117,7 @@ NTL_RESOURCE_API KSTATUS NtlResourceBind(SYS_HANDLE session,
SYS_HANDLE resourceHandle,
SYS_RIGHTS namespaceRights,
SYS_RIGHTS exportRights);
// Removes one name from an administrative resource session. Existing looked-up capabilities remain valid.
// Removes one non-root namespace node through an administrative session. Namespace directories must be empty.
NTL_RESOURCE_API KSTATUS NtlResourceUnbind(SYS_HANDLE session, SYS_STRING_VIEW path);
// Disconnects and closes one resource session endpoint.
NTL_RESOURCE_API KSTATUS NtlResourceClose(SYS_HANDLE session);
+4 -4
View File
@@ -5,19 +5,19 @@
#include <stdint.h>
#include <ntlite/status.h>
#define NTL_SERVICE_CONTROL_VERSION 1u
#define NTL_SERVICE_CONTROL_VERSION 2u
#define NTL_SERVICE_CONTROL_READY 1u
#define NTL_SERVICE_CONTROL_STOP 2u
#define NTL_SERVICE_READY_FLAG_RESOURCE_ADMIN_LISTENER 0x00000001u
// Service-control messages are notifications over a private Port connection.
// READY transfers ExportCount service-defined handles whose meaning is fixed by
// the service type known to the manager. Other operations transfer no handles.
typedef struct NTL_SERVICE_CONTROL_MESSAGE {
uint32_t Size;
uint32_t Version;
uint32_t Operation;
uint32_t Flags;
uint32_t ExportCount;
KSTATUS Status;
uint32_t Reserved[3];
} NTL_SERVICE_CONTROL_MESSAGE;
+12
View File
@@ -66,6 +66,17 @@ typedef uint32_t KSTATUS;
#define NTLSTATUS_CAPABILITY_REVOKED KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000017u)
#define NTLSTATUS_LIMIT_REACHED KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000018u)
#define NTLSTATUS_PORT_DISCONNECTED KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000019u)
#define NTLSTATUS_BROKEN_PIPE KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00001Au)
#define NTLSTATUS_NOT_A_DIRECTORY KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00001Bu)
#define NTLSTATUS_IS_A_DIRECTORY KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00001Cu)
#define NTLSTATUS_DIRECTORY_NOT_EMPTY KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00001Du)
#define NTLSTATUS_CROSS_DEVICE KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00001Eu)
#define NTLSTATUS_NO_CHILD KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00001Fu)
#define NTLSTATUS_INVALID_IMAGE_FORMAT KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000020u)
#define NTLSTATUS_NAME_TOO_LONG KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000021u)
#define NTLSTATUS_TOO_MANY_LINKS KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000022u)
#define NTLSTATUS_READ_ONLY_FILESYSTEM KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000023u)
#define NTLSTATUS_FILE_TOO_LARGE KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000024u)
// Process termination and fault statuses use the process facility.
#define NTLSTATUS_PROCESS_BASE KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_PROCESS, 0x000000u)
@@ -76,6 +87,7 @@ typedef uint32_t KSTATUS;
#define NTLSTATUS_PROCESS_DIVIDE_BY_ZERO KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_PROCESS, 0x000013u)
#define NTLSTATUS_PROCESS_BREAKPOINT KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_PROCESS, 0x000014u)
#define NTLSTATUS_PROCESS_ALIGNMENT_FAULT KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_PROCESS, 0x000015u)
#define NTLSTATUS_PROCESS_USER_EXCEPTION KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_PROCESS, 0x000016u)
#define NTLSTATUS_PROCESS_UNKNOWN_FAULT KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_PROCESS, 0x00001Fu)
#define KSUCCESS(status) (((KSTATUS)(status)) == NTLSTATUS_SUCCESS)
+175 -34
View File
@@ -18,6 +18,7 @@
#include <ntlite/service.h>
#include <ntlite/audio.h>
#include <ntlite/volume_manager.h>
#include <ntlite/thread.h>
// Syscall ABI convention: status-returning calls use KSTATUS. Syscalls use at most
// four register arguments; larger operations use request structures. Every
@@ -38,6 +39,9 @@
#define SYS_STARTUP_CAP_SERVICE_CONTROL 2u
#define SYS_STARTUP_CAP_SYSTEM_VOLUME_NAMESPACE 3u
#define SYS_STARTUP_CAP_VOLUME_MANAGER 4u
#define SYS_STARTUP_CAP_INPUT_MANAGER 5u
#define SYS_STARTUP_CAP_DISPLAY_MANAGER 6u
#define SYS_STARTUP_CAP_SESSION_CONTROL 7u
#define SYS_STARTUP_CAPABILITY_MAX 32u
typedef struct SYS_STARTUP_CAPABILITY {
@@ -186,7 +190,7 @@ typedef struct SYS_TRAP_FRAME_INFO {
// Structured exception delivery ABI. The kernel owns capture, delivery, and
// context validation; personalities own VEH, SEH, signal, and unwind policy.
#define SYS_EXCEPTION_ABI_VERSION 1u
#define SYS_EXCEPTION_ABI_VERSION 2u
#define SYS_EXCEPTION_MAXIMUM_PARAMETERS 15u
#define SYS_EXCEPTION_FLAG_NONE 0x00000000u
@@ -198,31 +202,28 @@ typedef struct SYS_TRAP_FRAME_INFO {
#define SYS_RAISE_EXCEPTION_FLAG_NONE 0x00000000u
#define SYS_RAISE_EXCEPTION_FLAG_NONCONTINUABLE 0x00000001u
// Common exception codes intentionally match the Windows values used by user
// VEH/SEH code. The native ABI remains policy-neutral; the matching numbers
// only avoid needless translation in the Win32 personality.
#define SYS_EXCEPTION_CODE_GUARD_PAGE_VIOLATION 0x80000001u
#define SYS_EXCEPTION_CODE_DATATYPE_MISALIGNMENT 0x80000002u
#define SYS_EXCEPTION_CODE_BREAKPOINT 0x80000003u
#define SYS_EXCEPTION_CODE_SINGLE_STEP 0x80000004u
#define SYS_EXCEPTION_CODE_ACCESS_VIOLATION 0xC0000005u
#define SYS_EXCEPTION_CODE_ILLEGAL_INSTRUCTION 0xC000001Du
#define SYS_EXCEPTION_CODE_NONCONTINUABLE_EXCEPTION 0xC0000025u
#define SYS_EXCEPTION_CODE_INVALID_DISPOSITION 0xC0000026u
#define SYS_EXCEPTION_CODE_ARRAY_BOUNDS_EXCEEDED 0xC000008Cu
#define SYS_EXCEPTION_CODE_FLT_DENORMAL_OPERAND 0xC000008Du
#define SYS_EXCEPTION_CODE_FLT_DIVIDE_BY_ZERO 0xC000008Eu
#define SYS_EXCEPTION_CODE_FLT_INEXACT_RESULT 0xC000008Fu
#define SYS_EXCEPTION_CODE_FLT_INVALID_OPERATION 0xC0000090u
#define SYS_EXCEPTION_CODE_FLT_OVERFLOW 0xC0000091u
#define SYS_EXCEPTION_CODE_FLT_STACK_CHECK 0xC0000092u
#define SYS_EXCEPTION_CODE_FLT_UNDERFLOW 0xC0000093u
#define SYS_EXCEPTION_CODE_INT_DIVIDE_BY_ZERO 0xC0000094u
#define SYS_EXCEPTION_CODE_INT_OVERFLOW 0xC0000095u
#define SYS_EXCEPTION_CODE_PRIVILEGED_INSTRUCTION 0xC0000096u
#define SYS_EXCEPTION_CODE_STACK_OVERFLOW 0xC00000FDu
#define SYS_EXCEPTION_CODE_NTLITE_UNKNOWN 0xE0000001u
#define SYS_EXCEPTION_CODE_NTLITE_USER_RAISED 0xE0000002u
// Native exception codes are an nt-lite ABI. Personality runtimes translate
// them to their own exception or signal namespaces at the user-mode boundary.
#define SYS_EXCEPTION_CODE_UNKNOWN 1u
#define SYS_EXCEPTION_CODE_USER_RAISED 2u
#define SYS_EXCEPTION_CODE_ACCESS_VIOLATION 3u
#define SYS_EXCEPTION_CODE_DATATYPE_MISALIGNMENT 4u
#define SYS_EXCEPTION_CODE_ILLEGAL_INSTRUCTION 5u
#define SYS_EXCEPTION_CODE_PRIVILEGED_INSTRUCTION 6u
#define SYS_EXCEPTION_CODE_BREAKPOINT 7u
#define SYS_EXCEPTION_CODE_SINGLE_STEP 8u
#define SYS_EXCEPTION_CODE_INT_DIVIDE_BY_ZERO 9u
#define SYS_EXCEPTION_CODE_INT_OVERFLOW 10u
#define SYS_EXCEPTION_CODE_ARRAY_BOUNDS_EXCEEDED 11u
#define SYS_EXCEPTION_CODE_FLT_DENORMAL_OPERAND 12u
#define SYS_EXCEPTION_CODE_FLT_DIVIDE_BY_ZERO 13u
#define SYS_EXCEPTION_CODE_FLT_INEXACT_RESULT 14u
#define SYS_EXCEPTION_CODE_FLT_INVALID_OPERATION 15u
#define SYS_EXCEPTION_CODE_FLT_OVERFLOW 16u
#define SYS_EXCEPTION_CODE_FLT_STACK_CHECK 17u
#define SYS_EXCEPTION_CODE_FLT_UNDERFLOW 18u
#define SYS_EXCEPTION_CODE_STACK_OVERFLOW 19u
#define SYS_EXCEPTION_CODE_GUARD_PAGE_VIOLATION 20u
#define SYS_EXCEPTION_DISPOSITION_CONTINUE_EXECUTION 0u
#define SYS_EXCEPTION_DISPOSITION_CONTINUE_SEARCH 1u
@@ -283,7 +284,9 @@ typedef struct SYS_EXCEPTION_RECORD {
uint64_t ErrorCode;
uint32_t ParameterCount;
uint32_t Reserved;
// Meaningful only when Code is SYS_EXCEPTION_CODE_USER_RAISED. The native
// kernel treats this as an opaque personality/application value.
uint32_t UserCode;
uint64_t Parameters[SYS_EXCEPTION_MAXIMUM_PARAMETERS];
} SYS_EXCEPTION_RECORD;
@@ -327,7 +330,8 @@ typedef struct SYS_CONTINUE_EXCEPTION_REQUEST {
typedef struct SYS_RAISE_EXCEPTION_REQUEST {
uint32_t Size;
uint32_t Flags;
uint32_t Code;
// Opaque user/personality exception value carried in SYS_EXCEPTION_RECORD.UserCode.
uint32_t UserCode;
uint32_t ParameterCount;
const uint64_t* Parameters;
} SYS_RAISE_EXCEPTION_REQUEST;
@@ -496,6 +500,72 @@ typedef struct SYS_UNLOCK_FILE_REQUEST {
uint64_t Length;
} SYS_UNLOCK_FILE_REQUEST;
#define SYS_FILE_LOCK_NONE 0u
typedef struct SYS_FILE_LOCK_INFO {
uint32_t Size;
uint32_t Mode;
uint32_t OwnerProcessId;
uint32_t Reserved;
uint64_t Offset;
uint64_t Length;
} SYS_FILE_LOCK_INFO;
typedef struct SYS_QUERY_FILE_LOCK_REQUEST {
uint32_t Size;
SYS_HANDLE FileHandle;
uint32_t Mode;
uint32_t Flags;
uint64_t Offset;
uint64_t Length;
SYS_FILE_LOCK_INFO* InfoOut;
} SYS_QUERY_FILE_LOCK_REQUEST;
#define SYS_FILE_STATUS_APPEND 0x00000001u
typedef struct SYS_SET_FILE_STATUS_REQUEST {
uint32_t Size;
SYS_HANDLE FileHandle;
uint32_t Mask;
uint32_t Flags;
} SYS_SET_FILE_STATUS_REQUEST;
#define SYS_PIPE_ATOMIC_WRITE_MAX 4096u
#define SYS_PIPE_BUFFER_CAPACITY 16384u
#define SYS_PIPE_SHARED_VERSION 1u
#define SYS_PIPE_SHARED_MAGIC 0x31504950u
#define SYS_PIPE_SHARED_HEADER_BYTES 4096u
// Shared pipe state. The first page is mapped read-only and contains
// kernel-authoritative lifecycle state. The following pages are writable and
// form the user-mode ring data plane. Positions are monotonic byte counters.
typedef struct SYS_PIPE_SHARED_STATE {
uint32_t Magic;
uint32_t Version;
uint32_t Capacity;
uint32_t HeaderBytes;
volatile long ReaderOpen;
volatile long WriterOpen;
uint8_t HeaderReserved[SYS_PIPE_SHARED_HEADER_BYTES - 24u];
volatile uint64_t ReadPosition;
volatile uint64_t WritePosition;
volatile long ReadLock;
volatile long WriteLock;
volatile long ReadWaiters;
volatile long WriteWaiters;
uint8_t RingReserved[16];
uint8_t Buffer[SYS_PIPE_BUFFER_CAPACITY];
} SYS_PIPE_SHARED_STATE;
typedef struct SYS_CREATE_PIPE_REQUEST {
uint32_t Size;
uint32_t Flags;
SYS_HANDLE* ReadHandleOut;
SYS_HANDLE* WriteHandleOut;
SYS_PIPE_SHARED_STATE** SharedStateOut;
} SYS_CREATE_PIPE_REQUEST;
typedef struct SYS_WRITE_CONSOLE_REQUEST {
uint32_t Size;
SYS_STRING_VIEW Text;
@@ -584,6 +654,8 @@ typedef struct SYS_CREATE_THREAD_REQUEST {
uintptr_t Argument;
uint32_t Priority;
uint32_t Flags;
// Both outputs are optional for a running detached thread. Suspended creation
// requires ThreadHandleOut so the caller retains a capability to resume it.
SYS_HANDLE* ThreadHandleOut;
uint32_t* ThreadIdOut;
} SYS_CREATE_THREAD_REQUEST;
@@ -666,8 +738,11 @@ KSTATUS SysKillProcess(SYS_HANDLE processHandle, int32_t exitCode);
#define SYS_THREAD_WAIT_SURFACE 16u
#define SYS_THREAD_WAIT_TIMER 17u
#define SYS_THREAD_WAIT_DISPLAY_CLOCK 18u
#define SYS_THREAD_WAIT_PIPE 19u
#define SYS_THREAD_WAIT_UNKNOWN 0xffffffffu
#define SYS_THREAD_NAME_MAX NTL_THREAD_NAME_MAX
typedef struct SYS_THREAD_INFO {
uint32_t Size;
uint32_t ProcessId;
@@ -691,8 +766,18 @@ typedef struct SYS_THREAD_INFO {
uint32_t WaitObjectType;
uint32_t WaitStatus;
uint32_t KernelApcDisable;
char Name[SYS_THREAD_NAME_MAX];
} SYS_THREAD_INFO;
// Sets one thread description. ThreadHandle == SYS_HANDLE_INVALID targets the
// calling thread. Name may be empty to clear the description.
typedef struct SYS_SET_THREAD_NAME_REQUEST {
uint32_t Size;
SYS_HANDLE ThreadHandle;
SYS_STRING_VIEW Name;
} SYS_SET_THREAD_NAME_REQUEST;
typedef struct SYS_PROCESS_INFO {
uint32_t Size;
uint32_t ProcessId;
@@ -734,6 +819,8 @@ KSTATUS SysResumeThread(SYS_HANDLE threadHandle, uint32_t* previousSuspendCountO
uint32_t SysGetCurrentTid(void);
uint32_t SysGetCurrentPid(void);
KSTATUS SysSetThreadPriority(uint32_t priority);
KSTATUS SysSetThreadName(const SYS_SET_THREAD_NAME_REQUEST* request);
KSTATUS SysQueryThreadName(SYS_HANDLE threadHandle, char* buffer, size_t bufferSize, size_t* lengthOut);
KSTATUS SysYield(void);
#define SYS_TIMER_FLAG_NONE 0u
@@ -923,6 +1010,10 @@ KSTATUS SysTruncateFile(SYS_HANDLE handle, uint64_t newSize);
KSTATUS SysFlushFile(SYS_HANDLE handle);
KSTATUS SysLockFile(const SYS_LOCK_FILE_REQUEST* request);
KSTATUS SysUnlockFile(const SYS_UNLOCK_FILE_REQUEST* request);
KSTATUS SysQueryFileLock(const SYS_QUERY_FILE_LOCK_REQUEST* request);
KSTATUS SysSetFileStatus(const SYS_SET_FILE_STATUS_REQUEST* request);
KSTATUS SysCreatePipe(const SYS_CREATE_PIPE_REQUEST* request);
KSTATUS SysNotifyPipe(SYS_HANDLE pipeHandle);
KSTATUS SysReadDir(SYS_HANDLE handle, SYS_DIR_ENTRY* entryOut);
@@ -983,13 +1074,39 @@ typedef struct SYS_CREATE_SURFACE_REQUEST {
} SYS_CREATE_SURFACE_REQUEST;
KSTATUS SysCreateSurface(const SYS_CREATE_SURFACE_REQUEST* request);
KSTATUS SysMapSurface(SYS_HANDLE surfaceHandle, void** baseOut, uint32_t* pitchBytesOut);
KSTATUS SysMapSurface(SYS_HANDLE surfaceHandle, uint32_t flags, void** baseOut, uint32_t* pitchBytesOut);
KSTATUS SysUnmapSurface(void* base);
KSTATUS SysQuerySurface(SYS_HANDLE surfaceHandle, SYS_SURFACE_DESC* descOut);
KSTATUS SysPresentSurface(SYS_HANDLE surfaceHandle, const DISPLAY_RECT* rects, uint32_t rectCount);
KSTATUS SysCommitSurface(SYS_HANDLE surfaceHandle, const DISPLAY_RECT* rects, uint32_t rectCount, uint64_t* generationOut);
KSTATUS SysClearScreen(uint32_t color);
KSTATUS SysGetScreenSize(int* widthOut, int* heightOut);
KSTATUS SysQueryDisplayInfo(SYS_DISPLAY_INFO* infoOut);
#define SYS_DISPLAY_MANAGER_CURSOR_FLAG_NONE 0x00000000u
#define SYS_DISPLAY_MANAGER_CURSOR_FLAG_SHOW 0x00000001u
#define SYS_DISPLAY_MANAGER_CURSOR_FLAG_HIDE 0x00000002u
typedef struct SYS_DISPLAY_MANAGER_CURSOR_REQUEST {
uint32_t Size;
SYS_HANDLE ManagerHandle;
uint32_t Flags;
int32_t X;
int32_t Y;
} SYS_DISPLAY_MANAGER_CURSOR_REQUEST;
// Capability-scoped display operations used by the native resource plane.
KSTATUS SysQueryDisplayManagerInfo(SYS_HANDLE managerHandle, SYS_DISPLAY_INFO* infoOut);
KSTATUS SysSetDisplayManagerCursor(const SYS_DISPLAY_MANAGER_CURSOR_REQUEST* request);
KSTATUS SysPresentDisplayManagerSurface(SYS_HANDLE managerHandle, SYS_HANDLE surfaceHandle,
const DISPLAY_RECT* rects, uint32_t rectCount);
KSTATUS SysWriteDisplayManagerConsole(SYS_HANDLE managerHandle, const SYS_WRITE_CONSOLE_REQUEST* request);
KSTATUS SysQueryDisplayManagerConsoleInfo(SYS_HANDLE managerHandle, SYS_CONSOLE_INFO* infoOut);
KSTATUS SysSetDisplayManagerConsoleCursor(SYS_HANDLE managerHandle, int x, int y);
KSTATUS SysFillDisplayManagerConsoleCharacter(SYS_HANDLE managerHandle, const SYS_FILL_CONSOLE_CHARACTER_REQUEST* request);
KSTATUS SysFillDisplayManagerConsoleAttribute(SYS_HANDLE managerHandle, const SYS_FILL_CONSOLE_ATTRIBUTE_REQUEST* request);
KSTATUS SysPutDisplayManagerConsoleCharacter(SYS_HANDLE managerHandle, const SYS_PUT_SCREEN_CHAR_REQUEST* request);
KSTATUS SysClearDisplayManagerConsole(SYS_HANDLE managerHandle, uint32_t color);
// Display clocks are waitable pacing objects. Providers with frame-event
// support signal them once per submitted frame. Other providers use the boot processor
// scheduler tick, with PeriodMilliseconds rounded up to one or more ticks.
@@ -1006,14 +1123,38 @@ typedef struct SYS_OPEN_DISPLAY_CLOCK_REQUEST {
KSTATUS SysOpenDisplayClock(const SYS_OPEN_DISPLAY_CLOCK_REQUEST* request);
// Input.
#define SYS_INPUT_MANAGER_EVENT_FLAG_NONE 0x00000000u
#define SYS_INPUT_MANAGER_EVENT_KEY 1u
#define SYS_INPUT_MANAGER_EVENT_MOUSE 2u
typedef struct SYS_INPUT_MANAGER_EVENT {
uint32_t Size;
uint32_t Type;
uint64_t Sequence;
union {
INPUT_KEY_EVENT Key;
INPUT_MOUSE_EVENT Mouse;
} Data;
} SYS_INPUT_MANAGER_EVENT;
typedef struct SYS_INPUT_MANAGER_READ_REQUEST {
uint32_t Size;
SYS_HANDLE ManagerHandle;
uint32_t Flags;
uint64_t TimeoutMilliseconds;
SYS_INPUT_MANAGER_EVENT* EventOut;
} SYS_INPUT_MANAGER_READ_REQUEST;
// Reads the next normalized physical input event through an input-manager capability.
KSTATUS SysReadInputManagerEvent(const SYS_INPUT_MANAGER_READ_REQUEST* request);
#define SYS_INPUT_QUEUE_FLAG_NONE 0x00000000u
#define SYS_INPUT_EVENT_FLAG_NONE 0x00000000u
#define SYS_GLOBAL_INPUT_STATE_FLAG_NONE 0x00000000u
#define SYS_GLOBAL_INPUT_KEY_BYTES 32u
// SysQueryGlobalInputState snapshots the current physical input state. It does
// not consume queued keyboard or mouse events and is intentionally global; a
// later routed input context API should use a context handle instead.
// Legacy kernel-global input snapshot retained for compatibility. Normal interactive
// clients should consume RSSRV logical input through <ntlite/input_service.h>.
typedef struct SYS_GLOBAL_INPUT_STATE {
uint32_t Size;
uint32_t Flags;
@@ -1267,7 +1408,7 @@ typedef struct SYS_MEMORY_STATUS {
// Public stats payloads start with Size and Version. Size is the byte count
// returned for that payload, including any trailing records. Version describes
// the field layout for fixed fields in the named payload.
#define SYS_STATS_VERSION 1u
#define SYS_STATS_VERSION 3u
typedef struct SYS_EXCEPTION_STATS {
+7
View File
@@ -0,0 +1,7 @@
// Public thread constants shared by native user mode and kernel clients.
#pragma once
// Thread descriptions are UTF-8 byte strings stored inline with the thread.
// The limit includes the terminating NUL byte.
#define NTL_THREAD_NAME_MAX 64u
+16
View File
@@ -0,0 +1,16 @@
// Internet address conversion declarations for nt-lite POSIX.
#pragma once
#include <netinet/in.h>
#include <ntlite_posix_api.h>
NTL_POSIX_API uint16_t htons(uint16_t value);
NTL_POSIX_API uint16_t ntohs(uint16_t value);
NTL_POSIX_API uint32_t htonl(uint32_t value);
NTL_POSIX_API uint32_t ntohl(uint32_t value);
NTL_POSIX_API in_addr_t inet_addr(const char* text);
NTL_POSIX_API char* inet_ntoa(struct in_addr address);
NTL_POSIX_API int inet_pton(int family, const char* source, void* destination);
NTL_POSIX_API const char* inet_ntop(int family, const void* source,
char* destination, socklen_t size);
+28
View File
@@ -0,0 +1,28 @@
// POSIX directory-stream declarations for nt-lite.
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <ntlite_posix_api.h>
#define NAME_MAX 259
#define DT_UNKNOWN 0
#define DT_DIR 4
#define DT_REG 8
typedef struct dirent {
char d_name[NAME_MAX + 1];
unsigned char d_type;
} dirent;
typedef struct DIR {
uint32_t KHandle;
dirent Current;
bool Valid;
} DIR;
NTL_POSIX_API DIR* opendir(const char* path);
NTL_POSIX_API struct dirent* readdir(DIR* directory);
NTL_POSIX_API int closedir(DIR* directory);
+15
View File
@@ -0,0 +1,15 @@
// nt-lite dynamic-loader POSIX extension declarations.
#pragma once
#include <ntlite_posix_api.h>
#define RTLD_LAZY 0x0001
#define RTLD_NOW 0x0002
#define RTLD_LOCAL 0x0004
#define RTLD_GLOBAL 0x0008
NTL_POSIX_API void* dlopen(const char* filename, int flags);
NTL_POSIX_API void* dlsym(void* handle, const char* symbol);
NTL_POSIX_API int dlclose(void* handle);
NTL_POSIX_API char* dlerror(void);
+50
View File
@@ -0,0 +1,50 @@
// POSIX errno declarations backed by nt-lite per-thread personality state.
#pragma once
#include <ntlite_posix_api.h>
// errno values are an nt-lite POSIX personality ABI. POSIX specifies the
// symbolic names, not their numeric representation, so keep this table compact
// and personality-owned instead of inheriting numbers from another Unix ABI.
#define EPERM 1
#define ENOENT 2
#define ESRCH 3
#define EINTR 4
#define EIO 5
#define ENOEXEC 6
#define EBADF 7
#define ECHILD 8
#define ENOMEM 9
#define EACCES 10
#define EFAULT 11
#define EEXIST 12
#define EXDEV 13
#define ENODEV 14
#define ENOTDIR 15
#define EISDIR 16
#define EINVAL 17
#define EMFILE 18
#define EFBIG 19
#define ENOSPC 20
#define ESPIPE 21
#define EROFS 22
#define EMLINK 23
#define EPIPE 24
#define ERANGE 25
#define EAGAIN 26
#define EWOULDBLOCK EAGAIN
#define ENAMETOOLONG 27
#define ENOSYS 28
#define ENOTEMPTY 29
#define EDEADLK 30
#define ENOTSOCK 31
#define EAFNOSUPPORT 32
#define ECONNRESET 33
#define EINPROGRESS 34
#define ETIMEDOUT 35
#define ECANCELED 36
NTL_POSIX_API int* __ntl_posix_errno_location(void);
#define errno (*__ntl_posix_errno_location())
+41
View File
@@ -0,0 +1,41 @@
// POSIX file-control declarations currently implemented by nt-lite.
#pragma once
#include <sys/types.h>
#include <ntlite_posix_api.h>
#define O_RDONLY 0x0000
#define O_WRONLY 0x0001
#define O_RDWR 0x0002
#define O_CREAT 0x0040
#define O_TRUNC 0x0200
#define O_APPEND 0x0400
#define O_NONBLOCK 0x0800
#define O_ACCMODE 0x0003
#define F_DUPFD 0
#define F_GETFD 1
#define F_SETFD 2
#define F_GETFL 3
#define F_SETFL 4
#define F_GETLK 5
#define F_SETLK 6
#define F_SETLKW 7
#define F_RDLCK 0
#define F_WRLCK 1
#define F_UNLCK 2
#define FD_CLOEXEC 1
struct flock {
short l_type;
short l_whence;
off_t l_start;
off_t l_len;
pid_t l_pid;
};
NTL_POSIX_API int open(const char* path, int flags, ...);
NTL_POSIX_API int fcntl(int fd, int command, ...);
+15
View File
@@ -0,0 +1,15 @@
// POSIX group-database declarations backed by posixsrv identity policy.
#pragma once
#include <sys/types.h>
#include <ntlite_posix_api.h>
struct group {
char* gr_name;
gid_t gr_gid;
char** gr_mem;
};
NTL_POSIX_API struct group* getgrnam(const char* name);
NTL_POSIX_API struct group* getgrgid(gid_t gid);
+34
View File
@@ -0,0 +1,34 @@
// POSIX name-resolution declarations supported by nt-lite.
#pragma once
#include <sys/socket.h>
#include <ntlite_posix_api.h>
struct hostent {
char* h_name;
char** h_aliases;
int h_addrtype;
int h_length;
char** h_addr_list;
};
#define h_addr h_addr_list[0]
struct addrinfo {
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
socklen_t ai_addrlen;
struct sockaddr* ai_addr;
char* ai_canonname;
struct addrinfo* ai_next;
};
#define AI_PASSIVE 0x0001
NTL_POSIX_API struct hostent* gethostbyname(const char* name);
NTL_POSIX_API int getaddrinfo(const char* node, const char* service,
const struct addrinfo* hints, struct addrinfo** result);
NTL_POSIX_API void freeaddrinfo(struct addrinfo* result);
+40
View File
@@ -0,0 +1,40 @@
// IPv4 and IPv6 address declarations for the nt-lite POSIX socket layer.
#pragma once
#include <stdint.h>
#include <sys/socket.h>
typedef uint16_t in_port_t;
typedef uint32_t in_addr_t;
#define IPPROTO_ICMP 1
#define IPPROTO_TCP 6
#define IPPROTO_UDP 17
#define IPPROTO_ICMPV6 58
#define INADDR_ANY ((in_addr_t)0x00000000u)
#define INADDR_NONE ((in_addr_t)0xFFFFFFFFu)
struct in_addr {
in_addr_t s_addr;
};
struct in6_addr {
uint8_t s6_addr[16];
};
struct sockaddr_in {
sa_family_t sin_family;
in_port_t sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
struct sockaddr_in6 {
sa_family_t sin6_family;
in_port_t sin6_port;
uint32_t sin6_flowinfo;
struct in6_addr sin6_addr;
uint32_t sin6_scope_id;
};
@@ -0,0 +1,10 @@
// nt-lite-specific extensions kept above the POSIX.1-1990-shaped profile.
#pragma once
#include <ntlite_posix_api.h>
NTL_POSIX_API const char* posix_get_command_line(void);
NTL_POSIX_API char* realpath(const char* path, char* resolvedPath);
NTL_POSIX_API void clearscreen(void);
NTL_POSIX_API void clearkeyboard(void);
+9
View File
@@ -0,0 +1,9 @@
// nt-lite POSIX public ABI decoration shared by the POSIX include tree.
#pragma once
#ifdef NTL_POSIX_BUILD
#define NTL_POSIX_API __declspec(dllexport)
#else
#define NTL_POSIX_API __declspec(dllimport)
#endif
+150
View File
@@ -0,0 +1,150 @@
// nt-lite POSIX target manifest: name, profile class, implementation state.
// IMPLEMENTED is callable now, PARTIAL has intentionally incomplete semantics,
// PLANNED belongs to the active target, and UNSUPPORTED is deliberately rejected.
POSIX_API(getpid, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(getppid, POSIX1990_DEFERRED_PROCESS_MODEL, PLANNED)
POSIX_API(wait, POSIX1990_DEFERRED_PROCESS_MODEL, PLANNED)
POSIX_API(waitpid, POSIX1990_DEFERRED_PROCESS_MODEL, PARTIAL)
POSIX_API(_exit, POSIX1990_REQUIRED, PLANNED)
POSIX_API(fork, POSIX1990_DEFERRED_PROCESS_MODEL, UNSUPPORTED)
POSIX_API(vfork, POSIX1990_DEFERRED_PROCESS_MODEL, PLANNED)
POSIX_API(execl, POSIX1990_DEFERRED_PROCESS_MODEL, DEFERRED)
POSIX_API(execle, POSIX1990_DEFERRED_PROCESS_MODEL, DEFERRED)
POSIX_API(execlp, POSIX1990_DEFERRED_PROCESS_MODEL, DEFERRED)
POSIX_API(execv, POSIX1990_DEFERRED_PROCESS_MODEL, DEFERRED)
POSIX_API(execve, POSIX1990_DEFERRED_PROCESS_MODEL, PLANNED)
POSIX_API(execvp, POSIX1990_DEFERRED_PROCESS_MODEL, DEFERRED)
POSIX_API(read, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(write, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(open, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(close, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(lseek, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(pipe, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(dup, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(dup2, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(fcntl, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(chdir, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(getcwd, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(unlink, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(stat, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(fstat, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(opendir, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(readdir, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(closedir, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(rewinddir, POSIX1990_REQUIRED, PLANNED)
POSIX_API(creat, POSIX1990_REQUIRED, PLANNED)
POSIX_API(umask, POSIX1990_REQUIRED, PLANNED)
POSIX_API(link, POSIX1990_REQUIRED, PLANNED)
POSIX_API(mkdir, POSIX1990_REQUIRED, PLANNED)
POSIX_API(mkfifo, POSIX1990_REQUIRED, PLANNED)
POSIX_API(rmdir, POSIX1990_REQUIRED, PLANNED)
POSIX_API(rename, POSIX1990_REQUIRED, PLANNED)
POSIX_API(access, POSIX1990_REQUIRED, PLANNED)
POSIX_API(chmod, POSIX1990_REQUIRED, PLANNED)
POSIX_API(fchmod, POSIX1990_REQUIRED, PLANNED)
POSIX_API(chown, POSIX1990_REQUIRED, PLANNED)
POSIX_API(fchown, POSIX1990_REQUIRED, PLANNED)
POSIX_API(utime, POSIX1990_REQUIRED, PLANNED)
POSIX_API(pathconf, POSIX1990_REQUIRED, PLANNED)
POSIX_API(fpathconf, POSIX1990_REQUIRED, PLANNED)
POSIX_API(getuid, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(geteuid, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(getgid, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(getegid, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(setuid, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(setgid, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(getgroups, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(getlogin, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(getpgrp, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(setpgid, POSIX1990_REQUIRED, PARTIAL)
POSIX_API(setsid, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(uname, POSIX1990_REQUIRED, PLANNED)
POSIX_API(time, POSIX1990_REQUIRED, PLANNED)
POSIX_API(times, POSIX1990_REQUIRED, PLANNED)
POSIX_API(getenv, POSIX1990_REQUIRED, PLANNED)
POSIX_API(ctermid, POSIX1990_REQUIRED, PLANNED)
POSIX_API(ttyname, POSIX1990_REQUIRED, PLANNED)
POSIX_API(isatty, POSIX1990_REQUIRED, PLANNED)
POSIX_API(sysconf, POSIX1990_REQUIRED, PLANNED)
POSIX_API(sigemptyset, POSIX1990_REQUIRED, PLANNED)
POSIX_API(sigfillset, POSIX1990_REQUIRED, PLANNED)
POSIX_API(sigaddset, POSIX1990_REQUIRED, PLANNED)
POSIX_API(sigdelset, POSIX1990_REQUIRED, PLANNED)
POSIX_API(sigismember, POSIX1990_REQUIRED, PLANNED)
POSIX_API(sigaction, POSIX1990_REQUIRED, PLANNED)
POSIX_API(sigprocmask, POSIX1990_REQUIRED, PLANNED)
POSIX_API(sigpending, POSIX1990_REQUIRED, PLANNED)
POSIX_API(sigsuspend, POSIX1990_REQUIRED, PLANNED)
POSIX_API(kill, POSIX1990_REQUIRED, PLANNED)
POSIX_API(alarm, POSIX1990_REQUIRED, PLANNED)
POSIX_API(pause, POSIX1990_REQUIRED, PLANNED)
POSIX_API(sleep, POSIX1990_REQUIRED, PLANNED)
POSIX_API(signal, POSIX1990_REQUIRED, PLANNED)
POSIX_API(raise, POSIX1990_REQUIRED, PLANNED)
POSIX_API(cfgetispeed, POSIX1990_REQUIRED, PLANNED)
POSIX_API(cfgetospeed, POSIX1990_REQUIRED, PLANNED)
POSIX_API(cfsetispeed, POSIX1990_REQUIRED, PLANNED)
POSIX_API(cfsetospeed, POSIX1990_REQUIRED, PLANNED)
POSIX_API(tcgetattr, POSIX1990_REQUIRED, PLANNED)
POSIX_API(tcsetattr, POSIX1990_REQUIRED, PLANNED)
POSIX_API(tcsendbreak, POSIX1990_REQUIRED, PLANNED)
POSIX_API(tcdrain, POSIX1990_REQUIRED, PLANNED)
POSIX_API(tcflush, POSIX1990_REQUIRED, PLANNED)
POSIX_API(tcflow, POSIX1990_REQUIRED, PLANNED)
POSIX_API(tcgetpgrp, POSIX1990_REQUIRED, PLANNED)
POSIX_API(tcsetpgrp, POSIX1990_REQUIRED, PLANNED)
POSIX_API(getpwnam, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(getpwuid, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(getgrnam, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(getgrgid, POSIX1990_REQUIRED, IMPLEMENTED)
POSIX_API(mmap, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(munmap, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(msync, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(dlopen, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(dlsym, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(dlclose, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(dlerror, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(pthread_create, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(pthread_join, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(pthread_exit, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(pthread_mutex_init, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(pthread_mutex_destroy, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(pthread_mutex_lock, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(pthread_mutex_trylock, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(pthread_mutex_unlock, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(posix_spawn, NTL_POSIX_EXTENSION, PARTIAL)
POSIX_API(socket, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(bind, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(listen, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(accept, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(connect, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(send, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(recv, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(sendto, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(recvfrom, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(shutdown, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(setsockopt, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(getsockopt, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(poll, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(htons, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(ntohs, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(htonl, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(ntohl, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(inet_addr, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(inet_ntoa, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(inet_pton, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(inet_ntop, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(gethostbyname, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(getaddrinfo, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(freeaddrinfo, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(posix_get_command_line, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(realpath, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(clearscreen, NTL_POSIX_EXTENSION, IMPLEMENTED)
POSIX_API(clearkeyboard, NTL_POSIX_EXTENSION, IMPLEMENTED)
+13
View File
@@ -0,0 +1,13 @@
// nt-lite POSIX profile identity and deliberate conformance limits.
#pragma once
#define NTL_POSIX_PROFILE_VERSION 199009L
#define NTL_POSIX_FORMAL_CONFORMANCE 0
#define NTL_POSIX_HAS_FORK 0
#define NTL_POSIX_HAS_VFORK 0
#define NTL_POSIX_HAS_EXECVE 0
#define NTL_POSIX_HAS_NATIVE_EXEC_REPLACEMENT 0
#define NTL_POSIX_HAS_POSIX_SPAWN 1
// ntlite_posix_profile.def is the X-macro API target/implementation manifest.
+21
View File
@@ -0,0 +1,21 @@
// POSIX poll declarations supported by nt-lite.
#pragma once
#include <ntlite_posix_api.h>
typedef unsigned long nfds_t;
struct pollfd {
int fd;
short events;
short revents;
};
#define POLLIN 0x0001
#define POLLOUT 0x0002
#define POLLERR 0x0004
#define POLLHUP 0x0008
#define POLLNVAL 0x0010
NTL_POSIX_API int poll(struct pollfd* descriptors, nfds_t count, int timeout);
+28
View File
@@ -0,0 +1,28 @@
// nt-lite pthread extension declarations.
#pragma once
#include <stdint.h>
#include <ntlite_posix_api.h>
typedef struct pthread_t {
uint32_t Handle;
uint32_t Tid;
} pthread_t;
typedef struct pthread_mutex_t {
uint32_t Handle;
} pthread_mutex_t;
typedef void* pthread_attr_t;
typedef void* pthread_mutexattr_t;
NTL_POSIX_API int pthread_create(pthread_t* thread, const pthread_attr_t* attr,
void* (*routine)(void*), void* argument);
NTL_POSIX_API int pthread_join(pthread_t thread, void** result);
NTL_POSIX_API void pthread_exit(void* result);
NTL_POSIX_API int pthread_mutex_init(pthread_mutex_t* mutex, const pthread_mutexattr_t* attr);
NTL_POSIX_API int pthread_mutex_destroy(pthread_mutex_t* mutex);
NTL_POSIX_API int pthread_mutex_lock(pthread_mutex_t* mutex);
NTL_POSIX_API int pthread_mutex_trylock(pthread_mutex_t* mutex);
NTL_POSIX_API int pthread_mutex_unlock(pthread_mutex_t* mutex);
+17
View File
@@ -0,0 +1,17 @@
// POSIX password-database declarations backed by posixsrv identity policy.
#pragma once
#include <sys/types.h>
#include <ntlite_posix_api.h>
struct passwd {
char* pw_name;
uid_t pw_uid;
gid_t pw_gid;
char* pw_dir;
char* pw_shell;
};
NTL_POSIX_API struct passwd* getpwnam(const char* name);
NTL_POSIX_API struct passwd* getpwuid(uid_t uid);
+8
View File
@@ -0,0 +1,8 @@
// POSIX signal type declarations reserved for the next runtime phase.
#pragma once
#include <stdint.h>
typedef uint64_t sigset_t;
typedef int sig_atomic_t;
+14
View File
@@ -0,0 +1,14 @@
// nt-lite posix_spawn declarations.
#pragma once
#include <sys/types.h>
#include <ntlite_posix_api.h>
typedef void* posix_spawn_file_actions_t;
typedef void* posix_spawnattr_t;
NTL_POSIX_API int posix_spawn(pid_t* pid, const char* path,
const posix_spawn_file_actions_t* fileActions,
const posix_spawnattr_t* attributes,
char* const argv[], char* const envp[]);
+12
View File
@@ -0,0 +1,12 @@
// C allocation and process-exit declarations exported by nt-lite posix.dll.
#pragma once
#include <stddef.h>
#include <ntlite_posix_api.h>
NTL_POSIX_API void* malloc(size_t size);
NTL_POSIX_API void* calloc(size_t count, size_t size);
NTL_POSIX_API void* realloc(void* pointer, size_t size);
NTL_POSIX_API void free(void* pointer);
NTL_POSIX_API void exit(int status);
+24
View File
@@ -0,0 +1,24 @@
// nt-lite mmap extension declarations.
#pragma once
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include <ntlite_posix_api.h>
#define PROT_NONE 0x0
#define PROT_READ 0x1
#define PROT_WRITE 0x2
#define PROT_EXEC 0x4
#define MAP_SHARED 0x01
#define MAP_PRIVATE 0x02
#define MAP_FAILED ((void*)(intptr_t)-1)
#define MS_ASYNC 0x01
#define MS_SYNC 0x04
#define MS_INVALIDATE 0x02
NTL_POSIX_API void* mmap(void* address, size_t length, int protection,
int flags, int fd, off_t offset);
NTL_POSIX_API int munmap(void* address, size_t length);
NTL_POSIX_API int msync(void* address, size_t length, int flags);
+50
View File
@@ -0,0 +1,50 @@
// POSIX socket declarations supported by nt-lite.
#pragma once
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include <ntlite_posix_api.h>
typedef uint16_t sa_family_t;
typedef uint32_t socklen_t;
#define AF_UNSPEC 0
#define AF_INET 2
#define AF_INET6 10
#define PF_INET AF_INET
#define PF_INET6 AF_INET6
#define SOCK_STREAM 1
#define SOCK_DGRAM 2
#define SOCK_RAW 3
#define SHUT_RD 0
#define SHUT_WR 1
#define SHUT_RDWR 2
#define SOL_SOCKET 1
#define SO_RCVTIMEO 1
#define SO_SNDTIMEO 2
#define SO_NONBLOCK 3
struct sockaddr {
sa_family_t sa_family;
char sa_data[14];
};
NTL_POSIX_API int socket(int domain, int type, int protocol);
NTL_POSIX_API int bind(int fd, const struct sockaddr* address, socklen_t addressLength);
NTL_POSIX_API int listen(int fd, int backlog);
NTL_POSIX_API int accept(int fd, struct sockaddr* address, socklen_t* addressLength);
NTL_POSIX_API int connect(int fd, const struct sockaddr* address, socklen_t addressLength);
NTL_POSIX_API ssize_t send(int fd, const void* buffer, size_t length, int flags);
NTL_POSIX_API ssize_t recv(int fd, void* buffer, size_t length, int flags);
NTL_POSIX_API ssize_t sendto(int fd, const void* buffer, size_t length, int flags,
const struct sockaddr* destination, socklen_t destinationLength);
NTL_POSIX_API ssize_t recvfrom(int fd, void* buffer, size_t length, int flags,
struct sockaddr* source, socklen_t* sourceLength);
NTL_POSIX_API int shutdown(int fd, int how);
NTL_POSIX_API int setsockopt(int fd, int level, int option, const void* value, socklen_t valueLength);
NTL_POSIX_API int getsockopt(int fd, int level, int option, void* value, socklen_t* valueLength);
+46
View File
@@ -0,0 +1,46 @@
// POSIX file-status declarations for nt-lite.
#pragma once
#include <stdint.h>
#include <sys/types.h>
#include <ntlite_posix_api.h>
#define S_IFMT 0170000
#define S_IFSOCK 0140000
#define S_IFIFO 0010000
#define S_IFCHR 0020000
#define S_IFDIR 0040000
#define S_IFREG 0100000
#define S_IRUSR 0000400
#define S_IWUSR 0000200
#define S_IXUSR 0000100
#define S_IRGRP 0000040
#define S_IWGRP 0000020
#define S_IXGRP 0000010
#define S_IROTH 0000004
#define S_IWOTH 0000002
#define S_IXOTH 0000001
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
struct stat {
uint64_t st_dev;
uint64_t st_ino;
mode_t st_mode;
uint32_t st_nlink;
uid_t st_uid;
gid_t st_gid;
uint64_t st_rdev;
off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
NTL_POSIX_API int stat(const char* path, struct stat* out);
NTL_POSIX_API int fstat(int fd, struct stat* out);
+8
View File
@@ -0,0 +1,8 @@
// POSIX time-value declarations used by nt-lite socket options.
#pragma once
struct timeval {
long tv_sec;
long tv_usec;
};
+12
View File
@@ -0,0 +1,12 @@
// POSIX process-time declarations reserved for the process facade.
#pragma once
#include <sys/types.h>
struct tms {
clock_t tms_utime;
clock_t tms_stime;
clock_t tms_cutime;
clock_t tms_cstime;
};
+15
View File
@@ -0,0 +1,15 @@
// POSIX scalar type declarations for nt-lite.
#pragma once
#include <stdint.h>
#include <stddef.h>
typedef int32_t pid_t;
typedef int32_t off_t;
typedef uint32_t mode_t;
typedef uint32_t uid_t;
typedef uint32_t gid_t;
typedef int64_t ssize_t;
typedef int64_t time_t;
typedef int64_t clock_t;
+13
View File
@@ -0,0 +1,13 @@
// POSIX system-name declarations reserved for the identity facade.
#pragma once
#define _UTSNAME_LENGTH 65
struct utsname {
char sysname[_UTSNAME_LENGTH];
char nodename[_UTSNAME_LENGTH];
char release[_UTSNAME_LENGTH];
char version[_UTSNAME_LENGTH];
char machine[_UTSNAME_LENGTH];
};
+10
View File
@@ -0,0 +1,10 @@
// POSIX wait declarations for nt-lite spawn associations.
#pragma once
#include <sys/types.h>
#include <ntlite_posix_api.h>
#define WEXITSTATUS(status) (((status) >> 8) & 0xff)
NTL_POSIX_API pid_t waitpid(pid_t pid, int* status, int options);
+19
View File
@@ -0,0 +1,19 @@
// POSIX terminal type declarations reserved for the tty phase.
#pragma once
#include <stdint.h>
typedef uint32_t tcflag_t;
typedef uint8_t cc_t;
typedef uint32_t speed_t;
#define NCCS 20
struct termios {
tcflag_t c_iflag;
tcflag_t c_oflag;
tcflag_t c_cflag;
tcflag_t c_lflag;
cc_t c_cc[NCCS];
};
+39
View File
@@ -0,0 +1,39 @@
// POSIX process, path, and byte-stream declarations for nt-lite.
#pragma once
#include <stddef.h>
#include <sys/types.h>
#include <ntlite_posix_api.h>
#include <ntlite_posix_profile.h>
#define _POSIX_VERSION NTL_POSIX_PROFILE_VERSION
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#define PIPE_BUF 4096
NTL_POSIX_API ssize_t read(int fd, void* buffer, size_t count);
NTL_POSIX_API ssize_t write(int fd, const void* buffer, size_t count);
NTL_POSIX_API int close(int fd);
NTL_POSIX_API int dup(int oldfd);
NTL_POSIX_API int dup2(int oldfd, int newfd);
NTL_POSIX_API int pipe(int pipefd[2]);
NTL_POSIX_API off_t lseek(int fd, off_t offset, int whence);
NTL_POSIX_API int chdir(const char* path);
NTL_POSIX_API char* getcwd(char* buffer, size_t size);
NTL_POSIX_API int unlink(const char* path);
NTL_POSIX_API pid_t getpid(void);
NTL_POSIX_API uid_t getuid(void);
NTL_POSIX_API uid_t geteuid(void);
NTL_POSIX_API gid_t getgid(void);
NTL_POSIX_API gid_t getegid(void);
NTL_POSIX_API int setuid(uid_t uid);
NTL_POSIX_API int setgid(gid_t gid);
NTL_POSIX_API int getgroups(int size, gid_t list[]);
NTL_POSIX_API char* getlogin(void);
NTL_POSIX_API pid_t getpgrp(void);
NTL_POSIX_API int setpgid(pid_t pid, pid_t pgid);
NTL_POSIX_API pid_t setsid(void);
+10
View File
@@ -0,0 +1,10 @@
// POSIX file-time declarations reserved for the filesystem facade.
#pragma once
#include <sys/types.h>
struct utimbuf {
time_t actime;
time_t modtime;
};