From a2085a332c962dda3d9898fd0e77bc6243dfadb9 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Fri, 24 May 2013 17:36:14 +0000 Subject: [PATCH] [HIDCLASS] - Implement HidClass_Power [USBCCGP] - Remove superflous spaces - Implement IRP_MJ_SYSTEM_CONTROL - Fix bug in IRP_MJ_POWER handler - Add driver unload routine [USBEHCI,USBOHCI, USBUHCI] - Support Win2k3 usbhub.sys, which uses null device handle for the root usb hub - Based on a patch by Thomas Faber svn path=/trunk/; revision=59080 --- reactos/drivers/hid/hidclass/hidclass.c | 17 ++++++++- reactos/drivers/hid/hidclass/precomp.h | 5 +++ reactos/drivers/usb/usbccgp/fdo.c | 37 ++++++++++++++++--- reactos/drivers/usb/usbccgp/pdo.c | 5 +++ reactos/drivers/usb/usbccgp/usbccgp.c | 3 +- reactos/lib/drivers/hidparser/api.c | 2 +- reactos/lib/drivers/libusb/hub_controller.cpp | 10 ++--- 7 files changed, 65 insertions(+), 14 deletions(-) diff --git a/reactos/drivers/hid/hidclass/hidclass.c b/reactos/drivers/hid/hidclass/hidclass.c index 99da022236b..b4985d9dc75 100644 --- a/reactos/drivers/hid/hidclass/hidclass.c +++ b/reactos/drivers/hid/hidclass/hidclass.c @@ -971,8 +971,21 @@ HidClass_Power( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { - UNIMPLEMENTED - return STATUS_NOT_IMPLEMENTED; + PHIDCLASS_COMMON_DEVICE_EXTENSION CommonDeviceExtension; + CommonDeviceExtension = DeviceObject->DeviceExtension; + + if (CommonDeviceExtension->IsFDO) + { + IoCopyCurrentIrpStackLocationToNext(Irp); + return HidClassFDO_DispatchRequest(DeviceObject, Irp); + } + else + { + Irp->IoStatus.Status = STATUS_SUCCESS; + PoStartNextPowerIrp(Irp); + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_SUCCESS; + } } NTSTATUS diff --git a/reactos/drivers/hid/hidclass/precomp.h b/reactos/drivers/hid/hidclass/precomp.h index 79d2bdd060e..7f086cb9ad2 100644 --- a/reactos/drivers/hid/hidclass/precomp.h +++ b/reactos/drivers/hid/hidclass/precomp.h @@ -185,6 +185,11 @@ HidClassFDO_PnP( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp); +NTSTATUS +HidClassFDO_DispatchRequest( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + NTSTATUS HidClassFDO_DispatchRequestSynchronous( IN PDEVICE_OBJECT DeviceObject, diff --git a/reactos/drivers/usb/usbccgp/fdo.c b/reactos/drivers/usb/usbccgp/fdo.c index 16ab983bd8e..6ac5bcbf905 100644 --- a/reactos/drivers/usb/usbccgp/fdo.c +++ b/reactos/drivers/usb/usbccgp/fdo.c @@ -97,7 +97,7 @@ FDO_QueryCapabilities( NTSTATUS FDO_DeviceRelations( - PDEVICE_OBJECT DeviceObject, + PDEVICE_OBJECT DeviceObject, PIRP Irp) { ULONG DeviceCount = 0; @@ -238,7 +238,7 @@ FDO_CreateChildPdo( NTSTATUS FDO_StartDevice( - PDEVICE_OBJECT DeviceObject, + PDEVICE_OBJECT DeviceObject, PIRP Irp) { NTSTATUS Status; @@ -565,7 +565,7 @@ FDO_HandleInternalDeviceControl( /* Get stack location */ IoStack = IoGetCurrentIrpStackLocation(Irp); - if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_INTERNAL_USB_RESET_PORT || + if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_INTERNAL_USB_RESET_PORT || IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_INTERNAL_USB_CYCLE_PORT) { /* Handle reset / cycle ports */ @@ -585,13 +585,34 @@ FDO_HandleInternalDeviceControl( return IoCallDriver(FDODeviceExtension->NextDeviceObject, Irp); } +NTSTATUS +FDO_HandleSystemControl( + PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + PFDO_DEVICE_EXTENSION FDODeviceExtension; + + /* Get device extension */ + FDODeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + ASSERT(FDODeviceExtension->Common.IsFDO); + + /* Forward and forget request */ + IoSkipCurrentIrpStackLocation(Irp); + return IoCallDriver(FDODeviceExtension->NextDeviceObject, Irp); +} + NTSTATUS FDO_Dispatch( - PDEVICE_OBJECT DeviceObject, + PDEVICE_OBJECT DeviceObject, PIRP Irp) { PIO_STACK_LOCATION IoStack; NTSTATUS Status; + PFDO_DEVICE_EXTENSION FDODeviceExtension; + + /* Get device extension */ + FDODeviceExtension = DeviceObject->DeviceExtension; + ASSERT(FDODeviceExtension->Common.IsFDO); /* Get stack location */ IoStack = IoGetCurrentIrpStackLocation(Irp); @@ -600,8 +621,14 @@ FDO_Dispatch( { case IRP_MJ_PNP: return FDO_HandlePnp(DeviceObject, Irp); - case IRP_MJ_INTERNAL_DEVICE_CONTROL: + case IRP_MJ_INTERNAL_DEVICE_CONTROL: return FDO_HandleInternalDeviceControl(DeviceObject, Irp); + case IRP_MJ_POWER: + PoStartNextPowerIrp(Irp); + IoSkipCurrentIrpStackLocation(Irp); + return PoCallDriver(FDODeviceExtension->NextDeviceObject, Irp); + case IRP_MJ_SYSTEM_CONTROL: + return FDO_HandleSystemControl(DeviceObject, Irp); default: DPRINT1("FDO_Dispatch Function %x not implemented\n", IoStack->MajorFunction); ASSERT(FALSE); diff --git a/reactos/drivers/usb/usbccgp/pdo.c b/reactos/drivers/usb/usbccgp/pdo.c index 617b2996c06..9ce5506407c 100644 --- a/reactos/drivers/usb/usbccgp/pdo.c +++ b/reactos/drivers/usb/usbccgp/pdo.c @@ -1076,6 +1076,11 @@ PDO_Dispatch( return PDO_HandlePnp(DeviceObject, Irp); case IRP_MJ_INTERNAL_DEVICE_CONTROL: return PDO_HandleInternalDeviceControl(DeviceObject, Irp); + case IRP_MJ_POWER: + PoStartNextPowerIrp(Irp); + Irp->IoStatus.Status = STATUS_SUCCESS; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_SUCCESS; default: DPRINT1("PDO_Dispatch Function %x not implemented\n", IoStack->MajorFunction); Status = Irp->IoStatus.Status; diff --git a/reactos/drivers/usb/usbccgp/usbccgp.c b/reactos/drivers/usb/usbccgp/usbccgp.c index 1725442c1a6..e8855701d6a 100644 --- a/reactos/drivers/usb/usbccgp/usbccgp.c +++ b/reactos/drivers/usb/usbccgp/usbccgp.c @@ -160,7 +160,8 @@ DriverEntry( DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = USBCCGP_Dispatch; DriverObject->MajorFunction[IRP_MJ_POWER] = USBCCGP_Dispatch; DriverObject->MajorFunction[IRP_MJ_PNP] = USBCCGP_Dispatch; - DriverObject->DriverUnload = USBCCGP_Unload; + DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = USBCCGP_Dispatch; + DriverObject->DriverUnload = USBCCGP_Unload; /* FIMXE query GenericCompositeUSBDeviceString */ diff --git a/reactos/lib/drivers/hidparser/api.c b/reactos/lib/drivers/hidparser/api.c index c02ee043873..0f0cfb43157 100644 --- a/reactos/lib/drivers/hidparser/api.c +++ b/reactos/lib/drivers/hidparser/api.c @@ -757,7 +757,7 @@ HidParser_GetScaledUsageValueWithReport( } else { - // HACK: logical boundaries are absolute values + // logical boundaries are absolute values return HIDPARSER_STATUS_BAD_LOG_PHY_VALUES; } diff --git a/reactos/lib/drivers/libusb/hub_controller.cpp b/reactos/lib/drivers/libusb/hub_controller.cpp index fa90685ff75..d744235d8df 100644 --- a/reactos/lib/drivers/libusb/hub_controller.cpp +++ b/reactos/lib/drivers/libusb/hub_controller.cpp @@ -839,7 +839,7 @@ CHubController::HandleBulkOrInterruptTransfer( // // Is the Request for the root hub // - if (Urb->UrbHeader.UsbdDeviceHandle == PVOID(this)) + if (Urb->UrbHeader.UsbdDeviceHandle == PVOID(this) || Urb->UrbHeader.UsbdDeviceHandle == NULL) { ASSERT(m_PendingSCEIrp == NULL); if (QueryStatusChageEndpoint(Irp)) @@ -1189,7 +1189,7 @@ CHubController::HandleGetStatusFromDevice( DeviceStatus = (PUSHORT)Urb->UrbControlGetStatusRequest.TransferBuffer; - if (Urb->UrbHeader.UsbdDeviceHandle == PVOID(this)) + if (Urb->UrbHeader.UsbdDeviceHandle == PVOID(this) || Urb->UrbHeader.UsbdDeviceHandle == NULL) { // // FIXME need more flags ? @@ -1319,7 +1319,7 @@ CHubController::HandleClassDevice( case USB_DEVICE_CLASS_RESERVED: // FALL THROUGH case USB_DEVICE_CLASS_HUB: { - if (Urb->UrbHeader.UsbdDeviceHandle == PVOID(this)) + if (Urb->UrbHeader.UsbdDeviceHandle == PVOID(this) || Urb->UrbHeader.UsbdDeviceHandle == NULL) { // // sanity checks @@ -1525,7 +1525,7 @@ CHubController::HandleGetDescriptor( PC_ASSERT(Urb->UrbControlDescriptorRequest.TransferBufferLength >= sizeof(USB_DEVICE_DESCRIPTOR)); PC_ASSERT(Urb->UrbControlDescriptorRequest.TransferBuffer); - if (Urb->UrbHeader.UsbdDeviceHandle == PVOID(this)) + if (Urb->UrbHeader.UsbdDeviceHandle == PVOID(this) || Urb->UrbHeader.UsbdDeviceHandle == NULL) { // // copy root hub device descriptor @@ -1578,7 +1578,7 @@ CHubController::HandleGetDescriptor( BufferLength = Urb->UrbControlDescriptorRequest.TransferBufferLength; Buffer = (PUCHAR) Urb->UrbControlDescriptorRequest.TransferBuffer; - if (Urb->UrbHeader.UsbdDeviceHandle == PVOID(this)) + if (Urb->UrbHeader.UsbdDeviceHandle == PVOID(this) || Urb->UrbHeader.UsbdDeviceHandle == NULL) { // // request is for the root bus controller