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
@@ -1,8 +1,8 @@
|
||||
#include <ntlite/ddk/module.h>
|
||||
// Realtek RTL816x network driver. This file owns PCI attachment, descriptor rings, and net-device registration.
|
||||
|
||||
#include "rtl816x.h"
|
||||
|
||||
const NTL_DDK* gRtl816xDdk;
|
||||
static DRIVER_OBJECT gRtl816xDriver;
|
||||
static RTL816X_DEVICE* gRtl816xDevices[RTL816X_MAX_DEVICES];
|
||||
static uint32_t gRtl816xDeviceCount;
|
||||
@@ -70,8 +70,7 @@ static KSTATUS RtlReset(RTL816X_DEVICE* r) {
|
||||
for (uint32_t i = 0; i < 1000; i++) {
|
||||
if ((RtlRead8(r, RTL_REG_CHIP_CMD) & RTL_CMD_RESET) == 0)
|
||||
return NTLSTATUS_SUCCESS;
|
||||
if (gRtl816xDdk->Timer->Stall)
|
||||
gRtl816xDdk->Timer->Stall(1000);
|
||||
KeStallExecution(1000);
|
||||
}
|
||||
return NTLSTATUS_TIMEOUT;
|
||||
}
|
||||
@@ -101,12 +100,12 @@ static void RtlStopDma(RTL816X_DEVICE* r) {
|
||||
|
||||
// Releases the common buffers and adapter owned by one RTL816x device.
|
||||
static void RtlReleaseDma(RTL816X_DEVICE* r) {
|
||||
if (!r || !gRtl816xDdk || !gRtl816xDdk->Dma)
|
||||
if (!r)
|
||||
return;
|
||||
gRtl816xDdk->Dma->FreeCommonBuffer(r->TxBuffersDma);
|
||||
gRtl816xDdk->Dma->FreeCommonBuffer(r->RxBuffersDma);
|
||||
gRtl816xDdk->Dma->FreeCommonBuffer(r->TxRingDma);
|
||||
gRtl816xDdk->Dma->FreeCommonBuffer(r->RxRingDma);
|
||||
IoDmaFreeCommonBuffer(r->TxBuffersDma);
|
||||
IoDmaFreeCommonBuffer(r->RxBuffersDma);
|
||||
IoDmaFreeCommonBuffer(r->TxRingDma);
|
||||
IoDmaFreeCommonBuffer(r->RxRingDma);
|
||||
r->TxBuffersDma = (IO_DMA_BUFFER*)0;
|
||||
r->RxBuffersDma = (IO_DMA_BUFFER*)0;
|
||||
r->TxRingDma = (IO_DMA_BUFFER*)0;
|
||||
@@ -119,7 +118,7 @@ static void RtlReleaseDma(RTL816X_DEVICE* r) {
|
||||
r->RxBuffersDeviceAddress = 0;
|
||||
r->TxRingDeviceAddress = 0;
|
||||
r->RxRingDeviceAddress = 0;
|
||||
gRtl816xDdk->Dma->PutAdapter(r->DmaAdapter);
|
||||
IoDmaPutAdapter(r->DmaAdapter);
|
||||
r->DmaAdapter = (IO_DMA_ADAPTER*)0;
|
||||
}
|
||||
|
||||
@@ -132,41 +131,41 @@ static KSTATUS RtlAllocateDma(RTL816X_DEVICE* r) {
|
||||
requirements.MaximumSegmentLength = RTL_BUF_SIZE;
|
||||
requirements.MaximumSegments = RTL_TX_COUNT;
|
||||
|
||||
KSTATUS status = gRtl816xDdk->Dma->GetAdapter(r->Fdo,
|
||||
KSTATUS status = IoDmaGetAdapter(r->Fdo,
|
||||
&requirements,
|
||||
&r->DmaAdapter);
|
||||
if (!KSUCCESS(status))
|
||||
return status;
|
||||
|
||||
status = gRtl816xDdk->Dma->AllocateCommonBuffer(r->DmaAdapter,
|
||||
status = IoDmaAllocateCommonBuffer(r->DmaAdapter,
|
||||
PAGE_SIZE * RTL_RING_PAGES,
|
||||
PAGE_SIZE,
|
||||
&r->RxRingDma);
|
||||
if (!KSUCCESS(status)) goto fail;
|
||||
status = gRtl816xDdk->Dma->AllocateCommonBuffer(r->DmaAdapter,
|
||||
status = IoDmaAllocateCommonBuffer(r->DmaAdapter,
|
||||
PAGE_SIZE * RTL_RING_PAGES,
|
||||
PAGE_SIZE,
|
||||
&r->TxRingDma);
|
||||
if (!KSUCCESS(status)) goto fail;
|
||||
status = gRtl816xDdk->Dma->AllocateCommonBuffer(r->DmaAdapter,
|
||||
status = IoDmaAllocateCommonBuffer(r->DmaAdapter,
|
||||
PAGE_SIZE * RTL_RXBUF_PAGES,
|
||||
PAGE_SIZE,
|
||||
&r->RxBuffersDma);
|
||||
if (!KSUCCESS(status)) goto fail;
|
||||
status = gRtl816xDdk->Dma->AllocateCommonBuffer(r->DmaAdapter,
|
||||
status = IoDmaAllocateCommonBuffer(r->DmaAdapter,
|
||||
PAGE_SIZE * RTL_TXBUF_PAGES,
|
||||
PAGE_SIZE,
|
||||
&r->TxBuffersDma);
|
||||
if (!KSUCCESS(status)) goto fail;
|
||||
|
||||
r->RxRing = (RTL_DESC*)gRtl816xDdk->Dma->GetCommonBufferAddress(r->RxRingDma);
|
||||
r->TxRing = (RTL_DESC*)gRtl816xDdk->Dma->GetCommonBufferAddress(r->TxRingDma);
|
||||
r->RxBuffers = (uint8_t*)gRtl816xDdk->Dma->GetCommonBufferAddress(r->RxBuffersDma);
|
||||
r->TxBuffers = (uint8_t*)gRtl816xDdk->Dma->GetCommonBufferAddress(r->TxBuffersDma);
|
||||
r->RxRingDeviceAddress = gRtl816xDdk->Dma->GetCommonBufferDeviceAddress(r->RxRingDma);
|
||||
r->TxRingDeviceAddress = gRtl816xDdk->Dma->GetCommonBufferDeviceAddress(r->TxRingDma);
|
||||
r->RxBuffersDeviceAddress = gRtl816xDdk->Dma->GetCommonBufferDeviceAddress(r->RxBuffersDma);
|
||||
r->TxBuffersDeviceAddress = gRtl816xDdk->Dma->GetCommonBufferDeviceAddress(r->TxBuffersDma);
|
||||
r->RxRing = (RTL_DESC*)IoDmaGetCommonBufferAddress(r->RxRingDma);
|
||||
r->TxRing = (RTL_DESC*)IoDmaGetCommonBufferAddress(r->TxRingDma);
|
||||
r->RxBuffers = (uint8_t*)IoDmaGetCommonBufferAddress(r->RxBuffersDma);
|
||||
r->TxBuffers = (uint8_t*)IoDmaGetCommonBufferAddress(r->TxBuffersDma);
|
||||
r->RxRingDeviceAddress = IoDmaGetCommonBufferDeviceAddress(r->RxRingDma);
|
||||
r->TxRingDeviceAddress = IoDmaGetCommonBufferDeviceAddress(r->TxRingDma);
|
||||
r->RxBuffersDeviceAddress = IoDmaGetCommonBufferDeviceAddress(r->RxBuffersDma);
|
||||
r->TxBuffersDeviceAddress = IoDmaGetCommonBufferDeviceAddress(r->TxBuffersDma);
|
||||
|
||||
DbgPrint("RTL816X: rxRing=0x%016llX txRing=0x%016llX rxBuf=0x%016llX txBuf=0x%016llX\n",
|
||||
(unsigned long long)r->RxRingDeviceAddress,
|
||||
@@ -667,14 +666,11 @@ KSTATUS Rtl816xAddDevice(DRIVER_OBJECT* driver, DEVICE_OBJECT* physicalDeviceObj
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the driver Entry operation.
|
||||
KSTATUS DriverEntry(const NTL_DDK* ddk, NTL_DRIVER_INIT* init) {
|
||||
(void)init;
|
||||
if (!ddk || !ddk->Dma || !ddk->Timer)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
static KSTATUS DriverInitialize(NTL_MODULE* module) {
|
||||
(void)module;
|
||||
|
||||
DbgPrint("RTL816X: driver loading...\n");
|
||||
gRtl816xDdk = ddk;
|
||||
|
||||
gRtl816xDeviceCount = 0;
|
||||
|
||||
memset(&gRtl816xDriver, 0, sizeof(gRtl816xDriver));
|
||||
@@ -682,9 +678,8 @@ KSTATUS DriverEntry(const NTL_DDK* ddk, NTL_DRIVER_INIT* init) {
|
||||
gRtl816xDriver.IdTable = &gRtl816xIdTable;
|
||||
gRtl816xDriver.DriverAddDevice = Rtl816xAddDevice;
|
||||
gRtl816xDriver.MajorFunction[IRP_MJ_PNP] = Rtl816xDispatchPnp;
|
||||
|
||||
KSTATUS st = IoRegisterDriverObject(&gRtl816xDriver);
|
||||
if (!KSUCCESS(st))
|
||||
DbgPrint("RTL816X: IoRegisterDriverObject failed: 0x%x\n", st);
|
||||
return st;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static DRIVER_OBJECT* const gModuleIoDrivers[] = { &gRtl816xDriver };
|
||||
NTL_DECLARE_IO_MODULE(DriverInitialize, gModuleIoDrivers);
|
||||
@@ -151,7 +151,5 @@ typedef struct RTL816X_DEVICE {
|
||||
NET_DEVICE NetDevice;
|
||||
} RTL816X_DEVICE;
|
||||
|
||||
extern const NTL_DDK* gRtl816xDdk;
|
||||
|
||||
KSTATUS Rtl816xAddDevice(DRIVER_OBJECT* driver, DEVICE_OBJECT* physicalDeviceObject);
|
||||
KSTATUS Rtl816xDispatchPnp(DEVICE_OBJECT* device, IRP* irp);
|
||||
Reference in new issue
Block a user