Move common code of USB miniport drivers into drivers/usb/miniport/common library

svn path=/trunk/; revision=17776
This commit is contained in:
Hervé Poussineau 2005-09-10 15:17:07 +00:00
parent e76d9c0ae2
commit f03b5bcdff
12 changed files with 345 additions and 315 deletions

View file

@ -0,0 +1,13 @@
<module name="usbminiportcommon" type="objectlibrary">
<define name="__USE_W32API" />
<define name="DEBUG_MODE" />
<include>../linux</include>
<include base="usbport"></include>
<file>cleanup.c</file>
<file>close.c</file>
<file>create.c</file>
<file>fdo.c</file>
<file>misc.c</file>
<file>pdo.c</file>
<file>uhci.c</file>
</module>

View file

@ -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);

View file

@ -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);

View file

@ -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;
}

View file

@ -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;

View file

@ -1,3 +1,6 @@
<directory name="common">
<xi:include href="common/common.xml" />
</directory>
<directory name="sys">
<xi:include href="sys/sys.xml" />
</directory>

View file

@ -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;
}

View file

@ -3,16 +3,12 @@
<define name="DEBUG_MODE" />
<include>../linux</include>
<include base="usbport"></include>
<include base="usbminiportcommon"></include>
<library>sys_base</library>
<library>usbminiportcommon</library>
<library>usbport</library>
<library>ntoskrnl</library>
<library>hal</library>
<library>usbport</library>
<file>cleanup.c</file>
<file>close.c</file>
<file>create.c</file>
<file>fdo.c</file>
<file>misc.c</file>
<file>pdo.c</file>
<file>uhci.c</file>
<file>uhci-hcd.c</file>
<file>uhci.rc</file>