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
7 * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
16 SermouseInternalDeviceControl(
17 IN PDEVICE_OBJECT DeviceObject
,
20 PSERMOUSE_DEVICE_EXTENSION DeviceExtension
;
21 PIO_STACK_LOCATION Stack
;
24 DeviceExtension
= (PSERMOUSE_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
25 Stack
= IoGetCurrentIrpStackLocation(Irp
);
27 switch (Stack
->Parameters
.DeviceIoControl
.IoControlCode
)
29 case IOCTL_INTERNAL_MOUSE_CONNECT
:
31 DPRINT("IRP_MJ_INTERNAL_DEVICE_CONTROL / IOCTL_INTERNAL_MOUSE_CONNECT\n");
32 DeviceExtension
->ConnectData
=
33 *((PCONNECT_DATA
)Stack
->Parameters
.DeviceIoControl
.Type3InputBuffer
);
36 Status
= PsCreateSystemThread(
37 &DeviceExtension
->WorkerThreadHandle
,
46 case IOCTL_INTERNAL_MOUSE_DISCONNECT
:
48 DPRINT("IRP_MJ_INTERNAL_DEVICE_CONTROL / IOCTL_INTERNAL_MOUSE_DISCONNECT\n");
50 /* Ask read loop to end */
51 KeSetEvent(&DeviceExtension
->StopWorkerThreadEvent
, (KPRIORITY
)0, FALSE
);
52 Status
= STATUS_SUCCESS
;
55 case IOCTL_MOUSE_QUERY_ATTRIBUTES
:
57 DPRINT("IRP_MJ_INTERNAL_DEVICE_CONTROL / IOCTL_MOUSE_QUERY_ATTRIBUTES\n");
58 if (Stack
->Parameters
.DeviceIoControl
.OutputBufferLength
>= sizeof(MOUSE_ATTRIBUTES
))
60 *(PMOUSE_ATTRIBUTES
)Irp
->AssociatedIrp
.SystemBuffer
=
61 DeviceExtension
->AttributesInformation
;
62 Irp
->IoStatus
.Information
= sizeof(MOUSE_ATTRIBUTES
);
63 Status
= STATUS_SUCCESS
;
65 Status
= STATUS_BUFFER_TOO_SMALL
;
71 DPRINT1("IRP_MJ_INTERNAL_DEVICE_CONTROL / unknown ioctl code 0x%lx\n",
72 Stack
->Parameters
.DeviceIoControl
.IoControlCode
);
73 Status
= STATUS_INVALID_DEVICE_REQUEST
;
78 Irp
->IoStatus
.Status
= Status
;
79 if (Status
== STATUS_PENDING
)
81 IoMarkIrpPending(Irp
);
82 IoStartPacket(DeviceObject
, Irp
, NULL
, NULL
);
86 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);