redo boot around an explicit system volume and fixed kernel/HAL images, redo volumes and filesystem paths around capabilities instead of drive numbers and kernel CWD state, add a capability/security model with derived and revocable handles and security contexts, add port IPC and rssrv to manage the userspace resource namespace and publish the system volume, move process, dll and path loading to userspace and add process builder syscalls, init now supervises rssrv and the session process, redo the syscall ABI around request structs and four arguments, add a volume manager and proper partition arrival/removal handling so FAT and NTFS mount dynamically, clean up the HAL/DDK boundary so drivers don't depend on HAL internals, save fpu state properly now, the serial driver doesn't hang on a missing port, fix AHCI startup races, fix timeout accounting, fix shared mmap writeback, more smoke tests
This commit is contained in:
1 parent
4add6789ba
commit
f882d339fb
232 files changed
+20934
-8898
No files matched your search
@@ -1,203 +0,0 @@
|
||||
// Public NTLite hal api ABI declarations shared between kernel, drivers, and user mode.
|
||||
|
||||
#pragma once
|
||||
// hal_api.h - HAL interface table exported as HalGetApi().
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <ntlite/status.h>
|
||||
|
||||
typedef struct BOOT_INFO BOOT_INFO;
|
||||
|
||||
typedef struct HAL_FRAMEBUFFER_INFO {
|
||||
uintptr_t Base; // kernel virtual address of the visible framebuffer
|
||||
uint32_t Width;
|
||||
uint32_t Height;
|
||||
uint32_t Stride; // pixels per scanline
|
||||
uint32_t Format; // currently 0x00RRGGBB / X8R8G8B8
|
||||
} HAL_FRAMEBUFFER_INFO;
|
||||
|
||||
typedef struct HAL_SCREEN {
|
||||
void (*Clear)(uint32_t color);
|
||||
void (*PutPixel)(int x, int y, uint32_t color);
|
||||
void (*Blit)(int x, int y, int w, int h, const uint32_t* pixels);
|
||||
void (*GetSize)(int* width, int* height);
|
||||
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.
|
||||
void (*DrawCursor)(int x, int y);
|
||||
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
|
||||
|
||||
typedef struct HAL_RTC_TIME {
|
||||
uint16_t Year;
|
||||
uint8_t Month;
|
||||
uint8_t Day;
|
||||
uint8_t Hour;
|
||||
uint8_t Minute;
|
||||
uint8_t Second;
|
||||
uint32_t Nanosecond;
|
||||
uint16_t Flags;
|
||||
uint16_t Reserved;
|
||||
} HAL_RTC_TIME;
|
||||
|
||||
typedef struct HAL_RTC {
|
||||
KSTATUS (*QueryTime)(HAL_RTC_TIME* outTime);
|
||||
} HAL_RTC;
|
||||
|
||||
typedef struct HAL_PCI {
|
||||
// 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,
|
||||
uint8_t bus,
|
||||
uint8_t dev,
|
||||
uint8_t fn,
|
||||
uint16_t offset);
|
||||
|
||||
void (*Write32)(uint16_t segment,
|
||||
uint8_t bus,
|
||||
uint8_t dev,
|
||||
uint8_t fn,
|
||||
uint16_t offset,
|
||||
uint32_t value);
|
||||
} HAL_PCI;
|
||||
|
||||
typedef struct HAL_INTC {
|
||||
void (*RouteIrq)(uint8_t irq);
|
||||
void (*MaskIrq)(uint8_t irq);
|
||||
void (*UnmaskIrq)(uint8_t irq);
|
||||
void (*SendEoi)(void);
|
||||
} HAL_INTC;
|
||||
|
||||
typedef struct HAL_POWER {
|
||||
// ACPI S5 soft-off. Disables interrupts, writes SLP_EN to PM1a/b_CNT,
|
||||
// and halts if firmware doesn't respond. Does not return.
|
||||
void (*Shutdown)(void);
|
||||
} HAL_POWER;
|
||||
|
||||
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;
|
||||
HAL_INTC Intc;
|
||||
HAL_POWER Power;
|
||||
} HAL_API;
|
||||
|
||||
typedef struct HAL_INIT_PARAMS {
|
||||
// Framebuffer.
|
||||
uintptr_t FramebufferBase;
|
||||
uint32_t FramebufferWidth;
|
||||
uint32_t FramebufferHeight;
|
||||
uint32_t FramebufferStride;
|
||||
|
||||
// ACPI.
|
||||
uintptr_t RsdpPhysical;
|
||||
|
||||
// Memory.
|
||||
uint64_t PhysicalWindowBase;
|
||||
|
||||
// Debug.
|
||||
int Debug;
|
||||
|
||||
void* (*AllocatePool)(size_t size);
|
||||
} HAL_INIT_PARAMS;
|
||||
|
||||
// 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);
|
||||
@@ -203,6 +203,27 @@ __declspec(dllexport) KSTATUS IoRegisterDiskChangeCallback(IO_DISK_CHANGE_CALLBA
|
||||
__declspec(dllexport) KSTATUS IoEnumerateDiskDevices(IO_DISK_ARRIVAL_CALLBACK callback,
|
||||
void* context);
|
||||
|
||||
// Dynamic partition discovery above registered block devices. Filesystem providers receive only immutable extents.
|
||||
typedef enum IO_PARTITION_CHANGE {
|
||||
IoPartitionArrived = 0,
|
||||
IoPartitionSurpriseRemoved,
|
||||
IoPartitionRemoved,
|
||||
} IO_PARTITION_CHANGE;
|
||||
|
||||
typedef struct IO_PARTITION_INFO {
|
||||
uint8_t DiskIndex;
|
||||
uint64_t StartLba;
|
||||
uint64_t SectorCount;
|
||||
} IO_PARTITION_INFO;
|
||||
|
||||
typedef void (*IO_PARTITION_CHANGE_CALLBACK)(const IO_PARTITION_INFO* partition,
|
||||
IO_PARTITION_CHANGE change,
|
||||
void* context);
|
||||
|
||||
// Registers one partition-change consumer and replays every currently discovered partition before returning.
|
||||
__declspec(dllexport) KSTATUS IoRegisterPartitionChangeCallback(IO_PARTITION_CHANGE_CALLBACK callback,
|
||||
void* context);
|
||||
|
||||
__declspec(dllexport) KSTATUS IoReadDiskSectors(uint8_t driveIndex,
|
||||
uint64_t lba,
|
||||
uint32_t count,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <ntlite/handle.h>
|
||||
|
||||
#define SYS_AF_INET 2u
|
||||
#define SYS_AF_INET6 10u
|
||||
@@ -48,7 +49,7 @@ typedef struct SYS_SOCKET_ADDRESS_K {
|
||||
} SYS_SOCKET_ADDRESS_K;
|
||||
|
||||
typedef struct SYS_POLLFD_K {
|
||||
uint32_t Handle;
|
||||
SYS_HANDLE Handle;
|
||||
uint32_t Events;
|
||||
uint32_t ReturnedEvents;
|
||||
} SYS_POLLFD_K;
|
||||
Reference in new issue
Block a user