add ntfs.sys standalone driver target, change default usb vhd layout formatting to ntfs, implement Fat32CreateDir for directory creation support in the fat32 file system driver, add a dedicated HAL serial output endpoint for COM1 writes in hal_serial.c and subscribe serial to HAL text streams, introduce waitable kernel timers with KeTimerCreate, KeTimerSet, and KeTimerCancel alongside spinlock-protected global timer list initialization and scheduler tick tracking, implement SyscallWriteFileAsync system call for asynchronous non-blocking file writes, refactor NetSocketConnect and NetSocketSendTo to use generic SYS_SOCKET_ADDRESS_K structures instead of being hardcoded to IPv4, update gethostbyname and DNS name resolution to support IPv6 parsing via ResolveNameFamily, update tcpserve.exe with -4 and -6 command-line flags to accept and display IPv6 addresses, append size and version headers to all kernel telemetry and statistics structures including SYS_PMM_STATS, SYS_CPU_STATS, and SYS_SCHEDULER_STATS, update winmm timeGetTime to look up high-resolution hardware frequencies via SysGetTickFrequency, integrate 14 native smoke test applications.
This commit is contained in:
1 parent
2c4a68a75f
commit
ed3d065abd
156 files changed
+10509
-2643
No files matched your search
@@ -4,7 +4,7 @@
|
||||
// display.h - display device DDI
|
||||
|
||||
// Display providers register DISPLAY_DEVICE objects with the kernel display
|
||||
// manager. The boot framebuffer backend is registered by the kernel itself;
|
||||
// manager. The boot framebuffer backend is registered by the kernel itself;
|
||||
// PCI/virtual GPU drivers register additional providers later.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -25,6 +25,7 @@ typedef struct HAL_SCREEN {
|
||||
KSTATUS (*GetFramebuffer)(HAL_FRAMEBUFFER_INFO* outInfo);
|
||||
void (*Scroll)(int lines);
|
||||
void (*PutChar)(char c, int x, int y, uint32_t fg, uint32_t bg);
|
||||
// Writes only to the boot framebuffer text console. Stream routing belongs to HAL_OUTPUT_ROUTER.
|
||||
void (*PrintChar)(char c, uint32_t fg, uint32_t bg);
|
||||
// Legacy software cursor hooks kept for early-boot/panic fallback only.
|
||||
// Normal input cursor ownership lives in ke_display.
|
||||
@@ -32,14 +33,69 @@ typedef struct HAL_SCREEN {
|
||||
void (*EraseCursor)(void);
|
||||
} HAL_SCREEN;
|
||||
|
||||
// Output streams describe the producer's intent. Endpoints subscribe by mask.
|
||||
#define HAL_OUTPUT_STREAM_DEBUG 0x00000001u
|
||||
#define HAL_OUTPUT_STREAM_CONSOLE 0x00000002u
|
||||
#define HAL_OUTPUT_STREAM_CRASH 0x00000004u
|
||||
#define HAL_OUTPUT_STREAM_PANIC 0x00000008u
|
||||
#define HAL_OUTPUT_STREAM_ALL 0x0000000Fu
|
||||
|
||||
// Emergency writes bypass endpoints that cannot run without scheduler services.
|
||||
#define HAL_OUTPUT_WRITE_EMERGENCY 0x00000001u
|
||||
#define HAL_OUTPUT_ENDPOINT_PANIC_SAFE 0x00000001u
|
||||
#define HAL_OUTPUT_ENDPOINT_INVALID UINT32_MAX
|
||||
|
||||
typedef struct HAL_OUTPUT_RECORD {
|
||||
// Exactly one HAL_OUTPUT_STREAM_* value.
|
||||
uint32_t Stream;
|
||||
// HAL_OUTPUT_WRITE_* flags.
|
||||
uint32_t Flags;
|
||||
// X8R8G8B8 text color hints.
|
||||
uint32_t Foreground;
|
||||
uint32_t Background;
|
||||
// The buffer remains valid only for the duration of Write().
|
||||
const char* Buffer;
|
||||
size_t Length;
|
||||
} HAL_OUTPUT_RECORD;
|
||||
|
||||
// Endpoint callbacks consume or copy the record synchronously and must not retain Buffer.
|
||||
typedef void (*HAL_OUTPUT_ENDPOINT_WRITE)(void* context, const HAL_OUTPUT_RECORD* record);
|
||||
|
||||
typedef struct HAL_OUTPUT_ENDPOINT {
|
||||
// The name remains stable for the endpoint lifetime.
|
||||
const char* Name;
|
||||
uint32_t StreamMask;
|
||||
uint32_t Capabilities;
|
||||
HAL_OUTPUT_ENDPOINT_WRITE Write;
|
||||
void* Context;
|
||||
} HAL_OUTPUT_ENDPOINT;
|
||||
|
||||
typedef struct HAL_OUTPUT_STATS {
|
||||
uint64_t RecordCount;
|
||||
uint64_t ByteCount;
|
||||
uint64_t EndpointWriteCount;
|
||||
uint64_t EmergencyRecordCount;
|
||||
uint32_t EndpointCount;
|
||||
} HAL_OUTPUT_STATS;
|
||||
|
||||
typedef struct HAL_OUTPUT_ROUTER {
|
||||
// Registration is append-only; endpoint callbacks and context remain valid until shutdown.
|
||||
KSTATUS (*RegisterEndpoint)(const HAL_OUTPUT_ENDPOINT* endpoint, uint32_t* endpointIdOut);
|
||||
KSTATUS (*SetEndpointStreams)(uint32_t endpointId, uint32_t streamMask);
|
||||
void (*Write)(const HAL_OUTPUT_RECORD* record);
|
||||
void (*QueryStats)(HAL_OUTPUT_STATS* statsOut);
|
||||
uint32_t SerialEndpointId;
|
||||
uint32_t BootFramebufferEndpointId;
|
||||
} HAL_OUTPUT_ROUTER;
|
||||
|
||||
typedef struct HAL_TIMER {
|
||||
uint64_t (*QueryTicks)(void);
|
||||
uint64_t (*QueryTickFrequency)(void);
|
||||
void (*Stall)(uint32_t us);
|
||||
void (*Isr)(void);
|
||||
uint8_t IrqNumber;
|
||||
} HAL_TIMER;
|
||||
|
||||
|
||||
#define HAL_RTC_TIME_FLAG_VALID 0x0001u
|
||||
#define HAL_RTC_TIME_FLAG_RTC 0x0002u
|
||||
|
||||
@@ -60,7 +116,7 @@ typedef struct HAL_RTC {
|
||||
} HAL_RTC;
|
||||
|
||||
typedef struct HAL_PCI {
|
||||
// Raw PCI configuration access. Policy-level operations such as
|
||||
// Raw PCI configuration access. Policy-level operations such as
|
||||
// enumeration, BAR decoding, interrupt discovery, and MSI programming
|
||||
// belong to pci.sys.
|
||||
uint32_t (*Read32)(uint16_t segment,
|
||||
@@ -94,6 +150,7 @@ typedef struct HAL_API {
|
||||
uint32_t Version;
|
||||
void *(*PhysToVirt)(uint64_t physAddr);
|
||||
HAL_SCREEN Screen;
|
||||
HAL_OUTPUT_ROUTER Output;
|
||||
HAL_TIMER Timer;
|
||||
HAL_RTC Rtc;
|
||||
HAL_PCI Pci;
|
||||
@@ -120,8 +177,27 @@ typedef struct HAL_INIT_PARAMS {
|
||||
void* (*AllocatePool)(size_t size);
|
||||
} HAL_INIT_PARAMS;
|
||||
|
||||
#define HAL_API_VERSION // do not change during development
|
||||
// Increment when the HAL API layout or semantics change when we go from indev to alpha.
|
||||
#define HAL_API_VERSION 1
|
||||
|
||||
__declspec(dllexport) const HAL_API* HalGetApi(void);
|
||||
__declspec(dllexport) void HalRegisterScheduler(void (*pKeSchedulerTick)(void));
|
||||
__declspec(dllexport) KSTATUS HalInitialize(const HAL_INIT_PARAMS* params);
|
||||
|
||||
// Masks interrupts and returns the previous RFLAGS value.
|
||||
__declspec(dllexport) uintptr_t HalDisableInterrupts(void);
|
||||
|
||||
// Restores the RFLAGS value returned by HalDisableInterrupts.
|
||||
__declspec(dllexport) void HalRestoreInterrupts(uintptr_t flags);
|
||||
|
||||
// Enables maskable interrupts.
|
||||
__declspec(dllexport) void HalEnableInterrupts(void);
|
||||
|
||||
// Enables interrupts and halts until the processor receives an interrupt.
|
||||
__declspec(dllexport) void HalWaitForInterrupt(void);
|
||||
|
||||
// Halts once without changing the interrupt state.
|
||||
__declspec(dllexport) void HalHalt(void);
|
||||
|
||||
// Masks interrupts and permanently stops the current processor.
|
||||
__declspec(dllexport) _Noreturn void HalStopProcessor(void);
|
||||
@@ -1,4 +1,4 @@
|
||||
// Public NTLite net abi ABI declarations shared between kernel, drivers, and user mode.
|
||||
// Public NTLite net ABI declarations shared between kernel, drivers, and user mode.
|
||||
|
||||
#pragma once
|
||||
// net_abi.h - native networking ABI shared by the kernel socket facade
|
||||
@@ -8,18 +8,20 @@
|
||||
#include <stddef.h>
|
||||
|
||||
#define SYS_AF_INET 2u
|
||||
#define SYS_AF_INET6 10u
|
||||
#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_IPPROTO_ICMPV6 58u
|
||||
|
||||
#define SYS_SHUTDOWN_READ 0u
|
||||
#define SYS_SHUTDOWN_WRITE 1u
|
||||
#define SYS_SHUTDOWN_BOTH 2u
|
||||
|
||||
#define SYS_SOCKET_ADDRESS_IPV4_SIZE 8u
|
||||
#define SYS_SOCKET_ADDRESS_SIZE 28u
|
||||
#define SYS_RESOLVE_HOST_NAME_MAX 255u
|
||||
|
||||
#define SYS_SOCKET_OPT_RECV_TIMEOUT_MS 1u
|
||||
@@ -33,11 +35,14 @@
|
||||
#define SYS_POLL_INVALID 0x0010u
|
||||
#define SYS_POLL_TIMEOUT_INFINITE 0xFFFFFFFFu
|
||||
|
||||
typedef struct SYS_SOCKET_ADDRESS_IPV4_K {
|
||||
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}
|
||||
} SYS_SOCKET_ADDRESS_IPV4_K;
|
||||
// Kernel socket providers use the same tagged native address shape as syscalls.
|
||||
typedef struct SYS_SOCKET_ADDRESS_K {
|
||||
uint16_t Family;
|
||||
uint16_t Size;
|
||||
uint16_t Port;
|
||||
uint8_t Address[16];
|
||||
uint32_t ScopeId;
|
||||
} SYS_SOCKET_ADDRESS_K;
|
||||
|
||||
typedef struct SYS_POLLFD_K {
|
||||
uint32_t Handle;
|
||||
|
||||
@@ -26,24 +26,24 @@ struct NET_STACK_PROVIDER {
|
||||
KSTATUS (*SocketCreate)(uint32_t domain, uint32_t type, uint32_t protocol, void** outSocket);
|
||||
void (*SocketClose)(void* socket);
|
||||
|
||||
KSTATUS (*Bind)(void* socket, const SYS_SOCKET_ADDRESS_IPV4_K* address, size_t addressSize);
|
||||
KSTATUS (*Bind)(void* socket, const SYS_SOCKET_ADDRESS_K* address, size_t addressSize);
|
||||
KSTATUS (*Listen)(void* socket, uint32_t backlog);
|
||||
KSTATUS (*Accept)(void* socket, void** acceptedOut, SYS_SOCKET_ADDRESS_IPV4_K* remoteOut);
|
||||
KSTATUS (*Connect)(void* socket, const SYS_SOCKET_ADDRESS_IPV4_K* address, size_t addressSize);
|
||||
KSTATUS (*Accept)(void* socket, void** acceptedOut, SYS_SOCKET_ADDRESS_K* remoteOut);
|
||||
KSTATUS (*Connect)(void* socket, const SYS_SOCKET_ADDRESS_K* address, size_t addressSize);
|
||||
|
||||
KSTATUS (*Send)(void* socket, const void* buffer, size_t length, uint32_t flags, size_t* sentOut);
|
||||
KSTATUS (*Receive)(void* socket, void* buffer, size_t length, uint32_t flags, size_t* receivedOut);
|
||||
KSTATUS (*SendTo)(void* socket, const void* buffer, size_t length, uint32_t flags,
|
||||
const SYS_SOCKET_ADDRESS_IPV4_K* remote, size_t remoteSize, size_t* sentOut);
|
||||
const SYS_SOCKET_ADDRESS_K* remote, size_t remoteSize, size_t* sentOut);
|
||||
KSTATUS (*ReceiveFrom)(void* socket, void* buffer, size_t length, uint32_t flags,
|
||||
SYS_SOCKET_ADDRESS_IPV4_K* remoteOut, size_t* receivedOut);
|
||||
SYS_SOCKET_ADDRESS_K* remoteOut, size_t* receivedOut);
|
||||
|
||||
KSTATUS (*Shutdown)(void* socket, uint32_t how);
|
||||
KSTATUS (*SetOption)(void* socket, uint32_t option, const void* value, size_t valueSize);
|
||||
KSTATUS (*GetOption)(void* socket, uint32_t option, void* value, size_t valueSize, size_t* actualSizeOut);
|
||||
KSTATUS (*Poll)(void* socket, uint32_t events, uint32_t* returnedEventsOut);
|
||||
|
||||
KSTATUS (*ResolveHostIpv4)(const char* name, SYS_SOCKET_ADDRESS_IPV4_K* addressOut);
|
||||
KSTATUS (*ResolveHost)(const char* name, uint32_t family, SYS_SOCKET_ADDRESS_K* addressOut);
|
||||
};
|
||||
|
||||
__declspec(dllexport) KSTATUS NetRegisterStackProvider(const NET_STACK_PROVIDER* provider);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#pragma once
|
||||
// pci.h - PCI bus driver DDI exported by pci.sys
|
||||
|
||||
// Function drivers must not enumerate PCI or decode BARs themselves. They bind
|
||||
// Function drivers must not enumerate PCI or decode BARs themselves. They bind
|
||||
// to PCI PDOs through the I/O manager and use these routines to access the PCI
|
||||
// function represented by their PDO.
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct PCI_ADDRESS {
|
||||
uint16_t Segment;
|
||||
uint8_t Bus;
|
||||
|
||||
Reference in new issue
Block a user