fixed uninitialized variable warnings
[reactos.git] / reactos / drivers / input / sermouse / internaldevctl.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Serial mouse driver
4 * FILE: drivers/input/sermouse/internaldevctl.c
5 * PURPOSE: IRP_MJ_INTERNAL_DEVICE_CONTROL operations
6 *
7 * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
8 */
9
10 #define NDEBUG
11 #include <debug.h>
12
13 #include "sermouse.h"
14
15 NTSTATUS NTAPI
16 SermouseInternalDeviceControl(
17 IN PDEVICE_OBJECT DeviceObject,
18 IN PIRP Irp)
19 {
20 PSERMOUSE_DEVICE_EXTENSION DeviceExtension;
21 PIO_STACK_LOCATION Stack;
22 NTSTATUS Status;
23
24 DeviceExtension = (PSERMOUSE_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
25 Stack = IoGetCurrentIrpStackLocation(Irp);
26
27 switch (Stack->Parameters.DeviceIoControl.IoControlCode)
28 {
29 case IOCTL_INTERNAL_MOUSE_CONNECT:
30 {
31 DPRINT("IRP_MJ_INTERNAL_DEVICE_CONTROL / IOCTL_INTERNAL_MOUSE_CONNECT\n");
32 DeviceExtension->ConnectData =
33 *((PCONNECT_DATA)Stack->Parameters.DeviceIoControl.Type3InputBuffer);
34
35 /* Start read loop */
36 Status = PsCreateSystemThread(
37 &DeviceExtension->WorkerThreadHandle,
38 (ACCESS_MASK)0L,
39 NULL,
40 NULL,
41 NULL,
42 SermouseDeviceWorker,
43 DeviceObject);
44 break;
45 }
46 case IOCTL_INTERNAL_MOUSE_DISCONNECT:
47 {
48 DPRINT("IRP_MJ_INTERNAL_DEVICE_CONTROL / IOCTL_INTERNAL_MOUSE_DISCONNECT\n");
49
50 /* Ask read loop to end */
51 KeSetEvent(&DeviceExtension->StopWorkerThreadEvent, (KPRIORITY)0, FALSE);
52 Status = STATUS_SUCCESS;
53 break;
54 }
55 case IOCTL_MOUSE_QUERY_ATTRIBUTES:
56 {
57 DPRINT("IRP_MJ_INTERNAL_DEVICE_CONTROL / IOCTL_MOUSE_QUERY_ATTRIBUTES\n");
58 if (Stack->Parameters.DeviceIoControl.OutputBufferLength >= sizeof(MOUSE_ATTRIBUTES))
59 {
60 *(PMOUSE_ATTRIBUTES)Irp->AssociatedIrp.SystemBuffer =
61 DeviceExtension->AttributesInformation;
62 Irp->IoStatus.Information = sizeof(MOUSE_ATTRIBUTES);
63 Status = STATUS_SUCCESS;
64 } else {
65 Status = STATUS_BUFFER_TOO_SMALL;
66 }
67 break;
68 }
69 default:
70 {
71 DPRINT1("IRP_MJ_INTERNAL_DEVICE_CONTROL / unknown ioctl code 0x%lx\n",
72 Stack->Parameters.DeviceIoControl.IoControlCode);
73 Status = STATUS_INVALID_DEVICE_REQUEST;
74 break;
75 }
76 }
77
78 Irp->IoStatus.Status = Status;
79 if (Status == STATUS_PENDING)
80 {
81 IoMarkIrpPending(Irp);
82 IoStartPacket(DeviceObject, Irp, NULL, NULL);
83 }
84 else
85 {
86 IoCompleteRequest(Irp, IO_NO_INCREMENT);
87 }
88
89 return Status;
90 }