https://git.reactos.org/?p=reactos.git;a=commitdiff;h=18702047a16f49053de45…
commit 18702047a16f49053de4597a56879edb357a3a24
Author: Vadim Galyant <vgal(a)rambler.ru>
AuthorDate: Mon Nov 27 18:20:28 2017 +0900
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Sun Jan 21 19:35:38 2018 +0100
[USBPORT] Implement USBPORT_InitializeTT().
---
drivers/usb/usbport/device.c | 52 +++++++++++++++++++++++++++++++++++++++++--
drivers/usb/usbport/usbport.h | 10 ++++++++-
2 files changed, 59 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/usbport/device.c b/drivers/usb/usbport/device.c
index f7180aaf96..268571fd7f 100644
--- a/drivers/usb/usbport/device.c
+++ b/drivers/usb/usbport/device.c
@@ -1770,7 +1770,55 @@ USBPORT_InitializeTT(IN PDEVICE_OBJECT FdoDevice,
IN PUSBPORT_DEVICE_HANDLE HubDeviceHandle,
IN ULONG TtNumber)
{
- DPRINT1("USBPORT_InitializeTT: UNIMPLEMENTED. FIXME. \n");
+ PUSBPORT_DEVICE_EXTENSION FdoExtension;
+ PUSB2_TT_EXTENSION TtExtension;
+ ULONG ix;
+
+ DPRINT("USBPORT_InitializeTT: HubDeviceHandle - %p, TtNumber - %X\n",
+ HubDeviceHandle,
+ TtNumber);
+
+ FdoExtension = FdoDevice->DeviceExtension;
+
+ TtExtension = ExAllocatePoolWithTag(NonPagedPool,
+ sizeof(USB2_TT_EXTENSION),
+ USB_PORT_TAG);
+
+ if (!TtExtension)
+ {
+ DPRINT1("USBPORT_InitializeTT: ExAllocatePoolWithTag return NULL\n");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ DPRINT("USBPORT_InitializeTT: TtExtension - %p\n", TtExtension);
+
+ RtlZeroMemory(TtExtension, sizeof(USB2_TT_EXTENSION));
+
+ TtExtension->DeviceAddress = HubDeviceHandle->DeviceAddress;
+ TtExtension->TtNumber = TtNumber;
+ TtExtension->RootHubPdo = FdoExtension->RootHubPdo;
+ TtExtension->BusBandwidth = TOTAL_USB11_BUS_BANDWIDTH;
+
+ InitializeListHead(&TtExtension->TtList);
+
+ /* 90% maximum allowed for periodic endpoints */
+ for (ix = 0; ix < USB2_FRAMES; ix++)
+ {
+ TtExtension->Bandwidth[ix] = TtExtension->BusBandwidth -
+ TtExtension->BusBandwidth / 10;
+ }
+
+ USBPORT_UpdateAllocatedBwTt(TtExtension);
+
+ for (ix = 0; ix < USB2_FRAMES; ix++)
+ {
+ FdoExtension->Bandwidth[ix] -= TtExtension->MaxBandwidth;
+ }
+
+ USB2_InitTT(FdoExtension->Usb2Extension, &TtExtension->Tt);
+
+ InsertTailList(&HubDeviceHandle->TtList, &TtExtension->Link);
+
return STATUS_SUCCESS;
}
@@ -1783,7 +1831,7 @@ USBPORT_Initialize20Hub(IN PDEVICE_OBJECT FdoDevice,
NTSTATUS Status;
ULONG ix;
- DPRINT("USBPORT_Initialize20Hub \n");
+ DPRINT("USBPORT_Initialize20Hub: TtCount - %X\n", TtCount);
if (!HubDeviceHandle)
{
diff --git a/drivers/usb/usbport/usbport.h b/drivers/usb/usbport/usbport.h
index 93c71a9516..026b297f17 100644
--- a/drivers/usb/usbport/usbport.h
+++ b/drivers/usb/usbport/usbport.h
@@ -194,6 +194,7 @@ typedef struct _USBPORT_DEVICE_HANDLE {
LIST_ENTRY DeviceHandleLink;
LONG DeviceHandleLock;
ULONG TtCount;
+ LIST_ENTRY TtList;
} USBPORT_DEVICE_HANDLE, *PUSBPORT_DEVICE_HANDLE;
typedef struct _USBPORT_ENDPOINT {
@@ -379,10 +380,11 @@ typedef struct _USBPORT_DEVICE_EXTENSION {
KDPC HcWakeDpc;
/* Usb 2.0 HC Extension */
PUSB2_HC_EXTENSION Usb2Extension;
+ ULONG Bandwidth[32];
/* Miniport extension should be aligned on 0x100 */
#if !defined(_M_X64)
- ULONG Padded[33];
+ ULONG Padded[1];
#else
ULONG Padded[0];
#endif
@@ -1294,6 +1296,12 @@ USBPORT_FreeBandwidthUSB2(
IN PDEVICE_OBJECT FdoDevice,
IN PUSBPORT_ENDPOINT Endpoint);
+VOID
+NTAPI
+USB2_InitTT(
+ IN PUSB2_HC_EXTENSION HcExtension,
+ IN PUSB2_TT Tt);
+
VOID
NTAPI
USB2_InitController(