move keyboard and mouse out of HAL into a standalone ps2.sys driver, implement usb stack with xhci controller discovery, hid keyboard/mouse, and bulk-only mass storage, add pci msi support with capability chain walking and software irq vector allocation (slots 16-23), rewrite user virtual memory as a USER_VA_REGION descriptor arena with per-process ownership tracking and guard page support, replacing the old bump allocator and top-down image region, add MmCreateUserRegion/MmDestroyAllUserRegions so process teardown reclaims all user va in one pass, allocate a pool-backed shadow framebuffer in hal_screen to fix cursor tearing and scroll corruption, reserve ap trampoline page below 1mb in uefi bootloader before boot services exit, rewrite memset/memcpy/memmove/memcmp with __stosq/__movsq intrinsics, promote driver flag literals to macros and add multi-tu STANDALONE_DRIVERS table to build.c, split rtl8139/rtl816x into header+source, rename KbReadScancode to KbReadKey, improve page fault output with MmDebugDescribeAddress and user region dump, fix %p to %016llX throughout.
This commit is contained in:
1 parent
b970d7f59c
commit
b838f8d83d
130 files changed
+8137
-2932
No files matched your search
@@ -20,42 +20,6 @@ typedef struct HAL_SCREEN {
|
||||
void (*EraseCursor)(void);
|
||||
} HAL_SCREEN;
|
||||
|
||||
typedef struct HAL_KEYBOARD {
|
||||
uint8_t (*Poll)(void);
|
||||
uint8_t (*ReadScancode)(void);
|
||||
char (*ReadChar)(void);
|
||||
uint32_t (*GetModifiers)(void);
|
||||
void (*SetCallback)(void (*cb)(uint8_t scancode));
|
||||
bool (*IsKeyDown)(uint8_t scancode, bool extended);
|
||||
void (*Isr)(void);
|
||||
// Optional bottom half, queued by the kernel after IRQ dispatch.
|
||||
void (*Dpc)(void);
|
||||
uint8_t IrqNumber;
|
||||
} HAL_KEYBOARD;
|
||||
|
||||
// HAL_MOUSE – PS/2 auxiliary mouse on IRQ 12.
|
||||
// Packet format: standard 3-byte PS/2 (buttons, deltaX, deltaY).
|
||||
// Y is already screen-oriented (positive = down) after ISR inversion.
|
||||
typedef struct HAL_MOUSE {
|
||||
// Non-blocking: returns true if a packet is waiting in the ring buffer.
|
||||
bool (*Poll)(void);
|
||||
// Non-blocking dequeue. Returns false when buffer is empty.
|
||||
// buttons: bit0=left, bit1=right, bit2=middle
|
||||
bool (*Read)(int* dx, int* dy, uint8_t* buttons);
|
||||
// Callback invoked from DPC context after every completed packet.
|
||||
void (*SetCallback)(void (*cb)(int dx, int dy, uint8_t buttons));
|
||||
// Absolute cursor position, clamped to screen bounds.
|
||||
void (*GetPosition)(int* x, int* y);
|
||||
void (*SetPosition)(int x, int y);
|
||||
// Update the clamping rectangle (call after mode change / resize).
|
||||
void (*SetBounds)(int w, int h);
|
||||
// Raw ISR – called by KeIrqDispatch for IRQ 12.
|
||||
void (*Isr)(void);
|
||||
// Optional bottom half, queued by the kernel after IRQ dispatch.
|
||||
void (*Dpc)(void);
|
||||
uint8_t IrqNumber; // always 12
|
||||
} HAL_MOUSE;
|
||||
|
||||
typedef struct HAL_TIMER {
|
||||
uint64_t (*QueryTicks)(void);
|
||||
void (*Stall)(uint32_t us);
|
||||
@@ -75,6 +39,10 @@ typedef struct HAL_PCI {
|
||||
// Returns the IRQ line from PCI config space (register 0x3C, byte 0).
|
||||
// Returns 0xFF if no interrupt is wired.
|
||||
uint8_t (*GetIrqLine)(uint8_t bus, uint8_t dev, uint8_t fn);
|
||||
|
||||
// Program a PCI MSI capability to deliver to vector (0x20 + irqSlot).
|
||||
// irqSlot must correspond to a kernel IRQ stub/vector slot.
|
||||
KSTATUS (*EnableMsi)(uint8_t bus, uint8_t dev, uint8_t fn, uint8_t irqSlot);
|
||||
} HAL_PCI;
|
||||
|
||||
typedef struct HAL_INTC {
|
||||
@@ -94,8 +62,6 @@ typedef struct HAL_API {
|
||||
uint32_t Version;
|
||||
void *(*PhysToVirt)(uint64_t physAddr);
|
||||
HAL_SCREEN Screen;
|
||||
HAL_KEYBOARD Keyboard;
|
||||
HAL_MOUSE Mouse;
|
||||
HAL_TIMER Timer;
|
||||
HAL_PCI Pci;
|
||||
HAL_INTC Intc;
|
||||
@@ -117,9 +83,11 @@ typedef struct HAL_INIT_PARAMS {
|
||||
|
||||
// Debug
|
||||
int Debug;
|
||||
|
||||
void* (*AllocatePool)(size_t size);
|
||||
} HAL_INIT_PARAMS;
|
||||
|
||||
#define HAL_API_VERSION 2
|
||||
#define HAL_API_VERSION 3
|
||||
|
||||
__declspec(dllexport) const HAL_API* HalGetApi(void);
|
||||
__declspec(dllexport) void HalRegisterScheduler(void (*pKeSchedulerTick)(void));
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
// input_device.h - driver-facing input submission DDI.
|
||||
|
||||
#include <ntlite/input.h>
|
||||
#include <ntlite/status.h>
|
||||
|
||||
__declspec(dllexport) KSTATUS KeInputRegisterDevice(const char* name, uint32_t flags, uint32_t* outDeviceId);
|
||||
__declspec(dllexport) void KeInputSubmitKey(const INPUT_KEY_EVENT* event);
|
||||
__declspec(dllexport) void KeInputSubmitMouse(const INPUT_MOUSE_EVENT* event);
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
// io_driver.h - definitive kernel driver/device I/O model
|
||||
//
|
||||
// Disk controllers register DEVICE_OBJECTs. IRPs are submitted only through
|
||||
// Disk controllers register DEVICE_OBJECTs. IRPs are submitted only through
|
||||
// IoCallDriver()/IoSubmitIrp(); drivers complete accepted IRPs by calling
|
||||
// IoCompleteRequest(). There is no legacy DISK_DRIVER submit table.
|
||||
// IoCompleteRequest(). There is no legacy DISK_DRIVER submit table.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
@@ -33,6 +33,75 @@ struct DRIVER_OBJECT {
|
||||
DRIVER_UNLOAD_FN DriverUnload;
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef enum IO_BUS_TYPE {
|
||||
IoBusUnknown = 0,
|
||||
IoBusPci = 1,
|
||||
IoBusUsb = 2,
|
||||
} IO_BUS_TYPE;
|
||||
|
||||
#define IO_PUBLISHED_USB_MAX_ENDPOINTS 8u
|
||||
|
||||
typedef struct IO_PUBLISHED_USB_ENDPOINT {
|
||||
uint8_t Address;
|
||||
uint8_t Attributes;
|
||||
uint16_t MaxPacketSize;
|
||||
uint8_t Interval;
|
||||
} IO_PUBLISHED_USB_ENDPOINT;
|
||||
|
||||
typedef struct IO_PUBLISHED_USB_DEVICE {
|
||||
uint16_t VendorId;
|
||||
uint16_t ProductId;
|
||||
uint16_t BcdUsb;
|
||||
uint16_t BcdDevice;
|
||||
|
||||
uint8_t DeviceClass;
|
||||
uint8_t DeviceSubclass;
|
||||
uint8_t DeviceProtocol;
|
||||
|
||||
uint8_t SlotId;
|
||||
uint8_t Port;
|
||||
uint8_t Speed;
|
||||
uint8_t ConfigurationValue;
|
||||
|
||||
uint8_t InterfaceNumber;
|
||||
uint8_t AlternateSetting;
|
||||
uint8_t InterfaceClass;
|
||||
uint8_t InterfaceSubclass;
|
||||
uint8_t InterfaceProtocol;
|
||||
|
||||
uint8_t EndpointCount;
|
||||
IO_PUBLISHED_USB_ENDPOINT Endpoints[IO_PUBLISHED_USB_MAX_ENDPOINTS];
|
||||
} IO_PUBLISHED_USB_DEVICE;
|
||||
|
||||
typedef struct IO_PUBLISHED_DEVICE {
|
||||
IO_BUS_TYPE BusType;
|
||||
const char* Name;
|
||||
void* BusContext;
|
||||
void* DeviceContext;
|
||||
uint32_t Flags;
|
||||
bool Bound;
|
||||
const char* BoundDriverName;
|
||||
|
||||
union {
|
||||
IO_PUBLISHED_USB_DEVICE Usb;
|
||||
} u;
|
||||
} IO_PUBLISHED_DEVICE;
|
||||
|
||||
typedef bool (*IO_DRIVER_MATCH_CALLBACK)(const IO_PUBLISHED_DEVICE* device,
|
||||
void* context);
|
||||
typedef KSTATUS (*IO_DRIVER_BIND_CALLBACK)(IO_PUBLISHED_DEVICE* device,
|
||||
void* context);
|
||||
|
||||
__declspec(dllexport) KSTATUS IoRegisterDriverMatcher(const char* driverName,
|
||||
IO_BUS_TYPE busType,
|
||||
IO_DRIVER_MATCH_CALLBACK match,
|
||||
IO_DRIVER_BIND_CALLBACK bind,
|
||||
void* context);
|
||||
__declspec(dllexport) KSTATUS IoPublishDevice(const IO_PUBLISHED_DEVICE* device);
|
||||
__declspec(dllexport) uint32_t IoPublishedDeviceCount(void);
|
||||
|
||||
struct DEVICE_OBJECT {
|
||||
DRIVER_OBJECT* DriverObject;
|
||||
void* DeviceExtension;
|
||||
@@ -56,6 +125,15 @@ __declspec(dllexport) DEVICE_OBJECT* IoGetDiskDevice(uint8_t driveIndex);
|
||||
__declspec(dllexport) bool IoDiskDevicePresent(uint8_t driveIndex);
|
||||
__declspec(dllexport) uint64_t IoDiskSectorCount(uint8_t driveIndex);
|
||||
|
||||
typedef void (*IO_DISK_ARRIVAL_CALLBACK)(uint8_t driveIndex,
|
||||
DEVICE_OBJECT* device,
|
||||
void* context);
|
||||
|
||||
__declspec(dllexport) KSTATUS IoRegisterDiskArrivalCallback(IO_DISK_ARRIVAL_CALLBACK callback,
|
||||
void* context);
|
||||
__declspec(dllexport) KSTATUS IoEnumerateDiskDevices(IO_DISK_ARRIVAL_CALLBACK callback,
|
||||
void* context);
|
||||
|
||||
__declspec(dllexport) KSTATUS IoCallDriver(DEVICE_OBJECT* device,
|
||||
struct IRP* irp);
|
||||
|
||||
|
||||
Reference in new issue
Block a user