Author: cgutman
Date: Sat Jan 21 02:59:46 2012
New Revision: 55041
URL:
http://svn.reactos.org/svn/reactos?rev=55041&view=rev
Log:
[USB-BRINGUP-TRUNK]
- Open a file handle to the port driver like Windows does
- USB mice are working now
Modified:
branches/usb-bringup-trunk/drivers/input/kbdclass/kbdclass.c
branches/usb-bringup-trunk/drivers/input/kbdclass/kbdclass.h
branches/usb-bringup-trunk/drivers/input/mouclass/mouclass.c
branches/usb-bringup-trunk/drivers/input/mouclass/mouclass.h
Modified: branches/usb-bringup-trunk/drivers/input/kbdclass/kbdclass.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/input…
==============================================================================
--- branches/usb-bringup-trunk/drivers/input/kbdclass/kbdclass.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/input/kbdclass/kbdclass.c [iso-8859-1] Sat Jan 21
02:59:46 2012
@@ -824,6 +824,72 @@
return Status;
}
+static NTSTATUS NTAPI
+ClassPnp(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ PPORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
+ PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ IO_STATUS_BLOCK Iosb;
+ NTSTATUS Status;
+
+ switch (IrpSp->MinorFunction)
+ {
+ case IRP_MN_START_DEVICE:
+ Status = ForwardIrpAndWait(DeviceObject, Irp);
+ if (NT_SUCCESS(Status))
+ {
+ InitializeObjectAttributes(&ObjectAttributes,
+ &DeviceExtension->InterfaceName,
+ OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
+ NULL,
+ NULL);
+
+ Status = ZwOpenFile(&DeviceExtension->FileHandle,
+ FILE_READ_DATA,
+ &ObjectAttributes,
+ &Iosb,
+ 0,
+ 0);
+ if (!NT_SUCCESS(Status))
+ DeviceExtension->FileHandle = NULL;
+ }
+ else
+ DeviceExtension->FileHandle = NULL;
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
+
+ case IRP_MN_REMOVE_DEVICE:
+ case IRP_MN_STOP_DEVICE:
+ if (DeviceExtension->FileHandle)
+ {
+ ZwClose(DeviceExtension->FileHandle);
+ DeviceExtension->FileHandle = NULL;
+ }
+ Status = STATUS_SUCCESS;
+ break;
+
+ default:
+ Status = Irp->IoStatus.Status;
+ break;
+ }
+
+ Irp->IoStatus.Status = Status;
+ if (NT_SUCCESS(Status))
+ {
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(DeviceExtension->LowerDevice, Irp);
+ }
+ else
+ {
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
+ }
+}
+
static VOID NTAPI
ClassStartIo(
IN PDEVICE_OBJECT DeviceObject,
@@ -1021,6 +1087,7 @@
DriverObject->MajorFunction[IRP_MJ_CLOSE] = ClassClose;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = ClassCleanup;
DriverObject->MajorFunction[IRP_MJ_READ] = ClassRead;
+ DriverObject->MajorFunction[IRP_MJ_PNP] = ClassPnp;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ClassDeviceControl;
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = ForwardIrpAndForget;
DriverObject->DriverStartIo = ClassStartIo;
Modified: branches/usb-bringup-trunk/drivers/input/kbdclass/kbdclass.h
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/input…
==============================================================================
--- branches/usb-bringup-trunk/drivers/input/kbdclass/kbdclass.h [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/input/kbdclass/kbdclass.h [iso-8859-1] Sat Jan 21
02:59:46 2012
@@ -48,6 +48,7 @@
PORT_DEVICE_STATE PnpState;
PDEVICE_OBJECT LowerDevice;
PDEVICE_OBJECT ClassDO;
+ HANDLE FileHandle;
UNICODE_STRING InterfaceName;
} PORT_DEVICE_EXTENSION, *PPORT_DEVICE_EXTENSION;
Modified: branches/usb-bringup-trunk/drivers/input/mouclass/mouclass.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/input…
==============================================================================
--- branches/usb-bringup-trunk/drivers/input/mouclass/mouclass.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/input/mouclass/mouclass.c [iso-8859-1] Sat Jan 21
02:59:46 2012
@@ -800,6 +800,72 @@
return Status;
}
+static NTSTATUS NTAPI
+ClassPnp(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ PPORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
+ PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ IO_STATUS_BLOCK Iosb;
+ NTSTATUS Status;
+
+ switch (IrpSp->MinorFunction)
+ {
+ case IRP_MN_START_DEVICE:
+ Status = ForwardIrpAndWait(DeviceObject, Irp);
+ if (NT_SUCCESS(Status))
+ {
+ InitializeObjectAttributes(&ObjectAttributes,
+ &DeviceExtension->InterfaceName,
+ OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
+ NULL,
+ NULL);
+
+ Status = ZwOpenFile(&DeviceExtension->FileHandle,
+ FILE_READ_DATA,
+ &ObjectAttributes,
+ &Iosb,
+ 0,
+ 0);
+ if (!NT_SUCCESS(Status))
+ DeviceExtension->FileHandle = NULL;
+ }
+ else
+ DeviceExtension->FileHandle = NULL;
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
+
+ case IRP_MN_REMOVE_DEVICE:
+ case IRP_MN_STOP_DEVICE:
+ if (DeviceExtension->FileHandle)
+ {
+ ZwClose(DeviceExtension->FileHandle);
+ DeviceExtension->FileHandle = NULL;
+ }
+ Status = STATUS_SUCCESS;
+ break;
+
+ default:
+ Status = Irp->IoStatus.Status;
+ break;
+ }
+
+ Irp->IoStatus.Status = Status;
+ if (NT_SUCCESS(Status))
+ {
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(DeviceExtension->LowerDevice, Irp);
+ }
+ else
+ {
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
+ }
+}
+
static VOID NTAPI
ClassStartIo(
IN PDEVICE_OBJECT DeviceObject,
@@ -993,6 +1059,7 @@
DriverObject->MajorFunction[IRP_MJ_CLOSE] = ClassClose;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = ClassCleanup;
DriverObject->MajorFunction[IRP_MJ_READ] = ClassRead;
+ DriverObject->MajorFunction[IRP_MJ_PNP] = ClassPnp;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ClassDeviceControl;
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = ForwardIrpAndForget;
DriverObject->DriverStartIo = ClassStartIo;
Modified: branches/usb-bringup-trunk/drivers/input/mouclass/mouclass.h
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/input…
==============================================================================
--- branches/usb-bringup-trunk/drivers/input/mouclass/mouclass.h [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/input/mouclass/mouclass.h [iso-8859-1] Sat Jan 21
02:59:46 2012
@@ -48,6 +48,7 @@
PORT_DEVICE_STATE PnpState;
PDEVICE_OBJECT LowerDevice;
PDEVICE_OBJECT ClassDO;
+ HANDLE FileHandle;
UNICODE_STRING InterfaceName;
} PORT_DEVICE_EXTENSION, *PPORT_DEVICE_EXTENSION;