Move shareable part of USB miniport drivers to a new directory. UHCI
uses it.
Modified: trunk/reactos/drivers/usb/miniport/common/cleanup.c
Modified: trunk/reactos/drivers/usb/miniport/common/close.c
Modified: trunk/reactos/drivers/usb/miniport/common/common.xml
Modified: trunk/reactos/drivers/usb/miniport/common/create.c
Modified: trunk/reactos/drivers/usb/miniport/common/fdo.c
Added: trunk/reactos/drivers/usb/miniport/common/main.c
Modified: trunk/reactos/drivers/usb/miniport/common/misc.c
Modified: trunk/reactos/drivers/usb/miniport/common/pdo.c
Deleted: trunk/reactos/drivers/usb/miniport/common/uhci.c
Deleted: trunk/reactos/drivers/usb/miniport/common/uhci.h
Added: trunk/reactos/drivers/usb/miniport/common/usbcommon.h
Added: trunk/reactos/drivers/usb/miniport/common/usbcommon_types.h
Modified: trunk/reactos/drivers/usb/miniport/linux/pci_hal.c
Modified: trunk/reactos/drivers/usb/miniport/sys/linuxwrapper.c
Modified: trunk/reactos/drivers/usb/miniport/usbuhci/uhci-hcd.c
Modified: trunk/reactos/drivers/usb/miniport/usbuhci/uhci.c
Added: trunk/reactos/drivers/usb/miniport/usbuhci/uhci.h
Modified: trunk/reactos/drivers/usb/miniport/usbuhci/usbuhci.xml
_____
Modified: trunk/reactos/drivers/usb/miniport/common/cleanup.c
--- trunk/reactos/drivers/usb/miniport/common/cleanup.c 2005-09-10
15:36:35 UTC (rev 17781)
+++ trunk/reactos/drivers/usb/miniport/common/cleanup.c 2005-09-10
18:04:42 UTC (rev 17782)
@@ -1,21 +1,23 @@
/*
* COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS UHCI controller driver (Cromwell type)
- * FILE: drivers/usb/cromwell/uhci/cleanup.c
+ * PROJECT: ReactOS USB miniport driver (Cromwell type)
+ * FILE: drivers/usb/miniport/common/cleanup.c
* PURPOSE: IRP_MJ_CLEANUP operations
*
- * PROGRAMMERS: HervÚ Poussineau (hpoussin(a)reactos.com)
+ * PROGRAMMERS: HervÚ Poussineau (hpoussin(a)reactos.org)
*/
#define NDEBUG
-#include "uhci.h"
+#include <debug.h>
+#include "usbcommon.h"
+
NTSTATUS STDCALL
-UhciCleanup(
+UsbMpCleanup(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
- DPRINT("UHCI: IRP_MJ_CLEANUP\n");
+ DPRINT("USBMP: IRP_MJ_CLEANUP\n");
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = STATUS_SUCCESS;
_____
Modified: trunk/reactos/drivers/usb/miniport/common/close.c
--- trunk/reactos/drivers/usb/miniport/common/close.c 2005-09-10
15:36:35 UTC (rev 17781)
+++ trunk/reactos/drivers/usb/miniport/common/close.c 2005-09-10
18:04:42 UTC (rev 17782)
@@ -1,24 +1,26 @@
/*
* COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS UHCI controller driver (Cromwell type)
- * FILE: drivers/usb/cromwell/uhci/close.c
+ * PROJECT: ReactOS USB miniport driver (Cromwell type)
+ * FILE: drivers/usb/miniport/common/close.c
* PURPOSE: IRP_MJ_CLOSE operations
*
- * PROGRAMMERS: HervÚ Poussineau (hpoussin(a)reactos.com)
+ * PROGRAMMERS: HervÚ Poussineau (hpoussin(a)reactos.org)
*/
#define NDEBUG
-#include "uhci.h"
+#include <debug.h>
+#include "usbcommon.h"
+
NTSTATUS STDCALL
-UhciClose(
+UsbMpClose(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
- POHCI_DEVICE_EXTENSION pDeviceExtension;
+ PUSBMP_DEVICE_EXTENSION pDeviceExtension;
- DPRINT("UHCI: IRP_MJ_CLOSE\n");
- pDeviceExtension =
(POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ DPRINT("USBMP: IRP_MJ_CLOSE\n");
+ pDeviceExtension =
(PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
InterlockedDecrement((PLONG)&pDeviceExtension->DeviceOpened);
Irp->IoStatus.Information = 0;
_____
Modified: trunk/reactos/drivers/usb/miniport/common/common.xml
--- trunk/reactos/drivers/usb/miniport/common/common.xml
2005-09-10 15:36:35 UTC (rev 17781)
+++ trunk/reactos/drivers/usb/miniport/common/common.xml
2005-09-10 18:04:42 UTC (rev 17782)
@@ -2,12 +2,12 @@
<define name="__USE_W32API" />
<define name="DEBUG_MODE" />
<include>../linux</include>
- <include base="usbport"></include>
+ <include base="usbport">.</include>
<file>cleanup.c</file>
<file>close.c</file>
<file>create.c</file>
<file>fdo.c</file>
+ <file>main.c</file>
<file>misc.c</file>
<file>pdo.c</file>
- <file>uhci.c</file>
</module>
_____
Modified: trunk/reactos/drivers/usb/miniport/common/create.c
--- trunk/reactos/drivers/usb/miniport/common/create.c 2005-09-10
15:36:35 UTC (rev 17781)
+++ trunk/reactos/drivers/usb/miniport/common/create.c 2005-09-10
18:04:42 UTC (rev 17782)
@@ -1,27 +1,29 @@
/*
* COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS UHCI controller driver (Cromwell type)
- * FILE: drivers/usb/cromwell/uhci/create.c
+ * PROJECT: ReactOS USB miniport driver (Cromwell type)
+ * FILE: drivers/usb/miniport/common/create.c
* PURPOSE: IRP_MJ_CREATE operations
*
- * PROGRAMMERS: HervÚ Poussineau (hpoussin(a)reactos.com)
+ * PROGRAMMERS: HervÚ Poussineau (hpoussin(a)reactos.org)
*/
#define NDEBUG
-#include "uhci.h"
+#include <debug.h>
+#include "usbcommon.h"
+
NTSTATUS STDCALL
-UhciCreate(
+UsbMpCreate(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
PIO_STACK_LOCATION Stack;
- POHCI_DEVICE_EXTENSION DeviceExtension;
+ PUSBMP_DEVICE_EXTENSION DeviceExtension;
NTSTATUS Status;
- DPRINT("UHCI: IRP_MJ_CREATE\n");
+ DPRINT("USBMP: IRP_MJ_CREATE\n");
Stack = IoGetCurrentIrpStackLocation(Irp);
- DeviceExtension =
(POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ DeviceExtension =
(PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
if (Stack->Parameters.Create.Options & FILE_DIRECTORY_FILE)
{
_____
Modified: trunk/reactos/drivers/usb/miniport/common/fdo.c
--- trunk/reactos/drivers/usb/miniport/common/fdo.c 2005-09-10
15:36:35 UTC (rev 17781)
+++ trunk/reactos/drivers/usb/miniport/common/fdo.c 2005-09-10
18:04:42 UTC (rev 17782)
@@ -1,20 +1,22 @@
/*
* COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS UHCI controller driver (Cromwell type)
- * FILE: drivers/usb/cromwell/uhci/fdo.c
+ * PROJECT: ReactOS USB miniport driver (Cromwell type)
+ * FILE: drivers/usb/miniport/common/fdo.c
* PURPOSE: IRP_MJ_PNP/IRP_MJ_DEVICE_CONTROL operations for
FDOs
*
- * PROGRAMMERS: HervÚ Poussineau (hpoussin(a)reactos.com),
+ * PROGRAMMERS: HervÚ Poussineau (hpoussin(a)reactos.org),
* James Tabor
(jimtabor(a)adsl-64-217-116-74.dsl.hstntx.swbell.net)
*/
#define NDEBUG
-#include "uhci.h"
+#include <debug.h>
+#include "usbcommon.h"
+
#define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003)
static VOID
-UhciGetUserBuffers(
+UsbMpGetUserBuffers(
IN PIRP Irp,
IN ULONG IoControlCode,
OUT PVOID* BufferIn,
@@ -47,14 +49,14 @@
}
NTSTATUS STDCALL
-UhciFdoStartDevice(
+UsbMpFdoStartDevice(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
PDRIVER_OBJECT DriverObject;
- POHCI_DRIVER_EXTENSION DriverExtension;
- POHCI_DEVICE_EXTENSION DeviceExtension;
+ PUSBMP_DRIVER_EXTENSION DriverExtension;
+ PUSBMP_DEVICE_EXTENSION DeviceExtension;
PCM_RESOURCE_LIST AllocatedResources;
/*
@@ -62,7 +64,7 @@
*/
DriverObject = DeviceObject->DriverObject;
DriverExtension = IoGetDriverObjectExtension(DriverObject,
DriverObject);
- DeviceExtension =
(POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ DeviceExtension =
(PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
/*
* Store some resources in the DeviceExtension.
@@ -131,7 +133,7 @@
}
/* Print assigned resources */
- DPRINT("UHCI: Interrupt Vector 0x%lx, %S base 0x%lx, Length
0x%lx\n",
+ DPRINT("USBMP: Interrupt Vector 0x%lx, %S base 0x%lx, Length
0x%lx\n",
DeviceExtension->InterruptVector,
((struct hc_driver *)(*pci_ids)->driver_data)->flags &
HCD_MEMORY ? L"Memory" : L"I/O",
DeviceExtension->BaseAddress,
@@ -142,15 +144,15 @@
}
static NTSTATUS
-UhciFdoQueryBusRelations(
+UsbMpFdoQueryBusRelations(
IN PDEVICE_OBJECT DeviceObject,
OUT PDEVICE_RELATIONS* pDeviceRelations)
{
- POHCI_DEVICE_EXTENSION DeviceExtension;
+ PUSBMP_DEVICE_EXTENSION DeviceExtension;
PDEVICE_RELATIONS DeviceRelations;
NTSTATUS Status = STATUS_SUCCESS;
- DeviceExtension =
(POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ DeviceExtension =
(PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
/* Handling this IRP is easy, as we only
* have one child: the root hub
@@ -171,7 +173,7 @@
}
NTSTATUS STDCALL
-UhciPnpFdo(
+UsbMpPnpFdo(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
@@ -189,7 +191,7 @@
{
Status = ForwardIrpAndWait(DeviceObject, Irp);
if (NT_SUCCESS(Status) &&
NT_SUCCESS(Irp->IoStatus.Status))
- Status =
UhciFdoStartDevice(DeviceObject, Irp);
+ Status =
UsbMpFdoStartDevice(DeviceObject, Irp);
break;
}
@@ -219,18 +221,18 @@
case BusRelations:
{
PDEVICE_RELATIONS
DeviceRelations;
- DPRINT("UHCI: IRP_MJ_PNP /
IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
- Status =
UhciFdoQueryBusRelations(DeviceObject, &DeviceRelations);
+ DPRINT("USBMP: IRP_MJ_PNP /
IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
+ Status =
UsbMpFdoQueryBusRelations(DeviceObject, &DeviceRelations);
Information =
(ULONG_PTR)DeviceRelations;
break;
}
case RemovalRelations:
{
- DPRINT1("UHCI: IRP_MJ_PNP /
IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations\n");
+ DPRINT1("USBMP: IRP_MJ_PNP /
IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations\n");
return
ForwardIrpAndForget(DeviceObject, Irp);
}
default:
- DPRINT1("UHCI: IRP_MJ_PNP /
IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
+ DPRINT1("USBMP: IRP_MJ_PNP /
IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
IrpSp->Parameters.QueryDeviceRelations.Type);
return
ForwardIrpAndForget(DeviceObject, Irp);
}
@@ -239,7 +241,7 @@
default:
{
- DPRINT1("UHCI: unknown minor function 0x%lx\n",
MinorFunction);
+ DPRINT1("USBMP: unknown minor function 0x%lx\n",
MinorFunction);
return ForwardIrpAndForget(DeviceObject, Irp);
}
}
@@ -250,32 +252,32 @@
}
NTSTATUS
-UhciDeviceControlFdo(
+UsbMpDeviceControlFdo(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
PIO_STACK_LOCATION Stack;
ULONG IoControlCode;
- POHCI_DEVICE_EXTENSION DeviceExtension;
+ PUSBMP_DEVICE_EXTENSION DeviceExtension;
ULONG LengthIn, LengthOut;
ULONG_PTR Information = 0;
PVOID BufferIn, BufferOut;
NTSTATUS Status;
- DPRINT("UHCI: UsbDeviceControlFdo() called\n");
+ DPRINT("USBMP: UsbDeviceControlFdo() called\n");
Stack = IoGetCurrentIrpStackLocation(Irp);
LengthIn = Stack->Parameters.DeviceIoControl.InputBufferLength;
LengthOut =
Stack->Parameters.DeviceIoControl.OutputBufferLength;
- DeviceExtension =
(POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ DeviceExtension =
(PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
IoControlCode = Stack->Parameters.DeviceIoControl.IoControlCode;
- UhciGetUserBuffers(Irp, IoControlCode, &BufferIn, &BufferOut);
+ UsbMpGetUserBuffers(Irp, IoControlCode, &BufferIn, &BufferOut);
switch (IoControlCode)
{
case IOCTL_GET_HCD_DRIVERKEY_NAME:
{
- DPRINT("UHCI: IOCTL_GET_HCD_DRIVERKEY_NAME\n");
+ DPRINT("USBMP: IOCTL_GET_HCD_DRIVERKEY_NAME\n");
if (LengthOut < sizeof(USB_HCD_DRIVERKEY_NAME))
Status = STATUS_BUFFER_TOO_SMALL;
else if (BufferOut == NULL)
@@ -286,7 +288,7 @@
ULONG StringSize;
StringDescriptor =
(PUSB_HCD_DRIVERKEY_NAME)BufferOut;
Status = IoGetDeviceProperty(
-
((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->PhysicalDeviceO
bject,
+
((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->PhysicalDevice
Object,
DevicePropertyDriverKeyName,
LengthOut -
FIELD_OFFSET(USB_HCD_DRIVERKEY_NAME, DriverKeyName),
StringDescriptor->DriverKeyName,
@@ -302,7 +304,7 @@
}
case IOCTL_USB_GET_ROOT_HUB_NAME:
{
- DPRINT("UHCI: IOCTL_USB_GET_ROOT_HUB_NAME\n");
+ DPRINT("USBMP: IOCTL_USB_GET_ROOT_HUB_NAME\n");
if (LengthOut < sizeof(USB_ROOT_HUB_NAME))
Status = STATUS_BUFFER_TOO_SMALL;
else if (BufferOut == NULL)
@@ -312,8 +314,8 @@
PUSB_ROOT_HUB_NAME StringDescriptor;
PUNICODE_STRING RootHubInterfaceName;
StringDescriptor =
(PUSB_ROOT_HUB_NAME)BufferOut;
- DeviceObject =
((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->RootHubPdo;
- RootHubInterfaceName =
&((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->HcdInterfaceNa
me;
+ DeviceObject =
((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->RootHubPdo;
+ RootHubInterfaceName =
&((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->HcdInterfaceN
ame;
StringDescriptor->ActualLength =
RootHubInterfaceName->Length + sizeof(WCHAR) +
FIELD_OFFSET(USB_ROOT_HUB_NAME, RootHubName);
if (StringDescriptor->ActualLength <=
LengthOut)
@@ -324,7 +326,7 @@
RootHubInterfaceName->Buffer,
RootHubInterfaceName->Length);
StringDescriptor->RootHubName[RootHubInterfaceName->Length /
sizeof(WCHAR)] = UNICODE_NULL;
- DPRINT("UHCI:
IOCTL_USB_GET_ROOT_HUB_NAME returns '%S'\n",
StringDescriptor->RootHubName);
+ DPRINT("USBMP:
IOCTL_USB_GET_ROOT_HUB_NAME returns '%S'\n",
StringDescriptor->RootHubName);
Information =
StringDescriptor->ActualLength;
}
else
@@ -337,7 +339,7 @@
default:
{
/* Pass Irp to lower driver */
- DPRINT1("UHCI: Unknown IOCTL code 0x%lx\n",
Stack->Parameters.DeviceIoControl.IoControlCode);
+ DPRINT1("USBMP: Unknown IOCTL code 0x%lx\n",
Stack->Parameters.DeviceIoControl.IoControlCode);
IoSkipCurrentIrpStackLocation(Irp);
return
IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
}
_____
Copied: trunk/reactos/drivers/usb/miniport/common/main.c (from rev
17776, trunk/reactos/drivers/usb/miniport/common/uhci.c)
--- trunk/reactos/drivers/usb/miniport/common/uhci.c 2005-09-10
15:17:07 UTC (rev 17776)
+++ trunk/reactos/drivers/usb/miniport/common/main.c 2005-09-10
18:04:42 UTC (rev 17782)
@@ -0,0 +1,282 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS USB miniport driver (Cromwell type)
+ * FILE: drivers/usb/miniport/common/main.c
+ * PURPOSE: Driver entry
+ *
+ * PROGRAMMERS: Aleksey Bragin (aleksey(a)reactos.com)
+ * HervÚ Poussineau (hpoussin(a)reactos.org),
+ *
+ * Some parts of code are inspired (or even just copied) from
+ * ReactOS Videoport driver (drivers/video/videoprt)
+ */
+
+#define NDEBUG
+#include <debug.h>
+
+#define INITGUID
+#include "usbcommon.h"
+
+static ULONG DeviceNumber = 0; /* FIXME: what is that? */
+
+static NTSTATUS
+CreateRootHubPdo(
+ IN PDRIVER_OBJECT DriverObject,
+ IN PDEVICE_OBJECT Fdo,
+ OUT PDEVICE_OBJECT* pPdo)
+{
+ PDEVICE_OBJECT Pdo;
+ PUSBMP_DEVICE_EXTENSION DeviceExtension;
+ NTSTATUS Status;
+
+ DPRINT("USBMP: CreateRootHubPdo()\n");
+
+ Status = IoCreateDevice(
+ DriverObject,
+ sizeof(USBMP_DEVICE_EXTENSION),
+ NULL, /* DeviceName */
+ FILE_DEVICE_BUS_EXTENDER,
+ FILE_DEVICE_SECURE_OPEN |
FILE_AUTOGENERATED_DEVICE_NAME,
+ FALSE,
+ &Pdo);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("USBMP: IoCreateDevice() call failed with status
0x%08x\n", Status);
+ return Status;
+ }
+
+ Pdo->Flags |= DO_BUS_ENUMERATED_DEVICE;
+ Pdo->Flags |= DO_POWER_PAGABLE;
+
+ // zerofill device extension
+ DeviceExtension = (PUSBMP_DEVICE_EXTENSION)Pdo->DeviceExtension;
+ RtlZeroMemory(DeviceExtension, sizeof(USBMP_DEVICE_EXTENSION));
+
+ DeviceExtension->IsFDO = FALSE;
+ DeviceExtension->FunctionalDeviceObject = Fdo;
+
+ Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
+
+ *pPdo = Pdo;
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS STDCALL
+AddDevice(
+ IN PDRIVER_OBJECT DriverObject,
+ IN PDEVICE_OBJECT pdo)
+{
+ PDEVICE_OBJECT fdo;
+ NTSTATUS Status;
+ WCHAR DeviceBuffer[20];
+ WCHAR LinkDeviceBuffer[20];
+ UNICODE_STRING DeviceName;
+ UNICODE_STRING LinkDeviceName;
+ PUSBMP_DRIVER_EXTENSION DriverExtension;
+ PUSBMP_DEVICE_EXTENSION DeviceExtension;
+
+ DPRINT("USBMP: AddDevice called\n");
+
+ // Allocate driver extension now
+ DriverExtension = IoGetDriverObjectExtension(DriverObject,
DriverObject);
+ if (DriverExtension == NULL)
+ {
+ Status = IoAllocateDriverObjectExtension(
+ DriverObject,
+ DriverObject,
+ sizeof(USBMP_DRIVER_EXTENSION),
+ (PVOID *)&DriverExtension);
+
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("USBMP: Allocating DriverObjectExtension
failed.\n");
+ return Status;
+ }
+ }
+
+ // Create a unicode device name
+// DeviceNumber = 0; //TODO: Allocate new device number every time
+ swprintf(DeviceBuffer, L"\\Device\\USBFDO-%lu", DeviceNumber);
+ RtlInitUnicodeString(&DeviceName, DeviceBuffer);
+
+ Status = IoCreateDevice(DriverObject,
+ sizeof(USBMP_DEVICE_EXTENSION),
+ &DeviceName,
+ FILE_DEVICE_BUS_EXTENDER,
+ 0,
+ FALSE,
+ &fdo);
+
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("USBMP: IoCreateDevice call failed with status
0x%08lx\n", Status);
+ return Status;
+ }
+
+ // zerofill device extension
+ DeviceExtension = (PUSBMP_DEVICE_EXTENSION)fdo->DeviceExtension;
+ RtlZeroMemory(DeviceExtension, sizeof(USBMP_DEVICE_EXTENSION));
+
+ /* Create root hub Pdo */
+ Status = CreateRootHubPdo(DriverObject, fdo,
&DeviceExtension->RootHubPdo);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("USBMP: CreateRootHubPdo() failed with status
0x%08lx\n", Status);
+ IoDeleteDevice(fdo);
+ return Status;
+ }
+
+ /* Register device interface for controller */
+ Status = IoRegisterDeviceInterface(
+ pdo,
+ &GUID_DEVINTERFACE_USB_HOST_CONTROLLER,
+ NULL,
+ &DeviceExtension->HcdInterfaceName);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("USBMP: IoRegisterDeviceInterface() failed with
status 0x%08lx\n", Status);
+ IoDeleteDevice(DeviceExtension->RootHubPdo);
+ IoDeleteDevice(fdo);
+ return Status;
+ }
+
+ DeviceExtension->NextDeviceObject =
IoAttachDeviceToDeviceStack(fdo, pdo);
+
+ fdo->Flags &= ~DO_DEVICE_INITIALIZING;
+
+ // Initialize device extension
+ DeviceExtension->IsFDO = TRUE;
+ DeviceExtension->DeviceNumber = DeviceNumber;
+ DeviceExtension->PhysicalDeviceObject = pdo;
+ DeviceExtension->FunctionalDeviceObject = fdo;
+ DeviceExtension->DriverExtension = DriverExtension;
+
+ /* FIXME: do a loop to find an available number */
+ swprintf(LinkDeviceBuffer, L"\\??\\HCD%lu", 0);
+
+ RtlInitUnicodeString(&LinkDeviceName, LinkDeviceBuffer);
+
+ Status = IoCreateSymbolicLink(&LinkDeviceName, &DeviceName);
+
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("USBMP: IoCreateSymbolicLink call failed with
status 0x%08x\n", Status);
+ IoDeleteDevice(DeviceExtension->RootHubPdo);
+ IoDeleteDevice(fdo);
+ return Status;
+ }
+
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS STDCALL
+IrpStub(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ NTSTATUS Status = STATUS_NOT_SUPPORTED;
+
+ if
(((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
+ {
+ DPRINT1("USBMP: FDO stub for major function 0x%lx\n",
+
IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
+#ifndef NDEBUG
+ DbgBreakPoint();
+#endif
+ return ForwardIrpAndForget(DeviceObject, Irp);
+ }
+ else
+ {
+ /* We can't forward request to the lower driver, because
+ * we are a Pdo, so we don't have lower driver...
+ */
+ DPRINT1("USBMP: PDO stub for major function 0x%lx\n",
+
IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
+#ifndef NDEBUG
+ DbgBreakPoint();
+#endif
+ }
+
+ Status = Irp->IoStatus.Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
+}
+
+static NTSTATUS STDCALL
+DispatchCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+ if
(((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
+ return UsbMpCreate(DeviceObject, Irp);
+ else
+ return IrpStub(DeviceObject, Irp);
+}
+
+static NTSTATUS STDCALL
+DispatchClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+ if
(((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
+ return UsbMpClose(DeviceObject, Irp);
+ else
+ return IrpStub(DeviceObject, Irp);
+}
+
+static NTSTATUS STDCALL
+DispatchCleanup(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+ if
(((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
+ return UsbMpCleanup(DeviceObject, Irp);
+ else
+ return IrpStub(DeviceObject, Irp);
+}
+
+static NTSTATUS STDCALL
+DispatchDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+ if
(((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
+ return UsbMpDeviceControlFdo(DeviceObject, Irp);
+ else
+ return UsbMpDeviceControlPdo(DeviceObject, Irp);
+}
+
+static NTSTATUS STDCALL
+DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+ if
(((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
+ return UsbMpPnpFdo(DeviceObject, Irp);
+ else
+ return UsbMpPnpPdo(DeviceObject, Irp);
+}
+
+static NTSTATUS STDCALL
+DispatchPower(PDEVICE_OBJECT fido, PIRP Irp)
+{
+ DPRINT1("USBMP: IRP_MJ_POWER unimplemented\n");
+ Irp->IoStatus.Information = 0;
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+}
+
+/*
+ * Standard DriverEntry method.
+ */
+NTSTATUS STDCALL
+DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegPath)
+{
+ ULONG i;
+
+ DriverObject->DriverUnload = DriverUnload;
+ DriverObject->DriverExtension->AddDevice = AddDevice;
+
+ for (i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++)
+ DriverObject->MajorFunction[i] = IrpStub;
+
+ DriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchCreate;
+ DriverObject->MajorFunction[IRP_MJ_CLOSE] = DispatchClose;
+ DriverObject->MajorFunction[IRP_MJ_CLEANUP] = DispatchCleanup;
+ DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
DispatchDeviceControl;
+ DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp;
+ DriverObject->MajorFunction[IRP_MJ_POWER] = DispatchPower;
+
+ return STATUS_SUCCESS;
+}
_____
Modified: trunk/reactos/drivers/usb/miniport/common/misc.c
--- trunk/reactos/drivers/usb/miniport/common/misc.c 2005-09-10
15:36:35 UTC (rev 17781)
+++ trunk/reactos/drivers/usb/miniport/common/misc.c 2005-09-10
18:04:42 UTC (rev 17782)
@@ -1,14 +1,16 @@
/*
* COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS UHCI controller driver (Cromwell type)
- * FILE: drivers/usb/cromwell/uhci/misc.c
+ * PROJECT: ReactOS USB miniport driver (Cromwell type)
+ * FILE: drivers/usb/miniport/common/misc.c
* PURPOSE: Misceallenous operations
*
- * PROGRAMMERS: HervÚ Poussineau (hpoussin(a)reactos.com),
+ * PROGRAMMERS: HervÚ Poussineau (hpoussin(a)reactos.org),
*/
#define NDEBUG
-#include "uhci.h"
+#include <debug.h>
+
+#include "usbcommon.h"
#include <stdarg.h>
NTSTATUS STDCALL
@@ -27,7 +29,7 @@
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
- PDEVICE_OBJECT LowerDevice =
((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->NextDeviceObjec
t;
+ PDEVICE_OBJECT LowerDevice =
((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->NextDeviceObje
ct;
KEVENT Event;
NTSTATUS Status;
@@ -36,7 +38,7 @@
KeInitializeEvent(&Event, NotificationEvent, FALSE);
IoCopyCurrentIrpStackLocationToNext(Irp);
- DPRINT("UHCI: Calling lower device %p [%wZ]\n", LowerDevice,
&LowerDevice->DriverObject->DriverName);
+ DPRINT("USBMP: Calling lower device %p [%wZ]\n", LowerDevice,
&LowerDevice->DriverObject->DriverName);
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event,
TRUE, TRUE, TRUE);
Status = IoCallDriver(LowerDevice, Irp);
@@ -55,7 +57,7 @@
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
- PDEVICE_OBJECT LowerDevice =
((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->NextDeviceObjec
t;
+ PDEVICE_OBJECT LowerDevice =
((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->NextDeviceObje
ct;
ASSERT(LowerDevice);
@@ -67,7 +69,7 @@
* PnP ids are ANSI-encoded in PnP device string
* identification */
NTSTATUS
-UhciInitMultiSzString(
+UsbMpInitMultiSzString(
OUT PUNICODE_STRING Destination,
... /* list of PCSZ */)
{
@@ -103,7 +105,7 @@
/* Initialize destination string */
DestinationSize += sizeof(WCHAR); // final NULL
- Destination->Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool,
DestinationSize, USB_UHCI_TAG);
+ Destination->Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool,
DestinationSize, USB_MINIPORT_TAG);
if (!Destination->Buffer)
return STATUS_INSUFFICIENT_RESOURCES;
Destination->Length = 0;
@@ -123,7 +125,7 @@
Status = RtlAnsiStringToUnicodeString(&UnicodeString,
&AnsiString, FALSE);
if (!NT_SUCCESS(Status))
{
- ExFreePoolWithTag(Destination->Buffer,
USB_UHCI_TAG);
+ ExFreePoolWithTag(Destination->Buffer,
USB_MINIPORT_TAG);
break;
}
Destination->Length += UnicodeString.Length +
sizeof(WCHAR);
@@ -143,7 +145,7 @@
}
NTSTATUS
-UhciDuplicateUnicodeString(
+UsbMpDuplicateUnicodeString(
OUT PUNICODE_STRING Destination,
IN PUNICODE_STRING Source,
IN POOL_TYPE PoolType)
_____
Modified: trunk/reactos/drivers/usb/miniport/common/pdo.c
--- trunk/reactos/drivers/usb/miniport/common/pdo.c 2005-09-10
15:36:35 UTC (rev 17781)
+++ trunk/reactos/drivers/usb/miniport/common/pdo.c 2005-09-10
18:04:42 UTC (rev 17782)
@@ -1,22 +1,24 @@
/*
* COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS UHCI controller driver (Cromwell type)
- * FILE: drivers/usb/cromwell/uhci/pdo.c
+ * PROJECT: ReactOS USB miniport driver (Cromwell type)
+ * FILE: drivers/usb/miniport/common/pdo.c
* PURPOSE: IRP_MJ_PNP/IRP_MJ_DEVICE_CONTROL operations for
PDOs
*
- * PROGRAMMERS: HervÚ Poussineau (hpoussin(a)reactos.com),
+ * PROGRAMMERS: HervÚ Poussineau (hpoussin(a)reactos.org),
* James Tabor
(jimtabor(a)adsl-64-217-116-74.dsl.hstntx.swbell.net)
*/
#define NDEBUG
-#include "uhci.h"
+#include <debug.h>
+#include "usbcommon.h"
+
extern struct usb_driver hub_driver;
#define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003)
NTSTATUS
-UhciDeviceControlPdo(
+UsbMpDeviceControlPdo(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
@@ -24,7 +26,7 @@
ULONG_PTR Information = 0;
NTSTATUS Status;
- DPRINT("UHCI: UhciDeviceControlPdo() called\n");
+ DPRINT("USBMP: UsbMpDeviceControlPdo() called\n");
Stack = IoGetCurrentIrpStackLocation(Irp);
Status = Irp->IoStatus.Status;
@@ -33,9 +35,9 @@
{
case IOCTL_INTERNAL_USB_GET_ROOT_USB_DEVICE:
{
- POHCI_DEVICE_EXTENSION DeviceExtension;
+ PUSBMP_DEVICE_EXTENSION DeviceExtension;
- DPRINT("UHCI:
IOCTL_INTERNAL_USB_GET_ROOT_USB_DEVICE\n");
+ DPRINT("USBMP:
IOCTL_INTERNAL_USB_GET_ROOT_USB_DEVICE\n");
if (Irp->AssociatedIrp.SystemBuffer == NULL
||
Stack->Parameters.DeviceIoControl.OutputBufferLength != sizeof(PVOID))
{
@@ -44,8 +46,8 @@
else
{
PVOID* pRootHubPointer;
- DeviceExtension =
(POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
- DeviceExtension =
(POHCI_DEVICE_EXTENSION)DeviceExtension->FunctionalDeviceObject->DeviceE
xtension;
+ DeviceExtension =
(PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ DeviceExtension =
(PUSBMP_DEVICE_EXTENSION)DeviceExtension->FunctionalDeviceObject->Device
Extension;
pRootHubPointer =
(PVOID*)Irp->AssociatedIrp.SystemBuffer;
*pRootHubPointer =
(PVOID)DeviceExtension->pdev->bus; /* struct usb_device* */
@@ -56,7 +58,7 @@
}
default:
{
- DPRINT1("UHCI: Unknown IOCTL code 0x%lx\n",
Stack->Parameters.DeviceIoControl.IoControlCode);
+ DPRINT1("USBMP: Unknown IOCTL code 0x%lx\n",
Stack->Parameters.DeviceIoControl.IoControlCode);
Information = Irp->IoStatus.Information;
Status = Irp->IoStatus.Status;
}
@@ -69,57 +71,57 @@
}
static NTSTATUS
-UhciPdoQueryId(
+UsbMpPdoQueryId(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
OUT ULONG_PTR* Information)
{
- POHCI_DEVICE_EXTENSION DeviceExtension;
+ PUSBMP_DEVICE_EXTENSION DeviceExtension;
ULONG IdType;
UNICODE_STRING SourceString;
UNICODE_STRING String;
NTSTATUS Status;
IdType =
IoGetCurrentIrpStackLocation(Irp)->Parameters.QueryId.IdType;
- DeviceExtension =
(POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ DeviceExtension =
(PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
RtlInitUnicodeString(&String, NULL);
switch (IdType)
{
case BusQueryDeviceID:
{
- DPRINT("UHCI: IRP_MJ_PNP / IRP_MN_QUERY_ID /
BusQueryDeviceID\n");
+ DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_ID /
BusQueryDeviceID\n");
RtlInitUnicodeString(&SourceString,
L"USB\\ROOT_HUB");
break;
}
case BusQueryHardwareIDs:
{
- DPRINT("UHCI: IRP_MJ_PNP / IRP_MN_QUERY_ID /
BusQueryHardwareIDs\n");
+ DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_ID /
BusQueryHardwareIDs\n");
/* FIXME: Should return
USB\ROOT_HUB&VID????&PID????&REV????
USB\ROOT_HUB&VID????&PID????
USB\ROOT_HUB
*/
- UhciInitMultiSzString(&SourceString,
"USB\\ROOT_HUB", NULL);
+ UsbMpInitMultiSzString(&SourceString,
"USB\\ROOT_HUB", NULL);
break;
}
case BusQueryCompatibleIDs:
- DPRINT("UHCI: IRP_MJ_PNP / IRP_MN_QUERY_ID /
BusQueryCompatibleIDs\n");
+ DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_ID /
BusQueryCompatibleIDs\n");
/* No compatible ID */
*Information = 0;
return STATUS_NOT_SUPPORTED;
case BusQueryInstanceID:
{
- DPRINT("UHCI: IRP_MJ_PNP / IRP_MN_QUERY_ID /
BusQueryInstanceID\n");
+ DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_ID /
BusQueryInstanceID\n");
RtlInitUnicodeString(&SourceString, L"0000"); /*
FIXME */
break;
}
default:
- DPRINT1("UHCI: IRP_MJ_PNP / IRP_MN_QUERY_ID /
unknown query id type 0x%lx\n", IdType);
+ DPRINT1("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_ID /
unknown query id type 0x%lx\n", IdType);
return STATUS_NOT_SUPPORTED;
}
- Status = UhciDuplicateUnicodeString(
+ Status = UsbMpDuplicateUnicodeString(
&String,
&SourceString,
PagedPool);
@@ -128,13 +130,13 @@
}
static NTSTATUS
-UhciPnpStartDevice(
+UsbMpPnpStartDevice(
IN PDEVICE_OBJECT DeviceObject)
{
- POHCI_DEVICE_EXTENSION DeviceExtension;
+ PUSBMP_DEVICE_EXTENSION DeviceExtension;
NTSTATUS Status;
- DeviceExtension =
(POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ DeviceExtension =
(PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
/* Register device interface for root hub */
Status = IoRegisterDeviceInterface(
@@ -144,7 +146,7 @@
&DeviceExtension->HcdInterfaceName);
if (!NT_SUCCESS(Status))
{
- DPRINT("UHCI: IoRegisterDeviceInterface() failed with
status 0x%08lx\n", Status);
+ DPRINT("USBMP: IoRegisterDeviceInterface() failed with
status 0x%08lx\n", Status);
return Status;
}
@@ -152,7 +154,7 @@
}
NTSTATUS STDCALL
-UhciPnpPdo(
+UsbMpPnpPdo(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
@@ -168,15 +170,15 @@
{
case IRP_MN_START_DEVICE: /* 0x00 */
{
- DPRINT("UHCI: IRP_MJ_PNP /
IRP_MN_START_DEVICE\n");
- Status = UhciPnpStartDevice(DeviceObject);
+ DPRINT("USBMP: IRP_MJ_PNP /
IRP_MN_START_DEVICE\n");
+ Status = UsbMpPnpStartDevice(DeviceObject);
break;
}
case IRP_MN_QUERY_CAPABILITIES: /* 0x09 */
{
PDEVICE_CAPABILITIES DeviceCapabilities;
ULONG i;
- DPRINT("UHCI: IRP_MJ_PNP /
IRP_MN_QUERY_CAPABILITIES\n");
+ DPRINT("USBMP: IRP_MJ_PNP /
IRP_MN_QUERY_CAPABILITIES\n");
DeviceCapabilities =
(PDEVICE_CAPABILITIES)Stack->Parameters.DeviceCapabilities.Capabilities;
/* FIXME: capabilities can change with connected
device */
@@ -202,7 +204,7 @@
}
case IRP_MN_QUERY_RESOURCES: /* 0x0a */
{
- DPRINT("UHCI: IRP_MJ_PNP /
IRP_MN_QUERY_RESOURCES\n");
+ DPRINT("USBMP: IRP_MJ_PNP /
IRP_MN_QUERY_RESOURCES\n");
/* Root buses don't need resources, except the
ones of
* the usb controller. This PDO is the root bus
PDO, so
* report no resource by not changing
Information and
@@ -214,7 +216,7 @@
}
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: /* 0x0b */
{
- DPRINT("UHCI: IRP_MJ_PNP /
IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
+ DPRINT("USBMP: IRP_MJ_PNP /
IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
/* Root buses don't need resources, except the
ones of
* the usb controller. This PDO is the root bus
PDO, so
* report no resource by not changing
Information and
@@ -233,7 +235,7 @@
{
ULONG DescriptionSize;
PWSTR Description;
- DPRINT("UHCI: IRP_MJ_PNP /
IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription\n");
+ DPRINT("USBMP: IRP_MJ_PNP /
IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription\n");
Status = IoGetDeviceProperty(
DeviceObject,
@@ -268,7 +270,7 @@
}
default:
{
- DPRINT1("UHCI: IRP_MJ_PNP /
IRP_MN_QUERY_DEVICE_TEXT / unknown type 0x%lx\n",
+ DPRINT1("USBMP: IRP_MJ_PNP /
IRP_MN_QUERY_DEVICE_TEXT / unknown type 0x%lx\n",
Stack->Parameters.QueryDeviceText.DeviceTextType);
Status = STATUS_NOT_SUPPORTED;
}
@@ -278,7 +280,7 @@
#endif
case IRP_MN_QUERY_ID: /* 0x13 */
{
- Status = UhciPdoQueryId(DeviceObject, Irp,
&Information);
+ Status = UsbMpPdoQueryId(DeviceObject, Irp,
&Information);
break;
}
default:
@@ -286,7 +288,7 @@
/* We can't forward request to the lower driver,
because
* we are a Pdo, so we don't have lower
driver...
*/
- DPRINT1("UHCI: IRP_MJ_PNP / unknown minor
function 0x%lx\n", MinorFunction);
+ DPRINT1("USBMP: IRP_MJ_PNP / unknown minor
function 0x%lx\n", MinorFunction);
Information = Irp->IoStatus.Information;
Status = Irp->IoStatus.Status;
}
_____
Deleted: trunk/reactos/drivers/usb/miniport/common/uhci.c
--- trunk/reactos/drivers/usb/miniport/common/uhci.c 2005-09-10
15:36:35 UTC (rev 17781)
+++ trunk/reactos/drivers/usb/miniport/common/uhci.c 2005-09-10
18:04:42 UTC (rev 17782)
@@ -1,274 +0,0 @@
-/*
- ReactOS specific functions for UHCI module
- by Aleksey Bragin (aleksey(a)reactos.com)
- and HervÚ Poussineau (hpoussin(a)reactos.com)
- Some parts of code are inspired (or even just copied) from ReactOS
Videoport driver
-*/
-#define NDEBUG
-#define INITGUID
-#include "uhci.h"
-
-static ULONG DeviceNumber = 0; /* FIXME: what is that? */
-
[truncated at 1000 lines; 719 more skipped]