ReactOS  0.4.14-dev-55-g2da92ac
i8042prt.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS i8042 (ps/2 keyboard-mouse controller) driver
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: drivers/input/i8042prt/i8042prt.c
5  * PURPOSE: Driver entry function
6  * PROGRAMMERS: Copyright Victor Kirhenshtein (sauros@iname.com)
7  Copyright Jason Filby (jasonfilby@yahoo.com)
8  Copyright Martijn Vernooij (o112w8r02@sneakemail.com)
9  Copyright 2006-2007 Hervé Poussineau (hpoussin@reactos.org)
10  */
11 
12 /* INCLUDES ******************************************************************/
13 
14 #include "i8042prt.h"
15 
16 #include <debug.h>
17 
18 /* FUNCTIONS *****************************************************************/
19 
20 static DRIVER_STARTIO i8042StartIo;
30 DRIVER_INITIALIZE DriverEntry;
31 
36 {
38  PFDO_DEVICE_EXTENSION DeviceExtension = NULL;
39  PDEVICE_OBJECT Fdo = NULL;
40  ULONG DeviceExtensionSize;
42 
43  TRACE_(I8042PRT, "i8042AddDevice(%p %p)\n", DriverObject, Pdo);
44 
46 
47  if (Pdo == NULL)
48  {
49  /* We're getting a NULL Pdo at the first call as
50  * we are a legacy driver. Ignore it */
51  return STATUS_SUCCESS;
52  }
53 
54  /* Create new device object. As we don't know if the device would be a keyboard
55  * or a mouse, we have to allocate the biggest device extension. */
56  DeviceExtensionSize = MAX(sizeof(I8042_KEYBOARD_EXTENSION), sizeof(I8042_MOUSE_EXTENSION));
59  DeviceExtensionSize,
60  NULL,
61  Pdo->DeviceType,
63  TRUE,
64  &Fdo);
65  if (!NT_SUCCESS(Status))
66  {
67  WARN_(I8042PRT, "IoCreateDevice() failed with status 0x%08lx\n", Status);
68  goto cleanup;
69  }
70 
71  DeviceExtension = (PFDO_DEVICE_EXTENSION)Fdo->DeviceExtension;
72  RtlZeroMemory(DeviceExtension, DeviceExtensionSize);
73  DeviceExtension->Type = Unknown;
74  DeviceExtension->Fdo = Fdo;
75  DeviceExtension->Pdo = Pdo;
76  DeviceExtension->PortDeviceExtension = &DriverExtension->Port;
77  Status = IoAttachDeviceToDeviceStackSafe(Fdo, Pdo, &DeviceExtension->LowerDevice);
78  if (!NT_SUCCESS(Status))
79  {
80  WARN_(I8042PRT, "IoAttachDeviceToDeviceStackSafe() failed with status 0x%08lx\n", Status);
81  goto cleanup;
82  }
83 
85  &DriverExtension->DeviceListHead,
86  &DeviceExtension->ListEntry,
87  &DriverExtension->DeviceListLock);
88 
90  return STATUS_SUCCESS;
91 
92 cleanup:
93  if (DeviceExtension && DeviceExtension->LowerDevice)
94  IoDetachDevice(DeviceExtension->LowerDevice);
95  if (Fdo)
96  IoDeleteDevice(Fdo);
97  return Status;
98 }
99 
100 VOID NTAPI
103  IN PVOID Context)
104 {
105  PI8042_HOOK_WORKITEM WorkItemData;
106  PFDO_DEVICE_EXTENSION FdoDeviceExtension;
107  PPORT_DEVICE_EXTENSION PortDeviceExtension;
108  PDEVICE_OBJECT TopOfStack = NULL;
113  KEVENT Event;
114  PIRP NewIrp;
116 
117  TRACE_(I8042PRT, "i8042SendHookWorkItem(%p %p)\n", DeviceObject, Context);
118 
119  WorkItemData = (PI8042_HOOK_WORKITEM)Context;
120  FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
121  PortDeviceExtension = FdoDeviceExtension->PortDeviceExtension;
122 
123  switch (FdoDeviceExtension->Type)
124  {
125  case Keyboard:
126  {
127  PI8042_KEYBOARD_EXTENSION DeviceExtension;
128  DeviceExtension = (PI8042_KEYBOARD_EXTENSION)FdoDeviceExtension;
130  InputBuffer = &DeviceExtension->KeyboardHook;
132  break;
133  }
134  case Mouse:
135  {
136  PI8042_MOUSE_EXTENSION DeviceExtension;
137  DeviceExtension = (PI8042_MOUSE_EXTENSION)FdoDeviceExtension;
139  InputBuffer = &DeviceExtension->MouseHook;
141  break;
142  }
143  default:
144  {
145  ERR_(I8042PRT, "Unknown FDO type %u\n", FdoDeviceExtension->Type);
146  ASSERT(FALSE);
147  WorkItemData->Irp->IoStatus.Status = STATUS_INTERNAL_ERROR;
148  goto cleanup;
149  }
150  }
151 
154 
157  TopOfStack,
158  InputBuffer,
160  NULL,
161  0,
162  TRUE,
163  &Event,
164  &IoStatus);
165 
166  if (!NewIrp)
167  {
168  WARN_(I8042PRT, "IoBuildDeviceIoControlRequest() failed\n");
169  WorkItemData->Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
170  goto cleanup;
171  }
172 
173  Status = IoCallDriver(TopOfStack, NewIrp);
174  if (Status == STATUS_PENDING)
175  {
177  &Event,
178  Executive,
179  KernelMode,
180  FALSE,
181  NULL);
182  Status = IoStatus.Status;
183  }
184  if (!NT_SUCCESS(Status))
185  {
186  WARN_(I8042PRT, "IoCallDriver() failed with status 0x%08lx\n", Status);
187  goto cleanup;
188  }
189 
190  if (FdoDeviceExtension->Type == Keyboard)
191  {
192  PI8042_KEYBOARD_EXTENSION DeviceExtension;
193 
194  DeviceExtension = (PI8042_KEYBOARD_EXTENSION)FdoDeviceExtension;
195  /* Call the hooked initialization if it exists */
196  if (DeviceExtension->KeyboardHook.InitializationRoutine)
197  {
198  Status = DeviceExtension->KeyboardHook.InitializationRoutine(
199  DeviceExtension->KeyboardHook.Context,
200  PortDeviceExtension,
203  FALSE);
204  if (!NT_SUCCESS(Status))
205  {
206  WARN_(I8042PRT, "KeyboardHook.InitializationRoutine() failed with status 0x%08lx\n", Status);
207  WorkItemData->Irp->IoStatus.Status = Status;
208  goto cleanup;
209  }
210  }
211  }
212 
213  WorkItemData->Irp->IoStatus.Status = STATUS_SUCCESS;
214 
215 cleanup:
216  if (TopOfStack != NULL)
217  ObDereferenceObject(TopOfStack);
218  WorkItemData->Irp->IoStatus.Information = 0;
219  IoCompleteRequest(WorkItemData->Irp, IO_NO_INCREMENT);
220 
221  IoFreeWorkItem(WorkItemData->WorkItem);
222  ExFreePoolWithTag(WorkItemData, I8042PRT_TAG);
223 }
224 
225 static VOID NTAPI
228  IN PIRP Irp)
229 {
230  PFDO_DEVICE_EXTENSION DeviceExtension;
231 
233  switch (DeviceExtension->Type)
234  {
235  case Keyboard:
237  break;
238  default:
239  ERR_(I8042PRT, "Unknown FDO type %u\n", DeviceExtension->Type);
240  ASSERT(FALSE);
241  break;
242  }
243 }
244 
245 /* Write the current byte of the packet. Returns FALSE in case
246  * of problems.
247  */
248 static BOOLEAN
250  IN PPORT_DEVICE_EXTENSION DeviceExtension)
251 {
252  UCHAR Port = DeviceExtension->PacketPort;
253 
254  if (Port)
255  {
256  if (!i8042Write(DeviceExtension,
257  DeviceExtension->ControlPort,
258  Port))
259  {
260  /* something is really wrong! */
261  WARN_(I8042PRT, "Failed to send packet byte!\n");
262  return FALSE;
263  }
264  }
265 
266  return i8042Write(DeviceExtension,
267  DeviceExtension->DataPort,
268  DeviceExtension->Packet.Bytes[DeviceExtension->Packet.CurrentByte]);
269 }
270 
271 BOOLEAN
273  IN PPORT_DEVICE_EXTENSION DeviceExtension,
274  IN UCHAR Output)
275 {
276  if (DeviceExtension->Packet.State == Idle)
277  return FALSE;
278 
279  switch (Output)
280  {
281  case KBD_RESEND:
282  DeviceExtension->PacketResends++;
283  if (DeviceExtension->PacketResends > DeviceExtension->Settings.ResendIterations)
284  {
285  DeviceExtension->Packet.State = Idle;
286  DeviceExtension->PacketComplete = TRUE;
287  DeviceExtension->PacketResult = STATUS_IO_TIMEOUT;
288  DeviceExtension->PacketResends = 0;
289  return TRUE;
290  }
291  DeviceExtension->Packet.CurrentByte--;
292  break;
293 
294  case KBD_NACK:
295  DeviceExtension->Packet.State = Idle;
296  DeviceExtension->PacketComplete = TRUE;
297  DeviceExtension->PacketResult = STATUS_UNEXPECTED_IO_ERROR;
298  DeviceExtension->PacketResends = 0;
299  return TRUE;
300 
301  default:
302  DeviceExtension->PacketResends = 0;
303  }
304 
305  if (DeviceExtension->Packet.CurrentByte >= DeviceExtension->Packet.ByteCount)
306  {
307  DeviceExtension->Packet.State = Idle;
308  DeviceExtension->PacketComplete = TRUE;
309  DeviceExtension->PacketResult = STATUS_SUCCESS;
310  return TRUE;
311  }
312 
313  if (!i8042PacketWrite(DeviceExtension))
314  {
315  DeviceExtension->Packet.State = Idle;
316  DeviceExtension->PacketComplete = TRUE;
317  DeviceExtension->PacketResult = STATUS_IO_TIMEOUT;
318  return TRUE;
319  }
320  DeviceExtension->Packet.CurrentByte++;
321 
322  return TRUE;
323 }
324 
325 /*
326  * This function starts a packet. It must be called with the
327  * correct DIRQL.
328  */
329 NTSTATUS
331  IN PPORT_DEVICE_EXTENSION DeviceExtension,
332  IN PFDO_DEVICE_EXTENSION FdoDeviceExtension,
333  IN PUCHAR Bytes,
335  IN PIRP Irp)
336 {
337  KIRQL Irql;
339 
340  Irql = KeAcquireInterruptSpinLock(DeviceExtension->HighestDIRQLInterrupt);
341 
342  if (DeviceExtension->Packet.State != Idle)
343  {
345  goto done;
346  }
347 
348  switch (FdoDeviceExtension->Type)
349  {
350  case Keyboard: DeviceExtension->PacketPort = 0; break;
351  case Mouse: DeviceExtension->PacketPort = CTRL_WRITE_MOUSE; break;
352  default:
353  ERR_(I8042PRT, "Unknown FDO type %u\n", FdoDeviceExtension->Type);
354  ASSERT(FALSE);
356  goto done;
357  }
358 
359  DeviceExtension->Packet.Bytes = Bytes;
360  DeviceExtension->Packet.CurrentByte = 0;
361  DeviceExtension->Packet.ByteCount = ByteCount;
362  DeviceExtension->Packet.State = SendingBytes;
363  DeviceExtension->PacketResult = Status = STATUS_PENDING;
364  DeviceExtension->CurrentIrp = Irp;
365  DeviceExtension->CurrentIrpDevice = FdoDeviceExtension->Fdo;
366 
367  if (!i8042PacketWrite(DeviceExtension))
368  {
370  DeviceExtension->Packet.State = Idle;
371  DeviceExtension->PacketResult = STATUS_ABANDONED;
372  goto done;
373  }
374 
375  DeviceExtension->Packet.CurrentByte++;
376 
377 done:
378  KeReleaseInterruptSpinLock(DeviceExtension->HighestDIRQLInterrupt, Irql);
379 
380  if (Status != STATUS_PENDING)
381  {
382  DeviceExtension->CurrentIrp = NULL;
383  DeviceExtension->CurrentIrpDevice = NULL;
384  Irp->IoStatus.Status = Status;
386  }
387  return Status;
388 }
389 
390 static NTSTATUS NTAPI
393  IN PIRP Irp)
394 {
395  NTSTATUS Status = Irp->IoStatus.Status;
396 
398 
399  /* Do nothing */
400  ASSERT(FALSE);
402  return Status;
403 }
404 
405 static NTSTATUS NTAPI
408  IN PIRP Irp)
409 {
410  PFDO_DEVICE_EXTENSION DeviceExtension;
411 
412  TRACE_(I8042PRT, "i8042DeviceControl(%p %p)\n", DeviceObject, Irp);
414 
415  switch (DeviceExtension->Type)
416  {
417  case Keyboard:
419  break;
420  default:
421  return IrpStub(DeviceObject, Irp);
422  }
423 }
424 
425 static NTSTATUS NTAPI
428  IN PIRP Irp)
429 {
430  PFDO_DEVICE_EXTENSION DeviceExtension;
433 
434  TRACE_(I8042PRT, "i8042InternalDeviceControl(%p %p)\n", DeviceObject, Irp);
436 
437  switch (DeviceExtension->Type)
438  {
439  case Unknown:
440  {
441  ControlCode = IoGetCurrentIrpStackLocation(Irp)->Parameters.DeviceIoControl.IoControlCode;
442  switch (ControlCode)
443  {
446  break;
449  break;
450  default:
451  ERR_(I8042PRT, "Unknown IO control code 0x%lx\n", ControlCode);
452  ASSERT(FALSE);
454  break;
455  }
456  break;
457  }
458  case Keyboard:
460  break;
461  case Mouse:
463  break;
464  default:
465  ERR_(I8042PRT, "Unknown FDO type %u\n", DeviceExtension->Type);
466  ASSERT(FALSE);
469  break;
470  }
471 
472  return Status;
473 }
474 
475 static NTSTATUS NTAPI
478  IN PIRP Irp)
479 {
481  PDEVICE_OBJECT LowerDevice = DeviceExtension->LowerDevice;
482 
485  return PoCallDriver(LowerDevice, Irp);
486 }
487 
488 static NTSTATUS NTAPI
491  IN PIRP Irp)
492 {
494 }
495 
500 {
502  ULONG i;
504 
505  /* ROS Hack: ideally, we shouldn't have to initialize debug level this way,
506  but since the only way is to change it via KDBG, it's better to leave
507  it here too. */
508 #if 0
511  (1 << DPFLTR_ERROR_LEVEL) | (1 << DPFLTR_WARNING_LEVEL) |
512  (1 << DPFLTR_TRACE_LEVEL) /*| (1 << DPFLTR_INFO_LEVEL)*/ | DPFLTR_MASK,
513  TRUE);
514 #endif
515 
517  DriverObject,
518  DriverObject,
519  sizeof(I8042_DRIVER_EXTENSION),
521  if (!NT_SUCCESS(Status))
522  {
523  WARN_(I8042PRT, "IoAllocateDriverObjectExtension() failed with status 0x%08lx\n", Status);
524  return Status;
525  }
527  KeInitializeSpinLock(&DriverExtension->Port.SpinLock);
528  InitializeListHead(&DriverExtension->DeviceListHead);
529  KeInitializeSpinLock(&DriverExtension->DeviceListLock);
530 
533  RegistryPath,
534  &DriverExtension->RegistryPath);
535  if (!NT_SUCCESS(Status))
536  {
537  WARN_(I8042PRT, "DuplicateUnicodeString() failed with status 0x%08lx\n", Status);
538  return Status;
539  }
540 
542  if (!NT_SUCCESS(Status))
543  {
544  WARN_(I8042PRT, "ReadRegistryEntries() failed with status 0x%08lx\n", Status);
545  return Status;
546  }
547 
550 
551  for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
553 
562 
564 
565  return STATUS_SUCCESS;
566 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
static NTSTATUS NTAPI i8042SystemControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: i8042prt.c:489
CPPORT Port[4]
Definition: headless.c:34
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT Pdo
Definition: classpnp.h:301
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
NTSTATUS NTAPI IoAllocateDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress, IN ULONG DriverObjectExtensionSize, OUT PVOID *DriverObjectExtension)
Definition: driver.c:1764
PIO_WORKITEM WorkItem
Definition: i8042prt.h:203
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
NTSTATUS NTAPI PoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: power.c:485
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
unsigned char * PUCHAR
Definition: retypes.h:3
NTSTATUS NTAPI i8042Pnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pnp.c:675
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LIST_ENTRY ListEntry
Definition: pci.h:82
DRIVER_DISPATCH ForwardIrpAndForget
Definition: i8042prt.h:341
#define ERR_(ch,...)
Definition: debug.h:156
#define IRP_MJ_MAXIMUM_FUNCTION
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI i8042SendHookWorkItem(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context)
Definition: i8042prt.c:101
_In_ UINT Bytes
Definition: mmcopy.h:9
#define DPFLTR_MASK
Definition: kdtypes.h:34
NTSTATUS NTAPI i8042Create(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: createclose.c:18
BOOLEAN i8042Write(IN PPORT_DEVICE_EXTENSION DeviceExtension, IN PUCHAR addr, IN UCHAR data)
Definition: readwrite.c:199
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
DRIVER_DISPATCH i8042KbdDeviceControl
Definition: i8042prt.h:316
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
struct _INTERNAL_I8042_HOOK_KEYBOARD INTERNAL_I8042_HOOK_KEYBOARD
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_Out_ PKIRQL Irql
Definition: csq.h:179
VOID NTAPI IoFreeWorkItem(IN PIO_WORKITEM IoWorkItem)
Definition: iowork.c:64
struct _I8042_KEYBOARD_EXTENSION * PI8042_KEYBOARD_EXTENSION
Definition: i8042prt.h:63
#define DPFLTR_WARNING_LEVEL
Definition: kdtypes.h:31
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
#define I8042PRT_TAG
Definition: i8042prt.h:12
CHAR InputBuffer[80]
Definition: conmgr.c:33
static DRIVER_DISPATCH IrpStub
Definition: i8042prt.c:21
NTSTATUS NTAPI i8042Close(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: createclose.c:46
DRIVER_ADD_DEVICE i8042AddDevice
Definition: i8042prt.h:324
struct _I8042_DRIVER_EXTENSION * PI8042_DRIVER_EXTENSION
DRIVER_STARTIO i8042KbdStartIo
Definition: i8042prt.h:314
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:451
UCHAR KIRQL
Definition: env_spec_w32.h:591
static BOOLEAN i8042PacketWrite(IN PPORT_DEVICE_EXTENSION DeviceExtension)
Definition: i8042prt.c:249
static NTSTATUS NTAPI i8042InternalDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: i8042prt.c:426
PPORT_DEVICE_EXTENSION PortDeviceExtension
Definition: i8042prt.h:134
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
PDRIVER_EXTENSION DriverExtension
Definition: iotypes.h:2174
_Dispatch_type_(IRP_MJ_DEVICE_CONTROL)
Definition: i8042prt.c:22
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
VOID NTAPI KeReleaseInterruptSpinLock(IN PKINTERRUPT Interrupt, IN KIRQL OldIrql)
Definition: spinlock.c:165
NTSTATUS i8042StartPacket(IN PPORT_DEVICE_EXTENSION DeviceExtension, IN PFDO_DEVICE_EXTENSION FdoDeviceExtension, IN PUCHAR Bytes, IN ULONG ByteCount, IN PIRP Irp)
Definition: i8042prt.c:330
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define IoCompleteRequest
Definition: irp.c:1240
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
switch(r->id)
Definition: btrfs.c:2932
Definition: ntdd8042.h:62
NTSTATUS NTAPI DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
Definition: i8042prt.c:497
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1406
BOOLEAN i8042PacketIsr(IN PPORT_DEVICE_EXTENSION DeviceExtension, IN UCHAR Output)
Definition: i8042prt.c:272
#define TRACE_(x)
Definition: compat.h:66
NTSTATUS NTAPI IoAttachDeviceToDeviceStackSafe(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice, IN OUT PDEVICE_OBJECT *AttachedToDeviceObject)
Definition: device.c:980
INTERNAL_I8042_HOOK_KEYBOARD KeyboardHook
Definition: i8042prt.h:141
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
static DRIVER_STARTIO i8042StartIo
Definition: i8042prt.c:20
NTSTATUS DuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: misc.c:72
NTSTATUS NTAPI i8042SynchWritePortKbd(IN PVOID Context, IN UCHAR Value, IN BOOLEAN WaitForAck)
Definition: keyboard.c:87
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
KIRQL NTAPI KeAcquireInterruptSpinLock(IN PKINTERRUPT Interrupt)
Definition: spinlock.c:148
#define IOCTL_INTERNAL_KEYBOARD_CONNECT
Definition: kbdmou.h:56
I8042_DEVICE_TYPE Type
Definition: i8042prt.h:122
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define IOCTL_INTERNAL_MOUSE_CONNECT
Definition: kbdmou.h:68
unsigned char UCHAR
Definition: xmlstorage.h:181
#define IRP_MJ_POWER
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
INTERNAL_I8042_HOOK_MOUSE MouseHook
Definition: i8042prt.h:179
Definition: arc.h:85
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1842
NTSTATUS NTAPI i8042Cleanup(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: createclose.c:32
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
DRIVER_DISPATCH(nfs41_FsdDispatch)
NTSTATUS NTAPI i8042SynchReadPort(IN PVOID Context, OUT PUCHAR Value, IN BOOLEAN WaitForAck)
Definition: readwrite.c:125
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG InputBufferLength
Definition: fltkernel.h:1372
#define IRP_MJ_SYSTEM_CONTROL
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _In_ LARGE_INTEGER ByteCount
Definition: iotypes.h:1061
Status
Definition: gdiplustypes.h:24
T MAX(T a, T b)
Definition: polytest.cpp:85
PDEVICE_OBJECT Fdo
Definition: i8042prt.h:126
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
PDRIVER_ADD_DEVICE AddDevice
Definition: iotypes.h:2112
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
static NTSTATUS NTAPI i8042DeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: i8042prt.c:406
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:626
#define IOCTL_INTERNAL_I8042_HOOK_MOUSE
Definition: ntdd8042.h:45
#define DPFLTR_ERROR_LEVEL
Definition: main.cpp:32
#define KBD_RESEND
Definition: i8042prt.h:244
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
NTSTATUS ReadRegistryEntries(IN PUNICODE_STRING RegistryPath, OUT PI8042_SETTINGS Settings)
Definition: registry.c:21
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define STATUS_IO_TIMEOUT
Definition: udferr_usr.h:163
#define STATUS_UNEXPECTED_IO_ERROR
Definition: ntstatus.h:455
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
static NTSTATUS NTAPI i8042Power(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: i8042prt.c:476
struct _I8042_HOOK_WORKITEM * PI8042_HOOK_WORKITEM
#define IRP_MJ_CLEANUP
NTSYSAPI NTSTATUS NTAPI DbgSetDebugFilterState(_In_ ULONG ComponentId, _In_ ULONG Level, _In_ BOOLEAN State)
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: iotypes.h:2181
PDEVICE_OBJECT Pdo
Definition: i8042prt.h:128
#define IOCTL_INTERNAL_I8042_HOOK_KEYBOARD
Definition: ntdd8042.h:36
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
char * cleanup(char *str)
Definition: wpickclick.c:99
VOID NTAPI i8042InitializeHwHacks(VOID)
Definition: hwhacks.c:183
PDRIVER_STARTIO DriverStartIo
Definition: iotypes.h:2179
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
PDEVICE_OBJECT LowerDevice
Definition: i8042prt.h:130
DRIVER_DISPATCH i8042MouInternalDeviceControl
Definition: i8042prt.h:367
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2966
struct _INTERNAL_I8042_HOOK_MOUSE INTERNAL_I8042_HOOK_MOUSE
#define DPFLTR_TRACE_LEVEL
Definition: kdtypes.h:32
OUT PI8042_KEYBOARD_INITIALIZATION_ROUTINE InitializationRoutine
Definition: ntdd8042.h:178
#define STATUS_ABANDONED
Definition: ntstatus.h:75
#define WARN_(ch,...)
Definition: debug.h:157
struct _I8042_MOUSE_EXTENSION * PI8042_MOUSE_EXTENSION
Definition: i8042prt.h:65
#define CTRL_WRITE_MOUSE
Definition: i8042prt.h:228
DRIVER_DISPATCH i8042KbdInternalDeviceControl
Definition: i8042prt.h:318
#define KBD_NACK
Definition: i8042prt.h:243
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52