Author: hpoussin
Date: Sat May 6 18:36:52 2006
New Revision: 21812
URL:
http://svn.reactos.ru/svn/reactos?rev=21812&view=rev
Log:
Code cleanup:
- Move IRP_MJ_CREATE, IRP_MJ_CLOSE and IRP_MJ_CLEANUP to fdo.c and pdo.c
- Implement IRP_MJ_PNP / IRP_MN_QUERY_BUS_INFORMATION for PDOs
- IRP_MJ_POWER now returns STATUS_NOT_SUPPORTED instead of STATUS_SUCCESS
- Replace STDCALL by NTAPI
- Delete useless white space
=> USB keyboard and mice are working, even if they require one reboot after the
installation of the USB controller
Removed:
trunk/reactos/drivers/usb/miniport/common/cleanup.c
trunk/reactos/drivers/usb/miniport/common/close.c
trunk/reactos/drivers/usb/miniport/common/create.c
Modified:
trunk/reactos/drivers/usb/miniport/common/common.rbuild
trunk/reactos/drivers/usb/miniport/common/fdo.c
trunk/reactos/drivers/usb/miniport/common/main.c
trunk/reactos/drivers/usb/miniport/common/misc.c
trunk/reactos/drivers/usb/miniport/common/pdo.c
trunk/reactos/drivers/usb/miniport/common/usbcommon.h
Removed: trunk/reactos/drivers/usb/miniport/common/cleanup.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/usb/miniport/common…
==============================================================================
--- trunk/reactos/drivers/usb/miniport/common/cleanup.c (original)
+++ trunk/reactos/drivers/usb/miniport/common/cleanup.c (removed)
@@ -1,26 +1,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * 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.org)
- */
-
-#define NDEBUG
-#include <debug.h>
-
-#include "usbcommon.h"
-
-NTSTATUS STDCALL
-UsbMpCleanup(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- DPRINT("USBMP: IRP_MJ_CLEANUP\n");
-
- Irp->IoStatus.Information = 0;
- Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SUCCESS;
-}
Removed: trunk/reactos/drivers/usb/miniport/common/close.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/usb/miniport/common…
==============================================================================
--- trunk/reactos/drivers/usb/miniport/common/close.c (original)
+++ trunk/reactos/drivers/usb/miniport/common/close.c (removed)
@@ -1,30 +1,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * 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.org)
- */
-
-#define NDEBUG
-#include <debug.h>
-
-#include "usbcommon.h"
-
-NTSTATUS STDCALL
-UsbMpClose(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- PUSBMP_DEVICE_EXTENSION pDeviceExtension;
-
- DPRINT("USBMP: IRP_MJ_CLOSE\n");
- pDeviceExtension = (PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
- InterlockedDecrement((PLONG)&pDeviceExtension->DeviceOpened);
-
- Irp->IoStatus.Information = 0;
- Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SUCCESS;
-}
Modified: trunk/reactos/drivers/usb/miniport/common/common.rbuild
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/usb/miniport/common…
==============================================================================
--- trunk/reactos/drivers/usb/miniport/common/common.rbuild (original)
+++ trunk/reactos/drivers/usb/miniport/common/common.rbuild Sat May 6 18:36:52 2006
@@ -2,9 +2,6 @@
<define name="__USE_W32API" />
<include>../linux</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>
Removed: trunk/reactos/drivers/usb/miniport/common/create.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/usb/miniport/common…
==============================================================================
--- trunk/reactos/drivers/usb/miniport/common/create.c (original)
+++ trunk/reactos/drivers/usb/miniport/common/create.c (removed)
@@ -1,43 +1,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * 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.org)
- */
-
-#define NDEBUG
-#include <debug.h>
-
-#include "usbcommon.h"
-
-NTSTATUS STDCALL
-UsbMpCreate(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- PIO_STACK_LOCATION Stack;
- PUSBMP_DEVICE_EXTENSION DeviceExtension;
- NTSTATUS Status;
-
- DPRINT("USBMP: IRP_MJ_CREATE\n");
- Stack = IoGetCurrentIrpStackLocation(Irp);
- DeviceExtension = (PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
- if (Stack->Parameters.Create.Options & FILE_DIRECTORY_FILE)
- {
- CHECKPOINT;
- Status = STATUS_NOT_A_DIRECTORY;
- goto ByeBye;
- }
-
- InterlockedIncrement((PLONG)&DeviceExtension->DeviceOpened);
- Status = STATUS_SUCCESS;
-
-ByeBye:
- Irp->IoStatus.Status = Status;
- Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return Status;
-}
Modified: trunk/reactos/drivers/usb/miniport/common/fdo.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/usb/miniport/common…
==============================================================================
--- trunk/reactos/drivers/usb/miniport/common/fdo.c (original)
+++ trunk/reactos/drivers/usb/miniport/common/fdo.c Sat May 6 18:36:52 2006
@@ -1,11 +1,10 @@
/*
- * COPYRIGHT: See COPYING in the top level directory
- * 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.org),
- * James Tabor (jimtabor(a)adsl-64-217-116-74.dsl.hstntx.swbell.net)
+ * PROJECT: ReactOS USB miniport driver (Cromwell type)
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: drivers/usb/miniport/common/fdo.c
+ * PURPOSE: Operations on FDOs
+ * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin(a)reactos.org)
+ * Copyright James Tabor
(jimtabor(a)adsl-64-217-116-74.dsl.hstntx.swbell.net)
*/
#define NDEBUG
@@ -48,7 +47,67 @@
}
}
-NTSTATUS STDCALL
+NTSTATUS
+UsbMpFdoCreate(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ PIO_STACK_LOCATION Stack;
+ PUSBMP_DEVICE_EXTENSION DeviceExtension;
+ NTSTATUS Status;
+
+ DPRINT("IRP_MJ_CREATE\n");
+ Stack = IoGetCurrentIrpStackLocation(Irp);
+ DeviceExtension = (PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+ if (Stack->Parameters.Create.Options & FILE_DIRECTORY_FILE)
+ {
+ CHECKPOINT;
+ Status = STATUS_NOT_A_DIRECTORY;
+ goto ByeBye;
+ }
+
+ InterlockedIncrement((PLONG)&DeviceExtension->DeviceOpened);
+ Status = STATUS_SUCCESS;
+
+ByeBye:
+ Irp->IoStatus.Status = Status;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
+}
+
+NTSTATUS
+UsbMpFdoClose(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ PUSBMP_DEVICE_EXTENSION pDeviceExtension;
+
+ DPRINT("IRP_MJ_CLOSE\n");
+ pDeviceExtension = (PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ InterlockedDecrement((PLONG)&pDeviceExtension->DeviceOpened);
+
+ Irp->IoStatus.Information = 0;
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+UsbMpFdoCleanup(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ DPRINT("IRP_MJ_CLEANUP\n");
+
+ Irp->IoStatus.Information = 0;
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+}
+
+static NTSTATUS
UsbMpFdoStartDevice(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
@@ -136,9 +195,9 @@
}
}
}
-
+
/* Print assigned resources */
- DPRINT("USBMP: Interrupt Vector 0x%lx, %S base 0x%lx, Length 0x%lx\n",
+ DPRINT("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,
@@ -155,11 +214,11 @@
if (!NT_SUCCESS(Status))
{
- DPRINT1("USBMP: IoGetDeviceProperty DevicePropertyBusNumber failed\n");
+ DPRINT1("IoGetDeviceProperty DevicePropertyBusNumber failed\n");
DeviceExtension->SystemIoBusNumber = 0;
}
- DPRINT("USBMP: Busnumber %d\n", DeviceExtension->SystemIoBusNumber);
+ DPRINT("Busnumber %d\n", DeviceExtension->SystemIoBusNumber);
/* Init wrapper with this object */
return InitLinuxWrapper(DeviceObject);
@@ -173,9 +232,9 @@
PUSBMP_DEVICE_EXTENSION DeviceExtension;
PDEVICE_RELATIONS DeviceRelations;
NTSTATUS Status = STATUS_SUCCESS;
-
+
DeviceExtension = (PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
+
/* Handling this IRP is easy, as we only
* have one child: the root hub
*/
@@ -184,18 +243,18 @@
sizeof(DEVICE_RELATIONS));
if (!DeviceRelations)
return STATUS_INSUFFICIENT_RESOURCES;
-
+
/* Fill returned structure */
DeviceRelations->Count = 1;
ObReferenceObject(DeviceExtension->RootHubPdo);
DeviceRelations->Objects[0] = DeviceExtension->RootHubPdo;
-
+
*pDeviceRelations = DeviceRelations;
return Status;
}
-NTSTATUS STDCALL
-UsbMpPnpFdo(
+NTSTATUS
+UsbMpFdoPnp(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
@@ -203,7 +262,7 @@
NTSTATUS Status;
ULONG MinorFunction;
ULONG_PTR Information = 0;
-
+
IrpSp = IoGetCurrentIrpStackLocation(Irp);
MinorFunction = IrpSp->MinorFunction;
@@ -255,18 +314,18 @@
case BusRelations:
{
PDEVICE_RELATIONS DeviceRelations = NULL;
- DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS /
BusRelations\n");
+ DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
Status = UsbMpFdoQueryBusRelations(DeviceObject, &DeviceRelations);
Information = (ULONG_PTR)DeviceRelations;
break;
}
case RemovalRelations:
{
- DPRINT1("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS /
RemovalRelations\n");
+ DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS /
RemovalRelations\n");
return ForwardIrpAndForget(DeviceObject, Irp);
}
default:
- DPRINT1("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type
0x%lx\n",
+ DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type
0x%lx\n",
IrpSp->Parameters.QueryDeviceRelations.Type);
return ForwardIrpAndForget(DeviceObject, Irp);
}
@@ -275,7 +334,7 @@
default:
{
- DPRINT1("USBMP: IRP_MJ_PNP / unknown minor function 0x%lx\n",
MinorFunction);
+ DPRINT1("IRP_MJ_PNP / unknown minor function 0x%lx\n", MinorFunction);
return ForwardIrpAndForget(DeviceObject, Irp);
}
}
@@ -286,7 +345,7 @@
}
NTSTATUS
-UsbMpDeviceControlFdo(
+UsbMpFdoDeviceControl(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
@@ -298,7 +357,7 @@
PVOID BufferIn, BufferOut;
NTSTATUS Status;
- DPRINT("USBMP: UsbDeviceControlFdo() called\n");
+ DPRINT("UsbDeviceControlFdo() called\n");
Stack = IoGetCurrentIrpStackLocation(Irp);
LengthIn = Stack->Parameters.DeviceIoControl.InputBufferLength;
@@ -311,7 +370,7 @@
{
case IOCTL_GET_HCD_DRIVERKEY_NAME:
{
- DPRINT("USBMP: IOCTL_GET_HCD_DRIVERKEY_NAME\n");
+ DPRINT("IOCTL_GET_HCD_DRIVERKEY_NAME\n");
if (LengthOut < sizeof(USB_HCD_DRIVERKEY_NAME))
Status = STATUS_BUFFER_TOO_SMALL;
else if (BufferOut == NULL)
@@ -338,7 +397,7 @@
}
case IOCTL_USB_GET_ROOT_HUB_NAME:
{
- DPRINT("USBMP: IOCTL_USB_GET_ROOT_HUB_NAME\n");
+ DPRINT("IOCTL_USB_GET_ROOT_HUB_NAME\n");
if (LengthOut < sizeof(USB_ROOT_HUB_NAME))
Status = STATUS_BUFFER_TOO_SMALL;
else if (BufferOut == NULL)
@@ -360,7 +419,7 @@
RootHubInterfaceName->Buffer,
RootHubInterfaceName->Length);
StringDescriptor->RootHubName[RootHubInterfaceName->Length / sizeof(WCHAR)] =
UNICODE_NULL;
- DPRINT("USBMP: IOCTL_USB_GET_ROOT_HUB_NAME returns '%S'\n",
StringDescriptor->RootHubName);
+ DPRINT("IOCTL_USB_GET_ROOT_HUB_NAME returns '%S'\n",
StringDescriptor->RootHubName);
Information = StringDescriptor->ActualLength;
}
else
@@ -373,7 +432,7 @@
default:
{
/* Pass Irp to lower driver */
- DPRINT1("USBMP: Unknown IOCTL code 0x%lx\n",
Stack->Parameters.DeviceIoControl.IoControlCode);
+ DPRINT1("Unknown IOCTL code 0x%lx\n",
Stack->Parameters.DeviceIoControl.IoControlCode);
IoSkipCurrentIrpStackLocation(Irp);
return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
}
@@ -384,218 +443,3 @@
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
-
-NTSTATUS
-UsbMpInternalDeviceControlFdo(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- NTSTATUS Status = STATUS_INVALID_DEVICE_REQUEST;
-
- DPRINT("USBMP: UsbMpDeviceInternalControlFdo(DO %p, code 0x%lx) called\n",
- DeviceObject,
- IoGetCurrentIrpStackLocation(Irp)->Parameters.DeviceIoControl.IoControlCode);
-
- if (DeviceObject == KeyboardFdo)
- {
- // it's keyboard's IOCTL
- PIO_STACK_LOCATION Stk;
-
- Irp->IoStatus.Information = 0;
- Stk = IoGetCurrentIrpStackLocation(Irp);
-
- switch (Stk->Parameters.DeviceIoControl.IoControlCode)
- {
- case IOCTL_INTERNAL_KEYBOARD_CONNECT:
- DPRINT("USBMP: IOCTL_INTERNAL_KEYBOARD_CONNECT\n");
- if (Stk->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONNECT_DATA))
{
- DPRINT1("USBMP: Keyboard IOCTL_INTERNAL_KEYBOARD_CONNECT "
- "invalid buffer size\n");
- Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
- goto intcontfailure;
- }
-
- RtlCopyMemory(&KbdClassInformation,
- Stk->Parameters.DeviceIoControl.Type3InputBuffer,
- sizeof(CONNECT_DATA));
-
- Irp->IoStatus.Status = STATUS_SUCCESS;
- break;
-
- case IOCTL_INTERNAL_I8042_KEYBOARD_WRITE_BUFFER:
- DPRINT("USBMP: IOCTL_INTERNAL_I8042_KEYBOARD_WRITE_BUFFER\n");
- if (Stk->Parameters.DeviceIoControl.InputBufferLength < 1) {
- Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
- goto intcontfailure;
- }
-/* if (!DevExt->KeyboardInterruptObject) {
- Irp->IoStatus.Status = STATUS_DEVICE_NOT_READY;
- goto intcontfailure;
- }*/
-
- Irp->IoStatus.Status = STATUS_SUCCESS;
- break;
- case IOCTL_KEYBOARD_QUERY_ATTRIBUTES:
- DPRINT("USBMP: IOCTL_KEYBOARD_QUERY_ATTRIBUTES\n");
- if (Stk->Parameters.DeviceIoControl.OutputBufferLength <
- sizeof(KEYBOARD_ATTRIBUTES)) {
- DPRINT("USBMP: Keyboard IOCTL_KEYBOARD_QUERY_ATTRIBUTES "
- "invalid buffer size\n");
- Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
- goto intcontfailure;
- }
- /*RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
- &DevExt->KeyboardAttributes,
- sizeof(KEYBOARD_ATTRIBUTES));*/
-
- Irp->IoStatus.Status = STATUS_SUCCESS;
- break;
- case IOCTL_KEYBOARD_QUERY_INDICATORS:
- DPRINT("USBMP: IOCTL_KEYBOARD_QUERY_INDICATORS\n");
- if (Stk->Parameters.DeviceIoControl.OutputBufferLength <
- sizeof(KEYBOARD_INDICATOR_PARAMETERS)) {
- DPRINT("USBMP: Keyboard IOCTL_KEYBOARD_QUERY_INDICATORS "
- "invalid buffer size\n");
- Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
- goto intcontfailure;
- }
- /*RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
- &DevExt->KeyboardIndicators,
- sizeof(KEYBOARD_INDICATOR_PARAMETERS));*/
-
- Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
- break;
- case IOCTL_KEYBOARD_QUERY_TYPEMATIC:
- DPRINT("USBMP: IOCTL_KEYBOARD_QUERY_TYPEMATIC\n");
- if (Stk->Parameters.DeviceIoControl.OutputBufferLength <
- sizeof(KEYBOARD_TYPEMATIC_PARAMETERS)) {
- DPRINT("USBMP: Keyboard IOCTL_KEYBOARD_QUERY_TYPEMATIC "
- "invalid buffer size\n");
- Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
- goto intcontfailure;
- }
- /*RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
- &DevExt->KeyboardTypematic,
- sizeof(KEYBOARD_TYPEMATIC_PARAMETERS));*/
-
- Irp->IoStatus.Status = STATUS_SUCCESS;
- break;
- case IOCTL_KEYBOARD_SET_INDICATORS:
- DPRINT("USBMP: IOCTL_KEYBOARD_SET_INDICATORS\n");
- if (Stk->Parameters.DeviceIoControl.InputBufferLength <
- sizeof(KEYBOARD_INDICATOR_PARAMETERS)) {
- DPRINT("USBMP: Keyboard IOCTL_KEYBOARD_SET_INDICTATORS "
- "invalid buffer size\n");
- Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
- goto intcontfailure;
- }
-
- /*RtlCopyMemory(&DevExt->KeyboardIndicators,
- Irp->AssociatedIrp.SystemBuffer,
- sizeof(KEYBOARD_INDICATOR_PARAMETERS));*/
-
- //DPRINT("%x\n", DevExt->KeyboardIndicators.LedFlags);
-
- Irp->IoStatus.Status = STATUS_SUCCESS;
- break;
- case IOCTL_KEYBOARD_SET_TYPEMATIC:
- DPRINT("USBMP: IOCTL_KEYBOARD_SET_TYPEMATIC\n");
- if (Stk->Parameters.DeviceIoControl.InputBufferLength <
- sizeof(KEYBOARD_TYPEMATIC_PARAMETERS)) {
- DPRINT("USBMP: Keyboard IOCTL_KEYBOARD_SET_TYPEMATIC "
- "invalid buffer size\n");
- Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
- goto intcontfailure;
- }
-
- /*RtlCopyMemory(&DevExt->KeyboardTypematic,
- Irp->AssociatedIrp.SystemBuffer,
- sizeof(KEYBOARD_TYPEMATIC_PARAMETERS));*/
-
- Irp->IoStatus.Status = STATUS_SUCCESS;
- break;
- case IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION:
- /* We should check the UnitID, but it's kind of pointless as
- * all keyboards are supposed to have the same one
- */
-#if 0
- DPRINT("USBMP: IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION\n");
- if (Stk->Parameters.DeviceIoControl.OutputBufferLength <
- sizeof(LOCAL_KEYBOARD_INDICATOR_TRANSLATION)) {
- DPRINT("USBMP: IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION: "
- "invalid buffer size (expected)\n");
- /* It's to query the buffer size */
- Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
- goto intcontfailure;
- }
- Irp->IoStatus.Information =
- sizeof(LOCAL_KEYBOARD_INDICATOR_TRANSLATION);
-#endif
- /*RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
- &IndicatorTranslation,
- sizeof(LOCAL_KEYBOARD_INDICATOR_TRANSLATION));*/
-
- Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
- break;
- case IOCTL_INTERNAL_I8042_HOOK_KEYBOARD:
- /* Nothing to do here */
- Irp->IoStatus.Status = STATUS_SUCCESS;
- break;
- default:
- Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
- break;
- }
-
- intcontfailure:
- Status = Irp->IoStatus.Status;
- }
- else if (DeviceObject == MouseFdo)
- {
- // it's mouse's IOCTL
- PIO_STACK_LOCATION Stk;
-
- Irp->IoStatus.Information = 0;
- Stk = IoGetCurrentIrpStackLocation(Irp);
-
- switch (Stk->Parameters.DeviceIoControl.IoControlCode)
- {
- case IOCTL_INTERNAL_MOUSE_CONNECT:
- DPRINT("USBMP: IOCTL_INTERNAL_MOUSE_CONNECT\n");
- if (Stk->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONNECT_DATA))
{
- DPRINT1("USBMP: IOCTL_INTERNAL_MOUSE_CONNECT "
- "invalid buffer size\n");
- Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
- goto intcontfailure2;
- }
-
- RtlCopyMemory(&MouseClassInformation,
- Stk->Parameters.DeviceIoControl.Type3InputBuffer,
- sizeof(CONNECT_DATA));
-
- Irp->IoStatus.Status = STATUS_SUCCESS;
- break;
-
- default:
- Irp->IoStatus.Status = STATUS_SUCCESS;//STATUS_INVALID_DEVICE_REQUEST;
- break;
- }
- intcontfailure2:
- Status = Irp->IoStatus.Status;
- }
- else
- {
- DPRINT("USBMP: We got IOCTL for UsbCore\n");
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SUCCESS;
- }
-
-
- if (Status == STATUS_INVALID_DEVICE_REQUEST) {
- DPRINT1("USBMP: Invalid internal device request!\n");
- }
-
- if (Status != STATUS_PENDING)
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
- return Status;
-}
Modified: trunk/reactos/drivers/usb/miniport/common/main.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/usb/miniport/common…
==============================================================================
--- trunk/reactos/drivers/usb/miniport/common/main.c (original)
+++ trunk/reactos/drivers/usb/miniport/common/main.c Sat May 6 18:36:52 2006
@@ -1,11 +1,11 @@
/*
- * 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),
+ * PROJECT: ReactOS USB miniport driver (Cromwell type)
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: drivers/usb/miniport/common/main.c
+ * PURPOSE: Driver entry
+ * PROGRAMMERS: Copyright Aleksey Bragin (aleksey(a)reactos.org)
+ * Copyright 2005-2006 Hervé Poussineau (hpoussin(a)reactos.org)
+ * Copyright James Tabor
(jimtabor(a)adsl-64-217-116-74.dsl.hstntx.swbell.net)
*
* Some parts of code are inspired (or even just copied) from
* ReactOS Videoport driver (drivers/video/videoprt)
@@ -33,7 +33,7 @@
PUSBMP_DEVICE_EXTENSION DeviceExtension;
NTSTATUS Status;
- DPRINT("USBMP: CreateRootHubPdo()\n");
+ DPRINT("CreateRootHubPdo()\n");
Status = IoCreateDevice(
DriverObject,
@@ -45,7 +45,7 @@
&Pdo);
if (!NT_SUCCESS(Status))
{
- DPRINT("USBMP: IoCreateDevice() call failed with status 0x%08x\n", Status);
+ DPRINT("IoCreateDevice() call failed with status 0x%08x\n", Status);
return Status;
}
@@ -125,7 +125,7 @@
Status = AddRegistryEntry(L"KeyboardPort", &DeviceName,
L"REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Services\\usbport");
if (!NT_SUCCESS(Status))
{
- DPRINT1("USBMP: AddRegistryEntry() for usb keyboard driver failed with status
0x%08lx\n", Status);
+ DPRINT1("AddRegistryEntry() for usb keyboard driver failed with status
0x%08lx\n", Status);
return Status;
}
@@ -139,15 +139,15 @@
if (!NT_SUCCESS(Status))
{
- DPRINT1("USBMP: IoCreateDevice() for usb keyboard driver failed with status
0x%08lx\n", Status);
+ DPRINT1("IoCreateDevice() for usb keyboard driver failed with status
0x%08lx\n", Status);
return Status;
}
DeviceExtension = (PUSBMP_DEVICE_EXTENSION)Fdo->DeviceExtension;
RtlZeroMemory(DeviceExtension, sizeof(USBMP_DEVICE_EXTENSION));
- DeviceExtension->IsFDO = TRUE;
+ DeviceExtension->IsFDO = FALSE;
KeyboardFdo = Fdo;
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
- DPRINT("USBMP: Created keyboard Fdo: %p\n", Fdo);
+ DPRINT("Created keyboard Fdo: %p\n", Fdo);
return STATUS_SUCCESS;
}
@@ -165,7 +165,7 @@
Status = AddRegistryEntry(L"PointerPort", &DeviceName,
L"REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Services\\usbport");
if (!NT_SUCCESS(Status))
{
- DPRINT1("USBMP: AddRegistryEntry() for usb mouse driver failed with status
0x%08lx\n", Status);
+ DPRINT1("AddRegistryEntry() for usb mouse driver failed with status
0x%08lx\n", Status);
return Status;
}
@@ -179,20 +179,20 @@
if (!NT_SUCCESS(Status))
{
- DPRINT1("USBMP: IoCreateDevice() for usb mouse driver failed with status
0x%08lx\n", Status);
+ DPRINT1("IoCreateDevice() for usb mouse driver failed with status 0x%08lx\n",
Status);
return Status;
}
DeviceExtension = (PUSBMP_DEVICE_EXTENSION)Fdo->DeviceExtension;
RtlZeroMemory(DeviceExtension, sizeof(USBMP_DEVICE_EXTENSION));
- DeviceExtension->IsFDO = TRUE;
+ DeviceExtension->IsFDO = FALSE;
MouseFdo = Fdo;
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
- DPRINT("USBMP: Created mouse Fdo: %p\n", Fdo);
+ DPRINT("Created mouse Fdo: %p\n", Fdo);
return STATUS_SUCCESS;
}
-NTSTATUS STDCALL
+NTSTATUS NTAPI
AddDevice(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT pdo)
@@ -220,7 +220,7 @@
if (!NT_SUCCESS(Status))
{
- DPRINT1("USBMP: Allocating DriverObjectExtension failed.\n");
+ DPRINT1("Allocating DriverObjectExtension failed.\n");
goto cleanup;
}
}
@@ -259,7 +259,7 @@
if (!NT_SUCCESS(Status))
{
- DPRINT1("USBMP: IoCreateDevice call failed with status 0x%08lx\n", Status);
+ DPRINT1("IoCreateDevice call failed with status 0x%08lx\n", Status);
goto cleanup;
}
@@ -271,7 +271,7 @@
Status = CreateRootHubPdo(DriverObject, fdo, &DeviceExtension->RootHubPdo);
if (!NT_SUCCESS(Status))
{
- DPRINT1("USBMP: CreateRootHubPdo() failed with status 0x%08lx\n", Status);
+ DPRINT1("CreateRootHubPdo() failed with status 0x%08lx\n", Status);
goto cleanup;
}
@@ -283,7 +283,7 @@
&DeviceExtension->HcdInterfaceName);
if (!NT_SUCCESS(Status))
{
- DPRINT1("USBMP: IoRegisterDeviceInterface() failed with status 0x%08lx\n",
Status);
+ DPRINT1("IoRegisterDeviceInterface() failed with status 0x%08lx\n", Status);
goto cleanup;
}
@@ -305,7 +305,7 @@
Status = IoCreateSymbolicLink(&LinkDeviceName, &DeviceName);
if (!NT_SUCCESS(Status))
{
- DPRINT1("USBMP: IoCreateSymbolicLink() call failed with status 0x%08x\n",
Status);
+ DPRINT1("IoCreateSymbolicLink() call failed with status 0x%08x\n", Status);
goto cleanup;
}
@@ -319,7 +319,7 @@
return Status;
}
-NTSTATUS STDCALL
+NTSTATUS NTAPI
IrpStub(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
@@ -328,7 +328,7 @@
if (((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
{
- DPRINT1("USBMP: FDO stub for major function 0x%lx\n",
+ DPRINT1("FDO stub for major function 0x%lx\n",
IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
ASSERT(FALSE);
return ForwardIrpAndForget(DeviceObject, Irp);
@@ -338,7 +338,7 @@
/* 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",
+ DPRINT1("PDO stub for major function 0x%lx\n",
IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
ASSERT(FALSE);
}
@@ -348,74 +348,74 @@
return Status;
}
-static NTSTATUS STDCALL
+static NTSTATUS NTAPI
DispatchCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
if (((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
- return UsbMpCreate(DeviceObject, Irp);
- else
+ return UsbMpFdoCreate(DeviceObject, Irp);
+ else
+ return UsbMpPdoCreate(DeviceObject, Irp);
+}
+
+static NTSTATUS NTAPI
+DispatchClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+ if (((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
+ return UsbMpFdoClose(DeviceObject, Irp);
+ else
+ return UsbMpPdoClose(DeviceObject, Irp);
+}
+
+static NTSTATUS NTAPI
+DispatchCleanup(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+ if (((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
+ return UsbMpFdoCleanup(DeviceObject, Irp);
+ else
+ return UsbMpPdoCleanup(DeviceObject, Irp);
+}
+
+static NTSTATUS NTAPI
+DispatchDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+ if (((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
+ return UsbMpFdoDeviceControl(DeviceObject, Irp);
+ else
+ return UsbMpPdoDeviceControl(DeviceObject, Irp);
+}
+
+static NTSTATUS NTAPI
+DispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+ if (((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
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
-DispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
-{
- if (((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
- return UsbMpInternalDeviceControlFdo(DeviceObject, Irp);
- else
- return IrpStub(DeviceObject, Irp);
-}
-
-static NTSTATUS STDCALL
+ else
+ return UsbMpPdoInternalDeviceControl(DeviceObject, Irp);
+}
+
+static NTSTATUS NTAPI
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
+ return UsbMpFdoPnp(DeviceObject, Irp);
+ else
+ return UsbMpPdoPnp(DeviceObject, Irp);
+}
+
+static NTSTATUS NTAPI
DispatchPower(PDEVICE_OBJECT fido, PIRP Irp)
{
- DPRINT1("USBMP: IRP_MJ_POWER unimplemented\n");
+ DPRINT1("IRP_MJ_POWER unimplemented\n");
Irp->IoStatus.Information = 0;
- Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SUCCESS;
+ return STATUS_NOT_SUPPORTED;
}
/*
* Standard DriverEntry method.
*/
-NTSTATUS STDCALL
+NTSTATUS NTAPI
DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegPath)
{
USBPORT_INTERFACE UsbPortInterface;
Modified: trunk/reactos/drivers/usb/miniport/common/misc.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/usb/miniport/common…
==============================================================================
--- trunk/reactos/drivers/usb/miniport/common/misc.c (original)
+++ trunk/reactos/drivers/usb/miniport/common/misc.c Sat May 6 18:36:52 2006
@@ -1,10 +1,9 @@
/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS USB miniport driver (Cromwell type)
- * FILE: drivers/usb/miniport/common/misc.c
- * PURPOSE: Misceallenous operations
- *
- * PROGRAMMERS: Hervé Poussineau (hpoussin(a)reactos.org),
+ * PROJECT: ReactOS USB miniport driver (Cromwell type)
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: drivers/usb/miniport/common/misc.c
+ * PURPOSE: Misceallenous operations
+ * PROGRAMMERS: Copyright 2005 Hervé Poussineau (hpoussin(a)reactos.org)
*/
#define NDEBUG
@@ -13,7 +12,7 @@
#include "usbcommon.h"
#include <stdarg.h>
-NTSTATUS STDCALL
+NTSTATUS NTAPI
ForwardIrpAndWaitCompletion(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
@@ -38,7 +37,7 @@
KeInitializeEvent(&Event, NotificationEvent, FALSE);
IoCopyCurrentIrpStackLocationToNext(Irp);
- DPRINT("USBMP: Calling lower device %p [%wZ]\n", LowerDevice,
&LowerDevice->DriverObject->DriverName);
+ DPRINT("Calling lower device %p [%wZ]\n", LowerDevice,
&LowerDevice->DriverObject->DriverName);
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
Status = IoCallDriver(LowerDevice, Irp);
@@ -52,7 +51,7 @@
return Status;
}
-NTSTATUS STDCALL
+NTSTATUS
ForwardIrpAndForget(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
Modified: trunk/reactos/drivers/usb/miniport/common/pdo.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/usb/miniport/common…
==============================================================================
--- trunk/reactos/drivers/usb/miniport/common/pdo.c (original)
+++ trunk/reactos/drivers/usb/miniport/common/pdo.c Sat May 6 18:36:52 2006
@@ -1,43 +1,85 @@
/*
- * COPYRIGHT: See COPYING in the top level directory
- * 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.org),
- * James Tabor (jimtabor(a)adsl-64-217-116-74.dsl.hstntx.swbell.net)
+ * PROJECT: ReactOS USB miniport driver (Cromwell type)
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: drivers/usb/miniport/common/pdo.c
+ * PURPOSE: Operations on PDOs
+ * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin(a)reactos.org)
+ * Copyright James Tabor
(jimtabor(a)adsl-64-217-116-74.dsl.hstntx.swbell.net)
*/
#define NDEBUG
#include <debug.h>
#include "usbcommon.h"
+#include <wdmguid.h>
extern struct usb_driver hub_driver;
#define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003)
NTSTATUS
-UsbMpDeviceControlPdo(
+UsbMpPdoCreate(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ DPRINT("IRP_MJ_CREATE\n");
+
+ /* Nothing to do */
+ Irp->IoStatus.Information = 0;
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+UsbMpPdoClose(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ DPRINT("IRP_MJ_CLOSE\n");
+
+ /* Nothing to do */
+ Irp->IoStatus.Information = 0;
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+UsbMpPdoCleanup(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ DPRINT("IRP_MJ_CLEANUP\n");
+
+ /* Nothing to do */
+ Irp->IoStatus.Information = 0;
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+UsbMpPdoDeviceControl(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
PIO_STACK_LOCATION Stack;
ULONG_PTR Information = 0;
NTSTATUS Status;
-
- DPRINT("USBMP: UsbMpDeviceControlPdo() called\n");
-
+
+ DPRINT("UsbMpDeviceControlPdo() called\n");
+
Stack = IoGetCurrentIrpStackLocation(Irp);
Status = Irp->IoStatus.Status;
-
+
switch (Stack->Parameters.DeviceIoControl.IoControlCode)
{
case IOCTL_INTERNAL_USB_GET_ROOT_USB_DEVICE:
{
PUSBMP_DEVICE_EXTENSION DeviceExtension;
-
- DPRINT("USBMP: IOCTL_INTERNAL_USB_GET_ROOT_USB_DEVICE\n");
+
+ DPRINT("IOCTL_INTERNAL_USB_GET_ROOT_USB_DEVICE\n");
if (Irp->AssociatedIrp.SystemBuffer == NULL
|| Stack->Parameters.DeviceIoControl.OutputBufferLength != sizeof(PVOID))
{
@@ -48,7 +90,7 @@
PVOID* pRootHubPointer;
DeviceExtension = (PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
DeviceExtension =
(PUSBMP_DEVICE_EXTENSION)DeviceExtension->FunctionalDeviceObject->DeviceExtension;
-
+
pRootHubPointer = (PVOID*)Irp->AssociatedIrp.SystemBuffer;
*pRootHubPointer = ((struct
usb_hcd*)DeviceExtension->pdev->data)->self.root_hub;
Information = sizeof(PVOID);
@@ -58,12 +100,12 @@
}
default:
{
- DPRINT1("USBMP: Unknown IOCTL code 0x%lx\n",
Stack->Parameters.DeviceIoControl.IoControlCode);
+ DPRINT1("Unknown IOCTL code 0x%lx\n",
Stack->Parameters.DeviceIoControl.IoControlCode);
Information = Irp->IoStatus.Information;
Status = Irp->IoStatus.Status;
}
}
-
+
Irp->IoStatus.Information = Information;
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
@@ -71,7 +113,7 @@
}
static NTSTATUS
-UsbMpPdoQueryId(
+QueryId(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
OUT ULONG_PTR* Information)
@@ -93,7 +135,7 @@
{
case BusQueryDeviceID:
{
- DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryDeviceID\n");
+ DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryDeviceID\n");
if (roothub->speed == USB_SPEED_LOW || roothub->speed == USB_SPEED_FULL)
RtlInitUnicodeString(&SourceString, L"USB\\ROOT_HUB"); /* USB 1.1 */
else
@@ -109,7 +151,7 @@
ULONG ret;
PDEVICE_OBJECT Pdo;
- DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryHardwareIDs\n");
+ DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryHardwareIDs\n");
Pdo = DeviceExtension->PhysicalDeviceObject;
Status = IoGetDeviceProperty(
@@ -120,7 +162,7 @@
&ret);
if (!NT_SUCCESS(Status))
{
- DPRINT("USBMP: IoGetDeviceProperty() failed with status 0x%08lx\n",
Status);
+ DPRINT("IoGetDeviceProperty() failed with status 0x%08lx\n", Status);
break;
}
@@ -132,7 +174,7 @@
&ret);
if (!NT_SUCCESS(Status))
{
- DPRINT("USBMP: IoGetDeviceProperty() failed with status 0x%08lx\n",
Status);
+ DPRINT("IoGetDeviceProperty() failed with status 0x%08lx\n", Status);
break;
}
@@ -144,7 +186,7 @@
PCI_COMMON_HDR_LENGTH);
if (ret != PCI_COMMON_HDR_LENGTH)
{
- DPRINT("USBMP: HalGetBusDataByOffset() failed (ret = %ld)\n", ret);
+ DPRINT("HalGetBusDataByOffset() failed (ret = %ld)\n", ret);
Status = STATUS_IO_DEVICE_ERROR;
break;
}
@@ -163,18 +205,18 @@
break;
}
case BusQueryCompatibleIDs:
- DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryCompatibleIDs\n");
+ DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryCompatibleIDs\n");
/* No compatible ID */
*Information = 0;
return STATUS_NOT_SUPPORTED;
case BusQueryInstanceID:
{
- DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryInstanceID\n");
+ DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryInstanceID\n");
*Information = 0;
return Status;
}
default:
- DPRINT1("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_ID / unknown query id type
0x%lx\n", IdType);
+ DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / unknown query id type 0x%lx\n",
IdType);
return STATUS_NOT_SUPPORTED;
}
@@ -190,14 +232,33 @@
}
static NTSTATUS
-UsbMpPnpStartDevice(
+QueryBusInformation(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp,
+ OUT ULONG_PTR* Information)
+{
+ PPNP_BUS_INFORMATION BusInformation;
+
+ DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_BUS_INFORMATION\n");
+
+ BusInformation = ExAllocatePool(PagedPool, sizeof(PNP_BUS_INFORMATION));
+ if (!BusInformation)
+ return STATUS_INSUFFICIENT_RESOURCES;
+ BusInformation->BusTypeGuid = GUID_BUS_TYPE_USB;
+ BusInformation->LegacyBusType = PNPBus;
+ BusInformation->BusNumber = 0; /* FIXME */
+ return STATUS_SUCCESS;
+}
+
+static NTSTATUS
+StartDevice(
IN PDEVICE_OBJECT DeviceObject)
{
PUSBMP_DEVICE_EXTENSION DeviceExtension;
NTSTATUS Status;
-
+
DeviceExtension = (PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
+
/* Register device interface for root hub */
Status = IoRegisterDeviceInterface(
DeviceObject,
@@ -206,15 +267,15 @@
&DeviceExtension->HcdInterfaceName);
if (!NT_SUCCESS(Status))
{
- DPRINT("USBMP: IoRegisterDeviceInterface() failed with status 0x%08lx\n",
Status);
+ DPRINT("IoRegisterDeviceInterface() failed with status 0x%08lx\n", Status);
return Status;
}
-
+
return Status;
}
-NTSTATUS STDCALL
-UsbMpPnpPdo(
+NTSTATUS
+UsbMpPdoPnp(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
@@ -222,7 +283,7 @@
PIO_STACK_LOCATION Stack;
ULONG_PTR Information = 0;
NTSTATUS Status;
-
+
Stack = IoGetCurrentIrpStackLocation(Irp);
MinorFunction = Stack->MinorFunction;
@@ -230,15 +291,15 @@
{
case IRP_MN_START_DEVICE: /* 0x00 */
{
- DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
- Status = UsbMpPnpStartDevice(DeviceObject);
+ DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
+ Status = StartDevice(DeviceObject);
break;
}
case IRP_MN_QUERY_CAPABILITIES: /* 0x09 */
{
PDEVICE_CAPABILITIES DeviceCapabilities;
ULONG i;
- DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_CAPABILITIES\n");
+ DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_CAPABILITIES\n");
DeviceCapabilities =
(PDEVICE_CAPABILITIES)Stack->Parameters.DeviceCapabilities.Capabilities;
/* FIXME: capabilities can change with connected device */
@@ -264,7 +325,7 @@
}
case IRP_MN_QUERY_RESOURCES: /* 0x0a */
{
- DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_RESOURCES\n");
+ DPRINT("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
@@ -276,7 +337,7 @@
}
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: /* 0x0b */
{
- DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
+ DPRINT("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
@@ -294,9 +355,9 @@
{
UNICODE_STRING SourceString = RTL_CONSTANT_STRING(L"Root USB hub");
UNICODE_STRING Description;
-
- DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT /
DeviceTextDescription\n");
-
+
+ DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT /
DeviceTextDescription\n");
+
Status = RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
&SourceString, &Description);
if (NT_SUCCESS(Status))
Information = (ULONG_PTR)Description.Buffer;
@@ -313,8 +374,9 @@
}
default:
{
- DPRINT1("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / unknown type
0x%lx\n",
+ DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / unknown type 0x%lx\n",
Stack->Parameters.QueryDeviceText.DeviceTextType);
+ ASSERT(FALSE);
Status = STATUS_NOT_SUPPORTED;
}
}
@@ -322,7 +384,12 @@
}
case IRP_MN_QUERY_ID: /* 0x13 */
{
- Status = UsbMpPdoQueryId(DeviceObject, Irp, &Information);
+ Status = QueryId(DeviceObject, Irp, &Information);
+ break;
+ }
+ case IRP_MN_QUERY_BUS_INFORMATION: /* 0x15 */
+ {
+ Status = QueryBusInformation(DeviceObject, Irp, &Information);
break;
}
default:
@@ -330,9 +397,10 @@
/* We can't forward request to the lower driver, because
* we are a Pdo, so we don't have lower driver...
*/
- DPRINT1("USBMP: IRP_MJ_PNP / unknown minor function 0x%lx\n",
MinorFunction);
+ DPRINT1("IRP_MJ_PNP / unknown minor function 0x%lx\n", MinorFunction);
Information = Irp->IoStatus.Information;
Status = Irp->IoStatus.Status;
+ ASSERT(FALSE);
}
}
@@ -342,3 +410,217 @@
return Status;
}
+NTSTATUS
+UsbMpPdoInternalDeviceControl(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ NTSTATUS Status = STATUS_INVALID_DEVICE_REQUEST;
+
+ DPRINT("UsbMpDeviceInternalControlPdo(DO %p, code 0x%lx) called\n",
+ DeviceObject,
+ IoGetCurrentIrpStackLocation(Irp)->Parameters.DeviceIoControl.IoControlCode);
+
+ if (DeviceObject == KeyboardFdo)
+ {
+ // it's keyboard's IOCTL
+ PIO_STACK_LOCATION Stk;
+
+ Irp->IoStatus.Information = 0;
+ Stk = IoGetCurrentIrpStackLocation(Irp);
+
+ switch (Stk->Parameters.DeviceIoControl.IoControlCode)
+ {
+ case IOCTL_INTERNAL_KEYBOARD_CONNECT:
+ DPRINT("IOCTL_INTERNAL_KEYBOARD_CONNECT\n");
+ if (Stk->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONNECT_DATA))
{
+ DPRINT1("Keyboard IOCTL_INTERNAL_KEYBOARD_CONNECT "
+ "invalid buffer size\n");
+ Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
+ goto intcontfailure;
+ }
+
+ RtlCopyMemory(&KbdClassInformation,
+ Stk->Parameters.DeviceIoControl.Type3InputBuffer,
+ sizeof(CONNECT_DATA));
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+
+ case IOCTL_INTERNAL_I8042_KEYBOARD_WRITE_BUFFER:
+ DPRINT("IOCTL_INTERNAL_I8042_KEYBOARD_WRITE_BUFFER\n");
+ if (Stk->Parameters.DeviceIoControl.InputBufferLength < 1) {
+ Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
+ goto intcontfailure;
+ }
+/* if (!DevExt->KeyboardInterruptObject) {
+ Irp->IoStatus.Status = STATUS_DEVICE_NOT_READY;
+ goto intcontfailure;
+ }*/
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+ case IOCTL_KEYBOARD_QUERY_ATTRIBUTES:
+ DPRINT("IOCTL_KEYBOARD_QUERY_ATTRIBUTES\n");
+ if (Stk->Parameters.DeviceIoControl.OutputBufferLength <
+ sizeof(KEYBOARD_ATTRIBUTES)) {
+ DPRINT("Keyboard IOCTL_KEYBOARD_QUERY_ATTRIBUTES: "
+ "invalid buffer size\n");
+ Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
+ goto intcontfailure;
+ }
+ /*RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
+ &DevExt->KeyboardAttributes,
+ sizeof(KEYBOARD_ATTRIBUTES));*/
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+ case IOCTL_KEYBOARD_QUERY_INDICATORS:
+ DPRINT("IOCTL_KEYBOARD_QUERY_INDICATORS\n");
+ if (Stk->Parameters.DeviceIoControl.OutputBufferLength <
+ sizeof(KEYBOARD_INDICATOR_PARAMETERS)) {
+ DPRINT("Keyboard IOCTL_KEYBOARD_QUERY_INDICATORS: "
+ "invalid buffer size\n");
+ Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
+ goto intcontfailure;
+ }
+ /*RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
+ &DevExt->KeyboardIndicators,
+ sizeof(KEYBOARD_INDICATOR_PARAMETERS));*/
+
+ Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
+ break;
+ case IOCTL_KEYBOARD_QUERY_TYPEMATIC:
+ DPRINT("IOCTL_KEYBOARD_QUERY_TYPEMATIC\n");
+ if (Stk->Parameters.DeviceIoControl.OutputBufferLength <
+ sizeof(KEYBOARD_TYPEMATIC_PARAMETERS)) {
+ DPRINT("Keyboard IOCTL_KEYBOARD_QUERY_TYPEMATIC: "
+ "invalid buffer size\n");
+ Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
+ goto intcontfailure;
+ }
+ /*RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
+ &DevExt->KeyboardTypematic,
+ sizeof(KEYBOARD_TYPEMATIC_PARAMETERS));*/
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+ case IOCTL_KEYBOARD_SET_INDICATORS:
+ DPRINT("IOCTL_KEYBOARD_SET_INDICATORS\n");
+ if (Stk->Parameters.DeviceIoControl.InputBufferLength <
+ sizeof(KEYBOARD_INDICATOR_PARAMETERS)) {
+ DPRINT("Keyboard IOCTL_KEYBOARD_SET_INDICTATORS: "
+ "invalid buffer size\n");
+ Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
+ goto intcontfailure;
+ }
+
+ /*RtlCopyMemory(&DevExt->KeyboardIndicators,
+ Irp->AssociatedIrp.SystemBuffer,
+ sizeof(KEYBOARD_INDICATOR_PARAMETERS));*/
+
+ //DPRINT("%x\n", DevExt->KeyboardIndicators.LedFlags);
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+ case IOCTL_KEYBOARD_SET_TYPEMATIC:
+ DPRINT("IOCTL_KEYBOARD_SET_TYPEMATIC\n");
+ if (Stk->Parameters.DeviceIoControl.InputBufferLength <
+ sizeof(KEYBOARD_TYPEMATIC_PARAMETERS)) {
+ DPRINT("Keyboard IOCTL_KEYBOARD_SET_TYPEMATIC "
+ "invalid buffer size\n");
+ Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
+ goto intcontfailure;
+ }
+
+ /*RtlCopyMemory(&DevExt->KeyboardTypematic,
+ Irp->AssociatedIrp.SystemBuffer,
+ sizeof(KEYBOARD_TYPEMATIC_PARAMETERS));*/
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+ case IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION:
+ /* We should check the UnitID, but it's kind of pointless as
+ * all keyboards are supposed to have the same one
+ */
+#if 0
+ DPRINT("IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION\n");
+ if (Stk->Parameters.DeviceIoControl.OutputBufferLength <
+ sizeof(LOCAL_KEYBOARD_INDICATOR_TRANSLATION)) {
+ DPRINT("IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION: "
+ "invalid buffer size (expected)\n");
+ /* It's to query the buffer size */
+ Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
+ goto intcontfailure;
+ }
+ Irp->IoStatus.Information =
+ sizeof(LOCAL_KEYBOARD_INDICATOR_TRANSLATION);
+#endif
+ /*RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
+ &IndicatorTranslation,
+ sizeof(LOCAL_KEYBOARD_INDICATOR_TRANSLATION));*/
+
+ Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
+ break;
+ case IOCTL_INTERNAL_I8042_HOOK_KEYBOARD:
+ /* Nothing to do here */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+ default:
+ Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
+ break;
+ }
+
+ intcontfailure:
+ Status = Irp->IoStatus.Status;
+ }
+ else if (DeviceObject == MouseFdo)
+ {
+ // it's mouse's IOCTL
+ PIO_STACK_LOCATION Stk;
+
+ Irp->IoStatus.Information = 0;
+ Stk = IoGetCurrentIrpStackLocation(Irp);
+
+ switch (Stk->Parameters.DeviceIoControl.IoControlCode)
+ {
+ case IOCTL_INTERNAL_MOUSE_CONNECT:
+ DPRINT("IOCTL_INTERNAL_MOUSE_CONNECT\n");
+ if (Stk->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONNECT_DATA))
{
+ DPRINT1("IOCTL_INTERNAL_MOUSE_CONNECT: "
+ "invalid buffer size\n");
+ Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
+ goto intcontfailure2;
+ }
+
+ RtlCopyMemory(&MouseClassInformation,
+ Stk->Parameters.DeviceIoControl.Type3InputBuffer,
+ sizeof(CONNECT_DATA));
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+
+ default:
+ Irp->IoStatus.Status = STATUS_SUCCESS;//STATUS_INVALID_DEVICE_REQUEST;
+ break;
+ }
+ intcontfailure2:
+ Status = Irp->IoStatus.Status;
+ }
+ else
+ {
+ DPRINT("We got IOCTL for UsbCore\n");
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+ }
+
+
+ if (Status == STATUS_INVALID_DEVICE_REQUEST) {
+ DPRINT1("Invalid internal device request!\n");
+ }
+
+ if (Status != STATUS_PENDING)
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ return Status;
+}
Modified: trunk/reactos/drivers/usb/miniport/common/usbcommon.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/usb/miniport/common…
==============================================================================
--- trunk/reactos/drivers/usb/miniport/common/usbcommon.h (original)
+++ trunk/reactos/drivers/usb/miniport/common/usbcommon.h Sat May 6 18:36:52 2006
@@ -20,37 +20,29 @@
extern PDEVICE_OBJECT KeyboardFdo;
extern PDEVICE_OBJECT MouseFdo;
-/* cleanup.c */
-NTSTATUS STDCALL
-UsbMpCleanup(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp);
-
-/* close.c */
-NTSTATUS STDCALL
-UsbMpClose(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp);
-
-/* create.c */
-NTSTATUS STDCALL
-UsbMpCreate(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp);
-
/* fdo.c */
-NTSTATUS STDCALL
-UsbMpPnpFdo(
+NTSTATUS
+UsbMpFdoCreate(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
NTSTATUS
-UsbMpDeviceControlFdo(
+UsbMpFdoClose(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
NTSTATUS
-UsbMpInternalDeviceControlFdo(
+UsbMpFdoCleanup(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp);
+
+NTSTATUS
+UsbMpFdoPnp(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp);
+
+NTSTATUS
+UsbMpFdoDeviceControl(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
@@ -60,7 +52,7 @@
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
-NTSTATUS STDCALL
+NTSTATUS
ForwardIrpAndForget(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
@@ -77,18 +69,41 @@
... /* list of PCSZ */);
/* pdo.c */
-NTSTATUS STDCALL
-UsbMpPnpPdo(
+NTSTATUS
+UsbMpPdoCreate(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
NTSTATUS
-UsbMpDeviceControlPdo(
+UsbMpPdoClose(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
-/* Needed by this object library */
-VOID STDCALL
+NTSTATUS
+UsbMpPdoCleanup(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp);
+
+NTSTATUS
+UsbMpPdoPnp(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp);
+
+NTSTATUS
+UsbMpPdoDeviceControl(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp);
+
+NTSTATUS
+UsbMpPdoInternalDeviceControl(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp);
+
+/*
+ * Needed by this object library, but not
+ * present in any file of this library
+ */
+VOID NTAPI
DriverUnload(PDRIVER_OBJECT DriverObject);
NTSTATUS