duct taped posix.dll (just like microsoft), new cursor, more info in the fault handlers, processes now have a parse-it-yourself cmdline, add SYS_WAIT_THREAD and SYS_GET_PROCESS_PID, writing still doesn't work

This commit is contained in:
maksw committed 2026-05-05 15:24:58 +02:00
1 parent a37f5b1581
commit b5c831f593
26 files changed
+1107 -56

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
#pragma once
// posix_fd.h - file descriptor table (internal to posix.dll)
#include <stdint.h>
#include <stdbool.h>
typedef enum {
FD_FREE,
FD_FILE,
FD_CONSOLE_R, // fd 0 - reads from keyboard via SysKbReadChar
FD_CONSOLE_W, // fd 1, 2 - writes via SysWriteConsole
FD_DEVNULL, // /dev/null
FD_DEVZERO, // /dev/zero
} FD_TYPE;
typedef struct {
FD_TYPE Type;
uint32_t KHandle; // kernel handle; 0 for console/devnull/devzero
bool Used;
} FD_ENTRY;
#define FD_MAX 64
#define FD_TABLE_PIDS 32 // circular, indexed by pid % FD_TABLE_PIDS
// Called from _start before main(); sets up fds 0/1/2 for this process.
void PosixFdInit(void);
// Allocate the lowest free fd >= 3. Returns -1 and sets errno=EMFILE on failure.
int FdAlloc(uint32_t pid, FD_TYPE type, uint32_t khandle);
// Look up an fd. Returns NULL and sets errno=EBADF if invalid.
FD_ENTRY* FdGet(uint32_t pid, int fd);
// Release an fd slot (does NOT close the kernel handle).
void FdFree(uint32_t pid, int fd);