https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3fcbd7744c8e595fb7aec…
commit 3fcbd7744c8e595fb7aecbb066f5e0197ba280e9
Author: Vadim Galyant <vgal(a)rambler.ru>
AuthorDate: Mon Nov 27 18:53:46 2017 +0900
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Sun Jan 21 19:35:38 2018 +0100
[USBPORT] Add support for transaction translators in USBPORT_OpenPipe().
---
drivers/usb/usbport/endpoint.c | 38 ++++++++++++++++++++++++++++++++++++++
drivers/usb/usbport/usbport.h | 11 +++++++++--
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/usbport/endpoint.c b/drivers/usb/usbport/endpoint.c
index be2c7eab6d..2479cf9dea 100644
--- a/drivers/usb/usbport/endpoint.c
+++ b/drivers/usb/usbport/endpoint.c
@@ -672,6 +672,26 @@ USBPORT_OpenPipe(IN PDEVICE_OBJECT FdoDevice,
Endpoint->DeviceHandle = DeviceHandle;
Endpoint->LockCounter = -1;
+ Endpoint->TtExtension = DeviceHandle->TtExtension;
+
+ if (DeviceHandle->TtExtension)
+ {
+ ExInterlockedInsertTailList(&DeviceHandle->TtExtension->TtList,
+ &Endpoint->TtLink,
+ &FdoExtension->TtSpinLock);
+ }
+
+ if (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2)
+ {
+ Endpoint->TtEndpoint = (PUSB2_TT_ENDPOINT)((ULONG_PTR)Endpoint +
+ sizeof(USBPORT_ENDPOINT) +
+ Packet->MiniPortEndpointSize);
+ }
+ else
+ {
+ Endpoint->TtEndpoint = NULL;
+ }
+
KeInitializeSpinLock(&Endpoint->EndpointSpinLock);
KeInitializeSpinLock(&Endpoint->StateChangeSpinLock);
@@ -695,6 +715,17 @@ USBPORT_OpenPipe(IN PDEVICE_OBJECT FdoDevice,
EndpointProperties->TotalMaxPacketSize = MaxPacketSize *
(AdditionalTransaction + 1);
+ if (Endpoint->TtExtension)
+ {
+ EndpointProperties->HubAddr = Endpoint->TtExtension->DeviceAddress;
+ }
+ else
+ {
+ EndpointProperties->HubAddr = -1;
+ }
+
+ EndpointProperties->PortNumber = DeviceHandle->PortNumber;
+
switch (EndpointDescriptor->bmAttributes & USB_ENDPOINT_TYPE_MASK)
{
case USB_ENDPOINT_TYPE_CONTROL:
@@ -960,6 +991,13 @@ ExitWithError:
}
}
+ if (Endpoint->TtExtension)
+ {
+ KeAcquireSpinLock(&FdoExtension->TtSpinLock, &OldIrql);
+ RemoveEntryList(&Endpoint->TtLink);
+ KeReleaseSpinLock(&FdoExtension->TtSpinLock, OldIrql);
+ }
+
ExFreePoolWithTag(Endpoint, USB_PORT_TAG);
}
diff --git a/drivers/usb/usbport/usbport.h b/drivers/usb/usbport/usbport.h
index 85636b24bf..2f37634468 100644
--- a/drivers/usb/usbport/usbport.h
+++ b/drivers/usb/usbport/usbport.h
@@ -154,7 +154,9 @@ typedef struct _USBPORT_COMMON_BUFFER_HEADER {
typedef struct _USBPORT_ENDPOINT *PUSBPORT_ENDPOINT;
typedef struct _USB2_HC_EXTENSION *PUSB2_HC_EXTENSION;
+typedef struct _USB2_TT_EXTENSION *PUSB2_TT_EXTENSION;
typedef struct _USB2_TT *PUSB2_TT;
+typedef struct _USB2_TT_ENDPOINT *PUSB2_TT_ENDPOINT;
typedef struct _USBPORT_PIPE_HANDLE {
ULONG Flags;
@@ -194,6 +196,7 @@ typedef struct _USBPORT_DEVICE_HANDLE {
LIST_ENTRY DeviceHandleLink;
LONG DeviceHandleLock;
ULONG TtCount;
+ PUSB2_TT_EXTENSION TtExtension; // Transaction Translator
LIST_ENTRY TtList;
} USBPORT_DEVICE_HANDLE, *PUSBPORT_DEVICE_HANDLE;
@@ -202,6 +205,8 @@ typedef struct _USBPORT_ENDPOINT {
PDEVICE_OBJECT FdoDevice;
PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer;
PUSBPORT_DEVICE_HANDLE DeviceHandle;
+ PUSB2_TT_EXTENSION TtExtension; // Transaction Translator
+ PUSB2_TT_ENDPOINT TtEndpoint;
USBPORT_ENDPOINT_PROPERTIES EndpointProperties;
ULONG EndpointWorker;
ULONG FrameNumber;
@@ -230,6 +235,7 @@ typedef struct _USBPORT_ENDPOINT {
LIST_ENTRY FlushLink;
LIST_ENTRY FlushControllerLink;
LIST_ENTRY FlushAbortLink;
+ LIST_ENTRY TtLink;
} USBPORT_ENDPOINT, *PUSBPORT_ENDPOINT;
typedef struct _USBPORT_ISO_BLOCK *PUSBPORT_ISO_BLOCK;
@@ -381,10 +387,11 @@ typedef struct _USBPORT_DEVICE_EXTENSION {
/* Usb 2.0 HC Extension */
PUSB2_HC_EXTENSION Usb2Extension;
ULONG Bandwidth[32];
+ KSPIN_LOCK TtSpinLock;
/* Miniport extension should be aligned on 0x100 */
#if !defined(_M_X64)
- ULONG Padded[1];
+ ULONG Padded[64];
#else
ULONG Padded[0];
#endif
@@ -392,7 +399,7 @@ typedef struct _USBPORT_DEVICE_EXTENSION {
} USBPORT_DEVICE_EXTENSION, *PUSBPORT_DEVICE_EXTENSION;
#if !defined(_M_X64)
-C_ASSERT(sizeof(USBPORT_DEVICE_EXTENSION) == 0x400);
+C_ASSERT(sizeof(USBPORT_DEVICE_EXTENSION) == 0x500);
#else
C_ASSERT(sizeof(USBPORT_DEVICE_EXTENSION) == 0x600);
#endif