Author: hpoussin Date: Sun Apr 23 12:46:25 2006 New Revision: 21714
URL: http://svn.reactos.ru/svn/reactos?rev=21714&view=rev Log: Fix little bug in mouse detection Create unnamed FDOs Read only registry parameters which make sense Start to read mouse only when receiving IRP_MN_START_DEVICE Cleanup of code
Modified: trunk/reactos/drivers/input/sermouse/createclose.c trunk/reactos/drivers/input/sermouse/detect.c trunk/reactos/drivers/input/sermouse/fdo.c trunk/reactos/drivers/input/sermouse/internaldevctl.c trunk/reactos/drivers/input/sermouse/misc.c trunk/reactos/drivers/input/sermouse/readmouse.c trunk/reactos/drivers/input/sermouse/sermouse.c trunk/reactos/drivers/input/sermouse/sermouse.h
Modified: trunk/reactos/drivers/input/sermouse/createclose.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/input/sermouse/creat... ============================================================================== --- trunk/reactos/drivers/input/sermouse/createclose.c (original) +++ trunk/reactos/drivers/input/sermouse/createclose.c Sun Apr 23 12:46:25 2006 @@ -1,21 +1,15 @@ /* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS Serial mouse driver - * FILE: drivers/input/sermouse/fdo.c - * PURPOSE: IRP_MJ_CREATE and IRP_MJ_CLOSE operations - * - * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org) + * PROJECT: ReactOS Serial mouse driver + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/input/sermouse/createclose.c + * PURPOSE: IRP_MJ_CREATE and IRP_MJ_CLOSE operations + * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org) */
#define NDEBUG #include <debug.h>
#include "sermouse.h" - -NTSTATUS NTAPI -SermouseStartDevice( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp); /* FIXME: remove the declaration */
NTSTATUS NTAPI SermouseCreate(
Modified: trunk/reactos/drivers/input/sermouse/detect.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/input/sermouse/detec... ============================================================================== --- trunk/reactos/drivers/input/sermouse/detect.c (original) +++ trunk/reactos/drivers/input/sermouse/detect.c Sun Apr 23 12:46:25 2006 @@ -1,12 +1,11 @@ /* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS Serial mouse driver - * FILE: drivers/input/sermouse/detect.c - * PURPOSE: Detect serial mouse type - * - * PROGRAMMERS: Jason Filby (jasonfilby@yahoo.com) - * Filip Navara (xnavara@volny.cz) - * Hervé Poussineau (hpoussin@reactos.org) + * PROJECT: ReactOS Serial mouse driver + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/input/sermouse/detect.c + * PURPOSE: Detect serial mouse type + * PROGRAMMERS: Copyright Jason Filby (jasonfilby@yahoo.com) + Copyright Filip Navara (xnavara@volny.cz) + Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org) */
#define NDEBUG @@ -17,7 +16,7 @@ /* Most of this file is ripped from reactos/drivers/bus/serenum/detect.c */
static NTSTATUS -SermouseDeviceIoControl( +DeviceIoControl( IN PDEVICE_OBJECT DeviceObject, IN ULONG CtlCode, IN PVOID InputBuffer OPTIONAL, @@ -65,7 +64,7 @@ }
static NTSTATUS -SermouseSendIrp( +SendIrp( IN PDEVICE_OBJECT DeviceObject, IN ULONG MajorFunction) { @@ -140,7 +139,8 @@ }
static NTSTATUS -SermouseWait(ULONG milliseconds) +Wait( + IN ULONG milliseconds) { KTIMER Timer; LARGE_INTEGER DueTime; @@ -165,16 +165,18 @@ SERMOUSE_MOUSE_TYPE MouseType = mtNone; NTSTATUS Status;
+ DPRINT("SermouseDetectLegacyDevice(LowerDevice %p)\n", LowerDevice); + RtlZeroMemory(Buffer, sizeof(Buffer));
/* Open port */ - Status = SermouseSendIrp(LowerDevice, IRP_MJ_CREATE); + Status = SendIrp(LowerDevice, IRP_MJ_CREATE); if (!NT_SUCCESS(Status)) return mtNone;
/* Reset UART */ CHECKPOINT; Mcr = 0; /* MCR: DTR/RTS/OUT2 off */ - Status = SermouseDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_MODEM_CONTROL, + Status = DeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_MODEM_CONTROL, &Mcr, sizeof(Mcr), NULL, NULL); if (!NT_SUCCESS(Status)) goto ByeBye;
@@ -182,57 +184,47 @@ CHECKPOINT; /* DLAB off */ Fcr = 0; - Status = SermouseDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_FIFO_CONTROL, + Status = DeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_FIFO_CONTROL, &Fcr, sizeof(Fcr), NULL, NULL); if (!NT_SUCCESS(Status)) goto ByeBye; /* Set serial port speed */ BaudRate = 1200; - Status = SermouseDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_BAUD_RATE, + Status = DeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_BAUD_RATE, &BaudRate, sizeof(BaudRate), NULL, NULL); if (!NT_SUCCESS(Status)) goto ByeBye; /* Set LCR */ LCR.WordLength = 7; LCR.Parity = NO_PARITY; LCR.StopBits = STOP_BITS_2; - Status = SermouseDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_LINE_CONTROL, + Status = DeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_LINE_CONTROL, &LCR, sizeof(LCR), NULL, NULL); if (!NT_SUCCESS(Status)) goto ByeBye;
- /* Disable DTR/RTS */ - CHECKPOINT; - Status = SermouseDeviceIoControl(LowerDevice, IOCTL_SERIAL_CLR_DTR, + /* Flush receive buffer */ + CHECKPOINT; + Command = SERIAL_PURGE_RXCLEAR; + Status = DeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_MODEM_CONTROL, + &Command, sizeof(Command), NULL, NULL); + if (!NT_SUCCESS(Status)) goto ByeBye; + /* Wait 100 ms */ + Wait(100); + + /* Enable DTR/RTS */ + CHECKPOINT; + Status = DeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_DTR, NULL, 0, NULL, NULL); if (!NT_SUCCESS(Status)) goto ByeBye; - Status = SermouseDeviceIoControl(LowerDevice, IOCTL_SERIAL_CLR_RTS, + Status = DeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_RTS, NULL, 0, NULL, NULL); if (!NT_SUCCESS(Status)) goto ByeBye;
- /* Flush receive buffer */ - CHECKPOINT; - Command = SERIAL_PURGE_RXCLEAR; - Status = SermouseDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_MODEM_CONTROL, - &Command, sizeof(Command), NULL, NULL); - if (!NT_SUCCESS(Status)) goto ByeBye; - /* Wait 100 ms */ - SermouseWait(100); - - /* Enable DTR/RTS */ - CHECKPOINT; - Status = SermouseDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_DTR, - NULL, 0, NULL, NULL); - if (!NT_SUCCESS(Status)) goto ByeBye; - SermouseWait(200); - Status = SermouseDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_RTS, - NULL, 0, NULL, NULL); - if (!NT_SUCCESS(Status)) goto ByeBye; - /* Set timeout to 500 microseconds */ CHECKPOINT; - Timeouts.ReadIntervalTimeout = 0; + Timeouts.ReadIntervalTimeout = 100; Timeouts.ReadTotalTimeoutMultiplier = 0; Timeouts.ReadTotalTimeoutConstant = 500; Timeouts.WriteTotalTimeoutMultiplier = Timeouts.WriteTotalTimeoutConstant = 0; - Status = SermouseDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_TIMEOUTS, + Status = DeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_TIMEOUTS, &Timeouts, sizeof(Timeouts), NULL, NULL); if (!NT_SUCCESS(Status)) goto ByeBye;
@@ -276,7 +268,7 @@
ByeBye: /* Close port */ - SermouseSendIrp(LowerDevice, IRP_MJ_CLOSE); - SermouseSendIrp(LowerDevice, IRP_MJ_CLEANUP); + SendIrp(LowerDevice, IRP_MJ_CLOSE); + SendIrp(LowerDevice, IRP_MJ_CLEANUP); return MouseType; }
Modified: trunk/reactos/drivers/input/sermouse/fdo.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/input/sermouse/fdo.c... ============================================================================== --- trunk/reactos/drivers/input/sermouse/fdo.c (original) +++ trunk/reactos/drivers/input/sermouse/fdo.c Sun Apr 23 12:46:25 2006 @@ -1,10 +1,9 @@ /* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS Serial mouse driver - * FILE: drivers/input/sermouse/fdo.c - * PURPOSE: IRP_MJ_PNP operations for FDOs - * - * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org) + * PROJECT: ReactOS Serial mouse driver + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/input/sermouse/fdo.c + * PURPOSE: IRP_MJ_PNP operations for FDOs + * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org) */
#define NDEBUG @@ -18,71 +17,26 @@ IN PDEVICE_OBJECT Pdo) { PSERMOUSE_DRIVER_EXTENSION DriverExtension; - ULONG DeviceId = 0; - ULONG PrefixLength; - UNICODE_STRING DeviceNameU; - PWSTR DeviceIdW = NULL; /* Pointer into DeviceNameU.Buffer */ PDEVICE_OBJECT Fdo; - PSERMOUSE_DEVICE_EXTENSION DeviceExtension; + PSERMOUSE_DEVICE_EXTENSION DeviceExtension = NULL; NTSTATUS Status;
DPRINT("SermouseAddDevice called. Pdo = 0x%p\n", Pdo);
/* Create new device object */ DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject); - DeviceNameU.Length = 0; - DeviceNameU.MaximumLength = - wcslen(L"\Device\") * sizeof(WCHAR) /* "\Device" */ - + DriverExtension->PointerDeviceBaseName.Length /* "PointerPort" */ - + 4 * sizeof(WCHAR) /* Id between 0 and 9999 */ - + sizeof(UNICODE_NULL); /* Final NULL char */ - DeviceNameU.Buffer = ExAllocatePool(PagedPool, DeviceNameU.MaximumLength); - if (!DeviceNameU.Buffer) - { - DPRINT("ExAllocatePool() failed\n"); - return STATUS_INSUFFICIENT_RESOURCES; - } - Status = RtlAppendUnicodeToString(&DeviceNameU, L"\Device\"); + Status = IoCreateDevice( + DriverObject, + sizeof(SERMOUSE_DEVICE_EXTENSION), + NULL, + FILE_DEVICE_SERIAL_MOUSE_PORT, + FILE_DEVICE_SECURE_OPEN, + TRUE, + &Fdo); if (!NT_SUCCESS(Status)) { - DPRINT("RtlAppendUnicodeToString() failed with status 0x%08lx\n", Status); + DPRINT("IoCreateDevice() failed with status 0x%08lx\n", Status); goto cleanup; - } - Status = RtlAppendUnicodeStringToString(&DeviceNameU, &DriverExtension->PointerDeviceBaseName); - if (!NT_SUCCESS(Status)) - { - DPRINT("RtlAppendUnicodeStringToString() failed with status 0x%08lx\n", Status); - goto cleanup; - } - PrefixLength = DeviceNameU.MaximumLength - 4 * sizeof(WCHAR) - sizeof(UNICODE_NULL); - DeviceIdW = &DeviceNameU.Buffer[PrefixLength / sizeof(WCHAR)]; - while (DeviceId < 9999) - { - DeviceNameU.Length = PrefixLength + swprintf(DeviceIdW, L"%lu", DeviceId) * sizeof(WCHAR); - Status = IoCreateDevice( - DriverObject, - sizeof(SERMOUSE_DEVICE_EXTENSION), - &DeviceNameU, - FILE_DEVICE_SERIAL_MOUSE_PORT, - FILE_DEVICE_SECURE_OPEN, - TRUE, - &Fdo); - if (NT_SUCCESS(Status)) - goto cleanup; - else if (Status != STATUS_OBJECT_NAME_COLLISION) - { - DPRINT("IoCreateDevice() failed with status 0x%08lx\n", Status); - goto cleanup; - } - DeviceId++; - } - DPRINT("Too much devices starting with '\Device\%wZ'\n", &DriverExtension->PointerDeviceBaseName); - Status = STATUS_UNSUCCESSFUL; -cleanup: - if (!NT_SUCCESS(Status)) - { - ExFreePool(DeviceNameU.Buffer); - return Status; }
DeviceExtension = (PSERMOUSE_DEVICE_EXTENSION)Fdo->DeviceExtension; @@ -91,41 +45,22 @@ DeviceExtension->PnpState = dsStopped; DeviceExtension->DriverExtension = DriverExtension; KeInitializeEvent(&DeviceExtension->StopWorkerThreadEvent, NotificationEvent, FALSE); - DeviceExtension->MouseInputData[0] = ExAllocatePool(NonPagedPool, DeviceExtension->DriverExtension->MouseDataQueueSize * sizeof(MOUSE_INPUT_DATA)); - if (!DeviceExtension->MouseInputData[0]) - { - DPRINT("ExAllocatePool() failed\n"); - Status = STATUS_INSUFFICIENT_RESOURCES; - goto cleanupFDO; - } - DeviceExtension->MouseInputData[1] = ExAllocatePool(NonPagedPool, DeviceExtension->DriverExtension->MouseDataQueueSize * sizeof(MOUSE_INPUT_DATA)); - if (!DeviceExtension->MouseInputData[1]) - { - DPRINT("ExAllocatePool() failed\n"); - Status = STATUS_INSUFFICIENT_RESOURCES; - goto cleanupFDO; - } Fdo->Flags |= DO_POWER_PAGABLE; Status = IoAttachDeviceToDeviceStackSafe(Fdo, Pdo, &DeviceExtension->LowerDevice); if (!NT_SUCCESS(Status)) { DPRINT("IoAttachDeviceToDeviceStackSafe() failed with status 0x%08lx\n", Status); - goto cleanupFDO; - } - Fdo->Flags |= DO_BUFFERED_IO; + goto cleanup; + } Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
- ExFreePool(DeviceNameU.Buffer); - return STATUS_SUCCESS;
-cleanupFDO: +cleanup: if (DeviceExtension) { if (DeviceExtension->LowerDevice) IoDetachDevice(DeviceExtension->LowerDevice); - ExFreePool(DeviceExtension->MouseInputData[0]); - ExFreePool(DeviceExtension->MouseInputData[1]); } if (Fdo) { @@ -141,6 +76,7 @@ { PSERMOUSE_DEVICE_EXTENSION DeviceExtension; SERMOUSE_MOUSE_TYPE MouseType; + NTSTATUS Status;
DeviceExtension = (PSERMOUSE_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
@@ -169,7 +105,8 @@ DeviceExtension->AttributesInformation.NumberOfButtons = 3; break; default: - CHECKPOINT; + DPRINT("Unknown mouse type 0x%lx\n", MouseType); + ASSERT(FALSE); return STATUS_UNSUCCESSFUL; }
@@ -177,12 +114,22 @@ /* Override the number of buttons */ DeviceExtension->AttributesInformation.NumberOfButtons = DeviceExtension->DriverExtension->NumberOfButtons;
- DeviceExtension->AttributesInformation.SampleRate = DeviceExtension->DriverExtension->SampleRate / 8; - DeviceExtension->AttributesInformation.InputDataQueueLength = DeviceExtension->DriverExtension->MouseDataQueueSize; + DeviceExtension->AttributesInformation.SampleRate = 1200 / 8; + DeviceExtension->AttributesInformation.InputDataQueueLength = 1; DeviceExtension->MouseType = MouseType; DeviceExtension->PnpState = dsStarted;
- return STATUS_SUCCESS; + /* Start read loop */ + Status = PsCreateSystemThread( + &DeviceExtension->WorkerThreadHandle, + (ACCESS_MASK)0L, + NULL, + NULL, + NULL, + SermouseDeviceWorker, + DeviceObject); + + return Status; }
NTSTATUS NTAPI @@ -197,6 +144,7 @@
Stack = IoGetCurrentIrpStackLocation(Irp); MinorFunction = Stack->MinorFunction; + Information = Irp->IoStatus.Information;
switch (MinorFunction) { @@ -207,7 +155,6 @@ IRP_MN_STOP_DEVICE 0x4 IRP_MN_QUERY_STOP_DEVICE 0x5 IRP_MN_CANCEL_STOP_DEVICE 0x6 - IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations (optional) 0x7 IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations (optional) 0x7 IRP_MN_QUERY_INTERFACE (optional) 0x8 IRP_MN_QUERY_CAPABILITIES (optional) 0x9 @@ -225,6 +172,35 @@ Status = SermouseStartDevice(DeviceObject, Irp); break; } + case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x7 */ + { + switch (Stack->Parameters.QueryDeviceRelations.Type) + { + case BusRelations: + { + PDEVICE_RELATIONS DeviceRelations = NULL; + DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / TargetDeviceRelation\n"); + + DeviceRelations = ExAllocatePool(PagedPool, FIELD_OFFSET(DEVICE_RELATIONS, Objects)); + if (!DeviceRelations) + Status = STATUS_INSUFFICIENT_RESOURCES; + else + { + DeviceRelations->Count = 0; + Status = STATUS_SUCCESS; + Information = (ULONG_PTR)DeviceRelations; + } + break; + } + default: + { + DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n", + Stack->Parameters.QueryDeviceRelations.Type); + return ForwardIrpAndForget(DeviceObject, Irp); + } + } + break; + } default: { DPRINT1("IRP_MJ_PNP / unknown minor function 0x%lx\n", MinorFunction);
Modified: trunk/reactos/drivers/input/sermouse/internaldevctl.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/input/sermouse/inter... ============================================================================== --- trunk/reactos/drivers/input/sermouse/internaldevctl.c (original) +++ trunk/reactos/drivers/input/sermouse/internaldevctl.c Sun Apr 23 12:46:25 2006 @@ -1,10 +1,9 @@ /* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS Serial mouse driver - * FILE: drivers/input/sermouse/internaldevctl.c - * PURPOSE: IRP_MJ_INTERNAL_DEVICE_CONTROL operations - * - * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org) + * PROJECT: ReactOS Serial mouse driver + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/input/sermouse/fdo.c + * PURPOSE: IRP_MJ_INTERNAL_DEVICE_CONTROL operations + * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org) */
#define NDEBUG @@ -31,16 +30,7 @@ DPRINT("IRP_MJ_INTERNAL_DEVICE_CONTROL / IOCTL_INTERNAL_MOUSE_CONNECT\n"); DeviceExtension->ConnectData = *((PCONNECT_DATA)Stack->Parameters.DeviceIoControl.Type3InputBuffer); - - /* Start read loop */ - Status = PsCreateSystemThread( - &DeviceExtension->WorkerThreadHandle, - (ACCESS_MASK)0L, - NULL, - NULL, - NULL, - SermouseDeviceWorker, - DeviceObject); + Status = STATUS_SUCCESS; break; } case IOCTL_INTERNAL_MOUSE_DISCONNECT: @@ -61,7 +51,9 @@ DeviceExtension->AttributesInformation; Irp->IoStatus.Information = sizeof(MOUSE_ATTRIBUTES); Status = STATUS_SUCCESS; - } else { + } + else + { Status = STATUS_BUFFER_TOO_SMALL; } break; @@ -70,6 +62,7 @@ { DPRINT1("IRP_MJ_INTERNAL_DEVICE_CONTROL / unknown ioctl code 0x%lx\n", Stack->Parameters.DeviceIoControl.IoControlCode); + ASSERT(FALSE); Status = STATUS_INVALID_DEVICE_REQUEST; break; }
Modified: trunk/reactos/drivers/input/sermouse/misc.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/input/sermouse/misc.... ============================================================================== --- trunk/reactos/drivers/input/sermouse/misc.c (original) +++ trunk/reactos/drivers/input/sermouse/misc.c Sun Apr 23 12:46:25 2006 @@ -1,10 +1,9 @@ /* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS Serial mouse driver - * FILE: drivers/input/sermouse/misc.c - * PURPOSE: Misceallenous operations - * - * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org) + * PROJECT: ReactOS Serial mouse driver + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/input/sermouse/fdo.c + * PURPOSE: Misceallenous operations + * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org) */
#define NDEBUG
Modified: trunk/reactos/drivers/input/sermouse/readmouse.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/input/sermouse/readm... ============================================================================== --- trunk/reactos/drivers/input/sermouse/readmouse.c (original) +++ trunk/reactos/drivers/input/sermouse/readmouse.c Sun Apr 23 12:46:25 2006 @@ -1,12 +1,11 @@ /* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS Serial mouse driver - * FILE: drivers/input/sermouse/readmouse.c - * PURPOSE: Read mouse moves and send them to mouclass - * - * PROGRAMMERS: Jason Filby (jasonfilby@yahoo.com) - * Filip Navara (xnavara@volny.cz) - * Hervé Poussineau (hpoussin@reactos.org) + * PROJECT: ReactOS Serial mouse driver + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/input/sermouse/fdo.c + * PURPOSE: Read mouse moves and send them to mouclass + * PROGRAMMERS: Copyright Jason Filby (jasonfilby@yahoo.com) + Copyright Filip Navara (xnavara@volny.cz) + Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org) */
#define NDEBUG @@ -106,7 +105,7 @@ &Fcr, sizeof(Fcr), NULL, NULL); if (!NT_SUCCESS(Status)) PsTerminateSystemThread(Status); /* Set serial port speed */ - BaudRate = DeviceExtension->DriverExtension->SampleRate; + BaudRate = DeviceExtension->AttributesInformation.SampleRate * 8; Status = SermouseDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_BAUD_RATE, &BaudRate, sizeof(BaudRate), NULL, NULL); if (!NT_SUCCESS(Status)) PsTerminateSystemThread(Status); @@ -187,10 +186,10 @@ Queue = DeviceExtension->ActiveQueue % 2;
/* Prevent buffer overflow */ - if (DeviceExtension->InputDataCount[Queue] == DeviceExtension->DriverExtension->MouseDataQueueSize) + if (DeviceExtension->InputDataCount[Queue] == 1) continue;
- Input = &DeviceExtension->MouseInputData[Queue][DeviceExtension->InputDataCount[Queue]]; + Input = &DeviceExtension->MouseInputData[Queue];
if (DeviceExtension->PacketBufferPosition == 3) { @@ -261,8 +260,8 @@ InterlockedIncrement((PLONG)&DeviceExtension->ActiveQueue); (*(PSERVICE_CALLBACK_ROUTINE)DeviceExtension->ConnectData.ClassService)( DeviceExtension->ConnectData.ClassDeviceObject, - DeviceExtension->MouseInputData[Queue], - DeviceExtension->MouseInputData[Queue] + 1, + &DeviceExtension->MouseInputData[Queue], + &DeviceExtension->MouseInputData[Queue] + 1, &DeviceExtension->InputDataCount[Queue]); KeLowerIrql(OldIrql); DeviceExtension->InputDataCount[Queue] = 0;
Modified: trunk/reactos/drivers/input/sermouse/sermouse.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/input/sermouse/sermo... ============================================================================== --- trunk/reactos/drivers/input/sermouse/sermouse.c (original) +++ trunk/reactos/drivers/input/sermouse/sermouse.c Sun Apr 23 12:46:25 2006 @@ -1,10 +1,9 @@ /* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS Serial mouse driver - * FILE: drivers/input/sermouse/sermouse.c - * PURPOSE: Serial mouse driver entry point - * - * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org) + * PROJECT: ReactOS Serial mouse driver + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/input/sermouse/fdo.c + * PURPOSE: Serial mouse driver entry point + * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org) */
#define NDEBUG @@ -36,13 +35,10 @@ IN PSERMOUSE_DRIVER_EXTENSION DriverExtension) { UNICODE_STRING ParametersRegistryKey; - RTL_QUERY_REGISTRY_TABLE Parameters[5]; + RTL_QUERY_REGISTRY_TABLE Parameters[2]; NTSTATUS Status;
- ULONG DefaultMouseDataQueueSize = 0x64; - ULONG DefaultNumberOfButtons = 0; - UNICODE_STRING DefaultPointerDeviceBaseName = RTL_CONSTANT_STRING(L"PointerPort"); - ULONG DefaultSampleRate = 1200; + ULONG DefaultNumberOfButtons = 2;
ParametersRegistryKey.Length = 0; ParametersRegistryKey.MaximumLength = RegistryPath->Length + sizeof(L"\Parameters") + sizeof(UNICODE_NULL); @@ -59,32 +55,11 @@ RtlZeroMemory(Parameters, sizeof(Parameters));
Parameters[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_REGISTRY_OPTIONAL; - Parameters[0].Name = L"MouseDataQueueSize"; - Parameters[0].EntryContext = &DriverExtension->MouseDataQueueSize; + Parameters[0].Name = L"NumberOfButtons"; + Parameters[0].EntryContext = &DriverExtension->NumberOfButtons; Parameters[0].DefaultType = REG_DWORD; - Parameters[0].DefaultData = &DefaultMouseDataQueueSize; + Parameters[0].DefaultData = &DefaultNumberOfButtons; Parameters[0].DefaultLength = sizeof(ULONG); - - Parameters[1].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_REGISTRY_OPTIONAL; - Parameters[1].Name = L"NumberOfButtons"; - Parameters[1].EntryContext = &DriverExtension->NumberOfButtons; - Parameters[1].DefaultType = REG_DWORD; - Parameters[1].DefaultData = &DefaultNumberOfButtons; - Parameters[1].DefaultLength = sizeof(ULONG); - - Parameters[2].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_REGISTRY_OPTIONAL; - Parameters[2].Name = L"PointerDeviceBaseName"; - Parameters[2].EntryContext = &DriverExtension->PointerDeviceBaseName; - Parameters[2].DefaultType = REG_SZ; - Parameters[2].DefaultData = &DefaultPointerDeviceBaseName; - Parameters[2].DefaultLength = 0; - - Parameters[3].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_REGISTRY_OPTIONAL; - Parameters[3].Name = L"SampleRate"; - Parameters[3].EntryContext = &DriverExtension->SampleRate; - Parameters[3].DefaultType = REG_DWORD; - Parameters[3].DefaultData = &DefaultSampleRate; - Parameters[3].DefaultLength = sizeof(ULONG);
Status = RtlQueryRegistryValues( RTL_REGISTRY_ABSOLUTE, @@ -96,21 +71,12 @@ if (NT_SUCCESS(Status)) { /* Check values */ - if (DriverExtension->MouseDataQueueSize == 0) - { - DriverExtension->MouseDataQueueSize = DefaultMouseDataQueueSize; - } } else if (Status == STATUS_OBJECT_NAME_NOT_FOUND) { /* Registry path doesn't exist. Set defaults */ - DriverExtension->MouseDataQueueSize = DefaultMouseDataQueueSize; DriverExtension->NumberOfButtons = DefaultNumberOfButtons; - Status = RtlDuplicateUnicodeString( - RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, - &DefaultPointerDeviceBaseName, - &DriverExtension->PointerDeviceBaseName); - DriverExtension->SampleRate = DefaultSampleRate; + Status = STATUS_SUCCESS; }
return Status;
Modified: trunk/reactos/drivers/input/sermouse/sermouse.h URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/input/sermouse/sermo... ============================================================================== --- trunk/reactos/drivers/input/sermouse/sermouse.h (original) +++ trunk/reactos/drivers/input/sermouse/sermouse.h Sun Apr 23 12:46:25 2006 @@ -3,16 +3,13 @@ #include <ntddser.h> #include <ntddmou.h>
-#if defined(__GNUC__) - #include <stdio.h> -#elif defined(_MSC_VER) +#if defined(_MSC_VER) + /* Missing prototype */ NTSTATUS NTAPI IoAttachDeviceToDeviceStackSafe( IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice, OUT PDEVICE_OBJECT *AttachedToDeviceObject); -#else - #error Unknown compiler! #endif
typedef enum @@ -57,10 +54,7 @@
typedef struct _SERMOUSE_DRIVER_EXTENSION { - ULONG MouseDataQueueSize; ULONG NumberOfButtons; - UNICODE_STRING PointerDeviceBaseName; - ULONG SampleRate; } SERMOUSE_DRIVER_EXTENSION, *PSERMOUSE_DRIVER_EXTENSION;
typedef struct _SERMOUSE_DEVICE_EXTENSION @@ -76,7 +70,7 @@ ULONG ActiveQueue; ULONG InputDataCount[2]; CONNECT_DATA ConnectData; - MOUSE_INPUT_DATA* MouseInputData[2]; + MOUSE_INPUT_DATA MouseInputData[2]; UCHAR PacketBuffer[PACKET_BUFFER_SIZE]; ULONG PacketBufferPosition; ULONG PreviousButtons;