replace nob with ms' build, move disk creation to build.bat, major comment cleanup, remove old and stupid tests, overhaul interrupt management with per-CPU vector allocation, affinity migration and safe teardown, add proper IOAPIC routing and PCI MSI/MSI-X/INTx support, migrate drivers to the new interrupt API, integrate ACPICA with a proper OS services layer, move ACPI firmware events, power button handling and S5 shutdown into acpi.sys, add parallel driver startup and atomic publication, replace PnP arrays with dynamic lists, redesign service startup again to be asynchronous, add delayed startup mode for services, allow omitting keys in services.ini, fix acpi ec deferred work handling, fix kernel threads having garbage exit code.

This commit is contained in:
maksw committed 2026-10-28 15:18:43 +01:00
1 parent d36f19509c
commit 36eef8f58d
696 files changed
+147281 -7530

No files matched your search

+1
View File
@@ -0,0 +1 @@
!include $(BASEDIR)\makefile.def
@@ -127,7 +127,6 @@ __declspec(dllexport) char* realpath(const char* path, char* resolved_path) {
return PosixCopyResolvedPath(posix, resolved_path);
}
// Implements the opendir operation.
__declspec(dllexport) DIR* opendir(const char* path) {
char native[512];
PosixTranslatePath(path, native, sizeof(native));
@@ -145,7 +144,6 @@ __declspec(dllexport) DIR* opendir(const char* path) {
return d;
}
// Implements the readdir operation.
__declspec(dllexport) struct dirent* readdir(DIR* d) {
if (!d) { errno = EBADF; return (struct dirent*)0; }
KDIR_ENTRY ke;
@@ -161,7 +159,6 @@ __declspec(dllexport) struct dirent* readdir(DIR* d) {
return &d->Current;
}
// Implements the closedir operation.
__declspec(dllexport) int closedir(DIR* d) {
if (!d) { errno = EBADF; return -1; }
SysCloseHandle(d->KHandle);
@@ -204,7 +201,6 @@ static int PosixFillSyntheticStat(mode_t type, struct stat* out) {
return 0;
}
// Implements the stat operation.
__declspec(dllexport) int stat(const char* path, struct stat* out) {
if (!path || !out) { errno = EINVAL; return -1; }
@@ -219,7 +215,6 @@ __declspec(dllexport) int stat(const char* path, struct stat* out) {
return PosixFillStat(&nativeStat, out);
}
// Implements the fstat operation.
__declspec(dllexport) int fstat(int fd, struct stat* out) {
if (!out) { errno = EINVAL; return -1; }
@@ -9,12 +9,10 @@
#include "posix_internal.h"
#include "posix_fd.h"
// Implements the bswap16 operation.
static uint16_t bswap16(uint16_t x) {
return (uint16_t)((x << 8) | (x >> 8));
}
// Implements the bswap32 operation.
static uint32_t bswap32(uint32_t x) {
return ((x & 0x000000FFu) << 24) |
((x & 0x0000FF00u) << 8) |
@@ -22,13 +20,9 @@ static uint32_t bswap32(uint32_t x) {
((x & 0xFF000000u) >> 24);
}
// Implements the htons operation.
__declspec(dllexport) uint16_t htons(uint16_t x) { return bswap16(x); }
// Implements the ntohs operation.
__declspec(dllexport) uint16_t ntohs(uint16_t x) { return bswap16(x); }
// Implements the htonl operation.
__declspec(dllexport) uint32_t htonl(uint32_t x) { return bswap32(x); }
// Implements the ntohl operation.
__declspec(dllexport) uint32_t ntohl(uint32_t x) { return bswap32(x); }
// Parses byte.
@@ -148,7 +142,6 @@ static char* AppendHex16(char* out, uint16_t value) {
return out;
}
// Implements the inet addr operation.
__declspec(dllexport) in_addr_t inet_addr(const char* text) {
uint8_t b[4];
if (!text || !ParseIpv4Bytes(text, b)) return INADDR_NONE;
@@ -158,7 +151,6 @@ __declspec(dllexport) in_addr_t inet_addr(const char* text) {
return out;
}
// Implements the inet ntoa operation.
__declspec(dllexport) char* inet_ntoa(struct in_addr in) {
static char buf[16];
const uint8_t* p = (const uint8_t*)&in.s_addr;
@@ -175,7 +167,6 @@ __declspec(dllexport) char* inet_ntoa(struct in_addr in) {
return buf;
}
// Implements the inet pton operation.
__declspec(dllexport) int inet_pton(int af, const char* src, void* dst) {
if (!src || !dst) { errno = EINVAL; return -1; }
if (af == AF_INET) {
@@ -196,7 +187,6 @@ __declspec(dllexport) int inet_pton(int af, const char* src, void* dst) {
return -1;
}
// Implements the inet ntop operation.
__declspec(dllexport) const char* inet_ntop(int af, const void* src, char* dst, socklen_t size) {
if (!src || !dst) { errno = EINVAL; return (const char*)0; }
if (af == AF_INET) {
@@ -223,7 +213,6 @@ __declspec(dllexport) const char* inet_ntop(int af, const void* src, char* dst,
return (const char*)0;
}
// Implements the sock Addr To Sys operation.
static int SockAddrToSys(const struct sockaddr* addr, socklen_t addrlen, SYS_SOCKET_ADDRESS* out) {
if (!addr || !out) { errno = EINVAL; return -1; }
memset(out, 0, sizeof(*out));
@@ -252,7 +241,6 @@ static int SockAddrToSys(const struct sockaddr* addr, socklen_t addrlen, SYS_SOC
return -1;
}
// Implements the to Sock Addr operation.
static void SysToSockAddr(const SYS_SOCKET_ADDRESS* in, struct sockaddr* addr, socklen_t* addrlen) {
if (!in || !addr || !addrlen) return;
@@ -691,7 +679,6 @@ static unsigned ParsePort(const char* s) {
return *s == '\0' ? v : 0;
}
// Implements the resolve Name operation.
static int ResolveNameFamily(const char* name, int family, SYS_SOCKET_ADDRESS* out) {
if (!name || !out) { errno = EINVAL; return -1; }
memset(out, 0, sizeof(*out));
@@ -739,7 +726,6 @@ static int ResolveNameAny(const char* name, int family, SYS_SOCKET_ADDRESS* out)
return ResolveNameFamily(name, AF_INET, out);
}
// Implements the gethostbyname operation.
__declspec(dllexport) struct hostent* gethostbyname(const char* name) {
static struct hostent h;
static char hname[256];
@@ -804,7 +790,6 @@ __declspec(dllexport) int getaddrinfo(const char* node, const char* service,
return 0;
}
// Implements the freeaddrinfo operation.
__declspec(dllexport) void freeaddrinfo(struct addrinfo* res) {
if (res) free(res);
}
@@ -38,7 +38,6 @@ typedef struct {
uint64_t SignalMask;
} PTHREAD_TRAMP;
// Implements the pthread Trampoline operation.
static void PthreadTrampoline(uintptr_t raw) {
PTHREAD_TRAMP* tr = (PTHREAD_TRAMP*)raw;
void* (*fn)(void*) = tr->Fn;
@@ -110,7 +109,6 @@ __declspec(dllexport) int pthread_create(pthread_t* t, const pthread_attr_t* att
return 0;
}
// Implements the pthread join operation.
__declspec(dllexport) int pthread_join(pthread_t t, void** retval) {
KSTATUS s = SysWait(t.Handle, SYS_WAIT_FLAG_NONE);
if (s != 0) return ESRCH;
@@ -122,7 +120,6 @@ __declspec(dllexport) int pthread_join(pthread_t t, void** retval) {
return 0;
}
// Implements the pthread exit operation.
__declspec(dllexport) void pthread_exit(void* retval) {
uint32_t tid = SysGetCurrentTid();
POSIX_PTHREAD_SLOT* slot = PthreadSlotFind(tid);
@@ -132,7 +129,6 @@ __declspec(dllexport) void pthread_exit(void* retval) {
while (1); // unreachable
}
// Implements the pthread mutex init operation.
__declspec(dllexport) int pthread_mutex_init(pthread_mutex_t* m, const pthread_mutexattr_t* attr) {
(void)attr;
uint32_t h;
@@ -142,26 +138,22 @@ __declspec(dllexport) int pthread_mutex_init(pthread_mutex_t* m, const pthread_m
return 0;
}
// Implements the pthread mutex destroy operation.
__declspec(dllexport) int pthread_mutex_destroy(pthread_mutex_t* m) {
SysCloseHandle(m->Handle);
m->Handle = 0;
return 0;
}
// Implements the pthread mutex lock operation.
__declspec(dllexport) int pthread_mutex_lock(pthread_mutex_t* m) {
KSTATUS s = SysWait(m->Handle, SYS_WAIT_FLAG_NONE);
return s == 0 ? 0 : EINVAL;
}
// Implements the pthread mutex trylock operation.
__declspec(dllexport) int pthread_mutex_trylock(pthread_mutex_t* m) {
KSTATUS s = SysTryAcquireMutex(m->Handle);
return s == 0 ? 0 : EAGAIN;
}
// Implements the pthread mutex unlock operation.
__declspec(dllexport) int pthread_mutex_unlock(pthread_mutex_t* m) {
KSTATUS s = SysReleaseMutex(m->Handle);
return s == 0 ? 0 : EINVAL;
@@ -80,7 +80,7 @@ vfork_wait:
mov ecx, dword ptr [r12 + VF_ThreadHandle]
lea rdx, [r12 + VF_PreviousSuspendCount]
mov eax, SYS_RESUME_THREAD_AND_WAIT
int 40h
int 02Fh
mov r9d, eax
; The child may have overwritten every byte of the old vfork/helper frames.
+13
View File
@@ -0,0 +1,13 @@
TARGETNAME=posix
TARGETPATH=obj
TARGETTYPE=DYNLINK
IMAGE_KIND=DLL
FLAVOR=POSIX
EXTRA_CFLAGS=/DNTL_POSIX_BUILD /DUSER_HEAP_EXPORTS /DNTL_EXCEPTION_EXPORTS
TARGETLIBS="$(BASEDIR)\bin\syscall.lib" "$(BASEDIR)\bin\libc.lib"
EXTRA_LFLAGS=/SUBSYSTEM:NATIVE /DYNAMICBASE /HIGHENTROPYVA
EXTRA_ASFLAGS=/I"$(BASEDIR)\code\user\syscall"
INCLUDES=$(BASEDIR)\code\user\syscall
SOURCES=@/code/user/runtime/heap.c @/code/user/runtime/heap_exports.c @/code/user/runtime/native_exception.c @/code/user/personalities/posix/posix_dir.c @/code/user/personalities/posix/posix_dlfcn.c @/code/user/personalities/posix/posix_fd.c \
@/code/user/personalities/posix/posix_io.c @/code/user/personalities/posix/posix_mman.c @/code/user/personalities/posix/posix_path.c @/code/user/personalities/posix/posix_proc.c @/code/user/personalities/posix/posix_runtime.c @/code/user/personalities/posix/posix_signal.c \
@/code/user/personalities/posix/posix_socket.c @/code/user/personalities/posix/posix_thread.c @/code/user/personalities/posix/posix_vfork.c @/code/user/personalities/posix/posix_vfork.asm