https://git.reactos.org/?p=reactos.git;a=commitdiff;h=67b3b73d82a067066fd20…
commit 67b3b73d82a067066fd2014af9a881580aa68c2b
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Sat Feb 22 10:32:11 2020 +0100
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Mon Mar 2 20:47:01 2020 +0100
[USBHUB] Partially implement USBH_ProcessHubStateChange. CORE-16704
---
drivers/usb/usbhub/usbhub.c | 93 ++++++++++++++++++++++++++++++++++++++++++---
drivers/usb/usbhub/usbhub.h | 4 +-
2 files changed, 89 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/usbhub/usbhub.c b/drivers/usb/usbhub/usbhub.c
index 33d9259b905..d3e9aa34345 100644
--- a/drivers/usb/usbhub/usbhub.c
+++ b/drivers/usb/usbhub/usbhub.c
@@ -1358,6 +1358,57 @@ USBH_SyncGetStatus(IN PDEVICE_OBJECT DeviceObject,
return NtStatus;
}
+NTSTATUS
+NTAPI
+USBH_SyncGetHubStatus(IN PUSBHUB_FDO_EXTENSION HubExtension,
+ IN PUSB_HUB_STATUS_AND_CHANGE HubStatus,
+ IN ULONG Length)
+{
+ BM_REQUEST_TYPE RequestType;
+
+ DPRINT("USBH_SyncGetHubStatus\n");
+
+ RequestType.B = 0;
+ RequestType.Recipient = BMREQUEST_TO_DEVICE;
+ RequestType.Type = BMREQUEST_CLASS;
+ RequestType.Dir = BMREQUEST_DEVICE_TO_HOST;
+
+ return USBH_Transact(HubExtension,
+ HubStatus,
+ Length,
+ BMREQUEST_DEVICE_TO_HOST,
+ URB_FUNCTION_CLASS_DEVICE,
+ RequestType,
+ USB_REQUEST_GET_STATUS,
+ 0,
+ 0);
+}
+
+NTSTATUS
+NTAPI
+USBH_SyncClearHubStatus(IN PUSBHUB_FDO_EXTENSION HubExtension,
+ IN USHORT RequestValue)
+{
+ BM_REQUEST_TYPE RequestType;
+
+ DPRINT("USBH_SyncClearHubStatus: RequestValue - %x\n", RequestValue);
+
+ RequestType.B = 0;
+ RequestType.Recipient = BMREQUEST_TO_DEVICE;
+ RequestType.Type = BMREQUEST_CLASS;
+ RequestType.Dir = BMREQUEST_HOST_TO_DEVICE;
+
+ return USBH_Transact(HubExtension,
+ NULL,
+ 0,
+ BMREQUEST_HOST_TO_DEVICE,
+ URB_FUNCTION_CLASS_DEVICE,
+ RequestType,
+ USB_REQUEST_CLEAR_FEATURE,
+ RequestValue,
+ 0);
+}
+
NTSTATUS
NTAPI
USBH_SyncGetPortStatus(IN PUSBHUB_FDO_EXTENSION HubExtension,
@@ -1785,6 +1836,35 @@ USBH_ChangeIndicationQueryChange(IN PUSBHUB_FDO_EXTENSION
HubExtension,
return Status;
}
+VOID
+NTAPI
+USBH_ProcessHubStateChange(IN PUSBHUB_FDO_EXTENSION HubExtension,
+ IN PUSB_HUB_STATUS_AND_CHANGE HubStatus)
+{
+ USB_HUB_CHANGE HubStatusChange;
+
+ DPRINT_SCE("USBH_ProcessHubStateChange: HubStatus - %lx\n",
HubStatus->AsUlong32);
+
+ HubStatusChange = HubStatus->HubChange;
+
+ if (HubStatusChange.LocalPowerChange)
+ {
+ DPRINT1("USBH_ProcessHubStateChange: LocalPowerChange\n");
+ USBH_SyncClearHubStatus(HubExtension,
+ USBHUB_FEATURE_C_HUB_LOCAL_POWER);
+ }
+ else if (HubStatusChange.OverCurrentChange)
+ {
+ USBH_SyncClearHubStatus(HubExtension,
+ USBHUB_FEATURE_C_HUB_OVER_CURRENT);
+ if (HubStatus->HubStatus.OverCurrent)
+ {
+ DPRINT1("USBH_ProcessHubStateChange: OverCurrent UNIMPLEMENTED.
FIXME\n");
+ DbgBreakPoint();
+ }
+ }
+}
+
VOID
NTAPI
USBH_ProcessPortStateChange(IN PUSBHUB_FDO_EXTENSION HubExtension,
@@ -2070,6 +2150,7 @@ USBH_ChangeIndicationWorker(IN PUSBHUB_FDO_EXTENSION HubExtension,
PUSBHUB_PORT_PDO_EXTENSION LowerPortExtension;
PUSBHUB_STATUS_CHANGE_CONTEXT WorkItem;
USB_PORT_STATUS_AND_CHANGE PortStatus;
+ USB_HUB_STATUS_AND_CHANGE HubStatus;
NTSTATUS Status;
USHORT Port = 0;
@@ -2169,13 +2250,13 @@ Enum:
Status = USBH_SyncGetPortStatus(HubExtension,
Port,
&PortStatus,
- sizeof(USB_PORT_STATUS_AND_CHANGE));
+ sizeof(PortStatus));
}
else
{
- DPRINT1("USBH_ChangeIndicationWorker: USBH_SyncGetHubStatus()
UNIMPLEMENTED. FIXME\n");
- DbgBreakPoint();
- Status = STATUS_ASSERTION_FAILURE;
+ Status = USBH_SyncGetHubStatus(HubExtension,
+ &HubStatus,
+ sizeof(HubStatus));
}
if (NT_SUCCESS(Status))
@@ -2188,8 +2269,8 @@ Enum:
}
else
{
- DPRINT1("USBH_ChangeIndicationWorker: USBH_ProcessHubStateChange()
UNIMPLEMENTED. FIXME\n");
- DbgBreakPoint();
+ USBH_ProcessHubStateChange(HubExtension,
+ &HubStatus);
}
}
else
diff --git a/drivers/usb/usbhub/usbhub.h b/drivers/usb/usbhub/usbhub.h
index d0f25537f57..5aada11883d 100644
--- a/drivers/usb/usbhub/usbhub.h
+++ b/drivers/usb/usbhub/usbhub.h
@@ -85,8 +85,8 @@
#define USBHUB_ENUM_FLAG_GHOST_DEVICE 0x02
/* Hub Class Feature Selectors */
-#define USBHUB_FEATURE_USBHUB_FEATURE_C_HUB_LOCAL_POWER 0
-#define USBHUB_FEATURE_C_HUB_OVER_CURRENT 1
+#define USBHUB_FEATURE_C_HUB_LOCAL_POWER 0
+#define USBHUB_FEATURE_C_HUB_OVER_CURRENT 1
#define USBHUB_FEATURE_PORT_CONNECTION 0
#define USBHUB_FEATURE_PORT_ENABLE 1