diff --git a/reactos/drivers/usb/miniport/usbuhci/cleanup.c b/reactos/drivers/usb/miniport/common/cleanup.c
similarity index 100%
rename from reactos/drivers/usb/miniport/usbuhci/cleanup.c
rename to reactos/drivers/usb/miniport/common/cleanup.c
diff --git a/reactos/drivers/usb/miniport/usbuhci/close.c b/reactos/drivers/usb/miniport/common/close.c
similarity index 100%
rename from reactos/drivers/usb/miniport/usbuhci/close.c
rename to reactos/drivers/usb/miniport/common/close.c
diff --git a/reactos/drivers/usb/miniport/common/common.xml b/reactos/drivers/usb/miniport/common/common.xml
new file mode 100644
index 00000000000..e4cdf1101a2
--- /dev/null
+++ b/reactos/drivers/usb/miniport/common/common.xml
@@ -0,0 +1,13 @@
+
+
+
+ ../linux
+
+ cleanup.c
+ close.c
+ create.c
+ fdo.c
+ misc.c
+ pdo.c
+ uhci.c
+
diff --git a/reactos/drivers/usb/miniport/usbuhci/create.c b/reactos/drivers/usb/miniport/common/create.c
similarity index 100%
rename from reactos/drivers/usb/miniport/usbuhci/create.c
rename to reactos/drivers/usb/miniport/common/create.c
diff --git a/reactos/drivers/usb/miniport/usbuhci/fdo.c b/reactos/drivers/usb/miniport/common/fdo.c
similarity index 85%
rename from reactos/drivers/usb/miniport/usbuhci/fdo.c
rename to reactos/drivers/usb/miniport/common/fdo.c
index 6e32df48c7b..e2d69b65963 100644
--- a/reactos/drivers/usb/miniport/usbuhci/fdo.c
+++ b/reactos/drivers/usb/miniport/common/fdo.c
@@ -11,57 +11,6 @@
#define NDEBUG
#include "uhci.h"
-/* declare basic init functions and structures */
-int uhci_hcd_init(void);
-int STDCALL usb_init(void);
-
-extern struct pci_driver uhci_pci_driver;
-extern struct pci_device_id uhci_pci_ids[];
-
-static NTSTATUS
-InitLinuxWrapper(PDEVICE_OBJECT DeviceObject)
-{
- NTSTATUS Status = STATUS_SUCCESS;
-
- POHCI_DEVICE_EXTENSION DeviceExtension = (POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
- /* Create generic linux structure */
- struct pci_dev *dev;
- dev = ExAllocatePoolWithTag(PagedPool, sizeof(struct pci_dev), USB_UHCI_TAG);
- DeviceExtension->pdev = dev;
-
- /* Initialize generic linux structure */
- dev->irq = DeviceExtension->InterruptVector;
- dev->dev_ext = (PVOID)DeviceExtension;
- dev->slot_name = ExAllocatePoolWithTag(NonPagedPool, 128, USB_UHCI_TAG); // 128 max len for slot name
- init_wrapper(dev);
-
- strcpy(dev->dev.name, "UnivHCI PCI-USB Controller");
- strcpy(dev->slot_name, "UHCD PCI Slot");
-
- /* Init the OHCI HCD. Probe will be called automatically, but will fail because id=NULL */
- Status = uhci_hcd_init();
- if (!NT_SUCCESS(Status))
- {
- DPRINT("UHCI: uhci_hcd_init() failed with status 0x%08lx\n", Status);
- /* FIXME: deinitialize linux wrapper */
- ExFreePoolWithTag(dev, USB_UHCI_TAG);
- return Status;
- }
-
- /* Init core usb */
- usb_init();
-
- /* Probe device with real id now */
- uhci_pci_driver.probe(dev, uhci_pci_ids);
-
-// DPRINT1("UHCI :SysIoBusNumA %d\n",DeviceExtension->SystemIoBusNumber);
-// DeviceExtension->SystemIoBusNumber = dev->bus->number;
-// DPRINT1("UHCI: SysIoBusNumB %d\n",DeviceExtension->SystemIoBusNumber);
-
- return Status;
-}
-
#define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003)
static VOID
@@ -167,7 +116,7 @@ UhciFdoStartDevice(
DeviceExtension->BaseAddrLength = Descriptor->u.Port.Length;
DeviceExtension->Flags = Descriptor->Flags;
- ((struct hc_driver *)uhci_pci_ids->driver_data)->flags &= ~HCD_MEMORY;
+ ((struct hc_driver *)(*pci_ids)->driver_data)->flags &= ~HCD_MEMORY;
}
else if (Descriptor->Type == CmResourceTypeMemory)
{
@@ -175,7 +124,7 @@ UhciFdoStartDevice(
DeviceExtension->BaseAddrLength = Descriptor->u.Memory.Length;
DeviceExtension->Flags = Descriptor->Flags;
- ((struct hc_driver *)uhci_pci_ids->driver_data)->flags |= HCD_MEMORY;
+ ((struct hc_driver *)(*pci_ids)->driver_data)->flags |= HCD_MEMORY;
}
}
}
@@ -184,7 +133,7 @@ UhciFdoStartDevice(
/* Print assigned resources */
DPRINT("UHCI: Interrupt Vector 0x%lx, %S base 0x%lx, Length 0x%lx\n",
DeviceExtension->InterruptVector,
- ((struct hc_driver *)uhci_pci_ids->driver_data)->flags & HCD_MEMORY ? L"Memory" : L"I/O",
+ ((struct hc_driver *)(*pci_ids)->driver_data)->flags & HCD_MEMORY ? L"Memory" : L"I/O",
DeviceExtension->BaseAddress,
DeviceExtension->BaseAddrLength);
diff --git a/reactos/drivers/usb/miniport/usbuhci/misc.c b/reactos/drivers/usb/miniport/common/misc.c
similarity index 95%
rename from reactos/drivers/usb/miniport/usbuhci/misc.c
rename to reactos/drivers/usb/miniport/common/misc.c
index db16b3bdc51..aa620b88a38 100644
--- a/reactos/drivers/usb/miniport/usbuhci/misc.c
+++ b/reactos/drivers/usb/miniport/common/misc.c
@@ -85,9 +85,13 @@ UhciInitMultiSzString(
Source = va_arg(args, PCSZ);
while (Source != NULL)
{
+ DPRINT1("Source = %s\n", Source);
RtlInitAnsiString(&AnsiString, Source);
+ DPRINT1("AnsiString = %Z\n", &AnsiString);
+ DPRINT1("NLS_MB_CODE_PAGE_TAG = %lu\n", (ULONG)NLS_MB_CODE_PAGE_TAG);
DestinationSize += RtlAnsiStringToUnicodeSize(&AnsiString)
+ sizeof(WCHAR) /* final NULL */;
+ DPRINT1("DestinationSize = %lu\n", DestinationSize);
Source = va_arg(args, PCSZ);
}
va_end(args);
diff --git a/reactos/drivers/usb/miniport/usbuhci/pdo.c b/reactos/drivers/usb/miniport/common/pdo.c
similarity index 100%
rename from reactos/drivers/usb/miniport/usbuhci/pdo.c
rename to reactos/drivers/usb/miniport/common/pdo.c
diff --git a/reactos/drivers/usb/miniport/common/uhci.c b/reactos/drivers/usb/miniport/common/uhci.c
new file mode 100644
index 00000000000..773193591ec
--- /dev/null
+++ b/reactos/drivers/usb/miniport/common/uhci.c
@@ -0,0 +1,274 @@
+/*
+ ReactOS specific functions for UHCI module
+ by Aleksey Bragin (aleksey@reactos.com)
+ and Hervé Poussineau (hpoussin@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? */
+
+static NTSTATUS
+CreateRootHubPdo(
+ IN PDRIVER_OBJECT DriverObject,
+ IN PDEVICE_OBJECT Fdo,
+ OUT PDEVICE_OBJECT* pPdo)
+{
+ PDEVICE_OBJECT Pdo;
+ POHCI_DEVICE_EXTENSION DeviceExtension;
+ NTSTATUS Status;
+
+ DPRINT("UHCI: CreateRootHubPdo()\n");
+
+ Status = IoCreateDevice(
+ DriverObject,
+ sizeof(OHCI_DEVICE_EXTENSION),
+ NULL, /* DeviceName */
+ FILE_DEVICE_BUS_EXTENDER,
+ FILE_DEVICE_SECURE_OPEN | FILE_AUTOGENERATED_DEVICE_NAME,
+ FALSE,
+ &Pdo);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("UHCI: 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 = (POHCI_DEVICE_EXTENSION)Pdo->DeviceExtension;
+ RtlZeroMemory(DeviceExtension, sizeof(OHCI_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;
+ POHCI_DRIVER_EXTENSION DriverExtension;
+ POHCI_DEVICE_EXTENSION DeviceExtension;
+
+ DPRINT("UHCI: AddDevice called\n");
+
+ // Allocate driver extension now
+ DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
+ if (DriverExtension == NULL)
+ {
+ Status = IoAllocateDriverObjectExtension(
+ DriverObject,
+ DriverObject,
+ sizeof(OHCI_DRIVER_EXTENSION),
+ (PVOID *)&DriverExtension);
+
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("UHCI: 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(OHCI_DEVICE_EXTENSION),
+ &DeviceName,
+ FILE_DEVICE_BUS_EXTENDER,
+ 0,
+ FALSE,
+ &fdo);
+
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("UHCI: IoCreateDevice call failed with status 0x%08lx\n", Status);
+ return Status;
+ }
+
+ // zerofill device extension
+ DeviceExtension = (POHCI_DEVICE_EXTENSION)fdo->DeviceExtension;
+ RtlZeroMemory(DeviceExtension, sizeof(OHCI_DEVICE_EXTENSION));
+
+ /* Create root hub Pdo */
+ Status = CreateRootHubPdo(DriverObject, fdo, &DeviceExtension->RootHubPdo);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("UHCI: 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("UHCI: 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("UHCI: 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 (((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
+ {
+ DPRINT1("UHCI: 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("UHCI: 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 (((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
+ return UhciCreate(DeviceObject, Irp);
+ else
+ return IrpStub(DeviceObject, Irp);
+}
+
+static NTSTATUS STDCALL
+DispatchClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+ if (((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
+ return UhciClose(DeviceObject, Irp);
+ else
+ return IrpStub(DeviceObject, Irp);
+}
+
+static NTSTATUS STDCALL
+DispatchCleanup(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+ if (((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
+ return UhciCleanup(DeviceObject, Irp);
+ else
+ return IrpStub(DeviceObject, Irp);
+}
+
+static NTSTATUS STDCALL
+DispatchDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+ if (((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
+ return UhciDeviceControlFdo(DeviceObject, Irp);
+ else
+ return UhciDeviceControlPdo(DeviceObject, Irp);
+}
+
+static NTSTATUS STDCALL
+DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+ if (((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
+ return UhciPnpFdo(DeviceObject, Irp);
+ else
+ return UhciPnpPdo(DeviceObject, Irp);
+}
+
+static NTSTATUS STDCALL
+DispatchPower(PDEVICE_OBJECT fido, PIRP Irp)
+{
+ DPRINT1("UHCI: 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;
+ DPRINT("********* Cromwell UHCI *********\n");
+
+ 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;
+}
diff --git a/reactos/drivers/usb/miniport/usbuhci/uhci.h b/reactos/drivers/usb/miniport/common/uhci.h
similarity index 87%
rename from reactos/drivers/usb/miniport/usbuhci/uhci.h
rename to reactos/drivers/usb/miniport/common/uhci.h
index adb7569f909..949eaacd475 100644
--- a/reactos/drivers/usb/miniport/usbuhci/uhci.h
+++ b/reactos/drivers/usb/miniport/common/uhci.h
@@ -73,3 +73,12 @@ NTSTATUS
UhciDeviceControlPdo(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
+
+/* Needed by this object library */
+VOID STDCALL
+DriverUnload(PDRIVER_OBJECT DriverObject);
+
+NTSTATUS
+InitLinuxWrapper(PDEVICE_OBJECT DeviceObject);
+
+extern struct pci_device_id** pci_ids;
diff --git a/reactos/drivers/usb/miniport/directory.xml b/reactos/drivers/usb/miniport/directory.xml
index 2dc67f1c79e..16006f713db 100644
--- a/reactos/drivers/usb/miniport/directory.xml
+++ b/reactos/drivers/usb/miniport/directory.xml
@@ -1,3 +1,6 @@
+
+
+
diff --git a/reactos/drivers/usb/miniport/usbuhci/uhci.c b/reactos/drivers/usb/miniport/usbuhci/uhci.c
index 4711859efe3..5f3e443bb5a 100644
--- a/reactos/drivers/usb/miniport/usbuhci/uhci.c
+++ b/reactos/drivers/usb/miniport/usbuhci/uhci.c
@@ -1,169 +1,64 @@
/*
ReactOS specific functions for UHCI module
by Aleksey Bragin (aleksey@reactos.com)
- and Hervé Poussineau (hpoussin@reactos.com)
+ and Hervé Poussineau (hpoussin@reactos.org)
Some parts of code are inspired (or even just copied) from ReactOS Videoport driver
*/
#define NDEBUG
-#define INITGUID
#include "uhci.h"
/* declare basic init functions and structures */
+int uhci_hcd_init(void);
void uhci_hcd_cleanup(void);
+int STDCALL usb_init(void);
void STDCALL usb_exit(void);
extern struct pci_driver uhci_pci_driver;
+extern struct pci_device_id* uhci_pci_ids;
+struct pci_device_id** pci_ids = &uhci_pci_ids;
-static ULONG DeviceNumber = 0; /* FIXME: what is that? */
-
-static NTSTATUS
-CreateRootHubPdo(
- IN PDRIVER_OBJECT DriverObject,
- IN PDEVICE_OBJECT Fdo,
- OUT PDEVICE_OBJECT* pPdo)
+NTSTATUS
+InitLinuxWrapper(PDEVICE_OBJECT DeviceObject)
{
- PDEVICE_OBJECT Pdo;
- POHCI_DEVICE_EXTENSION DeviceExtension;
- NTSTATUS Status;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ POHCI_DEVICE_EXTENSION DeviceExtension = (POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
- DPRINT("UHCI: CreateRootHubPdo()\n");
+ /* Create generic linux structure */
+ struct pci_dev *dev;
+ dev = ExAllocatePoolWithTag(PagedPool, sizeof(struct pci_dev), USB_UHCI_TAG);
+ DeviceExtension->pdev = dev;
- Status = IoCreateDevice(
- DriverObject,
- sizeof(OHCI_DEVICE_EXTENSION),
- NULL, /* DeviceName */
- FILE_DEVICE_BUS_EXTENDER,
- FILE_DEVICE_SECURE_OPEN | FILE_AUTOGENERATED_DEVICE_NAME,
- FALSE,
- &Pdo);
+ /* Initialize generic linux structure */
+ dev->irq = DeviceExtension->InterruptVector;
+ dev->dev_ext = (PVOID)DeviceExtension;
+ dev->slot_name = ExAllocatePoolWithTag(NonPagedPool, 128, USB_UHCI_TAG); // 128 max len for slot name
+ init_wrapper(dev);
+
+ strcpy(dev->dev.name, "UnivHCI PCI-USB Controller");
+ strcpy(dev->slot_name, "UHCD PCI Slot");
+
+ /* Init the OHCI HCD. Probe will be called automatically, but will fail because id=NULL */
+ Status = uhci_hcd_init();
if (!NT_SUCCESS(Status))
{
- DPRINT("UHCI: 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 = (POHCI_DEVICE_EXTENSION)Pdo->DeviceExtension;
- RtlZeroMemory(DeviceExtension, sizeof(OHCI_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;
- POHCI_DRIVER_EXTENSION DriverExtension;
- POHCI_DEVICE_EXTENSION DeviceExtension;
-
- DPRINT("UHCI: AddDevice called\n");
-
- // Allocate driver extension now
- DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
- if (DriverExtension == NULL)
- {
- Status = IoAllocateDriverObjectExtension(
- DriverObject,
- DriverObject,
- sizeof(OHCI_DRIVER_EXTENSION),
- (PVOID *)&DriverExtension);
-
- if (!NT_SUCCESS(Status))
- {
- DPRINT("UHCI: 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(OHCI_DEVICE_EXTENSION),
- &DeviceName,
- FILE_DEVICE_BUS_EXTENDER,
- 0,
- FALSE,
- &fdo);
-
- if (!NT_SUCCESS(Status))
- {
- DPRINT("UHCI: IoCreateDevice call failed with status 0x%08lx\n", Status);
+ DPRINT("UHCI: uhci_hcd_init() failed with status 0x%08lx\n", Status);
+ /* FIXME: deinitialize linux wrapper */
+ ExFreePoolWithTag(dev, USB_UHCI_TAG);
return Status;
}
- // zerofill device extension
- DeviceExtension = (POHCI_DEVICE_EXTENSION)fdo->DeviceExtension;
- RtlZeroMemory(DeviceExtension, sizeof(OHCI_DEVICE_EXTENSION));
-
- /* Create root hub Pdo */
- Status = CreateRootHubPdo(DriverObject, fdo, &DeviceExtension->RootHubPdo);
- if (!NT_SUCCESS(Status))
- {
- DPRINT("UHCI: CreateRootHubPdo() failed with status 0x%08lx\n", Status);
- IoDeleteDevice(fdo);
- return Status;
- }
+ /* Init core usb */
+ usb_init();
- /* Register device interface for controller */
- Status = IoRegisterDeviceInterface(
- pdo,
- &GUID_DEVINTERFACE_USB_HOST_CONTROLLER,
- NULL,
- &DeviceExtension->HcdInterfaceName);
- if (!NT_SUCCESS(Status))
- {
- DPRINT("UHCI: IoRegisterDeviceInterface() failed with status 0x%08lx\n", Status);
- IoDeleteDevice(DeviceExtension->RootHubPdo);
- IoDeleteDevice(fdo);
- return Status;
- }
+ /* Probe device with real id now */
+ uhci_pci_driver.probe(dev, uhci_pci_ids);
- DeviceExtension->NextDeviceObject = IoAttachDeviceToDeviceStack(fdo, pdo);
+// DPRINT1("UHCI :SysIoBusNumA %d\n",DeviceExtension->SystemIoBusNumber);
+// DeviceExtension->SystemIoBusNumber = dev->bus->number;
+// DPRINT1("UHCI: SysIoBusNumB %d\n",DeviceExtension->SystemIoBusNumber);
- 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("UHCI: IoCreateSymbolicLink call failed with status 0x%08x\n", Status);
- IoDeleteDevice(DeviceExtension->RootHubPdo);
- IoDeleteDevice(fdo);
- return Status;
- }
-
- return STATUS_SUCCESS;
+ return Status;
}
VOID STDCALL
@@ -192,116 +87,3 @@ DriverUnload(PDRIVER_OBJECT DriverObject)
// Perform some cleanup
uhci_hcd_cleanup();
}
-
-NTSTATUS STDCALL
-IrpStub(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- NTSTATUS Status = STATUS_NOT_SUPPORTED;
-
- if (((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
- {
- DPRINT1("UHCI: 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("UHCI: 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 (((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
- return UhciCreate(DeviceObject, Irp);
- else
- return IrpStub(DeviceObject, Irp);
-}
-
-static NTSTATUS STDCALL
-DispatchClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
-{
- if (((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
- return UhciClose(DeviceObject, Irp);
- else
- return IrpStub(DeviceObject, Irp);
-}
-
-static NTSTATUS STDCALL
-DispatchCleanup(PDEVICE_OBJECT DeviceObject, PIRP Irp)
-{
- if (((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
- return UhciCleanup(DeviceObject, Irp);
- else
- return IrpStub(DeviceObject, Irp);
-}
-
-static NTSTATUS STDCALL
-DispatchDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
-{
- if (((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
- return UhciDeviceControlFdo(DeviceObject, Irp);
- else
- return UhciDeviceControlPdo(DeviceObject, Irp);
-}
-
-static NTSTATUS STDCALL
-DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
-{
- if (((POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
- return UhciPnpFdo(DeviceObject, Irp);
- else
- return UhciPnpPdo(DeviceObject, Irp);
-}
-
-static NTSTATUS STDCALL
-DispatchPower(PDEVICE_OBJECT fido, PIRP Irp)
-{
- DPRINT1("UHCI: 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;
- DPRINT("********* Cromwell UHCI *********\n");
-
- 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;
-}
diff --git a/reactos/drivers/usb/miniport/usbuhci/usbuhci.xml b/reactos/drivers/usb/miniport/usbuhci/usbuhci.xml
index c81699478d6..8268ddce8b4 100644
--- a/reactos/drivers/usb/miniport/usbuhci/usbuhci.xml
+++ b/reactos/drivers/usb/miniport/usbuhci/usbuhci.xml
@@ -3,16 +3,12 @@
../linux
+
sys_base
+ usbminiportcommon
+ usbport
ntoskrnl
hal
- usbport
- cleanup.c
- close.c
- create.c
- fdo.c
- misc.c
- pdo.c
uhci.c
uhci-hcd.c
uhci.rc