replace nob with ms' build, move disk creation to build.bat, major comment cleanup, remove old and stupid tests, overhaul interrupt management with per-CPU vector allocation, affinity migration and safe teardown, add proper IOAPIC routing and PCI MSI/MSI-X/INTx support, migrate drivers to the new interrupt API, integrate ACPICA with a proper OS services layer, move ACPI firmware events, power button handling and S5 shutdown into acpi.sys, add parallel driver startup and atomic publication, replace PnP arrays with dynamic lists, redesign service startup again to be asynchronous, add delayed startup mode for services, allow omitting keys in services.ini, fix acpi ec deferred work handling, fix kernel threads having garbage exit code.
This commit is contained in:
1 parent
d36f19509c
commit
36eef8f58d
696 files changed
+147281
-7530
No files matched your search
@@ -31,19 +31,16 @@ static const IO_DRIVER_ID_TABLE gUsbHubIdTable = {
|
||||
#define USB_HUB_PORT_ENUMERATING 0xffu
|
||||
#define USB_HUB_PORT_FAILED 0xfeu
|
||||
|
||||
// Implements the hub Slot Busy operation.
|
||||
static bool UsbHubSlotBusy(uint8_t slot) {
|
||||
return slot != 0 && slot != USB_HUB_PORT_ENUMERATING && slot != USB_HUB_PORT_FAILED;
|
||||
}
|
||||
|
||||
// Implements the hub Root Port Connected operation.
|
||||
static bool UsbHubRootPortConnected(XHCI_CONTROLLER* xhci, uint8_t port) {
|
||||
if (!xhci || !xhci->Op || port == 0) return false;
|
||||
uint32_t portsc = XhciRead32(xhci->Op, XhciPortReg(port));
|
||||
return (portsc & XHCI_PORTSC_CCS) != 0;
|
||||
}
|
||||
|
||||
// Implements the hub Clear Root Port Failure operation.
|
||||
static void UsbHubClearRootPortFailure(USB_HUB_EXTENSION* hub, uint8_t port) {
|
||||
if (!hub || port == 0 || port > USB_ROOT_HUB_MAX_PORTS) return;
|
||||
hub->RootPortFailCount[port] = 0;
|
||||
@@ -51,7 +48,6 @@ static void UsbHubClearRootPortFailure(USB_HUB_EXTENSION* hub, uint8_t port) {
|
||||
hub->RootPortSlot[port] = 0;
|
||||
}
|
||||
|
||||
// Implements the hub Mark Root Port Failed operation.
|
||||
static void UsbHubMarkRootPortFailed(USB_HUB_EXTENSION* hub, uint8_t port) {
|
||||
if (!hub || port == 0 || port > USB_ROOT_HUB_MAX_PORTS) return;
|
||||
hub->RootPortSlot[port] = USB_HUB_PORT_FAILED;
|
||||
@@ -146,7 +142,6 @@ static KSTATUS UsbHubEnumerateConnectedRootPort(USB_HUB_EXTENSION* hub,
|
||||
return status;
|
||||
}
|
||||
|
||||
// Implements the hub Pop Pending Root Port operation.
|
||||
static bool UsbHubPopPendingRootPort(USB_HUB_EXTENSION* hub, uint8_t* outPort) {
|
||||
if (!hub || !outPort) return false;
|
||||
|
||||
@@ -168,7 +163,6 @@ static bool UsbHubPopPendingRootPort(USB_HUB_EXTENSION* hub, uint8_t* outPort) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Implements the hub Pop Pending External Port operation.
|
||||
static bool UsbHubPopPendingExternalPort(USB_HUB_EXTENSION* hub, uint8_t* outPort) {
|
||||
if (!hub || !outPort) return false;
|
||||
|
||||
@@ -193,7 +187,6 @@ static bool UsbHubPopPendingExternalPort(USB_HUB_EXTENSION* hub, uint8_t* outPor
|
||||
return false;
|
||||
}
|
||||
|
||||
// Implements the hub Record Root Port Change operation.
|
||||
static void UsbHubRecordRootPortChange(USB_HUB_EXTENSION* hub, uint8_t port) {
|
||||
if (!hub || port == 0 || port > hub->PortCount)
|
||||
return;
|
||||
@@ -206,7 +199,6 @@ static void UsbHubRecordRootPortChange(USB_HUB_EXTENSION* hub, uint8_t port) {
|
||||
KeSignalSemaphore(hub->WorkerSemaphore);
|
||||
}
|
||||
|
||||
// Implements the hub Queue External Port Change operation.
|
||||
void UsbHubQueueExternalPortChange(USB_HUB_EXTENSION* hub, uint8_t port) {
|
||||
if (!hub || port == 0 || port > hub->PortCount || port > USB_EXTERNAL_HUB_MAX_PORTS)
|
||||
return;
|
||||
@@ -217,7 +209,6 @@ void UsbHubQueueExternalPortChange(USB_HUB_EXTENSION* hub, uint8_t port) {
|
||||
KeSignalSemaphore(hub->WorkerSemaphore);
|
||||
}
|
||||
|
||||
// Implements the hub Remove Slot Child operation.
|
||||
static void UsbHubRemoveSlotChild(USB_HUB_EXTENSION* hub, uint8_t port, uint8_t slot) {
|
||||
if (!hub || !hub->Hcd || slot == 0)
|
||||
return;
|
||||
@@ -253,7 +244,6 @@ static void UsbHubRemoveSlotChild(USB_HUB_EXTENSION* hub, uint8_t port, uint8_t
|
||||
}
|
||||
}
|
||||
|
||||
// Implements the hub Remove Root Child operation.
|
||||
static void UsbHubRemoveRootChild(USB_HUB_EXTENSION* hub, uint8_t port, uint8_t slot) {
|
||||
UsbHubRemoveSlotChild(hub, port, slot);
|
||||
}
|
||||
@@ -306,7 +296,6 @@ static KSTATUS UsbHubControlNoData(USB_HUB_EXTENSION* hub,
|
||||
return UsbSubmitUrbSync(hub->LowerDevice, &urb);
|
||||
}
|
||||
|
||||
// Implements the hub Read Descriptor operation.
|
||||
static KSTATUS UsbHubReadDescriptor(USB_HUB_EXTENSION* hub, USB_HUB_DESCRIPTOR* outDesc) {
|
||||
if (!hub || !outDesc || !hub->ChangeBitmap || !hub->ChangeBitmapDeviceAddress)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
@@ -329,7 +318,6 @@ static KSTATUS UsbHubReadDescriptor(USB_HUB_EXTENSION* hub, USB_HUB_DESCRIPTOR*
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the hub Get Port Status operation.
|
||||
static KSTATUS UsbHubGetPortStatus(USB_HUB_EXTENSION* hub, uint8_t port, USB_HUB_PORT_STATUS* outStatus) {
|
||||
if (!hub || !outStatus || port == 0)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
@@ -350,7 +338,6 @@ static KSTATUS UsbHubGetPortStatus(USB_HUB_EXTENSION* hub, uint8_t port, USB_HUB
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the hub Set Port Feature operation.
|
||||
static KSTATUS UsbHubSetPortFeature(USB_HUB_EXTENSION* hub, uint8_t port, uint16_t feature) {
|
||||
return UsbHubControlNoData(hub,
|
||||
USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_OTHER,
|
||||
@@ -359,7 +346,6 @@ static KSTATUS UsbHubSetPortFeature(USB_HUB_EXTENSION* hub, uint8_t port, uint16
|
||||
port);
|
||||
}
|
||||
|
||||
// Implements the hub Clear Port Feature operation.
|
||||
static KSTATUS UsbHubClearPortFeature(USB_HUB_EXTENSION* hub, uint8_t port, uint16_t feature) {
|
||||
return UsbHubControlNoData(hub,
|
||||
USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_OTHER,
|
||||
@@ -368,7 +354,6 @@ static KSTATUS UsbHubClearPortFeature(USB_HUB_EXTENSION* hub, uint8_t port, uint
|
||||
port);
|
||||
}
|
||||
|
||||
// Implements the hub Speed From Port Status operation.
|
||||
static uint8_t UsbHubSpeedFromPortStatus(uint16_t status) {
|
||||
if (status & USB_HUB_PORT_STATUS_LOW_SPEED)
|
||||
return 2u;
|
||||
@@ -377,7 +362,6 @@ static uint8_t UsbHubSpeedFromPortStatus(uint16_t status) {
|
||||
return 1u;
|
||||
}
|
||||
|
||||
// Implements the hub Reset External Port operation.
|
||||
static KSTATUS UsbHubResetExternalPort(USB_HUB_EXTENSION* hub, uint8_t port, uint8_t* outSpeed) {
|
||||
if (outSpeed) *outSpeed = 0;
|
||||
if (!hub || port == 0)
|
||||
@@ -426,7 +410,6 @@ static KSTATUS UsbHubResetExternalPort(USB_HUB_EXTENSION* hub, uint8_t port, uin
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the hub Handle External Port Change operation.
|
||||
static void UsbHubHandleExternalPortChange(USB_HUB_EXTENSION* hub, uint8_t port) {
|
||||
if (!hub || hub->Kind != UsbHubKindExternal || port == 0 || port > hub->PortCount || port > USB_EXTERNAL_HUB_MAX_PORTS)
|
||||
return;
|
||||
@@ -509,7 +492,6 @@ static void UsbHubHandleExternalPortChange(USB_HUB_EXTENSION* hub, uint8_t port)
|
||||
}
|
||||
}
|
||||
|
||||
// Implements the hub Handle Root Port Change operation.
|
||||
static void UsbHubHandleRootPortChange(USB_HUB_EXTENSION* hub, uint8_t port) {
|
||||
if (!hub || !hub->Hcd || port == 0 || port > hub->PortCount || port > USB_ROOT_HUB_MAX_PORTS)
|
||||
return;
|
||||
@@ -575,7 +557,6 @@ static void UsbHubHandleRootPortChange(USB_HUB_EXTENSION* hub, uint8_t port) {
|
||||
static void UsbHubArmExternalInterrupt(USB_HUB_EXTENSION* hub);
|
||||
static KSTATUS UsbHubDoRootPortScan(USB_HCD* hcd);
|
||||
|
||||
// Implements the hub Take Initial Root Scan operation.
|
||||
static bool UsbHubTakeInitialRootScan(USB_HUB_EXTENSION* hub) {
|
||||
if (!hub || hub->Kind != UsbHubKindRoot)
|
||||
return false;
|
||||
@@ -589,7 +570,6 @@ static bool UsbHubTakeInitialRootScan(USB_HUB_EXTENSION* hub) {
|
||||
return take;
|
||||
}
|
||||
|
||||
// Implements the hub Worker operation.
|
||||
static void UsbHubWorker(void* arg) {
|
||||
USB_HUB_EXTENSION* hub = (USB_HUB_EXTENSION*)arg;
|
||||
if (hub && hub->Kind == UsbHubKindRoot && hub->Hcd) {
|
||||
@@ -687,7 +667,6 @@ static KSTATUS UsbHubStartWorker(USB_HUB_EXTENSION* hub) {
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the hub Do Root Port Scan operation.
|
||||
static KSTATUS UsbHubDoRootPortScan(USB_HCD* hcd) {
|
||||
if (!hcd || !hcd->RootHubContext)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
@@ -774,7 +753,6 @@ KSTATUS UsbHubScheduleRootScan(USB_HCD* hcd) {
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the hub Queue Root Port Change operation.
|
||||
void UsbHubQueueRootPortChange(USB_HCD* hcd, uint8_t port) {
|
||||
if (!hcd || !hcd->RootHubContext)
|
||||
return;
|
||||
@@ -782,7 +760,6 @@ void UsbHubQueueRootPortChange(USB_HCD* hcd, uint8_t port) {
|
||||
UsbHubRecordRootPortChange(hub, port);
|
||||
}
|
||||
|
||||
// Implements the hub Scan External Ports operation.
|
||||
static KSTATUS UsbHubScanExternalPorts(USB_HUB_EXTENSION* hub) {
|
||||
if (!hub || hub->Kind != UsbHubKindExternal)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
@@ -810,7 +787,6 @@ static KSTATUS UsbHubScanExternalPorts(USB_HUB_EXTENSION* hub) {
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the hub Find Interrupt In operation.
|
||||
static const USB_ENDPOINT_DESCRIPTOR* UsbHubFindInterruptIn(USB_PDO_EXTENSION* pdoExt) {
|
||||
if (!pdoExt)
|
||||
return (const USB_ENDPOINT_DESCRIPTOR*)0;
|
||||
@@ -844,7 +820,6 @@ static const USB_ENDPOINT_DESCRIPTOR* UsbHubFindInterruptIn(USB_PDO_EXTENSION* p
|
||||
return (const USB_ENDPOINT_DESCRIPTOR*)0;
|
||||
}
|
||||
|
||||
// Implements the hub External Change Complete operation.
|
||||
static void UsbHubExternalChangeComplete(USB_URB* urb, void* context) {
|
||||
USB_HUB_EXTENSION* hub = (USB_HUB_EXTENSION*)context;
|
||||
if (!hub || urb != &hub->ChangeUrb)
|
||||
@@ -869,7 +844,6 @@ static void UsbHubExternalChangeComplete(USB_URB* urb, void* context) {
|
||||
IoReleaseRemoveLock(&hub->RemoveLock, (IRP*)0);
|
||||
}
|
||||
|
||||
// Implements the hub Arm External Interrupt operation.
|
||||
static void UsbHubArmExternalInterrupt(USB_HUB_EXTENSION* hub) {
|
||||
if (!hub || !hub->InterruptPipe || !hub->ChangeBitmap || hub->ChangeUrbPending)
|
||||
return;
|
||||
@@ -902,7 +876,6 @@ static void UsbHubArmExternalInterrupt(USB_HUB_EXTENSION* hub) {
|
||||
}
|
||||
}
|
||||
|
||||
// Implements the hub Start Root Device operation.
|
||||
static KSTATUS UsbHubStartRootDevice(DEVICE_OBJECT* device, USB_HUB_EXTENSION* hub) {
|
||||
hub->PortCount = hub->Hcd ? hub->Hcd->MaxRootPorts : 0;
|
||||
if (hub->PortCount > USB_ROOT_HUB_MAX_PORTS)
|
||||
@@ -939,7 +912,6 @@ static KSTATUS UsbHubStartRootDevice(DEVICE_OBJECT* device, USB_HUB_EXTENSION* h
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the hub Start External Device operation.
|
||||
static KSTATUS UsbHubStartExternalDevice(DEVICE_OBJECT* device, USB_HUB_EXTENSION* hub) {
|
||||
if (!hub || !hub->Device)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
@@ -1019,7 +991,6 @@ static KSTATUS UsbHubStartExternalDevice(DEVICE_OBJECT* device, USB_HUB_EXTENSIO
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the hub Start Device operation.
|
||||
static KSTATUS UsbHubStartDevice(DEVICE_OBJECT* device, USB_HUB_EXTENSION* hub) {
|
||||
if (!device || !hub || hub->Started)
|
||||
return NTLSTATUS_SUCCESS;
|
||||
@@ -1029,7 +1000,6 @@ static KSTATUS UsbHubStartDevice(DEVICE_OBJECT* device, USB_HUB_EXTENSION* hub)
|
||||
return UsbHubStartExternalDevice(device, hub);
|
||||
}
|
||||
|
||||
// Implements the hub Dispatch Pnp operation.
|
||||
KSTATUS UsbHubDispatchPnp(DEVICE_OBJECT* device, IRP* irp) {
|
||||
if (!device || !irp)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
@@ -1154,7 +1124,6 @@ KSTATUS UsbHubDispatchPnp(DEVICE_OBJECT* device, IRP* irp) {
|
||||
}
|
||||
}
|
||||
|
||||
// Implements the hub Add Device operation.
|
||||
KSTATUS UsbHubAddDevice(DRIVER_OBJECT* driver, DEVICE_OBJECT* physicalDeviceObject) {
|
||||
if (!driver || !physicalDeviceObject || physicalDeviceObject->Type != DeviceObjectPhysical)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
Reference in new issue
Block a user