introduce a stable NTL_DDK driver ABI to replace direct HAL_API and kernel-header access in drivers, add code/kernel/io_ddk.c and code/public/ntlite/ddk/ headers, change DriverEntry to take (const NTL_DDK*, NTL_DRIVER_INIT*), update kmain to build the DDK once via IoInitializeDdk/IoGetDdk and hand it to both boot and runtime drivers, downgrade code/public/ntlite/ddi/io_driver.h to a legacy I/O model header pulling from ntlite/ddk instead of kernel internals, move code/third_party/lwip into code/drivers/net/lwip/third_party, fix up lwip_sources.txt and build.c include paths to match, split build.c's single CFLAGS macro into COMMON/KERNEL/USER/BOOT/DRIVER cflags.
This commit is contained in:
1 parent
08329516ba
commit
485a6bbfe7
385 files changed
+1822
-1079
No files matched your search
@@ -48,27 +48,27 @@ void XhciWrite64(volatile uint8_t* base, uint32_t reg, uint64_t value) {
|
||||
}
|
||||
|
||||
// Implements the delay Us operation.
|
||||
void UsbDelayUs(const HAL_API* hal, uint32_t us) {
|
||||
if (hal && hal->Timer.Stall) hal->Timer.Stall(us);
|
||||
void UsbDelayUs(const NTL_DDK* ddk, uint32_t us) {
|
||||
if (ddk && ddk->Timer && ddk->Timer->Stall) ddk->Timer->Stall(us);
|
||||
else {
|
||||
for (uint32_t i = 0; i < us * 32u; i++) _mm_pause();
|
||||
}
|
||||
}
|
||||
|
||||
bool UsbWaitSet32(const HAL_API* hal, volatile uint8_t* base, uint32_t reg,
|
||||
bool UsbWaitSet32(const NTL_DDK* ddk, volatile uint8_t* base, uint32_t reg,
|
||||
uint32_t mask, uint32_t timeoutUs) {
|
||||
for (uint32_t i = 0; i < timeoutUs; i++) {
|
||||
if ((XhciRead32(base, reg) & mask) == mask) return true;
|
||||
UsbDelayUs(hal, 1);
|
||||
UsbDelayUs(ddk, 1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UsbWaitClear32(const HAL_API* hal, volatile uint8_t* base, uint32_t reg,
|
||||
bool UsbWaitClear32(const NTL_DDK* ddk, volatile uint8_t* base, uint32_t reg,
|
||||
uint32_t mask, uint32_t timeoutUs) {
|
||||
for (uint32_t i = 0; i < timeoutUs; i++) {
|
||||
if ((XhciRead32(base, reg) & mask) == 0) return true;
|
||||
UsbDelayUs(hal, 1);
|
||||
UsbDelayUs(ddk, 1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ void* UsbDmaAllocPages(XHCI_CONTROLLER* xhci, size_t pages,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* virt = xhci->Hal->PhysToVirt(phys);
|
||||
void* virt = xhci->Ddk->Memory->PhysToVirt(phys);
|
||||
memset(virt, 0, pages * (size_t)PAGE_SIZE);
|
||||
*outPhys = phys;
|
||||
return virt;
|
||||
@@ -312,7 +312,7 @@ void XhciPowerRootPorts(XHCI_CONTROLLER* xhci) {
|
||||
}
|
||||
|
||||
if (powered) {
|
||||
UsbDelayUs(xhci->Hal, 20000u);
|
||||
UsbDelayUs(xhci->Ddk, 20000u);
|
||||
DbgPrint("usb: xHCI powered %u previously-off root port(s)\n", powered);
|
||||
}
|
||||
}
|
||||
@@ -518,7 +518,7 @@ KSTATUS XhciWaitForArmedTarget(XHCI_CONTROLLER* xhci, XHCI_WAIT_TARGET* target,
|
||||
KeInsertQueueDpc(&xhci->EventDpc, (void*)0, (void*)0);
|
||||
}
|
||||
|
||||
UsbDelayUs(xhci->Hal, 1);
|
||||
UsbDelayUs(xhci->Ddk, 1);
|
||||
}
|
||||
|
||||
XhciUnregisterWaitTarget(xhci, target);
|
||||
@@ -612,7 +612,7 @@ KSTATUS XhciBiosHandoff(XHCI_CONTROLLER* xhci) {
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
UsbDelayUs(xhci->Hal, 1);
|
||||
UsbDelayUs(xhci->Ddk, 1);
|
||||
}
|
||||
if (!ok) {
|
||||
DbgPrint("usb: xHCI BIOS handoff timed out; continuing anyway\n");
|
||||
@@ -635,7 +635,7 @@ KSTATUS XhciStopAndReset(XHCI_CONTROLLER* xhci) {
|
||||
uint32_t cmd = XhciRead32(xhci->Op, XHCI_OP_USBCMD);
|
||||
if (cmd & XHCI_USBCMD_RS) {
|
||||
XhciWrite32(xhci->Op, XHCI_OP_USBCMD, cmd & ~XHCI_USBCMD_RS);
|
||||
if (!UsbWaitSet32(xhci->Hal, xhci->Op, XHCI_OP_USBSTS,
|
||||
if (!UsbWaitSet32(xhci->Ddk, xhci->Op, XHCI_OP_USBSTS,
|
||||
XHCI_USBSTS_HCH, 1000000u)) {
|
||||
DbgPrint("usb: xHCI stop timeout usbsts=%08x\n",
|
||||
XhciRead32(xhci->Op, XHCI_OP_USBSTS));
|
||||
@@ -644,14 +644,14 @@ KSTATUS XhciStopAndReset(XHCI_CONTROLLER* xhci) {
|
||||
}
|
||||
|
||||
XhciWrite32(xhci->Op, XHCI_OP_USBCMD, XHCI_USBCMD_HCRST);
|
||||
if (!UsbWaitClear32(xhci->Hal, xhci->Op, XHCI_OP_USBCMD,
|
||||
if (!UsbWaitClear32(xhci->Ddk, xhci->Op, XHCI_OP_USBCMD,
|
||||
XHCI_USBCMD_HCRST, 1000000u)) {
|
||||
DbgPrint("usb: xHCI reset timeout usbcmd=%08x\n",
|
||||
XhciRead32(xhci->Op, XHCI_OP_USBCMD));
|
||||
return NTLSTATUS_TIMEOUT;
|
||||
}
|
||||
|
||||
if (!UsbWaitClear32(xhci->Hal, xhci->Op, XHCI_OP_USBSTS,
|
||||
if (!UsbWaitClear32(xhci->Ddk, xhci->Op, XHCI_OP_USBSTS,
|
||||
XHCI_USBSTS_CNR, 1000000u)) {
|
||||
DbgPrint("usb: xHCI controller-not-ready timeout usbsts=%08x\n",
|
||||
XhciRead32(xhci->Op, XHCI_OP_USBSTS));
|
||||
@@ -932,7 +932,7 @@ KSTATUS XhciStart(XHCI_CONTROLLER* xhci) {
|
||||
cmd |= XHCI_USBCMD_RS;
|
||||
XhciWrite32(xhci->Op, XHCI_OP_USBCMD, cmd);
|
||||
|
||||
if (!UsbWaitClear32(xhci->Hal, xhci->Op, XHCI_OP_USBSTS,
|
||||
if (!UsbWaitClear32(xhci->Ddk, xhci->Op, XHCI_OP_USBSTS,
|
||||
XHCI_USBSTS_HCH, 1000000u)) {
|
||||
DbgPrint("usb: xHCI start timeout usbsts=%08x\n",
|
||||
XhciRead32(xhci->Op, XHCI_OP_USBSTS));
|
||||
@@ -1004,7 +1004,7 @@ KSTATUS XhciResetPort(XHCI_CONTROLLER* xhci, uint8_t port, uint8_t* outSpeed) {
|
||||
break;
|
||||
}
|
||||
XhciDrainEventRingLocked(xhci, NULL);
|
||||
UsbDelayUs(xhci->Hal, 1);
|
||||
UsbDelayUs(xhci->Ddk, 1);
|
||||
}
|
||||
|
||||
XhciClearPortChanges(xhci, port);
|
||||
@@ -1033,7 +1033,7 @@ KSTATUS XhciResetPort(XHCI_CONTROLLER* xhci, uint8_t port, uint8_t* outSpeed) {
|
||||
break;
|
||||
}
|
||||
XhciDrainEventRingLocked(xhci, NULL);
|
||||
UsbDelayUs(xhci->Hal, 1);
|
||||
UsbDelayUs(xhci->Ddk, 1);
|
||||
}
|
||||
|
||||
if (!resetDone) {
|
||||
@@ -2076,7 +2076,7 @@ KSTATUS XhciAddDevice(DRIVER_OBJECT* driver, DEVICE_OBJECT* physicalDeviceObject
|
||||
XHCI_CONTROLLER* xhci = (XHCI_CONTROLLER*)fdo->DeviceExtension;
|
||||
memset(xhci, 0, sizeof(*xhci));
|
||||
xhci->Magic = XHCI_CONTROLLER_MAGIC;
|
||||
xhci->Hal = gUsbHal;
|
||||
xhci->Ddk = gUsbDdk;
|
||||
xhci->Fdo = fdo;
|
||||
xhci->Pdo = physicalDeviceObject;
|
||||
xhci->Irq = 0xFFu;
|
||||
|
||||
Reference in new issue
Block a user