replace ad hoc driver loading with a proper driver manager, new DDK, new PnP manager with device matching, asynchronous startup, resource ownership and removal, add shared PCI capability helpers, replace typed, rigid services with a proper service manager, implement proper system shutdown and restart, shutting down unloads drivers and shuts down services, add simple power button, remove heavyweight boot self-tests and SMP stress runs, add monotonic timestamps to kernel debug output, fruitless USB and PS/2 fixes, make test builds opt in.
This commit is contained in:
1 parent
c0ad63c27f
commit
d36f19509c
160 files changed
+6563
-7366
No files matched your search
@@ -77,30 +77,11 @@ typedef struct IO_AUDIO_ENDPOINT_REGISTRATION {
|
||||
uint32_t HardwareGainStepMilliDb;
|
||||
} IO_AUDIO_ENDPOINT_REGISTRATION;
|
||||
|
||||
// Driver-visible services for registering and advancing kernel audio endpoints.
|
||||
typedef struct NTL_DDK_AUDIO {
|
||||
// Registers one endpoint and returns a provider-owned reference valid until unregister returns.
|
||||
KSTATUS (*RegisterEndpoint)(const IO_AUDIO_ENDPOINT_REGISTRATION* registration,
|
||||
IO_AUDIO_ENDPOINT** outEndpoint);
|
||||
|
||||
// Stops the endpoint, removes it from enumeration, and consumes the provider-owned reference.
|
||||
void (*UnregisterEndpoint)(IO_AUDIO_ENDPOINT* endpoint, IO_AUDIO_REMOVAL_MODE mode);
|
||||
|
||||
// Reports one completed hardware period from ISR/DPC completion processing.
|
||||
// presentedFrames, hardwarePositionFrames, and interruptCount must be monotonic for the
|
||||
// endpoint lifetime. timestampTicks uses the DDK monotonic microsecond source.
|
||||
void (*NotifyPeriod)(IO_AUDIO_ENDPOINT* endpoint,
|
||||
uint32_t completedPeriodIndex,
|
||||
uint64_t presentedFrames,
|
||||
uint64_t hardwarePositionFrames,
|
||||
uint64_t interruptCount,
|
||||
uint64_t timestampTicks);
|
||||
|
||||
// Updates jack-derived endpoint availability without changing endpoint identity.
|
||||
void (*SetEndpointAvailable)(IO_AUDIO_ENDPOINT* endpoint, bool available);
|
||||
|
||||
// Fails an endpoint and wakes every stream owner.
|
||||
void (*ReportEndpointFailure)(IO_AUDIO_ENDPOINT* endpoint,
|
||||
KSTATUS status,
|
||||
uint32_t flags);
|
||||
} NTL_DDK_AUDIO;
|
||||
__declspec(dllexport) KSTATUS IoAudioRegisterEndpoint(const IO_AUDIO_ENDPOINT_REGISTRATION* registration, IO_AUDIO_ENDPOINT** outEndpoint);
|
||||
__declspec(dllexport) void IoAudioUnregisterEndpoint(IO_AUDIO_ENDPOINT* endpoint, IO_AUDIO_REMOVAL_MODE mode);
|
||||
__declspec(dllexport) void IoAudioNotifyPeriod(IO_AUDIO_ENDPOINT* endpoint, uint32_t completedPeriodIndex, uint64_t presentedFrames, uint64_t hardwarePositionFrames, uint64_t interruptCount, uint64_t timestampTicks);
|
||||
__declspec(dllexport) void IoAudioSetEndpointAvailable(IO_AUDIO_ENDPOINT* endpoint, bool available);
|
||||
__declspec(dllexport) void IoAudioReportEndpointFailure(IO_AUDIO_ENDPOINT* endpoint, KSTATUS status, uint32_t flags);
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <ntlite/ddk/display.h>
|
||||
#include <ntlite/ddk/dpc.h>
|
||||
#include <ntlite/ddk/driver.h>
|
||||
#include <ntlite/ddk/device.h>
|
||||
#include <ntlite/ddk/event.h>
|
||||
#include <ntlite/ddk/file.h>
|
||||
#include <ntlite/ddk/interrupt.h>
|
||||
@@ -26,23 +27,3 @@
|
||||
#include <ntlite/ddk/thread.h>
|
||||
#include <ntlite/ddk/time.h>
|
||||
#include <ntlite/ddk/timer.h>
|
||||
|
||||
#define NTL_DDK_VERSION 1u
|
||||
|
||||
// Root DDK table passed to kernel drivers by the driver loader.
|
||||
typedef struct NTL_DDK {
|
||||
uint32_t Version;
|
||||
const NTL_DDK_DEBUG* Debug;
|
||||
const NTL_DDK_AUDIO* Audio;
|
||||
const NTL_DDK_DMA* Dma;
|
||||
const NTL_DDK_INTERRUPT* Interrupt;
|
||||
const NTL_DDK_MEMORY* Memory;
|
||||
const NTL_DDK_PLATFORM* Platform;
|
||||
const NTL_DDK_SCHEDULER* Scheduler;
|
||||
const NTL_DDK_TIMER* Timer;
|
||||
} NTL_DDK;
|
||||
|
||||
// Driver initialization record filled by DriverEntry in the DDK-table model.
|
||||
typedef struct NTL_DRIVER_INIT {
|
||||
const char* Name;
|
||||
} NTL_DRIVER_INIT;
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
// Kernel boot debug flags. Keep these contiguous and document every bit in boot.ini.
|
||||
#define KE_DEBUG_CONSOLE 0x00000001u // Mirror debug output to the firmware/debug console.
|
||||
#define KE_DEBUG_SELFTEST 0x00000002u // Run kernel and SMP boot self-tests.
|
||||
#define KE_DEBUG_SELFTEST 0x00000002u // Run optional kernel diagnostics and bootstrap checks.
|
||||
#define KE_DEBUG_FILE_LOG 0x00000004u // Retain debug output for kernel.log persistence.
|
||||
#define KE_DEBUG_POOL_CANARY 0x00000008u // Validate pool block canaries.
|
||||
#define KE_DEBUG_POOL_POISON 0x00000010u // Poison released pool blocks.
|
||||
@@ -21,11 +21,7 @@
|
||||
KE_DEBUG_POOL_QUARANTINE | KE_DEBUG_POOL_CALLERS | \
|
||||
KE_DEBUG_DISPLAY_ASSERTS | KE_DEBUG_LIST_CHECKS)
|
||||
|
||||
// Driver-visible debug output service table passed through NTL_DDK.
|
||||
typedef struct NTL_DDK_DEBUG {
|
||||
void (*Print)(const char* fmt, ...);
|
||||
uint32_t (*GetFlags)(void);
|
||||
} NTL_DDK_DEBUG;
|
||||
|
||||
|
||||
// Current fatal categories used by kernel-mode driver diagnostics.
|
||||
typedef enum KE_PANIC_CODE {
|
||||
@@ -44,3 +40,5 @@ __declspec(dllexport) void DbgPrint(const char* fmt, ...);
|
||||
|
||||
// Stops the system with a formatted diagnostic message.
|
||||
__declspec(dllexport) _Noreturn void KePanic(int32_t code, const char* fmt, ...);
|
||||
|
||||
__declspec(dllexport) uint32_t KeGetDebugFlags(void);
|
||||
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <ntlite/status.h>
|
||||
|
||||
typedef struct NTL_DEVICE NTL_DEVICE;
|
||||
typedef struct NTL_DEVICE_RESOURCE NTL_DEVICE_RESOURCE;
|
||||
|
||||
typedef enum NTL_BUS_TYPE {
|
||||
NtlBusPci = 1,
|
||||
NtlBusUsb = 2,
|
||||
} NTL_BUS_TYPE;
|
||||
|
||||
typedef struct NTL_DEVICE_MATCH {
|
||||
NTL_BUS_TYPE Bus;
|
||||
const char* Id;
|
||||
} NTL_DEVICE_MATCH;
|
||||
|
||||
typedef KSTATUS (*NTL_DEVICE_START)(NTL_DEVICE* device);
|
||||
typedef void (*NTL_DEVICE_STOP)(NTL_DEVICE* device);
|
||||
typedef void (*NTL_DEVICE_CANCEL_START)(NTL_DEVICE* device);
|
||||
|
||||
typedef struct NTL_DEVICE_DESC {
|
||||
uint32_t Size;
|
||||
uint32_t Flags;
|
||||
const char* Name;
|
||||
const NTL_DEVICE_MATCH* Matches;
|
||||
uint32_t MatchCount;
|
||||
uint32_t ContextSize;
|
||||
NTL_DEVICE_START Start;
|
||||
NTL_DEVICE_STOP Stop;
|
||||
NTL_DEVICE_CANCEL_START CancelStart;
|
||||
} NTL_DEVICE_DESC;
|
||||
|
||||
#define NTL_DEVICE_DESCRIPTOR(nameValue, matchesValue, contextType, startFn, stopFn) \
|
||||
{ sizeof(NTL_DEVICE_DESC), 0u, (nameValue), (matchesValue), \
|
||||
(uint32_t)(sizeof(matchesValue) / sizeof((matchesValue)[0])), \
|
||||
(uint32_t)sizeof(contextType), (startFn), (stopFn), 0 }
|
||||
|
||||
typedef void (*NTL_DEVICE_RESOURCE_RELEASE)(void* context);
|
||||
|
||||
#ifdef NTL_KERNEL_BUILD
|
||||
#define NTL_DDK_DEVICE_API __declspec(dllexport)
|
||||
#else
|
||||
#define NTL_DDK_DEVICE_API __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
NTL_DDK_DEVICE_API void* NtlDeviceContext(NTL_DEVICE* device);
|
||||
NTL_DDK_DEVICE_API const char* NtlDeviceId(NTL_DEVICE* device, uint32_t index);
|
||||
NTL_DDK_DEVICE_API NTL_BUS_TYPE NtlDeviceBus(NTL_DEVICE* device);
|
||||
NTL_DDK_DEVICE_API KSTATUS NtlDeviceCompleteStart(NTL_DEVICE* device, KSTATUS result);
|
||||
NTL_DDK_DEVICE_API KSTATUS NtlDeviceOwnResource(NTL_DEVICE* device,
|
||||
void* context,
|
||||
NTL_DEVICE_RESOURCE_RELEASE release,
|
||||
NTL_DEVICE_RESOURCE** out);
|
||||
NTL_DDK_DEVICE_API KSTATUS NtlDeviceReleaseResource(NTL_DEVICE_RESOURCE* resource);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -64,83 +64,21 @@ typedef struct IO_DMA_STATS {
|
||||
uint64_t FailedMappings;
|
||||
} IO_DMA_STATS;
|
||||
|
||||
// Driver-visible DMA services. Device addresses are intentionally distinct
|
||||
// from physical addresses even while the first implementation maps them one to
|
||||
// one on x86-64.
|
||||
typedef struct NTL_DDK_DMA {
|
||||
// Returns the one adapter and requirement set owned by a device object.
|
||||
KSTATUS (*GetAdapter)(struct DEVICE_OBJECT* device,
|
||||
const IO_DMA_REQUIREMENTS* requirements,
|
||||
IO_DMA_ADAPTER** outAdapter);
|
||||
|
||||
// Releases one caller-owned adapter reference.
|
||||
void (*PutAdapter)(IO_DMA_ADAPTER* adapter);
|
||||
|
||||
// Allocates coherent memory with stable CPU and base device addresses. The
|
||||
// caller must quiesce every device reference before releasing the buffer.
|
||||
KSTATUS (*AllocateCommonBuffer)(IO_DMA_ADAPTER* adapter,
|
||||
size_t size,
|
||||
size_t alignment,
|
||||
IO_DMA_BUFFER** outBuffer);
|
||||
|
||||
// Releases a coherent common buffer.
|
||||
void (*FreeCommonBuffer)(IO_DMA_BUFFER* buffer);
|
||||
|
||||
// Returns the stable CPU address of a common buffer.
|
||||
void* (*GetCommonBufferAddress)(const IO_DMA_BUFFER* buffer);
|
||||
|
||||
// Returns the stable device address of a common buffer.
|
||||
uint64_t (*GetCommonBufferDeviceAddress)(const IO_DMA_BUFFER* buffer);
|
||||
|
||||
// Returns the caller-requested size of a common buffer.
|
||||
size_t (*GetCommonBufferSize)(const IO_DMA_BUFFER* buffer);
|
||||
|
||||
// Stabilizes a kernel range for one or more streaming mappings. Pinning
|
||||
// preserves the pages, but does not transfer ownership to a device.
|
||||
KSTATUS (*PinKernelMemory)(void* address,
|
||||
size_t size,
|
||||
IO_DMA_DIRECTION direction,
|
||||
MM_PINNED_MEMORY** outMemory);
|
||||
|
||||
// Stabilizes a process-owned user range for one or more mappings. The
|
||||
// descriptor retains the process and range until the final unpin.
|
||||
KSTATUS (*PinUserMemory)(struct PROCESS* process,
|
||||
void* address,
|
||||
size_t size,
|
||||
IO_DMA_DIRECTION direction,
|
||||
MM_PINNED_MEMORY** outMemory);
|
||||
|
||||
// Releases one pinned-memory reference after all mappings leave.
|
||||
void (*UnpinMemory)(MM_PINNED_MEMORY* memory);
|
||||
|
||||
// Maps a pinned subrange and creates a constrained segment list. A new
|
||||
// mapping begins CPU-owned and requires external operation serialization.
|
||||
KSTATUS (*MapPinnedMemory)(IO_DMA_ADAPTER* adapter,
|
||||
MM_PINNED_MEMORY* memory,
|
||||
size_t offset,
|
||||
size_t length,
|
||||
IO_DMA_DIRECTION direction,
|
||||
uint32_t flags,
|
||||
IO_DMA_MAPPING** outMapping);
|
||||
|
||||
// Releases a mapping and performs a final receive-side bounce copy only
|
||||
// when ownership was transferred to the device and not returned to the CPU.
|
||||
void (*UnmapMemory)(IO_DMA_MAPPING* mapping);
|
||||
|
||||
// Transfers mapping ownership from the CPU to the device. Streaming DMA
|
||||
// must not begin before this operation succeeds.
|
||||
KSTATUS (*SynchronizeForDevice)(IO_DMA_MAPPING* mapping);
|
||||
|
||||
// Transfers mapping ownership from the device to the CPU. CPU readers must
|
||||
// not consume receive data before this operation succeeds.
|
||||
KSTATUS (*SynchronizeForCpu)(IO_DMA_MAPPING* mapping);
|
||||
|
||||
// Returns the immutable segment count owned by a mapping.
|
||||
uint32_t (*GetSegmentCount)(const IO_DMA_MAPPING* mapping);
|
||||
|
||||
// Returns the immutable segment array owned by a mapping.
|
||||
const IO_DMA_SEGMENT* (*GetSegments)(const IO_DMA_MAPPING* mapping);
|
||||
|
||||
// Copies current DMA counters into caller-owned storage.
|
||||
void (*QueryStats)(IO_DMA_STATS* outStats);
|
||||
} NTL_DDK_DMA;
|
||||
__declspec(dllexport) KSTATUS IoDmaGetAdapter(struct DEVICE_OBJECT* device, const IO_DMA_REQUIREMENTS* requirements, IO_DMA_ADAPTER** outAdapter);
|
||||
__declspec(dllexport) void IoDmaPutAdapter(IO_DMA_ADAPTER* adapter);
|
||||
__declspec(dllexport) KSTATUS IoDmaAllocateCommonBuffer(IO_DMA_ADAPTER* adapter, size_t size, size_t alignment, IO_DMA_BUFFER** outBuffer);
|
||||
__declspec(dllexport) void IoDmaFreeCommonBuffer(IO_DMA_BUFFER* buffer);
|
||||
__declspec(dllexport) void* IoDmaGetCommonBufferAddress(const IO_DMA_BUFFER* buffer);
|
||||
__declspec(dllexport) uint64_t IoDmaGetCommonBufferDeviceAddress(const IO_DMA_BUFFER* buffer);
|
||||
__declspec(dllexport) size_t IoDmaGetCommonBufferSize(const IO_DMA_BUFFER* buffer);
|
||||
__declspec(dllexport) KSTATUS IoDmaPinKernelMemory(void* address, size_t size, IO_DMA_DIRECTION direction, MM_PINNED_MEMORY** outMemory);
|
||||
__declspec(dllexport) KSTATUS IoDmaPinUserMemory(struct PROCESS* process, void* address, size_t size, IO_DMA_DIRECTION direction, MM_PINNED_MEMORY** outMemory);
|
||||
__declspec(dllexport) void IoDmaUnpinMemory(MM_PINNED_MEMORY* memory);
|
||||
__declspec(dllexport) KSTATUS IoDmaMapPinnedMemory(IO_DMA_ADAPTER* adapter, MM_PINNED_MEMORY* memory, size_t offset, size_t length, IO_DMA_DIRECTION direction, uint32_t flags, IO_DMA_MAPPING** outMapping);
|
||||
__declspec(dllexport) void IoDmaUnmapMemory(IO_DMA_MAPPING* mapping);
|
||||
__declspec(dllexport) KSTATUS IoDmaSynchronizeForDevice(IO_DMA_MAPPING* mapping);
|
||||
__declspec(dllexport) KSTATUS IoDmaSynchronizeForCpu(IO_DMA_MAPPING* mapping);
|
||||
__declspec(dllexport) uint32_t IoDmaGetSegmentCount(const IO_DMA_MAPPING* mapping);
|
||||
__declspec(dllexport) const IO_DMA_SEGMENT* IoDmaGetSegments(const IO_DMA_MAPPING* mapping);
|
||||
__declspec(dllexport) void IoDmaQueryStats(IO_DMA_STATS* outStats);
|
||||
@@ -1,12 +1,2 @@
|
||||
// Public nt-lite DDK driver entry declarations.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ntlite/status.h>
|
||||
|
||||
struct NTL_DDK;
|
||||
struct NTL_DRIVER_INIT;
|
||||
|
||||
// Kernel driver entrypoint used by the future DDK-table driver model.
|
||||
typedef KSTATUS (*NTL_DRIVER_ENTRY_FN)(const struct NTL_DDK* ddk,
|
||||
struct NTL_DRIVER_INIT* init);
|
||||
#include <ntlite/ddk/module.h>
|
||||
@@ -11,14 +11,12 @@ typedef struct NTL_DDK_MSI_MESSAGE {
|
||||
uint32_t Reserved;
|
||||
} NTL_DDK_MSI_MESSAGE;
|
||||
|
||||
// Driver-visible interrupt services.
|
||||
typedef struct NTL_DDK_INTERRUPT {
|
||||
KSTATUS (*AllocateMsiVector)(uint8_t* outIrq);
|
||||
KSTATUS (*ComposeMsiMessage)(uint8_t irq, NTL_DDK_MSI_MESSAGE* messageOut);
|
||||
} NTL_DDK_INTERRUPT;
|
||||
|
||||
|
||||
// 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);
|
||||
@@ -69,16 +69,6 @@ typedef enum NTL_DDK_MAP_MODE {
|
||||
((uint32_t)(uint8_t)(a) | ((uint32_t)(uint8_t)(b) << 8) | \
|
||||
((uint32_t)(uint8_t)(c) << 16) | ((uint32_t)(uint8_t)(d) << 24))
|
||||
|
||||
// Driver-visible memory services. These are intentionally narrower than the
|
||||
// kernel memory-manager surface.
|
||||
typedef struct NTL_DDK_MEMORY {
|
||||
void* (*PhysToVirt)(uint64_t physicalAddress);
|
||||
KSTATUS (*MapPage)(uintptr_t virtualAddress,
|
||||
uint64_t physicalAddress,
|
||||
uint64_t pageFlags,
|
||||
NTL_DDK_MAP_MODE mode);
|
||||
} NTL_DDK_MEMORY;
|
||||
|
||||
// Allocates from kernel pool for current kernel-mode drivers.
|
||||
__declspec(dllexport) void* MmAllocatePool(size_t size);
|
||||
|
||||
@@ -90,3 +80,6 @@ __declspec(dllexport) void MmFreePool(void* ptr);
|
||||
|
||||
// Reallocates kernel pool memory.
|
||||
__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);
|
||||
@@ -0,0 +1,90 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ntlite/status.h>
|
||||
#include <ntlite/ddk/device.h>
|
||||
|
||||
#define NTL_DDK_MODULE_EXPORT_NAME "NtlDriverModule"
|
||||
#define NTL_DDK_MODULE_SIGNATURE 0x324D444Eu // "NDM2" in little-endian memory.
|
||||
#define NTL_DDK_MODULE_ABI_VERSION 5u
|
||||
|
||||
typedef struct NTL_MODULE NTL_MODULE;
|
||||
typedef KSTATUS (*NTL_MODULE_INITIALIZE)(NTL_MODULE* module);
|
||||
typedef KSTATUS (*NTL_MODULE_PREPARE_SHUTDOWN)(NTL_MODULE* module);
|
||||
typedef void (*NTL_MODULE_COMMIT_SHUTDOWN)(NTL_MODULE* module);
|
||||
|
||||
struct DRIVER_OBJECT;
|
||||
|
||||
typedef struct NTL_MODULE_EXPORT {
|
||||
uint32_t Signature;
|
||||
uint32_t Version;
|
||||
uint32_t Size;
|
||||
uint32_t Flags;
|
||||
NTL_MODULE_INITIALIZE Initialize;
|
||||
const NTL_DEVICE_DESC* Devices;
|
||||
uint32_t DeviceCount;
|
||||
uint32_t Reserved;
|
||||
struct DRIVER_OBJECT* const* IoDrivers;
|
||||
uint32_t IoDriverCount;
|
||||
uint32_t Reserved2;
|
||||
NTL_MODULE_PREPARE_SHUTDOWN PrepareShutdown;
|
||||
NTL_MODULE_COMMIT_SHUTDOWN CommitShutdown;
|
||||
} NTL_MODULE_EXPORT;
|
||||
|
||||
#ifdef __cplusplus
|
||||
static_assert(sizeof(NTL_MODULE_EXPORT) == 72u, "DDK module export ABI changed");
|
||||
#define NTL_DDK_C_EXPORT extern "C"
|
||||
#else
|
||||
_Static_assert(sizeof(NTL_MODULE_EXPORT) == 72u, "DDK module export ABI changed");
|
||||
#define NTL_DDK_C_EXPORT
|
||||
#endif
|
||||
|
||||
#define NTL_DECLARE_MODULE(initialize_fn) \
|
||||
NTL_DDK_C_EXPORT __declspec(dllexport) const NTL_MODULE_EXPORT NtlDriverModule = { \
|
||||
NTL_DDK_MODULE_SIGNATURE, NTL_DDK_MODULE_ABI_VERSION, \
|
||||
(uint32_t)sizeof(NTL_MODULE_EXPORT), 0u, (initialize_fn), 0, 0u, 0u, 0, 0u, 0u, 0, 0 \
|
||||
}
|
||||
|
||||
#define NTL_DECLARE_DEVICE_MODULE(deviceArray) \
|
||||
NTL_DDK_C_EXPORT __declspec(dllexport) const NTL_MODULE_EXPORT NtlDriverModule = { \
|
||||
NTL_DDK_MODULE_SIGNATURE, NTL_DDK_MODULE_ABI_VERSION, \
|
||||
(uint32_t)sizeof(NTL_MODULE_EXPORT), 0u, 0, (deviceArray), \
|
||||
(uint32_t)(sizeof(deviceArray) / sizeof((deviceArray)[0])), 0u, 0, 0u, 0u, 0, 0 \
|
||||
}
|
||||
|
||||
#define NTL_DECLARE_IO_MODULE(initialize_fn, driverArray) \
|
||||
NTL_DDK_C_EXPORT __declspec(dllexport) const NTL_MODULE_EXPORT NtlDriverModule = { \
|
||||
NTL_DDK_MODULE_SIGNATURE, NTL_DDK_MODULE_ABI_VERSION, \
|
||||
(uint32_t)sizeof(NTL_MODULE_EXPORT), 0u, (initialize_fn), 0, 0u, 0u, \
|
||||
(driverArray), (uint32_t)(sizeof(driverArray) / sizeof((driverArray)[0])), 0u, 0, 0 \
|
||||
}
|
||||
|
||||
#define NTL_DECLARE_MODULE_WITH_SHUTDOWN(initialize_fn, prepareFn, commitFn) \
|
||||
NTL_DDK_C_EXPORT __declspec(dllexport) const NTL_MODULE_EXPORT NtlDriverModule = { \
|
||||
NTL_DDK_MODULE_SIGNATURE, NTL_DDK_MODULE_ABI_VERSION, \
|
||||
(uint32_t)sizeof(NTL_MODULE_EXPORT), 0u, (initialize_fn), 0, 0u, 0u, \
|
||||
0, 0u, 0u, (prepareFn), (commitFn) \
|
||||
}
|
||||
|
||||
#define NTL_DECLARE_IO_MODULE_WITH_SHUTDOWN(initialize_fn, driverArray, prepareFn, commitFn) \
|
||||
NTL_DDK_C_EXPORT __declspec(dllexport) const NTL_MODULE_EXPORT NtlDriverModule = { \
|
||||
NTL_DDK_MODULE_SIGNATURE, NTL_DDK_MODULE_ABI_VERSION, \
|
||||
(uint32_t)sizeof(NTL_MODULE_EXPORT), 0u, (initialize_fn), 0, 0u, 0u, \
|
||||
(driverArray), (uint32_t)(sizeof(driverArray) / sizeof((driverArray)[0])), 0u, \
|
||||
(prepareFn), (commitFn) \
|
||||
}
|
||||
|
||||
// Query the configured module identity; the returned string is borrowed.
|
||||
#ifdef NTL_KERNEL_BUILD
|
||||
#define NTL_DDK_MODULE_API __declspec(dllexport)
|
||||
#else
|
||||
#define NTL_DDK_MODULE_API __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
NTL_DDK_MODULE_API const char* NtlModuleGetName(const NTL_MODULE* module);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -36,6 +36,7 @@ typedef enum OBJECT_TYPE {
|
||||
ObjectTypeInputManager = 27,
|
||||
ObjectTypeDisplayManager = 28,
|
||||
ObjectTypePipeEndpoint = 29,
|
||||
ObjectTypeServiceRegistration = 30,
|
||||
} OBJECT_TYPE;
|
||||
|
||||
typedef enum OBJECT_LIFETIME_STATE {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Pure driver-library helpers for walking PCI capability lists.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ntlite/status.h>
|
||||
|
||||
typedef struct NTL_PCI_CONFIG_READER {
|
||||
void* Context;
|
||||
uint32_t (*Read32)(void* context, uint16_t offset);
|
||||
} NTL_PCI_CONFIG_READER;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Finds an ordinary PCI capability using an explicitly supplied config reader.
|
||||
// Returns NOT_FOUND for a valid exhausted list and DEVICE_ERROR for malformed lists.
|
||||
KSTATUS NtlPciFindCapability(const NTL_PCI_CONFIG_READER* reader,
|
||||
uint8_t firstOffset,
|
||||
uint8_t capabilityId,
|
||||
uint8_t* outOffset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -4,18 +4,5 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Driver-visible platform services. PCI bus policy stays in pci.sys; these are
|
||||
// only the raw platform hooks needed by the PCI bus driver itself.
|
||||
typedef struct NTL_DDK_PLATFORM {
|
||||
uint32_t (*PciRead32)(uint16_t segment,
|
||||
uint8_t bus,
|
||||
uint8_t device,
|
||||
uint8_t function,
|
||||
uint16_t offset);
|
||||
void (*PciWrite32)(uint16_t segment,
|
||||
uint8_t bus,
|
||||
uint8_t device,
|
||||
uint8_t function,
|
||||
uint16_t offset,
|
||||
uint32_t value);
|
||||
} NTL_DDK_PLATFORM;
|
||||
__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);
|
||||
@@ -6,8 +6,7 @@
|
||||
#include <ntlite/status.h>
|
||||
#include <ntlite/ddk/thread.h>
|
||||
|
||||
// Driver-visible scheduler services.
|
||||
typedef struct NTL_DDK_SCHEDULER {
|
||||
KSTATUS (*DelayThread)(uint64_t milliseconds);
|
||||
void (*Yield)(void);
|
||||
} NTL_DDK_SCHEDULER;
|
||||
|
||||
|
||||
__declspec(dllexport) KSTATUS KeDelayThread(uint64_t milliseconds);
|
||||
__declspec(dllexport) void KeYield(void);
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Driver-visible timing services.
|
||||
typedef struct NTL_DDK_TIMER {
|
||||
uint64_t (*QueryTicks)(void);
|
||||
void (*Stall)(uint32_t microseconds);
|
||||
} NTL_DDK_TIMER;
|
||||
|
||||
|
||||
__declspec(dllexport) uint64_t KeQueryTicks(void);
|
||||
__declspec(dllexport) void KeStallExecution(uint32_t microseconds);
|
||||
Reference in new issue
Block a user