[USBPORT]
authorThomas Faber <thomas.faber@reactos.org>
Sat, 2 Sep 2017 22:48:45 +0000 (22:48 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Sat, 2 Sep 2017 22:48:45 +0000 (22:48 +0000)
Patch by Vadim Galyant:
- Move isochronous transfer functions to their own file
- Fix return type of PUSBPORT_COMPLETE_TRANSFER
- Improve some debug prints

svn path=/trunk/; revision=75745

reactos/drivers/usb/usbport/CMakeLists.txt
reactos/drivers/usb/usbport/iso.c [new file with mode: 0644]
reactos/drivers/usb/usbport/queue.c
reactos/drivers/usb/usbport/usbport.c
reactos/drivers/usb/usbport/usbport.h
reactos/sdk/include/reactos/drivers/usbport/usbmport.h

index e37477e..52db934 100644 (file)
@@ -7,6 +7,7 @@ list(APPEND SOURCE
     endpoint.c
     iface.c
     ioctl.c
+    iso.c
     pnp.c
     power.c
     queue.c
diff --git a/reactos/drivers/usb/usbport/iso.c b/reactos/drivers/usb/usbport/iso.c
new file mode 100644 (file)
index 0000000..9729a7a
--- /dev/null
@@ -0,0 +1,26 @@
+#include "usbport.h"
+
+#define NDEBUG
+#include <debug.h>
+
+USBD_STATUS
+NTAPI
+USBPORT_InitializeIsoTransfer(PDEVICE_OBJECT FdoDevice,
+                              struct _URB_ISOCH_TRANSFER * Urb,
+                              PUSBPORT_TRANSFER Transfer)
+{
+    DPRINT1("USBPORT_InitializeIsoTransfer: UNIMPLEMENTED. FIXME.\n");
+    return USBD_STATUS_NOT_SUPPORTED;
+}
+
+ULONG
+NTAPI
+USBPORT_CompleteIsoTransfer(IN PVOID MiniPortExtension,
+                            IN PVOID MiniPortEndpoint,
+                            IN PVOID TransferParameters,
+                            IN ULONG TransferLength)
+{
+    DPRINT1("USBPORT_CompleteIsoTransfer: UNIMPLEMENTED. FIXME.\n");
+    return 0;
+}
+
index 72cf4f5..9cdebbc 100644 (file)
@@ -531,7 +531,7 @@ USBPORT_CancelActiveTransferIrp(IN PDEVICE_OBJECT DeviceObject,
     PIRP irp;
     KIRQL OldIrql;
 
-    DPRINT_CORE("USBPORT_CancelTransferIrp: Irp - %p\n", Irp);
+    DPRINT_CORE("USBPORT_CancelActiveTransferIrp: Irp - %p\n", Irp);
 
     PdoExtension = DeviceObject->DeviceExtension;
     FdoDevice = PdoExtension->FdoDevice;
@@ -549,7 +549,7 @@ USBPORT_CancelActiveTransferIrp(IN PDEVICE_OBJECT DeviceObject,
         Transfer = Urb->UrbControlTransfer.hca.Reserved8[0];
         Endpoint = Transfer->Endpoint;
 
-        DPRINT_CORE("USBPORT_CancelTransferIrp: irp - %p, Urb - %p, Transfer - %p\n",
+        DPRINT_CORE("USBPORT_CancelActiveTransferIrp: irp - %p, Urb - %p, Transfer - %p\n",
                     irp,
                     Urb,
                     Transfer);
index 8318fe8..cae479b 100644 (file)
@@ -588,7 +588,7 @@ USBPORT_SoftInterruptDpc(IN PRKDPC Dpc,
     PDEVICE_OBJECT FdoDevice;
     PUSBPORT_DEVICE_EXTENSION FdoExtension;
 
-    DPRINT("USBPORT_SoftInterruptDpc: ... \n");
+    DPRINT_INT("USBPORT_SoftInterruptDpc: ... \n");
 
     FdoDevice = DeferredContext;
     FdoExtension = FdoDevice->DeviceExtension;
@@ -606,7 +606,7 @@ USBPORT_SoftInterrupt(IN PDEVICE_OBJECT FdoDevice)
     PUSBPORT_DEVICE_EXTENSION FdoExtension;
     LARGE_INTEGER DueTime = {{0, 0}};
 
-    DPRINT("USBPORT_SoftInterrupt: ... \n");
+    DPRINT_INT("USBPORT_SoftInterrupt: ... \n");
 
     FdoExtension = FdoDevice->DeviceExtension;
 
@@ -1079,7 +1079,8 @@ USBPORT_InterruptService(IN PKINTERRUPT Interrupt,
     FdoExtension = FdoDevice->DeviceExtension;
     Packet = &FdoExtension->MiniPortInterface->Packet;
 
-    DPRINT_INT("USBPORT_InterruptService: FdoExtension->Flags - %lx\n",
+    DPRINT_INT("USBPORT_InterruptService: FdoExtension[%p]->Flags - %08X\n",
+           FdoExtension,
            FdoExtension->Flags);
 
     if (FdoExtension->Flags & USBPORT_FLAG_INTERRUPT_ENABLED &&
@@ -1936,7 +1937,7 @@ USBPORT_Unload(IN PDRIVER_OBJECT DriverObject)
     //MiniPortInterface->DriverUnload(DriverObject); // Call MiniPort _HCI_Unload
 }
 
-ULONG
+VOID
 NTAPI
 USBPORT_MiniportCompleteTransfer(IN PVOID MiniPortExtension,
                                  IN PVOID MiniPortEndpoint,
@@ -1969,18 +1970,7 @@ USBPORT_MiniportCompleteTransfer(IN PVOID MiniPortExtension,
                                 &Transfer->TransferLink,
                                 &FdoExtension->DoneTransferSpinLock);
 
-    return KeInsertQueueDpc(&FdoExtension->TransferFlushDpc, NULL, NULL);
-}
-
-ULONG
-NTAPI
-USBPORT_CompleteIsoTransfer(IN PVOID MiniPortExtension,
-                            IN PVOID MiniPortEndpoint,
-                            IN PVOID TransferParameters,
-                            IN ULONG TransferLength)
-{
-    DPRINT1("USBPORT_CompleteIsoTransfer: UNIMPLEMENTED. FIXME.\n");
-    return 0;
+    KeInsertQueueDpc(&FdoExtension->TransferFlushDpc, NULL, NULL);
 }
 
 VOID
@@ -2309,7 +2299,7 @@ USBPORT_MapTransfer(IN PDEVICE_OBJECT FdoDevice,
 
         do
         {
-            ElementLength = 0x1000 - (PhAddress.LowPart & 0xFFF);
+            ElementLength = PAGE_SIZE - (PhAddress.LowPart & (PAGE_SIZE - 1));
 
             if (ElementLength > SgCurrentLength)
                 ElementLength = SgCurrentLength;
@@ -2331,9 +2321,9 @@ USBPORT_MapTransfer(IN PDEVICE_OBJECT FdoDevice,
         }
         while (SgCurrentLength);
 
-        if ((PhAddr.LowPart == PhAddress.LowPart) &&
-            (PhAddr.HighPart == PhAddress.HighPart))
+        if (PhAddr.QuadPart == PhAddress.QuadPart)
         {
+            DPRINT1("USBPORT_MapTransfer: PhAddr == PhAddress\n");
             ASSERT(FALSE);
         }
 
index 7a1443d..b9ea84e 100644 (file)
@@ -862,6 +862,22 @@ USBPORT_GetSymbolicName(
   IN PDEVICE_OBJECT RootHubPdo,
   IN PUNICODE_STRING DestinationString);
 
+/* iso.c */
+USBD_STATUS
+NTAPI
+USBPORT_InitializeIsoTransfer(
+  IN PDEVICE_OBJECT FdoDevice,
+  IN struct _URB_ISOCH_TRANSFER * Urb,
+  IN PUSBPORT_TRANSFER Transfer);
+
+ULONG
+NTAPI
+USBPORT_CompleteIsoTransfer(
+  IN PVOID MiniPortExtension,
+  IN PVOID MiniPortEndpoint,
+  IN PVOID TransferParameters,
+  IN ULONG TransferLength);
+
 /* pnp.c */
 NTSTATUS
 NTAPI
index ebafef3..8cb2c96 100644 (file)
@@ -43,7 +43,7 @@
 
 typedef struct _USBPORT_RESOURCES {
   ULONG ResourcesTypes;
-  ULONG HcFlavor;
+  USB_CONTROLLER_FLAVOR HcFlavor;
   ULONG InterruptVector;
   KIRQL InterruptLevel;
   UCHAR Padded1[3];
@@ -364,7 +364,7 @@ typedef ULONG
   PVOID,
   PVOID);
 
-typedef ULONG
+typedef VOID
 (NTAPI *PUSBPORT_COMPLETE_TRANSFER)(
   PVOID,
   PVOID,
@@ -581,6 +581,8 @@ typedef struct _USBPORT_MINIPORT_INTERFACE {
 C_ASSERT(sizeof(USBPORT_MINIPORT_INTERFACE) == 32 + 76 * sizeof(PVOID));
 
 #define USBPORT_TRANSFER_DIRECTION_OUT  1 // From host to device
+#define USBPORT_MAX_DEVICE_ADDRESS      127
+
 typedef struct _USBPORT_ENDPOINT_PROPERTIES {
   USHORT DeviceAddress;
   USHORT EndpointAddress;