add lwIP TCP/IP stack as a runtime driver, native socket syscalls, SysGetMemoryStatus replacing CatchAllDebugBucket, fix timeGetTime to return milliseconds, fix SysSleep to interpret argument as milliseconds, SysGetTick now returns microseconds, harden all syscalls against bad user pointers with CopyFromUser/CopyToUser/MmProbeUser throughout, add networking test apps, port-forward 8080 in runa.bat, split LWIP_DRIVER_CFLAGS, add settings.ini to deploy, remove ethernet.c stub

This commit is contained in:
maksw committed 2026-05-22 18:54:53 +02:00
1 parent 18b4dd0f61
commit df13b8056c
365 files changed
+143263 -1362

No files matched your search

+104 -2
View File
@@ -7,11 +7,13 @@
#include <intrin.h>
#define SYS_STATUS_SUCCESS 0u
#define SYS_STATUS_TIMEOUT 3u
#define SYS_STATUS_PENDING 4u
#define SYS_STATUS_ALERTED 5u
#define SYS_STATUS_KERNEL_APC 6u
#define SYS_STATUS_USER_APC 7u
#define SYS_STATUS_CANCELLED 0x33u
#define SYS_STATUS_NOT_FOUND 0x22u
// ---------------------------------------------------------------------------
// User process/thread environment
@@ -227,11 +229,111 @@ uint64_t SysMousePoll(void);
uint64_t SysMouseRead(int* dx, int* dy, uint8_t* buttons);
void SysMouseGetPos(int* x, int* y);
// ---------------------------------------------------------------------------
// Time and debug (70-72)
// Native sockets
// ---------------------------------------------------------------------------
#define SYS_AF_INET 2u
#define SYS_SOCK_STREAM 1u
#define SYS_SOCK_DGRAM 2u
#define SYS_SOCK_RAW 3u
#define SYS_IPPROTO_ICMP 1u
#define SYS_IPPROTO_TCP 6u
#define SYS_IPPROTO_UDP 17u
#define SYS_RESOLVE_HOST_NAME_MAX 255u
#define SYS_SOCKET_OPT_RECV_TIMEOUT_MS 1u
#define SYS_SOCKET_OPT_SEND_TIMEOUT_MS 2u
#define SYS_SOCKET_OPT_NONBLOCKING 3u
#define SYS_POLL_READ 0x0001u
#define SYS_POLL_WRITE 0x0002u
#define SYS_POLL_ERROR 0x0004u
#define SYS_POLL_HANGUP 0x0008u
#define SYS_POLL_INVALID 0x0010u
#define SYS_POLL_TIMEOUT_INFINITE 0xFFFFFFFFu
#define SYS_SHUTDOWN_READ 0u
#define SYS_SHUTDOWN_WRITE 1u
#define SYS_SHUTDOWN_BOTH 2u
typedef struct SYS_SOCKET_ADDRESS_IPV4 {
uint16_t Family; // SYS_AF_INET
uint16_t Port; // host byte order
uint8_t Address[4]; // dotted-quad bytes, e.g. {10,0,2,2}
uint8_t Reserved[8];
} SYS_SOCKET_ADDRESS_IPV4;
typedef struct SYS_SOCKET_SEND_TO_REQUEST {
const void* Buffer;
size_t Length;
uint32_t Flags;
uint32_t Reserved;
const SYS_SOCKET_ADDRESS_IPV4* RemoteAddress;
size_t RemoteAddressSize;
size_t* SentOut;
} SYS_SOCKET_SEND_TO_REQUEST;
typedef struct SYS_SOCKET_RECV_FROM_REQUEST {
void* Buffer;
size_t Length;
uint32_t Flags;
uint32_t Reserved;
SYS_SOCKET_ADDRESS_IPV4* RemoteAddressOut;
size_t* RemoteAddressSizeInOut;
size_t* ReceivedOut;
} SYS_SOCKET_RECV_FROM_REQUEST;
typedef struct SYS_RESOLVE_HOST_REQUEST {
const char* Name;
size_t NameLength;
uint32_t Family;
uint32_t Flags;
SYS_SOCKET_ADDRESS_IPV4* AddressOut;
size_t* AddressSizeInOut;
} SYS_RESOLVE_HOST_REQUEST;
typedef struct SYS_SOCKET_OPTION_REQUEST {
uint32_t Option;
uint32_t Reserved;
void* Value;
size_t ValueSize;
size_t* ActualSizeOut;
} SYS_SOCKET_OPTION_REQUEST;
typedef struct SYS_POLLFD {
uint32_t Handle;
uint32_t Events;
uint32_t ReturnedEvents;
} SYS_POLLFD;
uint32_t SysSocket(uint32_t domain, uint32_t type, uint32_t protocol, uint32_t* handleOut);
uint32_t SysBind(uint32_t socket, const SYS_SOCKET_ADDRESS_IPV4* address, size_t addressSize);
uint32_t SysListen(uint32_t socket, uint32_t backlog);
uint32_t SysAccept(uint32_t socket, SYS_SOCKET_ADDRESS_IPV4* remoteAddressOut, size_t* remoteAddressSizeInOut, uint32_t* acceptedHandleOut);
uint32_t SysConnect(uint32_t socket, const SYS_SOCKET_ADDRESS_IPV4* address, size_t addressSize);
uint32_t SysSend(uint32_t socket, const void* buffer, size_t length, uint32_t flags, size_t* sentOut);
uint32_t SysRecv(uint32_t socket, void* buffer, size_t length, uint32_t flags, size_t* receivedOut);
uint32_t SysShutdown(uint32_t socket, uint32_t how);
uint32_t SysSendTo(uint32_t socket, const SYS_SOCKET_SEND_TO_REQUEST* request);
uint32_t SysRecvFrom(uint32_t socket, const SYS_SOCKET_RECV_FROM_REQUEST* request);
uint32_t SysResolveHost(const SYS_RESOLVE_HOST_REQUEST* request);
uint32_t SysSetSocketOption(uint32_t socket, const SYS_SOCKET_OPTION_REQUEST* request);
uint32_t SysGetSocketOption(uint32_t socket, const SYS_SOCKET_OPTION_REQUEST* request);
uint32_t SysPoll(SYS_POLLFD* fds, size_t count, uint32_t timeoutMs, size_t* readyOut);
typedef struct SYS_MEMORY_STATUS {
uint64_t FreePhysicalBytes;
uint64_t KernelPoolBytes;
uint64_t UserHeapBytes;
} SYS_MEMORY_STATUS;
// ---------------------------------------------------------------------------
// Time and diagnostics
// ---------------------------------------------------------------------------
uint64_t SysGetTick(void);
uint32_t SysDebugPrint(const char* str);
uint32_t SysQueryTrapFrame(SYS_TRAP_FRAME_INFO* info);
uint64_t SysCatchAllDebugBucket(uint64_t a0, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a5);
uint32_t SysGetMemoryStatus(SYS_MEMORY_STATUS* statusOut);
+16 -2
View File
@@ -75,6 +75,20 @@ SYS_MOUSE_GET_POS EQU 71
SYS_GET_TICK EQU 72
SYS_DEBUG_PRINT EQU 73
SYS_QUERY_TRAP_FRAME EQU 74
SYS_CATCHALLDEBUGBUCKET EQU 75
SYS_SOCKET EQU 75
SYS_BIND EQU 76
SYS_LISTEN EQU 77
SYS_ACCEPT EQU 78
SYS_CONNECT EQU 79
SYS_SEND EQU 80
SYS_RECV EQU 81
SYS_SHUTDOWN EQU 82
SYS_SEND_TO EQU 83
SYS_RECV_FROM EQU 84
SYS_RESOLVE_HOST EQU 85
SYS_SET_SOCKET_OPTION EQU 86
SYS_GET_SOCKET_OPTION EQU 87
SYS_POLL EQU 88
SYS_GET_MEMORY_STATUS EQU 89
SYS_MAX EQU 76
SYS_MAX EQU 90
+19 -1
View File
@@ -197,6 +197,24 @@ SYSCALL_STUB2 GetTick, SYS_GET_TICK
SYSCALL_STUB2 DebugPrint, SYS_DEBUG_PRINT
SYSCALL_STUB2 QueryTrapFrame, SYS_QUERY_TRAP_FRAME
SYSCALL_STUB6 CatchAllDebugBucket, SYS_CATCHALLDEBUGBUCKET
; ---------------------------------------------------------------------------
; Native sockets
; ---------------------------------------------------------------------------
SYSCALL_STUB2 Socket, SYS_SOCKET
SYSCALL_STUB2 Bind, SYS_BIND
SYSCALL_STUB2 Listen, SYS_LISTEN
SYSCALL_STUB2 Accept, SYS_ACCEPT
SYSCALL_STUB2 Connect, SYS_CONNECT
SYSCALL_STUB6 Send, SYS_SEND
SYSCALL_STUB6 Recv, SYS_RECV
SYSCALL_STUB2 Shutdown, SYS_SHUTDOWN
SYSCALL_STUB2 SendTo, SYS_SEND_TO
SYSCALL_STUB2 RecvFrom, SYS_RECV_FROM
SYSCALL_STUB2 ResolveHost, SYS_RESOLVE_HOST
SYSCALL_STUB2 SetSocketOption, SYS_SET_SOCKET_OPTION
SYSCALL_STUB2 GetSocketOption, SYS_GET_SOCKET_OPTION
SYSCALL_STUB2 Poll, SYS_POLL
SYSCALL_STUB2 GetMemoryStatus, SYS_GET_MEMORY_STATUS
END