add display subsystem and vmwaresvga driver, support absolute mouse and qemu tablet, map pci mmio to private virtual aperture, better smp panic handling, remove legacy io publish/match, add sys query display info and display command to native shell

This commit is contained in:
maksw committed 2026-06-15 09:58:12 +02:00
1 parent e41bf6e2c0
commit 6260de0085
38 files changed
+4011 -467

No files matched your search

+67
View File
@@ -0,0 +1,67 @@
#pragma once
// 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;
// PCI/virtual GPU drivers register additional providers later.
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <ntlite/status.h>
#ifndef DISPLAY_API
#define DISPLAY_API __declspec(dllimport)
#endif
#include <ntlite/display.h>
typedef struct DISPLAY_DEVICE DISPLAY_DEVICE;
typedef struct DISPLAY_DEVICE_OPS {
KSTATUS (*GetMode)(DISPLAY_DEVICE* device, DISPLAY_MODE* outMode);
KSTATUS (*Blit)(DISPLAY_DEVICE* device,
int x, int y, int w, int h,
const uint32_t* pixels);
KSTATUS (*FillRect)(DISPLAY_DEVICE* device,
int x, int y, int w, int h,
uint32_t color);
KSTATUS (*CopyRect)(DISPLAY_DEVICE* device,
int dstX, int dstY,
int srcX, int srcY,
int w, int h);
KSTATUS (*ReadRect)(DISPLAY_DEVICE* device,
int x, int y, int w, int h,
uint32_t* outPixels, uint32_t outStride);
KSTATUS (*Present)(DISPLAY_DEVICE* device,
const DISPLAY_RECT* rects,
size_t rectCount);
KSTATUS (*Sync)(DISPLAY_DEVICE* device);
KSTATUS (*SetCursorImage)(DISPLAY_DEVICE* device,
int width, int height,
int hotX, int hotY,
const uint32_t* argbPixels);
KSTATUS (*SetCursorPosition)(DISPLAY_DEVICE* device, int x, int y);
KSTATUS (*ShowCursor)(DISPLAY_DEVICE* device, bool show);
KSTATUS (*QueryStats)(DISPLAY_DEVICE* device, DISPLAY_STATS* outStats);
} DISPLAY_DEVICE_OPS;
struct DISPLAY_DEVICE {
const char* Name;
uint32_t Caps;
void* DriverContext;
const DISPLAY_DEVICE_OPS* Ops;
DISPLAY_DEVICE* Next;
};
DISPLAY_API KSTATUS KeDisplayRegisterDevice(DISPLAY_DEVICE* device);
DISPLAY_API KSTATUS KeDisplaySetPrimary(DISPLAY_DEVICE* device);
+11 -1
View File
@@ -7,15 +7,25 @@
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);
void (*PrintChar)(char c, uint32_t fg, uint32_t bg);
// Hardware mouse cursor: save/restore background and blit sprite
// 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;
+2
View File
@@ -7,3 +7,5 @@
__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);
__declspec(dllexport) void KeInputSubmitMouseAbsolute(const INPUT_MOUSE_ABSOLUTE_EVENT* event);
__declspec(dllexport) void KeInputSubmitMouseAbsoluteScaled(uint32_t rawX, uint32_t rawY, uint32_t maxX, uint32_t maxY, int wheel, uint8_t buttons);
-66
View File
@@ -165,72 +165,6 @@ __declspec(dllexport) uint8_t IoGetDeviceStackSize(DEVICE_OBJECT* device);
__declspec(dllexport) KSTATUS IoSendPnpIrpSync(DEVICE_OBJECT* device,
IO_PNP_MINOR_FUNCTION minor);
// -------------------------------------------------------------------------
// Legacy USB publish/matcher path. This remains only until USB is migrated to
// PDO/interface-PDO enumeration in the later USB stages.
// -------------------------------------------------------------------------
#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);
// -------------------------------------------------------------------------
// Disk namespace above storage DEVICE_OBJECTs
// -------------------------------------------------------------------------
+71
View File
@@ -0,0 +1,71 @@
#pragma once
// display.h - user/kernel shared display ABI types
//
// This header is safe for user-mode code. It contains only plain syscall ABI
// data types and capability bits. Kernel/driver provider interfaces live in
// <ntlite/ddi/display.h>.
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum DISPLAY_PIXEL_FORMAT {
DisplayPixelFormatUnknown = 0,
DisplayPixelFormatX8R8G8B8 = 1,
} DISPLAY_PIXEL_FORMAT;
typedef struct DISPLAY_MODE {
uint32_t Width;
uint32_t Height;
uint32_t Stride; // pixels per scanline
DISPLAY_PIXEL_FORMAT Format;
} DISPLAY_MODE;
typedef struct DISPLAY_RECT {
int32_t X;
int32_t Y;
int32_t W;
int32_t H;
} DISPLAY_RECT;
typedef struct DISPLAY_STATS {
uint64_t BlitCount;
uint64_t FillRectCount;
uint64_t CopyRectCount;
uint64_t ReadRectCount;
uint64_t PresentCount;
uint64_t PresentRectCount;
uint64_t DirtyRectCount;
uint64_t DirtyAllCount;
uint64_t BytesCopied;
uint64_t SyncCount;
uint64_t CursorMoveCount;
uint64_t CursorShowCount;
uint64_t CursorHideCount;
} DISPLAY_STATS;
#define DISPLAY_CAP_FRAMEBUFFER 0x00000001u
#define DISPLAY_CAP_SOFTWARE_CURSOR 0x00000002u
#define DISPLAY_CAP_HARDWARE_CURSOR 0x00000004u
#define DISPLAY_CAP_ACCEL_FILL 0x00000008u
#define DISPLAY_CAP_ACCEL_COPY 0x00000010u
#define DISPLAY_CAP_PRESENT_SYNC 0x00000020u
#define DISPLAY_CAP_VBLANK 0x00000040u
#define DISPLAY_CAP_3D 0x00000080u
#define SYS_DISPLAY_NAME_MAX 32u
typedef struct SYS_DISPLAY_INFO {
char PrimaryName[SYS_DISPLAY_NAME_MAX];
DISPLAY_MODE Mode;
uint32_t Caps;
uint32_t DeviceCount;
DISPLAY_STATS ManagerStats;
DISPLAY_STATS DeviceStats;
} SYS_DISPLAY_INFO;
#ifdef __cplusplus
}
#endif
+7
View File
@@ -140,3 +140,10 @@ typedef struct INPUT_MOUSE_EVENT {
int wheel;
uint8_t buttons; // bit0=left, bit1=right, bit2=middle
} INPUT_MOUSE_EVENT;
typedef struct INPUT_MOUSE_ABSOLUTE_EVENT {
int x;
int y;
int wheel;
uint8_t buttons; // bit0=left, bit1=right, bit2=middle
} INPUT_MOUSE_ABSOLUTE_EVENT;
+18 -4
View File
@@ -9,6 +9,7 @@
#include <ntlite/dirent.h>
#include <ntlite/input.h>
#include <ntlite/time.h>
#include <ntlite/display.h>
#define SYS_STATUS_SUCCESS 0u
#define SYS_STATUS_TIMEOUT 3u
@@ -329,16 +330,29 @@ uint32_t SysSetCwd(const SYS_PATH_REQUEST* request);
uint32_t SysGetCwd(const SYS_GET_CWD_REQUEST* request);
// ---------------------------------------------------------------------------
// Console and graphics (57-61)
// Console and graphics.
// ---------------------------------------------------------------------------
typedef struct SYS_CONSOLE_INFO {
uint32_t Columns;
uint32_t Rows;
uint32_t CursorX;
uint32_t CursorY;
uint16_t Attribute;
} SYS_CONSOLE_INFO;
uint32_t SysWriteConsole(const SYS_WRITE_CONSOLE_REQUEST* request);
uint32_t SysGetConsoleInfo(SYS_CONSOLE_INFO* infoOut);
uint32_t SysSetConsoleCursor(int x, int y);
uint32_t SysFillConsoleCharacter(char c, int x, int y, size_t length, size_t* writtenOut);
uint32_t SysFillConsoleAttribute(uint16_t attr, int x, int y, size_t length, size_t* writtenOut);
uint32_t SysPutScreenChar(char c, int x, int y, uint32_t fg, uint32_t bg);
uint32_t SysBlitScreen(int x, int y, int w, int h, const uint32_t* pixels);
uint32_t SysClearScreen(uint32_t color);
uint32_t SysGetScreenSize(int* widthOut, int* heightOut);
uint32_t SysPutScreenChar(char c, int x, int y, uint32_t fg, uint32_t bg);
uint32_t SysQueryDisplayInfo(SYS_DISPLAY_INFO* infoOut);
// ---------------------------------------------------------------------------
// Input (62-69)
// Input.
// ---------------------------------------------------------------------------
uint64_t SysPollKeyboard(void);
uint64_t SysIsKeyDown(INPUT_KEY key);
@@ -501,9 +515,9 @@ typedef struct SYS_CPU_STATS {
// Time and diagnostics
// ---------------------------------------------------------------------------
uint64_t SysGetTick(void);
uint32_t SysGetSystemTime(SYS_SYSTEM_TIME* timeOut);
uint32_t SysPrintDebug(const SYS_PRINT_DEBUG_REQUEST* request);
uint32_t SysQueryTrapFrame(SYS_TRAP_FRAME_INFO* info);
uint32_t SysGetMemoryStatus(SYS_MEMORY_STATUS* statusOut);
uint32_t SysQueryKernelStats(uint32_t classId, void* buffer, size_t bufferSize, size_t* requiredSizeOut);
uint32_t SysGetSystemTime(SYS_SYSTEM_TIME* timeOut);