Author: hbelusca
Date: Wed Mar 8 22:20:11 2017
New Revision: 74129
URL:
http://svn.reactos.org/svn/reactos?rev=74129&view=rev
Log:
[CLT-2017]: For this 0.4.4 release, let's play safe & revert the USB stack import
from r73605, as the latter need more real-hardware testing & fixes.
Modified:
branches/ReactOS-0.4.4-CLT2017/reactos/ (props changed)
branches/ReactOS-0.4.4-CLT2017/reactos/drivers/hid/hidparse/ (props changed)
branches/ReactOS-0.4.4-CLT2017/reactos/drivers/hid/hidparse/hidparse.c
branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/ (props changed)
branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/CMakeLists.txt
branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/fdo.c
branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/misc.c
branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/pdo.c
branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/usbhub.c
branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/usbhub.h
branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/hidparser/context.c
branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/hidparser/hidparser.c
branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/hidparser/parser.c
branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/libusb/hub_controller.cpp
(contents, props changed)
Propchange: branches/ReactOS-0.4.4-CLT2017/reactos/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 8 22:20:11 2017
@@ -2,7 +2,7 @@
/branches/GSoC_2011/GSoC_TcpIpDriver:51550
/branches/GSoC_2011/TcpIpDriver:51551-53074,53076-53119
/branches/GSoC_2016/AHCI:71203-73603
-/branches/GSoC_2016/USB:72365-73604
+/branches/GSoC_2016/USB:72366,72376
/branches/GSoC_Network:51545-51546
/branches/cmake-bringup:50484,50693,50719,51544-52564
/branches/colins-printing-for-freedom/reactos:67543-68405,68407-68414,68417-70595
Propchange: branches/ReactOS-0.4.4-CLT2017/reactos/drivers/hid/hidparse/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 8 22:20:11 2017
@@ -1,7 +1,6 @@
/branches/GSoC_2011/GSoC_Network/drivers/hid/hidparse:51548
/branches/GSoC_2011/GSoC_TcpIpDriver/drivers/hid/hidparse:51550
/branches/GSoC_2011/TcpIpDriver/drivers/hid/hidparse:51551-53074,53076-53119
-/branches/GSoC_2016/USB/drivers/hid/hidparse:72365-73604
/branches/GSoC_Network/drivers/hid/hidparse:51545-51546
/branches/cmake-bringup/drivers/hid/hidparse:50484,50693,50719,51544-52564
/branches/condrv_restructure/drivers/hid/hidparse:63104-64101
Modified: branches/ReactOS-0.4.4-CLT2017/reactos/drivers/hid/hidparse/hidparse.c
URL:
http://svn.reactos.org/svn/reactos/branches/ReactOS-0.4.4-CLT2017/reactos/d…
==============================================================================
--- branches/ReactOS-0.4.4-CLT2017/reactos/drivers/hid/hidparse/hidparse.c [iso-8859-1]
(original)
+++ branches/ReactOS-0.4.4-CLT2017/reactos/drivers/hid/hidparse/hidparse.c [iso-8859-1]
Wed Mar 8 22:20:11 2017
@@ -126,29 +126,6 @@
}
NTSTATUS
-TranslateStatusForUpperLayer(
- IN HIDPARSER_STATUS Status)
-{
- //
- // now we are handling only this values, for others just return
- // status as it is.
- //
- switch (Status)
- {
- case HIDPARSER_STATUS_INSUFFICIENT_RESOURCES:
- return STATUS_INSUFFICIENT_RESOURCES;
- case HIDPARSER_STATUS_INVALID_REPORT_TYPE:
- return HIDP_STATUS_INVALID_REPORT_TYPE;
- case HIDPARSER_STATUS_BUFFER_TOO_SMALL:
- return STATUS_BUFFER_TOO_SMALL;
- case HIDPARSER_STATUS_COLLECTION_NOT_FOUND:
- return STATUS_NO_DATA_DETECTED;
- default:
- return Status;
- }
-}
-
-NTSTATUS
NTAPI
HidP_GetCollectionDescription(
IN PHIDP_REPORT_DESCRIPTOR ReportDesc,
@@ -157,7 +134,6 @@
OUT PHIDP_DEVICE_DESC DeviceDescription)
{
HID_PARSER Parser;
- NTSTATUS Status;
//
// init parser
@@ -167,8 +143,7 @@
//
// get description;
//
- Status = HidParser_GetCollectionDescription(&Parser, ReportDesc, DescLength,
PoolType, DeviceDescription);
- return TranslateStatusForUpperLayer(Status);
+ return HidParser_GetCollectionDescription(&Parser, ReportDesc, DescLength,
PoolType, DeviceDescription);
}
HIDAPI
Propchange: branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 8 22:20:11 2017
@@ -4,7 +4,7 @@
/branches/GSoC_2011/GSoC_TcpIpDriver/drivers/usb/usbhub_new:51550
/branches/GSoC_2011/TcpIpDriver/drivers/usb/usbhub:51551-53074,53076-53119
/branches/GSoC_2011/TcpIpDriver/drivers/usb/usbhub_new:51551-53074,53076-53119
-/branches/GSoC_2016/USB/drivers/usb/usbhub:72365-73604
+/branches/GSoC_2016/USB/drivers/usb/usbhub:72366,72376
/branches/GSoC_Network/drivers/usb/usbhub:51545-51546
/branches/GSoC_Network/drivers/usb/usbhub_new:51545-51546
/branches/cmake-bringup/drivers/usb/usbhub:50484,50693,50719,51544-52564
Modified: branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/ReactOS-0.4.4-CLT2017/reactos/d…
==============================================================================
--- branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/CMakeLists.txt [iso-8859-1]
(original)
+++ branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/CMakeLists.txt [iso-8859-1]
Wed Mar 8 22:20:11 2017
@@ -1,6 +1,5 @@
add_definitions(-DDEBUG_MODE)
-add_definitions(-DNTDDI_VERSION=0x05020400)
include_directories(${REACTOS_SOURCE_DIR}/ntoskrnl/include)
list(APPEND SOURCE
Modified: branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/fdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/ReactOS-0.4.4-CLT2017/reactos/d…
==============================================================================
--- branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/fdo.c [iso-8859-1]
(original)
+++ branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/fdo.c [iso-8859-1] Wed Mar
8 22:20:11 2017
@@ -568,11 +568,6 @@
Stack->Parameters.QueryInterface.Version = Version;
Stack->Parameters.QueryInterface.Interface = Interface;
Stack->Parameters.QueryInterface.InterfaceSpecificData = NULL;
-
- //
- // Initialize the status block before sending the IRP
- //
- Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
Status = IoCallDriver(DeviceObject, Irp);
@@ -1094,7 +1089,8 @@
PDEVICE_OBJECT ChildDeviceObject = NULL;
ULONG Index = 0;
- KeAcquireGuardedMutex(&HubDeviceExtension->HubMutexLock);
+ DPRINT("Removing device on port %d (Child index: %d)\n", PortId, Index);
+
for (Index = 0; Index < USB_MAXCHILDREN; Index++)
{
if (HubDeviceExtension->ChildDeviceObject[Index])
@@ -1115,16 +1111,11 @@
if (!ChildDeviceObject)
{
DPRINT1("Removal request for non-existant device!\n");
- KeReleaseGuardedMutex(&HubDeviceExtension->HubMutexLock);
return STATUS_UNSUCCESSFUL;
}
-
- DPRINT("Removing device on port %d (Child index: %d)\n", PortId, Index);
/* Remove the device from the table */
HubDeviceExtension->ChildDeviceObject[Index] = NULL;
-
- KeReleaseGuardedMutex(&HubDeviceExtension->HubMutexLock);
/* Invalidate device relations for the root hub */
IoInvalidateDeviceRelations(HubDeviceExtension->RootHubPhysicalDeviceObject,
BusRelations);
@@ -1156,6 +1147,26 @@
HubInterface = &HubDeviceExtension->HubInterface;
RootHubDeviceObject = HubDeviceExtension->RootHubPhysicalDeviceObject;
HubInterfaceBusContext = HubDeviceExtension->UsbDInterface.BusContext;
+ //
+ // Find an empty slot in the child device array
+ //
+ for (ChildDeviceCount = 0; ChildDeviceCount < USB_MAXCHILDREN;
ChildDeviceCount++)
+ {
+ if (HubDeviceExtension->ChildDeviceObject[ChildDeviceCount] == NULL)
+ {
+ DPRINT("Found unused entry at %d\n", ChildDeviceCount);
+ break;
+ }
+ }
+
+ //
+ // Check if the limit has been reached for maximum usb devices
+ //
+ if (ChildDeviceCount == USB_MAXCHILDREN)
+ {
+ DPRINT1("USBHUB: Too many child devices!\n");
+ return STATUS_UNSUCCESSFUL;
+ }
while (TRUE)
{
@@ -1215,6 +1226,10 @@
UsbChildExtension->ParentDeviceObject = UsbHubDeviceObject;
UsbChildExtension->PortNumber = PortId;
+ // copy device interface
+ RtlCopyMemory(&UsbChildExtension->DeviceInterface,
&HubDeviceExtension->DeviceInterface, sizeof(USB_BUS_INTERFACE_USBDI_V2));
+
+
//
// Create the UsbDeviceObject
//
@@ -1228,6 +1243,12 @@
DPRINT1("USBHUB: CreateUsbDevice failed with status %x\n", Status);
goto Cleanup;
}
+
+ // copy device interface
+ RtlCopyMemory(&UsbChildExtension->DeviceInterface,
&HubDeviceExtension->DeviceInterface, sizeof(USB_BUS_INTERFACE_USBDI_V2));
+
+ // FIXME replace buscontext
+ UsbChildExtension->DeviceInterface.BusContext =
UsbChildExtension->UsbDeviceHandle;
//
// Initialize UsbDevice
@@ -1318,43 +1339,8 @@
goto Cleanup;
}
- // copy device interface
- RtlCopyMemory(&UsbChildExtension->DeviceInterface,
&HubDeviceExtension->UsbDInterface, sizeof(USB_BUS_INTERFACE_USBDI_V2));
-
UsbChildExtension->DeviceInterface.InterfaceReference(UsbChildExtension->DeviceInterface.BusContext);
-
- INITIALIZE_PNP_STATE(UsbChildExtension->Common);
-
- IoInitializeRemoveLock(&UsbChildExtension->Common.RemoveLock, 'pbuH',
0, 0);
-
- KeAcquireGuardedMutex(&HubDeviceExtension->HubMutexLock);
-
- //
- // Find an empty slot in the child device array
- //
- for (ChildDeviceCount = 0; ChildDeviceCount < USB_MAXCHILDREN;
ChildDeviceCount++)
- {
- if (HubDeviceExtension->ChildDeviceObject[ChildDeviceCount] == NULL)
- {
- DPRINT("Found unused entry at %d\n", ChildDeviceCount);
- break;
- }
- }
-
- //
- // Check if the limit has been reached for maximum usb devices
- //
- if (ChildDeviceCount == USB_MAXCHILDREN)
- {
- DPRINT1("USBHUB: Too many child devices!\n");
- Status = STATUS_UNSUCCESSFUL;
- KeReleaseGuardedMutex(&HubDeviceExtension->HubMutexLock);
-
UsbChildExtension->DeviceInterface.InterfaceDereference(UsbChildExtension->DeviceInterface.BusContext);
- goto Cleanup;
- }
-
HubDeviceExtension->ChildDeviceObject[ChildDeviceCount] = NewChildDeviceObject;
HubDeviceExtension->InstanceCount++;
- KeReleaseGuardedMutex(&HubDeviceExtension->HubMutexLock);
IoInvalidateDeviceRelations(RootHubDeviceObject, BusRelations);
return STATUS_SUCCESS;
@@ -1398,20 +1384,16 @@
NTSTATUS
USBHUB_FdoQueryBusRelations(
IN PDEVICE_OBJECT DeviceObject,
- IN PDEVICE_RELATIONS RelationsFromTop,
OUT PDEVICE_RELATIONS* pDeviceRelations)
{
PHUB_DEVICE_EXTENSION HubDeviceExtension;
PDEVICE_RELATIONS DeviceRelations;
ULONG i;
- ULONG ChildrenFromTop = 0;
ULONG Children = 0;
ULONG NeededSize;
HubDeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
- KeAcquireGuardedMutex(&HubDeviceExtension->HubMutexLock);
-
//
// Count the number of children
//
@@ -1425,19 +1407,9 @@
Children++;
}
- if (RelationsFromTop)
- {
- ChildrenFromTop = RelationsFromTop->Count;
- if (!Children)
- {
- // We have nothing to add
- *pDeviceRelations = RelationsFromTop;
- KeReleaseGuardedMutex(&HubDeviceExtension->HubMutexLock);
- return STATUS_SUCCESS;
- }
- }
-
- NeededSize = sizeof(DEVICE_RELATIONS) + (Children + ChildrenFromTop - 1) *
sizeof(PDEVICE_OBJECT);
+ NeededSize = sizeof(DEVICE_RELATIONS);
+ if (Children > 1)
+ NeededSize += (Children - 1) * sizeof(PDEVICE_OBJECT);
//
// Allocate DeviceRelations
@@ -1446,22 +1418,9 @@
NeededSize);
if (!DeviceRelations)
- {
- KeReleaseGuardedMutex(&HubDeviceExtension->HubMutexLock);
- if (!RelationsFromTop)
- return STATUS_INSUFFICIENT_RESOURCES;
- else
- return STATUS_NOT_SUPPORTED;
- }
- // Copy the objects coming from top
- if (ChildrenFromTop)
- {
- RtlCopyMemory(DeviceRelations->Objects, RelationsFromTop->Objects,
- ChildrenFromTop * sizeof(PDEVICE_OBJECT));
- }
-
- DeviceRelations->Count = Children + ChildrenFromTop;
- Children = ChildrenFromTop;
+ return STATUS_INSUFFICIENT_RESOURCES;
+ DeviceRelations->Count = Children;
+ Children = 0;
//
// Fill in return structure
@@ -1470,18 +1429,11 @@
{
if (HubDeviceExtension->ChildDeviceObject[i])
{
- // The PnP Manager removes the reference when appropriate.
ObReferenceObject(HubDeviceExtension->ChildDeviceObject[i]);
HubDeviceExtension->ChildDeviceObject[i]->Flags &=
~DO_DEVICE_INITIALIZING;
DeviceRelations->Objects[Children++] =
HubDeviceExtension->ChildDeviceObject[i];
}
}
-
- KeReleaseGuardedMutex(&HubDeviceExtension->HubMutexLock);
-
- // We should do this, because replaced this with our's one
- if (RelationsFromTop)
- ExFreePool(RelationsFromTop);
ASSERT(Children == DeviceRelations->Count);
*pDeviceRelations = DeviceRelations;
@@ -1599,8 +1551,7 @@
if (!Urb)
{
// no memory
- Status = STATUS_INSUFFICIENT_RESOURCES;
- goto cleanup;
+ return STATUS_INSUFFICIENT_RESOURCES;
}
// zero urb
@@ -1615,7 +1566,8 @@
{
// failed to obtain hub pdo
DPRINT1("IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO failed with %x\n",
Status);
- goto cleanup;
+ ExFreePool(Urb);
+ return Status;
}
// sanity checks
@@ -1626,13 +1578,14 @@
RootHubDeviceObject = HubDeviceExtension->RootHubPhysicalDeviceObject;
// Send the StartDevice to RootHub
- Status = ForwardIrpAndWait(HubDeviceExtension->LowerDeviceObject, Irp);
+ Status = ForwardIrpAndWait(RootHubDeviceObject, Irp);
if (!NT_SUCCESS(Status))
{
// failed to start pdo
DPRINT1("Failed to start the RootHub PDO\n");
- goto cleanup;
+ ExFreePool(Urb);
+ return Status;
}
// Get the current number of hubs
@@ -1643,7 +1596,8 @@
{
// failed to get number of hubs
DPRINT1("IOCTL_INTERNAL_USB_GET_HUB_COUNT failed with %x\n", Status);
- goto cleanup;
+ ExFreePool(Urb);
+ return Status;
}
// Get the Hub Interface
@@ -1657,7 +1611,8 @@
{
// failed to get root hub interface
DPRINT1("Failed to get HUB_GUID interface with status 0x%08lx\n",
Status);
- goto cleanup;
+ ExFreePool(Urb);
+ return Status;
}
HubInterfaceBusContext = HubDeviceExtension->HubInterface.BusContext;
@@ -1673,7 +1628,8 @@
{
// failed to get usbdi interface
DPRINT1("Failed to get USBDI_GUID interface with status 0x%08lx\n",
Status);
- goto cleanup;
+ ExFreePool(Urb);
+ return Status;
}
// Get Root Hub Device Handle
@@ -1686,7 +1642,8 @@
{
// failed
DPRINT1("IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE failed with status
0x%08lx\n", Status);
- goto cleanup;
+ ExFreePool(Urb);
+ return Status;
}
//
@@ -1730,7 +1687,8 @@
{
// failed to get device descriptor of hub
DPRINT1("Failed to get HubDeviceDescriptor!\n");
- goto cleanup;
+ ExFreePool(Urb);
+ return Status;
}
// build configuration request
@@ -1757,7 +1715,8 @@
{
// failed to get configuration descriptor
DPRINT1("Failed to get RootHub Configuration with status %x\n",
Status);
- goto cleanup;
+ ExFreePool(Urb);
+ return Status;
}
// sanity checks
@@ -1783,15 +1742,16 @@
{
// failed to get hub information
DPRINT1("Failed to extended hub information. Unable to determine the number
of ports!\n");
- goto cleanup;
+ ExFreePool(Urb);
+ return Status;
}
if (!HubDeviceExtension->UsbExtHubInfo.NumberOfPorts)
{
// bogus port driver
DPRINT1("Failed to retrieve the number of ports\n");
- Status = STATUS_UNSUCCESSFUL;
- goto cleanup;
+ ExFreePool(Urb);
+ return STATUS_UNSUCCESSFUL;
}
DPRINT("HubDeviceExtension->UsbExtHubInfo.NumberOfPorts %x\n",
HubDeviceExtension->UsbExtHubInfo.NumberOfPorts);
@@ -1822,8 +1782,8 @@
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to get Hub Descriptor!\n");
- Status = STATUS_UNSUCCESSFUL;
- goto cleanup;
+ ExFreePool(Urb);
+ return STATUS_UNSUCCESSFUL;
}
// sanity checks
@@ -1851,21 +1811,14 @@
{
// failed to get hub status
DPRINT1("Failed to get Hub Status!\n");
- Status = STATUS_UNSUCCESSFUL;
- goto cleanup;
+ ExFreePool(Urb);
+ return STATUS_UNSUCCESSFUL;
}
// Allocate memory for PortStatusChange to hold 2 USHORTs for each port on hub
HubDeviceExtension->PortStatusChange = ExAllocatePoolWithTag(NonPagedPool,
sizeof(ULONG) *
HubDeviceExtension->UsbExtHubInfo.NumberOfPorts,
USB_HUB_TAG);
-
- if (!HubDeviceExtension->PortStatusChange)
- {
- DPRINT1("Failed to allocate pool for PortStatusChange!\n");
- Status = STATUS_INSUFFICIENT_RESOURCES;
- goto cleanup;
- }
// Get the first Configuration Descriptor
Pid =
USBD_ParseConfigurationDescriptorEx(&HubDeviceExtension->HubConfigDescriptor,
@@ -1875,8 +1828,8 @@
{
// failed parse hub descriptor
DPRINT1("Failed to parse configuration descriptor\n");
- Status = STATUS_UNSUCCESSFUL;
- goto cleanup;
+ ExFreePool(Urb);
+ return STATUS_UNSUCCESSFUL;
}
// create configuration request
@@ -1887,8 +1840,8 @@
{
// failed to build urb
DPRINT1("Failed to allocate urb\n");
- Status = STATUS_INSUFFICIENT_RESOURCES;
- goto cleanup;
+ ExFreePool(Urb);
+ return STATUS_INSUFFICIENT_RESOURCES;
}
// send request
@@ -1900,7 +1853,9 @@
{
// failed to select configuration
DPRINT1("Failed to select configuration with %x\n", Status);
- goto cleanup;
+ ExFreePool(Urb);
+ ExFreePool(ConfigUrb);
+ return Status;
}
// store configuration & pipe handle
@@ -1908,6 +1863,12 @@
HubDeviceExtension->PipeHandle =
ConfigUrb->UrbSelectConfiguration.Interface.Pipes[0].PipeHandle;
DPRINT("Configuration Handle %x\n",
HubDeviceExtension->ConfigurationHandle);
+ FDO_QueryInterface(DeviceObject, &HubDeviceExtension->DeviceInterface);
+
+
+ // free urb
+ ExFreePool(ConfigUrb);
+
// check if function is available
if (HubDeviceExtension->UsbDInterface.IsDeviceHighSpeed)
{
@@ -1947,7 +1908,8 @@
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to set callback\n");
- goto cleanup;
+ ExFreePool(Urb);
+ return Status;
}
}
else
@@ -1999,29 +1961,7 @@
// free urb
ExFreePool(Urb);
- // free ConfigUrb
- ExFreePool(ConfigUrb);
-
// done
- return Status;
-
-cleanup:
- if (Urb)
- ExFreePool(Urb);
-
- // Dereference interfaces
- if (HubDeviceExtension->HubInterface.Size)
-
HubDeviceExtension->HubInterface.InterfaceDereference(HubDeviceExtension->HubInterface.BusContext);
-
- if (HubDeviceExtension->UsbDInterface.Size)
-
HubDeviceExtension->UsbDInterface.InterfaceDereference(HubDeviceExtension->UsbDInterface.BusContext);
-
- if (HubDeviceExtension->PortStatusChange)
- ExFreePool(HubDeviceExtension->PortStatusChange);
-
- if (ConfigUrb)
- ExFreePool(ConfigUrb);
-
return Status;
}
@@ -2032,31 +1972,17 @@
{
PIO_STACK_LOCATION Stack;
NTSTATUS Status = STATUS_SUCCESS;
- PDEVICE_OBJECT ChildDeviceObject;
+ ULONG_PTR Information = 0;
PHUB_DEVICE_EXTENSION HubDeviceExtension;
- PUSB_BUS_INTERFACE_HUB_V5 HubInterface;
- PHUB_CHILDDEVICE_EXTENSION ChildDeviceExtension;
HubDeviceExtension = (PHUB_DEVICE_EXTENSION) DeviceObject->DeviceExtension;
- HubInterface = &HubDeviceExtension->HubInterface;
Stack = IoGetCurrentIrpStackLocation(Irp);
- Status = IoAcquireRemoveLock(&HubDeviceExtension->Common.RemoveLock, Irp);
- if (!NT_SUCCESS(Status))
- {
- Irp->IoStatus.Status = Status;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return Status;
- }
-
switch (Stack->MinorFunction)
{
- int i;
-
case IRP_MN_START_DEVICE:
{
- DPRINT("IRP_MN_START_DEVICE\n");
if (USBHUB_IsRootHubFDO(DeviceObject))
{
// start root hub fdo
@@ -2066,13 +1992,7 @@
{
Status = USBHUB_ParentFDOStartDevice(DeviceObject, Irp);
}
-
- SET_NEW_PNP_STATE(HubDeviceExtension->Common, Started);
-
- Irp->IoStatus.Status = Status;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- IoReleaseRemoveLock(&HubDeviceExtension->Common.RemoveLock, Irp);
- return Status;
+ break;
}
case IRP_MN_QUERY_DEVICE_RELATIONS:
@@ -2082,197 +2002,66 @@
case BusRelations:
{
PDEVICE_RELATIONS DeviceRelations = NULL;
- PDEVICE_RELATIONS RelationsFromTop =
(PDEVICE_RELATIONS)Irp->IoStatus.Information;
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS /
BusRelations\n");
- Status = USBHUB_FdoQueryBusRelations(DeviceObject, RelationsFromTop,
&DeviceRelations);
-
- if (!NT_SUCCESS(Status))
- {
- if (Status == STATUS_NOT_SUPPORTED)
- {
- // We should process this to not lose relations from top.
- Irp->IoStatus.Status = STATUS_SUCCESS;
- break;
- }
- // We should fail an IRP
- Irp->IoStatus.Status = Status;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
IoReleaseRemoveLock(&HubDeviceExtension->Common.RemoveLock, Irp);
- return Status;
- }
-
- Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
- Irp->IoStatus.Status = Status;
+ Status = USBHUB_FdoQueryBusRelations(DeviceObject,
&DeviceRelations);
+
+ Information = (ULONG_PTR)DeviceRelations;
break;
}
case RemovalRelations:
{
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS /
RemovalRelations\n");
- break;
+ return ForwardIrpAndForget(DeviceObject, Irp);
}
default:
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown
type 0x%lx\n",
Stack->Parameters.QueryDeviceRelations.Type);
- break;
+ return ForwardIrpAndForget(DeviceObject, Irp);
}
break;
}
+ case IRP_MN_QUERY_REMOVE_DEVICE:
case IRP_MN_QUERY_STOP_DEVICE:
{
- //
- // We should fail this request, because we're not handling
- // IRP_MN_STOP_DEVICE for now.We'll receive this IRP ONLY when
- // PnP manager rebalances resources.
- //
- Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ return ForwardIrpAndForget(DeviceObject, Irp);
+ }
+ case IRP_MN_REMOVE_DEVICE:
+ {
+ Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_NOT_SUPPORTED;
- }
- case IRP_MN_QUERY_REMOVE_DEVICE:
- {
- // No action is required from FDO because it have nothing to free.
- DPRINT("IRP_MN_QUERY_REMOVE_DEVICE\n");
-
- SET_NEW_PNP_STATE(HubDeviceExtension->Common, RemovePending);
-
- Irp->IoStatus.Status = STATUS_SUCCESS;
- break;
- }
- case IRP_MN_CANCEL_REMOVE_DEVICE:
- {
- DPRINT("IRP_MN_CANCEL_REMOVE_DEVICE\n");
-
- if (HubDeviceExtension->Common.PnPState == RemovePending)
- RESTORE_PREVIOUS_PNP_STATE(HubDeviceExtension->Common);
-
- Irp->IoStatus.Status = STATUS_SUCCESS;
- break;
- }
- case IRP_MN_SURPRISE_REMOVAL:
- {
- //
- // We'll receive this IRP on HUB unexpected removal, or on USB
- // controller removal from PCI port. Here we should "let know" all
- // our children that their parent is removed and on next removal
- // they also can be removed.
- //
- SET_NEW_PNP_STATE(HubDeviceExtension->Common, SurpriseRemovePending);
-
- KeAcquireGuardedMutex(&HubDeviceExtension->HubMutexLock);
-
- for (i = 0; i < USB_MAXCHILDREN; i++)
- {
- ChildDeviceObject = HubDeviceExtension->ChildDeviceObject[i];
- if (ChildDeviceObject)
- {
- ChildDeviceExtension =
(PHUB_CHILDDEVICE_EXTENSION)ChildDeviceObject->DeviceObjectExtension;
- ChildDeviceExtension->ParentDeviceObject = NULL;
- }
- }
-
- KeReleaseGuardedMutex(&HubDeviceExtension->HubMutexLock);
-
- // This IRP can't be failed
- Irp->IoStatus.Status = STATUS_SUCCESS;
- break;
- }
- case IRP_MN_REMOVE_DEVICE:
- {
- DPRINT("IRP_MN_REMOVE_DEVICE\n");
-
- SET_NEW_PNP_STATE(HubDeviceExtension->Common, Deleted);
-
- IoReleaseRemoveLockAndWait(&HubDeviceExtension->Common.RemoveLock,
Irp);
-
- //
- // Here we should remove all child PDOs. At this point all children
- // received and returned from IRP_MN_REMOVE so remove synchronization
- // isn't needed here
- //
-
- KeAcquireGuardedMutex(&HubDeviceExtension->HubMutexLock);
-
- for (i = 0; i < USB_MAXCHILDREN; i++)
- {
- ChildDeviceObject = HubDeviceExtension->ChildDeviceObject[i];
- if (ChildDeviceObject)
- {
- PHUB_CHILDDEVICE_EXTENSION UsbChildExtension =
(PHUB_CHILDDEVICE_EXTENSION)ChildDeviceObject->DeviceExtension;
-
- SET_NEW_PNP_STATE(UsbChildExtension->Common, Deleted);
-
- // Remove the usb device
- if (UsbChildExtension->UsbDeviceHandle)
- {
- Status =
HubInterface->RemoveUsbDevice(HubInterface->BusContext,
UsbChildExtension->UsbDeviceHandle, 0);
- ASSERT(Status == STATUS_SUCCESS);
- }
-
- // Free full configuration descriptor
- if (UsbChildExtension->FullConfigDesc)
- ExFreePool(UsbChildExtension->FullConfigDesc);
-
- // Free ID buffers
- if (UsbChildExtension->usCompatibleIds.Buffer)
- ExFreePool(UsbChildExtension->usCompatibleIds.Buffer);
-
- if (UsbChildExtension->usDeviceId.Buffer)
- ExFreePool(UsbChildExtension->usDeviceId.Buffer);
-
- if (UsbChildExtension->usHardwareIds.Buffer)
- ExFreePool(UsbChildExtension->usHardwareIds.Buffer);
-
- if (UsbChildExtension->usInstanceId.Buffer)
- ExFreePool(UsbChildExtension->usInstanceId.Buffer);
-
- DPRINT("Deleting child PDO\n");
- IoDeleteDevice(DeviceObject);
- ChildDeviceObject = NULL;
- }
- }
-
- KeReleaseGuardedMutex(&HubDeviceExtension->HubMutexLock);
-
- Irp->IoStatus.Status = STATUS_SUCCESS;
- Status = ForwardIrpAndForget(DeviceObject, Irp);
IoDetachDevice(HubDeviceExtension->LowerDeviceObject);
- DPRINT("Deleting FDO 0x%p\n", DeviceObject);
IoDeleteDevice(DeviceObject);
- return Status;
+ return STATUS_SUCCESS;
}
case IRP_MN_QUERY_BUS_INFORMATION:
{
- // Function drivers and filter drivers do not handle this IRP.
DPRINT("IRP_MN_QUERY_BUS_INFORMATION\n");
break;
}
case IRP_MN_QUERY_ID:
{
DPRINT("IRP_MN_QUERY_ID\n");
- // Function drivers and filter drivers do not handle this IRP.
break;
}
case IRP_MN_QUERY_CAPABILITIES:
{
- //
- // If a function or filter driver does not handle this IRP, it
- // should pass that down.
- //
DPRINT("IRP_MN_QUERY_CAPABILITIES\n");
break;
}
default:
{
DPRINT(" IRP_MJ_PNP / unknown minor function 0x%lx\n",
Stack->MinorFunction);
- break;
- }
- }
-
- Status = ForwardIrpAndForget(DeviceObject, Irp);
- IoReleaseRemoveLock(&HubDeviceExtension->Common.RemoveLock, Irp);
+ return ForwardIrpAndForget(DeviceObject, Irp);
+ }
+ }
+
+ Irp->IoStatus.Information = Information;
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
@@ -2297,25 +2086,6 @@
// get device extension
HubDeviceExtension = (PHUB_DEVICE_EXTENSION) DeviceObject->DeviceExtension;
- Status = IoAcquireRemoveLock(&HubDeviceExtension->Common.RemoveLock, Irp);
- if (!NT_SUCCESS(Status))
- {
- Irp->IoStatus.Status = Status;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return Status;
- }
-
- // Prevent handling of control requests in remove pending state
- if (HubDeviceExtension->Common.PnPState == RemovePending)
- {
- DPRINT1("[USBHUB] Request for removed device object %p\n",
DeviceObject);
- Irp->IoStatus.Status = STATUS_DEVICE_NOT_CONNECTED;
- Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- IoReleaseRemoveLock(&HubDeviceExtension->Common.RemoveLock, Irp);
- return STATUS_DEVICE_NOT_CONNECTED;
- }
-
if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_USB_GET_NODE_INFORMATION)
{
// is the buffer big enough
@@ -2361,7 +2131,6 @@
// sanity checks
ASSERT(NodeConnectionInfo);
- KeAcquireGuardedMutex(&HubDeviceExtension->HubMutexLock);
for(Index = 0; Index < USB_MAXCHILDREN; Index++)
{
if (HubDeviceExtension->ChildDeviceObject[Index] == NULL)
@@ -2388,7 +2157,6 @@
}
break;
}
- KeReleaseGuardedMutex(&HubDeviceExtension->HubMutexLock);
// done
Irp->IoStatus.Information = sizeof(USB_NODE_INFORMATION);
Status = STATUS_SUCCESS;
@@ -2409,7 +2177,6 @@
// sanity checks
ASSERT(NodeKey);
- KeAcquireGuardedMutex(&HubDeviceExtension->HubMutexLock);
for(Index = 0; Index < USB_MAXCHILDREN; Index++)
{
if (HubDeviceExtension->ChildDeviceObject[Index] == NULL)
@@ -2449,7 +2216,6 @@
NodeKey->ActualLength = Length +
sizeof(USB_NODE_CONNECTION_DRIVERKEY_NAME);
break;
}
- KeReleaseGuardedMutex(&HubDeviceExtension->HubMutexLock);
}
}
else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_USB_GET_NODE_CONNECTION_NAME)
@@ -2481,7 +2247,6 @@
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
- IoReleaseRemoveLock(&HubDeviceExtension->Common.RemoveLock, Irp);
return Status;
}
Modified: branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/misc.c
URL:
http://svn.reactos.org/svn/reactos/branches/ReactOS-0.4.4-CLT2017/reactos/d…
==============================================================================
--- branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/misc.c [iso-8859-1]
(original)
+++ branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/misc.c [iso-8859-1] Wed Mar
8 22:20:11 2017
@@ -211,3 +211,84 @@
return Status;
}
+
+NTSTATUS
+NTAPI
+FDO_QueryInterfaceCompletionRoutine(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp,
+ IN PVOID Context)
+{
+ /* Set event */
+ KeSetEvent((PRKEVENT)Context, 0, FALSE);
+
+ /* Completion is done in the HidClassFDO_QueryCapabilities routine */
+ return STATUS_MORE_PROCESSING_REQUIRED;
+}
+
+NTSTATUS
+FDO_QueryInterface(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN OUT PUSB_BUS_INTERFACE_USBDI_V2 Interface)
+{
+ PIRP Irp;
+ KEVENT Event;
+ NTSTATUS Status;
+ PIO_STACK_LOCATION IoStack;
+ PHUB_DEVICE_EXTENSION HubDeviceExtension;
+
+ /* Get device extension */
+ HubDeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ ASSERT(HubDeviceExtension->Common.IsFDO);
+
+ /* Init event */
+ KeInitializeEvent(&Event, NotificationEvent, FALSE);
+
+ /* Now allocate the irp */
+ Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
+ if (!Irp)
+ {
+ /* No memory */
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* Get next stack location */
+ IoStack = IoGetNextIrpStackLocation(Irp);
+
+ /* Init stack location */
+ IoStack->MajorFunction = IRP_MJ_PNP;
+ IoStack->MinorFunction = IRP_MN_QUERY_INTERFACE;
+ IoStack->Parameters.QueryInterface.Interface = (PINTERFACE)Interface;
+ IoStack->Parameters.QueryInterface.InterfaceType =
&USB_BUS_INTERFACE_USBDI_GUID;
+ IoStack->Parameters.QueryInterface.Version = USB_BUSIF_USBDI_VERSION_2;
+ IoStack->Parameters.QueryInterface.Size = sizeof(USB_BUS_INTERFACE_USBDI_V2);
+
+
+ /* Set completion routine */
+ IoSetCompletionRoutine(Irp,
+ FDO_QueryInterfaceCompletionRoutine,
+ (PVOID)&Event,
+ TRUE,
+ TRUE,
+ TRUE);
+
+ /* Pnp irps have default completion code */
+ Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
+
+ /* Call lower device */
+ Status = IoCallDriver(HubDeviceExtension->LowerDeviceObject, Irp);
+ if (Status == STATUS_PENDING)
+ {
+ /* Wait for completion */
+ KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
+ }
+
+ /* Get status */
+ Status = Irp->IoStatus.Status;
+
+ /* Complete request */
+ IoFreeIrp(Irp);
+
+ /* Done */
+ return Status;
+}
Modified: branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/pdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/ReactOS-0.4.4-CLT2017/reactos/d…
==============================================================================
--- branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/pdo.c [iso-8859-1]
(original)
+++ branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/pdo.c [iso-8859-1] Wed Mar
8 22:20:11 2017
@@ -146,25 +146,16 @@
ChildDeviceExtension = (PHUB_CHILDDEVICE_EXTENSION)DeviceObject->DeviceExtension;
ASSERT(ChildDeviceExtension->Common.IsFDO == FALSE);
-
- // This can happen when parent device was surprise removed.
- if (ChildDeviceExtension->ParentDeviceObject == NULL)
- return FALSE;
-
HubDeviceExtension =
(PHUB_DEVICE_EXTENSION)ChildDeviceExtension->ParentDeviceObject->DeviceExtension;
- KeAcquireGuardedMutex(&HubDeviceExtension->HubMutexLock);
for(Index = 0; Index < USB_MAXCHILDREN; Index++)
{
if (HubDeviceExtension->ChildDeviceObject[Index] == DeviceObject)
{
- KeReleaseGuardedMutex(&HubDeviceExtension->HubMutexLock);
-
/* PDO exists */
return TRUE;
}
}
- KeReleaseGuardedMutex(&HubDeviceExtension->HubMutexLock);
/* invalid pdo */
return FALSE;
@@ -199,30 +190,17 @@
ChildDeviceExtension = (PHUB_CHILDDEVICE_EXTENSION)DeviceObject->DeviceExtension;
ASSERT(ChildDeviceExtension->Common.IsFDO == FALSE);
-
- Status = IoAcquireRemoveLock(&ChildDeviceExtension->Common.RemoveLock, Irp);
- if (!NT_SUCCESS(Status))
- {
- Irp->IoStatus.Status = Status;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return Status;
- }
-
- if (ChildDeviceExtension->Common.PnPState == SurpriseRemovePending ||
- ChildDeviceExtension->Common.PnPState == RemovePending ||
- ChildDeviceExtension->ParentDeviceObject == NULL)
- {
- // Parent or child device was surprise removed.
+ HubDeviceExtension =
(PHUB_DEVICE_EXTENSION)ChildDeviceExtension->ParentDeviceObject->DeviceExtension;
+ RootHubDeviceObject = HubDeviceExtension->RootHubPhysicalDeviceObject;
+
+ if(!IsValidPDO(DeviceObject))
+ {
DPRINT1("[USBHUB] Request for removed device object %p\n",
DeviceObject);
Irp->IoStatus.Status = STATUS_DEVICE_NOT_CONNECTED;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
- IoReleaseRemoveLock(&ChildDeviceExtension->Common.RemoveLock, Irp);
return STATUS_DEVICE_NOT_CONNECTED;
}
-
- HubDeviceExtension =
(PHUB_DEVICE_EXTENSION)ChildDeviceExtension->ParentDeviceObject->DeviceExtension;
- RootHubDeviceObject = HubDeviceExtension->RootHubPhysicalDeviceObject;
switch (Stack->Parameters.DeviceIoControl.IoControlCode)
{
@@ -323,7 +301,6 @@
// Send the request to RootHub
//
Status = ForwardUrbToRootHub(RootHubDeviceObject,
IOCTL_INTERNAL_USB_SUBMIT_URB, Irp, Urb, NULL);
- IoReleaseRemoveLock(&ChildDeviceExtension->Common.RemoveLock, Irp);
return Status;
}
//
@@ -420,7 +397,6 @@
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
- IoReleaseRemoveLock(&ChildDeviceExtension->Common.RemoveLock, Irp);
return Status;
}
@@ -444,8 +420,6 @@
//
IoRegisterDeviceInterface(DeviceObject, &GUID_DEVINTERFACE_USB_DEVICE, NULL,
&ChildDeviceExtension->SymbolicLinkName);
IoSetDeviceInterfaceState(&ChildDeviceExtension->SymbolicLinkName, TRUE);
-
- SET_NEW_PNP_STATE(ChildDeviceExtension->Common, Started);
UNIMPLEMENTED;
return STATUS_SUCCESS;
@@ -589,19 +563,14 @@
PIO_STACK_LOCATION Stack;
ULONG_PTR Information = 0;
PHUB_CHILDDEVICE_EXTENSION UsbChildExtension;
+ ULONG Index;
+ ULONG bFound;
PDEVICE_RELATIONS DeviceRelation;
+ PDEVICE_OBJECT ParentDevice;
UsbChildExtension = (PHUB_CHILDDEVICE_EXTENSION)DeviceObject->DeviceExtension;
Stack = IoGetCurrentIrpStackLocation(Irp);
MinorFunction = Stack->MinorFunction;
-
- Status = IoAcquireRemoveLock(&UsbChildExtension->Common.RemoveLock, Irp);
- if (!NT_SUCCESS(Status))
- {
- Irp->IoStatus.Status = Status;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return Status;
- }
switch (MinorFunction)
{
@@ -659,20 +628,17 @@
}
case IRP_MN_QUERY_DEVICE_TEXT:
{
- DPRINT("IRP_MN_QUERY_DEVICE_TEXT\n");
Status = USBHUB_PdoQueryDeviceText(DeviceObject, Irp, &Information);
break;
}
case IRP_MN_QUERY_ID:
{
- DPRINT("IRP_MN_QUERY_ID\n");
Status = USBHUB_PdoQueryId(DeviceObject, Irp, &Information);
break;
}
case IRP_MN_QUERY_BUS_INFORMATION:
{
PPNP_BUS_INFORMATION BusInfo;
- DPRINT("IRP_MN_QUERY_BUS_INFORMATION\n");
BusInfo = (PPNP_BUS_INFORMATION)ExAllocatePool(PagedPool,
sizeof(PNP_BUS_INFORMATION));
RtlCopyMemory(&BusInfo->BusTypeGuid,
&GUID_BUS_TYPE_USB,
@@ -688,58 +654,42 @@
{
PHUB_DEVICE_EXTENSION HubDeviceExtension =
(PHUB_DEVICE_EXTENSION)UsbChildExtension->ParentDeviceObject->DeviceExtension;
PUSB_BUS_INTERFACE_HUB_V5 HubInterface =
&HubDeviceExtension->HubInterface;
+ ParentDevice = UsbChildExtension->ParentDeviceObject;
DPRINT("IRP_MJ_PNP / IRP_MN_REMOVE_DEVICE\n");
- ASSERT((UsbChildExtension->Common.PnPState == RemovePending) ||
- (UsbChildExtension->Common.PnPState == SurpriseRemovePending));
-
- SET_NEW_PNP_STATE(UsbChildExtension->Common, NotStarted);
-
- if (!IsValidPDO(DeviceObject))
- {
- // Parent or child device was surprise removed, freeing resources
allocated for child device.
- SET_NEW_PNP_STATE(UsbChildExtension->Common, Deleted);
-
- IoReleaseRemoveLockAndWait(&UsbChildExtension->Common.RemoveLock,
Irp);
-
- // Remove the usb device
- if (UsbChildExtension->UsbDeviceHandle)
+ /* remove us from pdo list */
+ bFound = FALSE;
+ for(Index = 0; Index < USB_MAXCHILDREN; Index++)
+ {
+ if (HubDeviceExtension->ChildDeviceObject[Index] == DeviceObject)
{
- Status =
HubInterface->RemoveUsbDevice(HubInterface->BusContext,
UsbChildExtension->UsbDeviceHandle, 0);
- ASSERT(Status == STATUS_SUCCESS);
+ /* Remove the device */
+ Status =
HubInterface->RemoveUsbDevice(HubDeviceExtension->UsbDInterface.BusContext,
UsbChildExtension->UsbDeviceHandle, 0);
+
+ /* FIXME handle error */
+ ASSERT(Status == STATUS_SUCCESS);
+
+ /* remove us */
+ HubDeviceExtension->ChildDeviceObject[Index] = NULL;
+ bFound = TRUE;
+ break;
}
- // Free full configuration descriptor
- if (UsbChildExtension->FullConfigDesc)
- ExFreePool(UsbChildExtension->FullConfigDesc);
-
- // Free ID buffers
- if (UsbChildExtension->usCompatibleIds.Buffer)
- ExFreePool(UsbChildExtension->usCompatibleIds.Buffer);
-
- if (UsbChildExtension->usDeviceId.Buffer)
- ExFreePool(UsbChildExtension->usDeviceId.Buffer);
-
- if (UsbChildExtension->usHardwareIds.Buffer)
- ExFreePool(UsbChildExtension->usHardwareIds.Buffer);
-
- if (UsbChildExtension->usInstanceId.Buffer)
- ExFreePool(UsbChildExtension->usInstanceId.Buffer);
-
- DPRINT("Deleting child PDO\n");
- IoDeleteDevice(DeviceObject);
- }
- else
- {
- IoReleaseRemoveLock(&UsbChildExtension->Common.RemoveLock, Irp);
- }
-
- // If device is physically presented, we leave its PDO undeleted.
+ }
/* Complete the IRP */
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ /* delete device */
+ IoDeleteDevice(DeviceObject);
+
+ if (bFound)
+ {
+ /* invalidate device relations */
+ IoInvalidateDeviceRelations(ParentDevice, BusRelations);
+ }
+
return STATUS_SUCCESS;
}
case IRP_MN_QUERY_DEVICE_RELATIONS:
@@ -749,7 +699,6 @@
{
/* not supported */
Status = Irp->IoStatus.Status;
- Information = Irp->IoStatus.Information;
break;
}
@@ -773,46 +722,13 @@
break;
}
case IRP_MN_QUERY_STOP_DEVICE:
- {
- //
- // We should fail this request, because we're not handling
IRP_MN_STOP_DEVICE for now.
- // We'll receive this IRP ONLY when the PnP manager rebalances
resources.
- //
- Status = STATUS_NOT_SUPPORTED;
- break;
- }
case IRP_MN_QUERY_REMOVE_DEVICE:
{
- //
- // Free interface obtained from bottom, according MSDN we should
- // check interfaces provided to top, but here we are not checking.
- // All checking will be performed in roothub driver's
- // IRP_MN_QUERY_REMOVE_DEVICE handler. This will make problems when
- // buggy driver is loaded on top of us. But we decided to keep source
- // simpler, because in any case buggy driver will prevent removing of
- // whole stack.
- //
-
UsbChildExtension->DeviceInterface.InterfaceDereference(UsbChildExtension->DeviceInterface.BusContext);
-
- SET_NEW_PNP_STATE(UsbChildExtension->Common, RemovePending);
-
/* Sure, no problem */
Status = STATUS_SUCCESS;
Information = 0;
break;
}
- case IRP_MN_CANCEL_REMOVE_DEVICE:
- {
- // Check to see have we received query-remove before
- if (UsbChildExtension->Common.PnPState == RemovePending)
- {
- RESTORE_PREVIOUS_PNP_STATE(UsbChildExtension->Common);
-
UsbChildExtension->DeviceInterface.InterfaceReference(UsbChildExtension->DeviceInterface.BusContext);
- }
-
- Status = STATUS_SUCCESS;
- break;
- }
case IRP_MN_QUERY_INTERFACE:
{
DPRINT1("IRP_MN_QUERY_INTERFACE\n");
@@ -820,28 +736,17 @@
{
DPRINT1("USB_BUS_INTERFACE_USBDI_GUID\n");
RtlCopyMemory(Stack->Parameters.QueryInterface.Interface,
&UsbChildExtension->DeviceInterface, Stack->Parameters.QueryInterface.Size);
-
UsbChildExtension->DeviceInterface.InterfaceReference(UsbChildExtension->DeviceInterface.BusContext);
Status = STATUS_SUCCESS;
break;
}
// pass irp down
IoSkipCurrentIrpStackLocation(Irp);
- Status = IoCallDriver(UsbChildExtension->ParentDeviceObject, Irp);
- IoReleaseRemoveLock(&UsbChildExtension->Common.RemoveLock, Irp);
- return Status;
+ return IoCallDriver(UsbChildExtension->ParentDeviceObject, Irp);
}
case IRP_MN_SURPRISE_REMOVAL:
{
DPRINT("[USBHUB] HandlePnp IRP_MN_SURPRISE_REMOVAL\n");
-
- //
- // Here we should free all resources and stop all access, lets just set
- // the flag and do further clean-up in subsequent IRP_MN_REMOVE_DEVICE
- // We can receive this IRP when device is physically connected (on stop/start
fail).
- //
- SET_NEW_PNP_STATE(UsbChildExtension->Common, SurpriseRemovePending);
-
Status = STATUS_SUCCESS;
break;
}
@@ -852,8 +757,6 @@
Status = Irp->IoStatus.Status;
}
}
-
- IoReleaseRemoveLock(&UsbChildExtension->Common.RemoveLock, Irp);
Irp->IoStatus.Information = Information;
Irp->IoStatus.Status = Status;
Modified: branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/usbhub.c
URL:
http://svn.reactos.org/svn/reactos/branches/ReactOS-0.4.4-CLT2017/reactos/d…
==============================================================================
--- branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/usbhub.c [iso-8859-1]
(original)
+++ branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/usbhub.c [iso-8859-1] Wed
Mar 8 22:20:11 2017
@@ -62,7 +62,7 @@
PDEVICE_OBJECT DeviceObject;
PHUB_DEVICE_EXTENSION HubDeviceExtension;
NTSTATUS Status;
- DPRINT("USBHUB: AddDevice (%p)\n", PhysicalDeviceObject);
+ DPRINT("USBHUB: AddDevice\n");
//
// Create the Device Object
//
@@ -86,19 +86,11 @@
HubDeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
RtlZeroMemory(HubDeviceExtension, sizeof(HUB_DEVICE_EXTENSION));
- INITIALIZE_PNP_STATE(HubDeviceExtension->Common);
-
//
// Set this to Fdo
//
HubDeviceExtension->Common.IsFDO = TRUE;
DeviceObject->Flags |= DO_POWER_PAGABLE;
-
- // initialize mutex
- KeInitializeGuardedMutex(&HubDeviceExtension->HubMutexLock);
-
- // initialize remove lock
- IoInitializeRemoveLock(&HubDeviceExtension->Common.RemoveLock, 'buH',
0, 0);
//
// initialize reset complete event
@@ -167,26 +159,14 @@
}
NTSTATUS NTAPI
-USBHUB_DispatchSystemControl(
- PDEVICE_OBJECT DeviceObject,
- PIRP Irp)
-{
- DPRINT("Usbhub: DispatchSystemControl\n");
+USBHUB_DispatchInternalDeviceControl(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ DPRINT("Usbhub: DispatchInternalDeviceControl\n");
if (((PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.IsFDO)
return USBHUB_IrpStub(DeviceObject, Irp);
else
- return USBHUB_IrpStub(DeviceObject, Irp);
-}
-
-NTSTATUS NTAPI
-USBHUB_DispatchInternalDeviceControl(
- PDEVICE_OBJECT DeviceObject,
- PIRP Irp)
-{
- DPRINT("Usbhub: DispatchInternalDeviceControl\n");
- if (((PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.IsFDO)
- return USBHUB_IrpStub(DeviceObject, Irp);
- else
return USBHUB_PdoHandleInternalDeviceControl(DeviceObject, Irp);
}
@@ -208,59 +188,37 @@
PIRP Irp)
{
PIO_STACK_LOCATION IoStack;
- PHUB_DEVICE_EXTENSION DeviceExtension;
- NTSTATUS Status;
+
IoStack = IoGetCurrentIrpStackLocation(Irp);
- DeviceExtension = DeviceObject->DeviceExtension;
-
- Status = IoAcquireRemoveLock(&DeviceExtension->Common.RemoveLock, Irp);
- if (!NT_SUCCESS(Status))
- {
- Irp->IoStatus.Status = Status;
+ DPRINT1("Power Function %x\n", IoStack->MinorFunction);
+
+ if (IoStack->MinorFunction == IRP_MN_SET_POWER)
+ {
+ PoStartNextPowerIrp(Irp);
+ Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return Status;
- }
-
- DPRINT1("Power Function %x\n", IoStack->MinorFunction);
-
- if (DeviceExtension->Common.IsFDO)
+ return STATUS_SUCCESS;
+
+ }
+ else if (IoStack->MinorFunction == IRP_MN_QUERY_POWER)
{
PoStartNextPowerIrp(Irp);
- IoSkipCurrentIrpStackLocation(Irp);
- Status = PoCallDriver(DeviceExtension->LowerDeviceObject, Irp);
- IoReleaseRemoveLock(&DeviceExtension->Common.RemoveLock, Irp);
- return Status;
- }
-
- switch (IoStack->MinorFunction)
- {
- case IRP_MN_SET_POWER:
- {
- DPRINT("IRP_MN_SET_POWER\n");
- break;
- }
- case IRP_MN_QUERY_POWER:
- {
- DPRINT("IRP_MN_QUERY_POWER\n");
- break;
- }
- case IRP_MN_WAIT_WAKE:
- {
- DPRINT("IRP_MN_WAIT_WAKE\n");
- break;
- }
- default:
- {
- DPRINT1("PDO IRP_MJ_POWER / unknown minor function 0x%lx\n",
IoStack->MinorFunction);
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return Irp->IoStatus.Status;
- }
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+
+ }
+ else if (IoStack->MinorFunction == IRP_MN_WAIT_WAKE)
+ {
+ PoStartNextPowerIrp(Irp);
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
}
PoStartNextPowerIrp(Irp);
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
- IoReleaseRemoveLock(&DeviceExtension->Common.RemoveLock, Irp);
return STATUS_SUCCESS;
}
@@ -287,7 +245,6 @@
DriverObject->MajorFunction[IRP_MJ_CLOSE] = USBHUB_Close;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = USBHUB_Cleanup;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
USBHUB_DispatchDeviceControl;
- DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] =
USBHUB_DispatchSystemControl;
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] =
USBHUB_DispatchInternalDeviceControl;
DriverObject->MajorFunction[IRP_MJ_PNP] = USBHUB_DispatchPnp;
DriverObject->MajorFunction[IRP_MJ_POWER] =USBHUB_DispatchPower;
Modified: branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/usbhub.h
URL:
http://svn.reactos.org/svn/reactos/branches/ReactOS-0.4.4-CLT2017/reactos/d…
==============================================================================
--- branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/usbhub.h [iso-8859-1]
(original)
+++ branches/ReactOS-0.4.4-CLT2017/reactos/drivers/usb/usbhub/usbhub.h [iso-8859-1] Wed
Mar 8 22:20:11 2017
@@ -39,43 +39,9 @@
PVOID Context;
} WORK_ITEM_DATA, *PWORK_ITEM_DATA;
-
-//
-// Definitions for device's PnP state tracking, all this states are described
-// in PnP Device States diagram of DDK documentation.
-//
-typedef enum _DEVICE_PNP_STATE {
-
- NotStarted = 0, // Not started
- Started, // After handling of START_DEVICE IRP
- StopPending, // After handling of QUERY_STOP IRP
- Stopped, // After handling of STOP_DEVICE IRP
- RemovePending, // After handling of QUERY_REMOVE IRP
- SurpriseRemovePending, // After handling of SURPRISE_REMOVE IRP
- Deleted, // After handling of REMOVE_DEVICE IRP
- UnKnown // Unknown state
-
-} DEVICE_PNP_STATE;
-
-#define INITIALIZE_PNP_STATE(Data) \
-(Data).PnPState = NotStarted;\
-(Data).PreviousPnPState = NotStarted;
-
-#define SET_NEW_PNP_STATE(Data, state) \
-(Data).PreviousPnPState = (Data).PnPState;\
-(Data).PnPState = (state);
-
-#define RESTORE_PREVIOUS_PNP_STATE(Data) \
-(Data).PnPState = (Data).PreviousPnPState;
-
typedef struct
{
BOOLEAN IsFDO;
- // We'll track device PnP state via this variables
- DEVICE_PNP_STATE PnPState;
- DEVICE_PNP_STATE PreviousPnPState;
- // Remove lock
- IO_REMOVE_LOCK RemoveLock;
} COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
typedef struct _HUB_CHILDDEVICE_EXTENSION
@@ -106,8 +72,6 @@
PDEVICE_OBJECT RootHubPhysicalDeviceObject;
PDEVICE_OBJECT RootHubFunctionalDeviceObject;
- KGUARDED_MUTEX HubMutexLock;
-
ULONG NumberOfHubs;
KEVENT ResetComplete;
@@ -130,6 +94,7 @@
USBD_CONFIGURATION_HANDLE ConfigurationHandle;
USBD_PIPE_HANDLE PipeHandle;
PVOID RootHubHandle;
+ USB_BUS_INTERFACE_USBDI_V2 DeviceInterface;
UNICODE_STRING SymbolicLinkName;
ULONG InstanceCount;
Modified: branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/hidparser/context.c
URL:
http://svn.reactos.org/svn/reactos/branches/ReactOS-0.4.4-CLT2017/reactos/s…
==============================================================================
---
branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/hidparser/context.c [iso-8859-1]
(original)
+++
branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/hidparser/context.c [iso-8859-1]
Wed Mar 8 22:20:11 2017
@@ -163,7 +163,7 @@
//
// store offset
//
- TargetCollection->Offsets[Collection->ReportCount + Index] =
CurrentOffset;
+ TargetCollection->Offsets[Collection->NodeCount + Index] = CurrentOffset;
//
// store sub collections
@@ -254,7 +254,7 @@
//
// get collection
//
- SubCollection = (PHID_COLLECTION)(CollectionContext->RawData +
Collection->Offsets[Collection->ReportCount + Index]);
+ SubCollection = (PHID_COLLECTION)(CollectionContext->RawData +
Collection->Offsets[Collection->NodeCount + Index]);
//
// recursively search collection
@@ -314,7 +314,7 @@
//
// get offset to sub collection
//
- SubCollection = (PHID_COLLECTION)(CollectionContext->RawData +
Collection->Offsets[Collection->ReportCount + Index]);
+ SubCollection = (PHID_COLLECTION)(CollectionContext->RawData +
Collection->Offsets[Collection->NodeCount + Index]);
//
// count collection for sub nodes
Modified: branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/hidparser/hidparser.c
URL:
http://svn.reactos.org/svn/reactos/branches/ReactOS-0.4.4-CLT2017/reactos/s…
==============================================================================
---
branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/hidparser/hidparser.c [iso-8859-1]
(original)
+++
branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/hidparser/hidparser.c [iso-8859-1]
Wed Mar 8 22:20:11 2017
@@ -68,7 +68,7 @@
// failed to parse report descriptor
//
Parser->Debug("[HIDPARSER] Failed to parse report descriptor with
%x\n", ParserStatus);
- return ParserStatus;
+ return TranslateHidParserStatus(ParserStatus);
}
//
@@ -126,9 +126,7 @@
//
// no memory
//
- Parser->Free(DeviceDescription->CollectionDesc);
- Parser->Free(DeviceDescription->ReportIDs);
- return ParserStatus;
+ return TranslateHidParserStatus(ParserStatus);
}
//
@@ -155,13 +153,6 @@
// get collection usage page
//
ParserStatus =
HidParser_GetCollectionUsagePage((PVOID)DeviceDescription->CollectionDesc[Index].PreparsedData,
&DeviceDescription->CollectionDesc[Index].Usage,
&DeviceDescription->CollectionDesc[Index].UsagePage);
- if (ParserStatus != HIDPARSER_STATUS_SUCCESS)
- {
- // collection not found
- Parser->Free(DeviceDescription->CollectionDesc);
- Parser->Free(DeviceDescription->ReportIDs);
- return ParserStatus;
- }
//
// windows seems to prepend the report id, regardless if it is required
Modified: branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/hidparser/parser.c
URL:
http://svn.reactos.org/svn/reactos/branches/ReactOS-0.4.4-CLT2017/reactos/s…
==============================================================================
--- branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/hidparser/parser.c [iso-8859-1]
(original)
+++ branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/hidparser/parser.c [iso-8859-1]
Wed Mar 8 22:20:11 2017
@@ -712,6 +712,30 @@
//
return HIDPARSER_STATUS_SUCCESS;
}
+
+HIDPARSER_STATUS
+AllocateParserContext(
+ IN PHID_PARSER Parser,
+ OUT PHID_PARSER_CONTEXT *OutParserContext)
+{
+ PHID_PARSER_CONTEXT ParserContext;
+
+ ParserContext = Parser->Alloc(sizeof(HID_PARSER_CONTEXT));
+ if (!ParserContext)
+ {
+ //
+ // failed
+ //
+ return HIDPARSER_STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ //
+ // store result
+ //
+ *OutParserContext = ParserContext;
+ return HIDPARSER_STATUS_SUCCESS;
+}
+
HIDPARSER_STATUS
HidParser_ParseReportDescriptor(
@@ -736,18 +760,12 @@
PMAIN_ITEM_DATA MainItemData;
PHID_PARSER_CONTEXT ParserContext;
- CurrentOffset = ReportDescriptor;
- ReportEnd = ReportDescriptor + ReportLength;
-
- if (ReportDescriptor >= ReportEnd)
- return HIDPARSER_STATUS_COLLECTION_NOT_FOUND;
-
//
// allocate parser
//
- ParserContext = Parser->Alloc(sizeof(HID_PARSER_CONTEXT));;
- if (!ParserContext)
- return HIDPARSER_STATUS_INSUFFICIENT_RESOURCES;
+ Status = AllocateParserContext(Parser, &ParserContext);
+ if (Status != HIDPARSER_STATUS_SUCCESS)
+ return Status;
//
@@ -760,7 +778,6 @@
//
// no memory
//
- Parser->Free(ParserContext);
return HIDPARSER_STATUS_INSUFFICIENT_RESOURCES;
}
@@ -775,7 +792,6 @@
//
Parser->Free(ParserContext->LocalItemState.UsageStack);
ParserContext->LocalItemState.UsageStack = NULL;
- Parser->Free(ParserContext);
return HIDPARSER_STATUS_INSUFFICIENT_RESOURCES;
}
@@ -783,6 +799,8 @@
// start parsing
//
CurrentCollection = ParserContext->RootCollection;
+ CurrentOffset = ReportDescriptor;
+ ReportEnd = ReportDescriptor + ReportLength;
do
{
@@ -1212,7 +1230,8 @@
//
CurrentOffset += CurrentItemSize + sizeof(ITEM_PREFIX);
- }while (CurrentOffset < ReportEnd);
+
+ }while(CurrentOffset < ReportEnd);
//
Modified:
branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/libusb/hub_controller.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/ReactOS-0.4.4-CLT2017/reactos/s…
==============================================================================
---
branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/libusb/hub_controller.cpp [iso-8859-1]
(original)
+++
branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/libusb/hub_controller.cpp [iso-8859-1]
Wed Mar 8 22:20:11 2017
@@ -568,8 +568,7 @@
break;
}
}
- // Here we should leave Status as is.
- Status = Irp->IoStatus.Status;
+ Status = STATUS_SUCCESS;
break;
}
case IRP_MN_QUERY_CAPABILITIES:
@@ -612,14 +611,6 @@
// handle device interface requests
//
Status = HandleQueryInterface(IoStack);
-
- //
- // If a bus driver does not export the requested interface, it
- // should leave Status as is.
- //
- if (Status == STATUS_NOT_SUPPORTED)
- Status = Irp->IoStatus.Status;
-
break;
}
case IRP_MN_REMOVE_DEVICE:
@@ -3745,7 +3736,6 @@
InterfaceHub->SetDeviceHandleData = USBHI_SetDeviceHandleData;
}
- InterfaceHub->InterfaceReference(InterfaceHub->BusContext);
//
// request completed
//
@@ -3800,7 +3790,6 @@
InterfaceDI->EnumLogEntry = USBDI_EnumLogEntry;
}
- InterfaceDI->InterfaceReference(InterfaceDI->BusContext);
//
// request completed
//
Propchange:
branches/ReactOS-0.4.4-CLT2017/reactos/sdk/lib/drivers/libusb/hub_controller.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 8 22:20:11 2017
@@ -4,7 +4,6 @@
/branches/GSoC_2011/GSoC_TcpIpDriver/drivers/usb/usbehci_new/hub_controller.cpp:51550
/branches/GSoC_2011/TcpIpDriver/drivers/usb/usbehci/hub_controller.cpp:51551-53074,53076-53119
/branches/GSoC_2011/TcpIpDriver/drivers/usb/usbehci_new/hub_controller.cpp:51551-53074,53076-53119
-/branches/GSoC_2016/USB/sdk/lib/drivers/libusb/hub_controller.cpp:72365-73604
/branches/GSoC_Network/drivers/usb/usbehci/hub_controller.cpp:51545-51546
/branches/GSoC_Network/drivers/usb/usbehci_new/hub_controller.cpp:51545-51546
/branches/cmake-bringup/drivers/usb/usbehci/hub_controller.cpp:50484,50693,50719,51544-52564