https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ae800da85bd34ad2ce6b19cb049090f95e1787bc

commit ae800da85bd34ad2ce6b19cb049090f95e1787bc
Author:     Vadim Galyant <[email protected]>
AuthorDate: Mon Dec 11 16:24:26 2017 +0900
Commit:     Amine Khaldi <[email protected]>
CommitDate: Sun Jan 21 19:35:52 2018 +0100

    [USBPORT] Implement USB2_MoveTtEndpoint().
---
 drivers/usb/usbport/usb2.c    | 78 +++++++++++++++++++++++++++++++++++++++++--
 drivers/usb/usbport/usbport.h |  2 +-
 2 files changed, 76 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/usbport/usb2.c b/drivers/usb/usbport/usb2.c
index 14512d771d..ade65b4357 100644
--- a/drivers/usb/usbport/usb2.c
+++ b/drivers/usb/usbport/usb2.c
@@ -634,9 +634,81 @@ USB2_MoveTtEndpoint(IN PUSB2_TT_ENDPOINT TtEndpoint,
                     IN ULONG RebalanceListEntries,
                     OUT BOOLEAN * OutResult)
 {
-    DPRINT("USB2_MoveTtEndpoint: UNIMPLEMENTED FIXME\n");
-    ASSERT(FALSE);
-    return FALSE;
+    ULONG EndBusTime;
+    ULONG TransferType;
+    ULONG Num;
+    UCHAR ix;
+
+    DPRINT("USB2_MoveTtEndpoint: TtEndpoint - %p, BusTime - %X\n",
+           TtEndpoint,
+           BusTime);
+
+    *OutResult = TRUE;
+
+    for (Num = 0; Rebalance->RebalanceEndpoint[Num]; Num++)
+    {
+        if (Rebalance->RebalanceEndpoint[Num] == TtEndpoint)
+            break;
+    }
+
+    DPRINT("USB2_MoveTtEndpoint: Num - %X\n", Num);
+
+    TransferType = TtEndpoint->TtEndpointParams.TransferType;
+
+    if (Rebalance->RebalanceEndpoint[Num] &&
+        TtEndpoint->TtEndpointParams.EndpointMoved == TRUE &&
+        (TransferType != USBPORT_TRANSFER_TYPE_INTERRUPT || BusTime >= 0))
+    {
+        DPRINT("USB2_MoveTtEndpoint: result - FALSE\n");
+        return FALSE;
+    }
+
+    for (ix = 0;
+         (TtEndpoint->StartFrame + ix) < USB2_FRAMES;
+         ix += TtEndpoint->ActualPeriod)
+    {
+        USB2_DeallocateHS(TtEndpoint, ix);
+    }
+
+    TtEndpoint->StartTime += BusTime;
+
+    EndBusTime = TtEndpoint->StartTime + TtEndpoint->CalcBusTime;
+
+    if (EndBusTime > USB2_FS_MAX_PERIODIC_ALLOCATION)
+    {
+        DPRINT("USB2_MoveTtEndpoint: EndBusTime is too large!\n");
+        *OutResult = FALSE;
+    }
+
+    TtEndpoint->TtEndpointParams.EndpointMoved = TRUE;
+
+    if (Rebalance->RebalanceEndpoint[Num] == NULL)
+    {
+        if (Num >= RebalanceListEntries)
+        {
+            DPRINT("USB2_MoveTtEndpoint: Too many changes!\n");
+            *OutResult = FALSE;
+        }
+        else
+        {
+            Rebalance->RebalanceEndpoint[Num] = TtEndpoint;
+            Rebalance->RebalanceEndpoint[Num + 1] = NULL;
+        }
+    }
+
+    for (ix = 0;
+         (TtEndpoint->StartFrame + ix) < USB2_FRAMES;
+         ix += TtEndpoint->ActualPeriod)
+    {
+        if (!USB2_AllocateHS(TtEndpoint, ix))
+        {
+            DPRINT("USB2_MoveTtEndpoint: OutResult - FALSE\n");
+            OutResult = FALSE;
+        }
+    }
+
+    DPRINT("USB2_MoveTtEndpoint: result - TRUE\n");
+    return TRUE;
 }
 
 VOID
diff --git a/drivers/usb/usbport/usbport.h b/drivers/usb/usbport/usbport.h
index 8df658b12d..b98ac15e00 100644
--- a/drivers/usb/usbport/usbport.h
+++ b/drivers/usb/usbport/usbport.h
@@ -483,7 +483,7 @@ typedef union _USB2_TT_ENDPOINT_PARAMS {
     ULONG TransferType           : 4;
     ULONG Direction              : 1;
     USB_DEVICE_SPEED DeviceSpeed : 2;
-    ULONG EndpointMoved          : 1;
+    BOOL EndpointMoved           : 1;
     ULONG Reserved               : 24;
   };
   ULONG AsULONG;

Reply via email to