This commit is contained in:
maksw committed 2026-10-27 09:28:31 +01:00
1 parent d36f19509c
commit 30d20457f0
309 files changed
+121746 -1963

No files matched your search

+17 -4
View File
@@ -12,6 +12,7 @@
#include <stddef.h>
#include <ntlite/status.h>
#include <ntlite/ddi/io_driver.h>
#include <ntlite/ddk/interrupt.h>
#ifndef PCI_API
# ifdef PCI_SYS_BUILD
@@ -115,8 +116,20 @@ PCI_API KSTATUS PciEnableDevice(DEVICE_OBJECT* pdo,
PCI_API KSTATUS PciGetInterrupt(DEVICE_OBJECT* pdo,
uint8_t* outIrq);
PCI_API KSTATUS PciEnableMsi(DEVICE_OBJECT* pdo,
uint8_t irqSlot);
typedef struct PCI_INTERRUPT_REQUEST {
KE_INTERRUPT_ROUTINE Routine;
void* Context;
uint64_t Affinity;
KE_INTERRUPT* Interrupt;
// Owned and cleared by pci.sys while the interrupt is connected.
void* BusContext;
} PCI_INTERRUPT_REQUEST;
PCI_API KSTATUS PciEnableMsiAuto(DEVICE_OBJECT* pdo,
uint8_t* outIrqSlot);
// Allocates and programs one or more MSI-X/MSI routes, or a shared INTx route.
PCI_API KSTATUS PciConnectInterrupts(DEVICE_OBJECT* pdo,
PCI_INTERRUPT_REQUEST* requests,
uint32_t count, bool* usingMessages);
// Disable the PCI source before releasing the interrupt objects.
PCI_API void PciDisconnectInterrupts(DEVICE_OBJECT* pdo,
PCI_INTERRUPT_REQUEST* requests,
uint32_t count);
+1
View File
@@ -20,6 +20,7 @@
#include <ntlite/ddk/mutex.h>
#include <ntlite/ddk/object.h>
#include <ntlite/ddk/platform.h>
#include <ntlite/ddk/power.h>
#include <ntlite/ddk/scheduler.h>
#include <ntlite/ddk/semaphore.h>
#include <ntlite/ddk/settings.h>
+44 -9
View File
@@ -1,22 +1,57 @@
// Public nt-lite DDK interrupt declarations.
// Kernel interrupt objects and platform source registration.
#pragma once
#include <stdint.h>
#include <ntlite/status.h>
typedef struct KE_INTERRUPT KE_INTERRUPT;
typedef void (*KE_INTERRUPT_ROUTINE)(void* context);
typedef struct KE_INTERRUPT_INFO {
uint32_t CpuIndex;
uint32_t HardwareId;
uint32_t Gsi;
uint16_t Flags;
uint8_t Vector;
uint8_t IsMessage;
uint64_t Delivered;
} KE_INTERRUPT_INFO;
typedef enum KE_INTERRUPT_MESSAGE_OPERATION {
KeInterruptMessageQuiesce = 1,
KeInterruptMessageProgram,
KeInterruptMessageResume
} KE_INTERRUPT_MESSAGE_OPERATION;
typedef struct NTL_DDK_MSI_MESSAGE {
uint64_t Address;
uint32_t Data;
uint32_t Reserved;
} NTL_DDK_MSI_MESSAGE;
// Only the bus owner programs a device's message source. The interrupt manager
// selects CPUs/vectors and coordinates quiescence with this device callback.
typedef KSTATUS (*KE_INTERRUPT_MESSAGE_PROGRAM)(void* context,
KE_INTERRUPT_MESSAGE_OPERATION operation, const NTL_DDK_MSI_MESSAGE* message);
// The platform owns GSI routing and ISA overrides; drivers own only their handler.
__declspec(dllexport) KSTATUS KeInterruptConnectGsi(uint32_t gsi, uint16_t flags,
uint64_t affinity, KE_INTERRUPT_ROUTINE routine, void* context, KE_INTERRUPT** out);
__declspec(dllexport) KSTATUS KeInterruptConnectIsa(uint8_t isaIrq, uint16_t sourceFlags, uint64_t affinity,
KE_INTERRUPT_ROUTINE routine, void* context, KE_INTERRUPT** out);
// Allocates one kernel IRQ slot for MSI delivery.
__declspec(dllexport) KSTATUS KeIrqAllocateMsiVector(uint8_t* outIrq);
// Registers a legacy interrupt handler for an IRQ slot.
__declspec(dllexport) void KeIrqRegister(uint8_t irq, void (*handler)(void));
__declspec(dllexport) KSTATUS KeIrqComposeMsiMessage(uint8_t irq, NTL_DDK_MSI_MESSAGE* messageOut);
// PCI enables the device's MSI/MSI-X source after reserving the CPU/vector route.
__declspec(dllexport) KSTATUS KeInterruptReserveMessage(uint64_t affinity,
KE_INTERRUPT_ROUTINE routine, void* context, KE_INTERRUPT** out);
__declspec(dllexport) KSTATUS KeInterruptComposeMessage(const KE_INTERRUPT* interrupt,
NTL_DDK_MSI_MESSAGE* out);
__declspec(dllexport) KSTATUS KeInterruptQuery(const KE_INTERRUPT* interrupt, KE_INTERRUPT_INFO* out);
__declspec(dllexport) KSTATUS KeInterruptBindMessageSource(KE_INTERRUPT* interrupt,
KE_INTERRUPT_MESSAGE_PROGRAM program, void* context);
__declspec(dllexport) KSTATUS KeInterruptActivateMessage(KE_INTERRUPT* interrupt);
__declspec(dllexport) KSTATUS KeInterruptSetAffinity(KE_INTERRUPT* interrupt,
uint64_t permittedCpuMask);
// Bus drivers close a route before disabling its source, serializing migration.
__declspec(dllexport) void KeInterruptBeginDisconnect(KE_INTERRUPT* interrupt);
// Disconnect waits for active handlers and requires PASSIVE_LEVEL.
__declspec(dllexport) void KeInterruptDisconnect(KE_INTERRUPT* interrupt);
+5
View File
@@ -83,3 +83,8 @@ __declspec(dllexport) void* MmReallocatePool(void* ptr, size_t newSize);
__declspec(dllexport) void* MmDdkPhysToVirt(uint64_t physicalAddress);
__declspec(dllexport) KSTATUS MmDdkMapPage(uintptr_t virtualAddress, uint64_t physicalAddress, uint64_t flags, NTL_DDK_MAP_MODE mode);
// UC device mapping with a private kernel VA and an exact matching unmap.
// Use in thread context. Returned mappings must be released with their length.
__declspec(dllexport) KSTATUS MmDdkMapIoMemory(uint64_t physicalAddress, size_t length, void** outVirtual);
__declspec(dllexport) KSTATUS MmDdkUnmapIoMemory(void* virtualAddress, size_t length);
+5
View File
@@ -3,6 +3,11 @@
#pragma once
#include <stdint.h>
#include <ntlite/status.h>
__declspec(dllexport) uint32_t KePciReadConfig32(uint16_t segment, uint8_t bus, uint8_t device, uint8_t function, uint16_t offset);
__declspec(dllexport) void KePciWriteConfig32(uint16_t segment, uint8_t bus, uint8_t device, uint8_t function, uint16_t offset, uint32_t value);
// Returns a checksum-validated ACPI RSDP root, independent of its consumer.
// A firmware driver maps the physical tables using the DDK memory interface.
__declspec(dllexport) KSTATUS KeFirmwareQueryAcpiRsdp(uint64_t* physicalAddressOut);
+36
View File
@@ -0,0 +1,36 @@
// Firmware power provider interface for resident platform drivers.
#pragma once
#include <stdint.h>
#include <ntlite/status.h>
// A registered provider remains resident through the final hardware transition.
// Callbacks run in thread context; Enter returns an error if the transition fails.
typedef struct NTL_FIRMWARE_POWER_PROVIDER {
uint32_t Size;
void* Context;
KSTATUS (*Prepare)(void* context, uint32_t action);
KSTATUS (*Enter)(void* context, uint32_t action);
} NTL_FIRMWARE_POWER_PROVIDER;
#ifdef NTL_KERNEL_BUILD
#define NTL_DDK_POWER_API __declspec(dllexport)
#else
#define NTL_DDK_POWER_API __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C" {
#endif
// Installs one firmware power provider for the lifetime of the boot.
NTL_DDK_POWER_API KSTATUS KeRegisterFirmwarePowerProvider(
const NTL_FIRMWARE_POWER_PROVIDER* provider);
// Reports a physical button press from a firmware driver's worker context.
NTL_DDK_POWER_API KSTATUS KeNotifyPowerButton(void);
#ifdef __cplusplus
}
#endif
+3
View File
@@ -72,3 +72,6 @@ __declspec(dllexport) KSTATUS KeResumeThread(THREAD* thread,
// Yields the current processor to another runnable thread.
__declspec(dllexport) void KeYield(void);
// Returns the stable opaque identity of the calling kernel thread.
__declspec(dllexport) uintptr_t KeCurrentThreadIdentity(void);