47 WARN_(I8042PRT,
"Can't read i8042 mode\n");
54 WARN_(I8042PRT,
"No response after read i8042 mode\n");
58 Value &= ~FlagsToDisable;
59 Value |= FlagsToEnable;
63 WARN_(I8042PRT,
"Can't set i8042 mode\n");
69 WARN_(I8042PRT,
"Can't send i8042 mode\n");
81 ULONG ResendIterations;
92 ResendIterations = DeviceExtension->Settings.ResendIterations + 1;
93 while (ResendIterations--)
97 WARN_(I8042PRT,
"Writing CTRL_SELF_TEST command failed\n");
104 WARN_(I8042PRT,
"Failed to read CTRL_SELF_TEST response, status 0x%08lx\n",
Status);
110 INFO_(I8042PRT,
"CTRL_SELF_TEST completed successfully!\n");
115 TRACE_(I8042PRT,
"Resending...\n");
120 WARN_(I8042PRT,
"Got 0x%02x instead of 0x55\n",
Value);
141 WARN_(I8042PRT,
"Can't finish SET_LEDS (0x%08lx)\n",
Status);
147 WARN_(I8042PRT,
"Warning: can't write SET_LEDS (0x%08lx)\n",
Status);
161 INFO_(I8042PRT,
"Keyboard detected\n");
180 WARN_(I8042PRT,
"Mouse line test failed\n");
190 WARN_(I8042PRT,
"Failed to write reset command to mouse\n");
206 ReplyByte <
sizeof(ExpectedReply) /
sizeof(ExpectedReply[0]);
224 WARN_(I8042PRT,
"No ACK after mouse reset, status 0x%08lx\n",
Status);
227 else if (
Value != ExpectedReply[ReplyByte])
229 WARN_(I8042PRT,
"Unexpected reply: 0x%02x (expected 0x%02x)\n",
Value, ExpectedReply[ReplyByte]);
240 WARN_(I8042PRT,
"Last byte was not transmitted after mouse reset, status 0x%08lx\n",
Status);
243 else if(
Value != 0x00)
245 WARN_(I8042PRT,
"Last byte after mouse reset was not 0x00, but 0x%02x\n",
Value);
250 INFO_(I8042PRT,
"Mouse detected\n");
263 INFO_(I8042PRT,
"Mouse not detected\n");
274 TRACE_(I8042PRT,
"i8042ConnectKeyboardInterrupt()\n");
276 PortDeviceExtension = DeviceExtension->
Common.PortDeviceExtension;
285 INFO_(I8042PRT,
"KeyboardInterrupt.Vector %lu\n",
287 INFO_(I8042PRT,
"KeyboardInterrupt.Dirql %lu\n",
289 INFO_(I8042PRT,
"KeyboardInterrupt.DirqlMax %lu\n",
291 INFO_(I8042PRT,
"KeyboardInterrupt.InterruptMode %s\n",
293 INFO_(I8042PRT,
"KeyboardInterrupt.ShareInterrupt %s\n",
295 INFO_(I8042PRT,
"KeyboardInterrupt.Affinity 0x%lx\n",
300 DeviceExtension, &PortDeviceExtension->
SpinLock,
306 WARN_(I8042PRT,
"IoConnectInterrupt() failed with status 0x%08x\n",
Status);
324 TRACE_(I8042PRT,
"i8042ConnectMouseInterrupt()\n");
330 PortDeviceExtension = DeviceExtension->
Common.PortDeviceExtension;
335 INFO_(I8042PRT,
"MouseInterrupt.Vector %lu\n",
337 INFO_(I8042PRT,
"MouseInterrupt.Dirql %lu\n",
339 INFO_(I8042PRT,
"MouseInterrupt.DirqlMax %lu\n",
341 INFO_(I8042PRT,
"MouseInterrupt.InterruptMode %s\n",
343 INFO_(I8042PRT,
"MouseInterrupt.ShareInterrupt %s\n",
345 INFO_(I8042PRT,
"MouseInterrupt.Affinity 0x%lx\n",
350 DeviceExtension, &PortDeviceExtension->
SpinLock,
356 WARN_(I8042PRT,
"IoConnectInterrupt() failed with status 0x%08x\n",
Status);
398 UCHAR FlagsToDisable = 0;
399 UCHAR FlagsToEnable = 0;
402 if (DeviceExtension->DataPort == 0)
411 TRACE_(I8042PRT,
"Check if the controller is really a i8042\n");
415 WARN_(I8042PRT,
"i8042BasicDetect() failed with status 0x%08lx\n",
Status);
421 TRACE_(I8042PRT,
"Detecting mouse\n");
423 TRACE_(I8042PRT,
"Detecting keyboard\n");
427 INFO_(I8042PRT,
"Mouse present : %s\n", DeviceExtension->Flags &
MOUSE_PRESENT ?
"YES" :
"NO");
429 TRACE_(I8042PRT,
"Enabling i8042 interrupts\n");
444 WARN_(I8042PRT,
"EnableInterrupts failed: %lx\n",
Status);
464 WARN_(I8042PRT,
"i8042ConnectKeyboardInterrupt failed: %lx\n",
Status);
481 WARN_(I8042PRT,
"i8042ConnectMouseInterrupt failed: %lx\n",
Status);
523 WARN_(I8042PRT,
"No allocated resources sent to driver\n");
528 WARN_(I8042PRT,
"Wrong number of allocated resources sent to driver\n");
536 WARN_(I8042PRT,
"Revision mismatch: %u.%u != 1.1 or %u.%u != 1.1\n",
547 ResourceDescriptor = &
AllocatedResources->List[0].PartialResourceList.PartialDescriptors[
i];
549 switch (ResourceDescriptor->
Type)
553 if (ResourceDescriptor->
u.
Port.Length == 1)
562 INFO_(I8042PRT,
"Found data port: %p\n", PortDeviceExtension->
DataPort);
563 FoundDataPort =
TRUE;
565 else if (!FoundControlPort)
568 INFO_(I8042PRT,
"Found control port: %p\n", PortDeviceExtension->
ControlPort);
569 FoundControlPort =
TRUE;
574 ERR_(I8042PRT,
"Unhandled I/O ranges provided: 0x%lx\n", ResourceDescriptor->
u.
Port.Length);
578 WARN_(I8042PRT,
"Invalid I/O range length: 0x%lx\n", ResourceDescriptor->
u.
Port.Length);
593 INFO_(I8042PRT,
"Found irq resource: %lu\n", ResourceDescriptor->
u.
Interrupt.Level);
598 WARN_(I8042PRT,
"Unknown resource descriptor type 0x%x\n", ResourceDescriptor->
Type);
604 WARN_(I8042PRT,
"Interrupt resource was not found in allocated resources list\n");
607 else if (DeviceExtension->
Type ==
Keyboard && (!FoundDataPort || !FoundControlPort))
609 WARN_(I8042PRT,
"Some required resources were not found in allocated resources list\n");
612 else if (DeviceExtension->
Type ==
Mouse && (FoundDataPort || FoundControlPort))
614 WARN_(I8042PRT,
"Too much resources were provided in allocated resources list\n");
618 switch (DeviceExtension->
Type)
642 WARN_(I8042PRT,
"Unknown FDO type %u\n", DeviceExtension->
Type);
693 TRACE_(I8042PRT,
"IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
702 Stack->Parameters.StartDevice.AllocatedResources,
703 Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
711 switch (
Stack->Parameters.QueryDeviceRelations.Type)
715 TRACE_(I8042PRT,
"IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
720 TRACE_(I8042PRT,
"IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations\n");
724 ERR_(I8042PRT,
"IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
725 Stack->Parameters.QueryDeviceRelations.Type);
732 TRACE_(I8042PRT,
"IRP_MJ_PNP / IRP_MN_QUERY_CAPABILITIES\n");
737 TRACE_(I8042PRT,
"IRP_MJ_PNP / IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
742 TRACE_(I8042PRT,
"IRP_MJ_PNP / IRP_MN_QUERY_PNP_DEVICE_STATE\n");
747 TRACE_(I8042PRT,
"IRP_MJ_PNP / IRP_MN_QUERY_REMOVE_DEVICE\n");
752 TRACE_(I8042PRT,
"IRP_MJ_PNP / IRP_MN_CANCEL_REMOVE_DEVICE\n");
757 TRACE_(I8042PRT,
"IRP_MJ_PNP / IRP_MN_REMOVE_DEVICE\n");
#define STATUS_REVISION_MISMATCH
#define CCB_MOUSE_INT_ENAB
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_REMOVE_DEVICE
#define STATUS_INSUFFICIENT_RESOURCES
#define KEYBOARD_INITIALIZED
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@385::@388 Interrupt
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResources
#define MOUSE_INITIALIZED
#define STATUS_INVALID_PARAMETER
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
COMMON_DEVICE_EXTENSION Common
PKINTERRUPT HighestDIRQLInterrupt
DRIVER_DISPATCH ForwardIrpAndForget
BOOLEAN i8042Write(IN PPORT_DEVICE_EXTENSION DeviceExtension, IN PUCHAR addr, IN UCHAR data)
#define STATUS_INVALID_DEVICE_REQUEST
BOOLEAN i8042IsrWritePort(IN PPORT_DEVICE_EXTENSION DeviceExtension, IN UCHAR Value, IN UCHAR SelectCmd OPTIONAL)
VOID i8042Flush(IN PPORT_DEVICE_EXTENSION DeviceExtension)
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
PDEVICE_OBJECT PhysicalDeviceObject
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@385::@387 Port
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
#define CmResourceTypePort
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
INTERRUPT_DATA KeyboardInterrupt
struct _I8042_DRIVER_EXTENSION * PI8042_DRIVER_EXTENSION
#define STATUS_IO_DEVICE_ERROR
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
_In_ PDEVICE_OBJECT DeviceObject
PPORT_DEVICE_EXTENSION PortDeviceExtension
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@385 u
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
#define IRP_MN_QUERY_REMOVE_DEVICE
NTSTATUS NTAPI IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject, IN PKSERVICE_ROUTINE ServiceRoutine, IN PVOID ServiceContext, IN PKSPIN_LOCK SpinLock, IN ULONG Vector, IN KIRQL Irql, IN KIRQL SynchronizeIrql, IN KINTERRUPT_MODE InterruptMode, IN BOOLEAN ShareVector, IN KAFFINITY ProcessorEnableMask, IN BOOLEAN FloatingSave)
_In_ UCHAR _In_ UCHAR MinorFunction
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResourcesTranslated
VOID NTAPI KeReleaseInterruptSpinLock(IN PKINTERRUPT Interrupt, IN KIRQL OldIrql)
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
#define IoCompleteRequest
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
NTSTATUS i8042MouInitialize(IN PI8042_MOUSE_EXTENSION DeviceExtension)
#define NT_SUCCESS(StatCode)
#define KeAcquireSpinLock(sl, irql)
#define IRP_MN_START_DEVICE
DRIVER_DISPATCH ForwardIrpAndWait
KIRQL NTAPI KeAcquireInterruptSpinLock(IN PKINTERRUPT Interrupt)
#define STATUS_UNSUCCESSFUL
INTERRUPT_DATA MouseInterrupt
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
NTSTATUS NTAPI i8042SynchWritePort(IN PPORT_DEVICE_EXTENSION DeviceExtension, IN UCHAR Port, IN UCHAR Value, IN BOOLEAN WaitForAck)
PPCI_DRIVER_EXTENSION DriverExtension
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
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
enum _I8042_DEVICE_TYPE I8042_DEVICE_TYPE
#define KeReleaseSpinLock(sl, irql)
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define STATUS_IO_TIMEOUT
#define CmResourceTypeInterrupt
static LARGE_INTEGER Counter
#define KEYBOARD_CONNECTED
#define CM_RESOURCE_INTERRUPT_LATCHED
char * cleanup(char *str)
#define RtlCopyMemory(Destination, Source, Length)
NTSTATUS i8042ReadDataWait(IN PPORT_DEVICE_EXTENSION DeviceExtension, OUT PUCHAR Data)
PDEVICE_OBJECT LowerDevice
KSERVICE_ROUTINE i8042KbdInterruptService
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
#define IRP_MN_QUERY_PNP_DEVICE_STATE
KINTERRUPT_MODE InterruptMode
#define IRP_MN_QUERY_CAPABILITIES
KSERVICE_ROUTINE i8042MouInterruptService