ReactOS 0.4.16-dev-88-ga65b6ae
i8042prt.h
Go to the documentation of this file.
1#ifndef _I8042PRT_PCH_
2#define _I8042PRT_PCH_
3
4#include <ntifs.h>
5#include <kbdmou.h>
6#include <ntdd8042.h>
7
8/*-----------------------------------------------------
9 * Structures
10 * --------------------------------------------------*/
11
12#define I8042PRT_TAG '2408'
13
14typedef enum
15{
22
23typedef struct _I8042_SETTINGS
24{
25 /* Registry settings */
42
44{
49
50typedef struct _INTERRUPT_DATA
51{
59
60#define WHEEL_DELTA 120
61
66
67/* PORT_DEVICE_EXTENSION.Flags */
68#define KEYBOARD_PRESENT 0x01 /* A keyboard is attached */
69#define KEYBOARD_CONNECTED 0x02 /* Keyboard received IOCTL_INTERNAL_KEYBOARD_CONNECT */
70#define KEYBOARD_STARTED 0x04 /* Keyboard FDO received IRP_MN_START_DEVICE */
71#define KEYBOARD_INITIALIZED 0x08 /* Keyboard interrupt is connected */
72#define MOUSE_PRESENT 0x10 /* A mouse is attached */
73#define MOUSE_CONNECTED 0x20 /* Mouse received IOCTL_INTERNAL_MOUSE_CONNECT */
74#define MOUSE_STARTED 0x40 /* Mouse FDO received IRP_MN_START_DEVICE */
75#define MOUSE_INITIALIZED 0x80 /* Mouse interrupt is connected */
76
78{
79 PUCHAR DataPort; /* Usually 0x60 */
80 PUCHAR ControlPort; /* Usually 0x64 */
83
91
98
102
104{
106
111
113{
119
120typedef struct _FDO_DEVICE_EXTENSION
121{
123 // Linkage in I8042_DRIVER_EXTENSION.DeviceListHead
125 // Associated device object (FDO)
127 // Associated device object (PDO)
129 // Lower device object
131 // Current state of the driver
133
136
138{
141 INTERNAL_I8042_HOOK_KEYBOARD KeyboardHook; /* FIXME: IsrWritePort ignored */
143
145
147
152
153 /* Power keys items */
160
161 /* Debug items */
166
168{
172 Ps2pp
174
176{
181
183
191
196
200
202{
206
207/*-----------------------------------------------------
208 * Some defines
209 * --------------------------------------------------*/
210
211#define MAX(a, b) ((a) >= (b) ? (a) : (b))
212
213#define KEYBOARD_POWER_CODE 0x5E
214#define KEYBOARD_SLEEP_CODE 0x5F
215#define KEYBOARD_WAKE_CODE 0x63
216
217/*-----------------------------------------------------
218 * Controller commands
219 * --------------------------------------------------*/
220
221#define KBD_READ_MODE 0x20
222#define KBD_WRITE_MODE 0x60
223#define MOUSE_ENAB 0xA8
224#define MOUSE_LINE_TEST 0xA9
225#define CTRL_SELF_TEST 0xAA
226#define KBD_CLK_DISABLE 0xAD
227#define KBD_CLK_ENABLE 0xAE
228#define CTRL_WRITE_MOUSE 0xD4
229
230/*-----------------------------------------------------
231 * Keyboard commands
232 * --------------------------------------------------*/
233
234#define KBD_CMD_SET_LEDS 0xED
235#define KBD_CMD_GET_ID 0xF2
236
237/*-----------------------------------------------------
238 * Keyboard responses
239 * --------------------------------------------------*/
240
241#define KBD_SELF_TEST_OK 0x55
242#define KBD_ACK 0xFA
243#define KBD_NACK 0xFC
244#define KBD_RESEND 0xFE
245
246/*-----------------------------------------------------
247 * Controller status register bits
248 * --------------------------------------------------*/
249
250#define KBD_OBF 0x01
251#define KBD_IBF 0x02
252#define MOU_OBF 0x20
253#define KBD_PERR 0x80
254
255/*-----------------------------------------------------
256 * Controller command byte bits
257 * --------------------------------------------------*/
258
259#define CCB_KBD_INT_ENAB 0x01
260#define CCB_MOUSE_INT_ENAB 0x02
261#define CCB_SYSTEM_FLAG 0x04
262#define CCB_KBD_DISAB 0x10
263#define CCB_MOUSE_DISAB 0x20
264#define CCB_TRANSLATE 0x40
265
266/*-----------------------------------------------------
267 * LED bits
268 * --------------------------------------------------*/
269
270#define KBD_LED_SCROLL 0x01
271#define KBD_LED_NUM 0x02
272#define KBD_LED_CAPS 0x04
273
274/*-----------------------------------------------------
275 * Mouse commands
276 * --------------------------------------------------*/
277
278#define MOU_ENAB 0xF4
279#define MOU_CMD_RESET 0xFF
280
281/*-----------------------------------------------------
282 * Mouse responses
283 * --------------------------------------------------*/
284
285#define MOUSE_ACK 0xFA
286#define MOUSE_ERROR 0xFC
287#define MOUSE_NACK 0xFE
288
289/*-----------------------------------------------------
290 * Prototypes
291 * --------------------------------------------------*/
292
293/* createclose.c */
294
295IO_WORKITEM_ROUTINE i8042SendHookWorkItem;
296
299
302
305
306/* keyboard.c */
307
311 IN UCHAR Value,
312 IN BOOLEAN WaitForAck);
313
314DRIVER_STARTIO i8042KbdStartIo;
315
317
319
321
322/* i8042prt.c */
323
324DRIVER_ADD_DEVICE i8042AddDevice;
325
328 IN PPORT_DEVICE_EXTENSION DeviceExtension,
329 IN UCHAR Output);
330
333 IN PPORT_DEVICE_EXTENSION DeviceExtension,
334 IN PFDO_DEVICE_EXTENSION FdoDeviceExtension,
337 IN PIRP Irp);
338
339/* misc.c */
340
342
345 IN ULONG Flags,
348
349/* mouse.c */
350
351VOID
353 IN PI8042_MOUSE_EXTENSION DeviceExtension,
354 IN UCHAR Output);
355
356VOID
358 IN PI8042_MOUSE_EXTENSION DeviceExtension,
359 IN USHORT Mask);
360
363 IN PI8042_MOUSE_EXTENSION DeviceExtension);
364
366
368
369/* pnp.c */
370
373 IN PPORT_DEVICE_EXTENSION DeviceExtension,
374 IN UCHAR FlagsToDisable,
375 IN UCHAR FlagsToEnable);
376
379
380/* ps2pp.c */
381VOID
383 IN PI8042_MOUSE_EXTENSION DeviceExtension,
384 IN UCHAR Input);
385
386/* readwrite.c */
387
388VOID
390 IN PPORT_DEVICE_EXTENSION DeviceExtension);
391
394 IN PPORT_DEVICE_EXTENSION DeviceExtension,
395 IN UCHAR Value,
396 IN UCHAR SelectCmd OPTIONAL);
397
400 IN PPORT_DEVICE_EXTENSION DeviceExtension,
401 IN UCHAR StatusFlags,
402 OUT PUCHAR Data);
403#define i8042ReadKeyboardData(DeviceExtension, Data) \
404 i8042ReadData(DeviceExtension, KBD_OBF, Data)
405#define i8042ReadMouseData(DeviceExtension, Data) \
406 i8042ReadData(DeviceExtension, MOU_OBF, Data)
407
410 IN PPORT_DEVICE_EXTENSION DeviceExtension,
411 OUT PUCHAR Data);
412
415 IN PPORT_DEVICE_EXTENSION DeviceExtension,
417
422 IN BOOLEAN WaitForAck);
423
426 IN PPORT_DEVICE_EXTENSION DeviceExtension,
427 IN UCHAR Port,
428 IN UCHAR Value,
429 IN BOOLEAN WaitForAck);
430
433 IN PPORT_DEVICE_EXTENSION DeviceExtension,
434 IN PUCHAR addr,
435 IN UCHAR data);
436
437/* registry.c */
438
443
444/* hwhacks.c */
445
446VOID
447NTAPI
449 VOID);
450
452{
453 FL_NOLOOP = 0x01,
455};
456
457extern ULONG i8042HwFlags;
458
459#endif /* _I8042PRT_PCH_ */
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define _Dispatch_type_(a)
Definition: btrfs_drv.h:204
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
_In_ PIRP Irp
Definition: csq.h:116
ULONG_PTR KAFFINITY
Definition: compat.h:85
NTSTATUS NTAPI i8042Cleanup(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: createclose.c:32
NTSTATUS NTAPI i8042Close(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: createclose.c:46
NTSTATUS NTAPI i8042Create(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: createclose.c:18
NTSTATUS NTAPI i8042Pnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pnp.c:675
DEVICE_STATE
Definition: precomp.h:36
UCHAR KIRQL
Definition: env_spec_w32.h:591
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
unsigned int Mask
Definition: fpcontrol.c:82
Status
Definition: gdiplustypes.h:25
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum const GLvoid * addr
Definition: glext.h:9621
CPPORT Port[4]
Definition: headless.c:35
struct _I8042_HOOK_WORKITEM I8042_HOOK_WORKITEM
struct _FDO_DEVICE_EXTENSION FDO_DEVICE_EXTENSION
struct _I8042_HOOK_WORKITEM * PI8042_HOOK_WORKITEM
NTSTATUS i8042StartPacket(IN PPORT_DEVICE_EXTENSION DeviceExtension, IN PFDO_DEVICE_EXTENSION FdoDeviceExtension, IN PUCHAR Bytes, IN ULONG ByteCount, IN PIRP Irp)
Definition: i8042prt.c:329
NTSTATUS NTAPI i8042SynchWritePortKbd(IN PVOID Context, IN UCHAR Value, IN BOOLEAN WaitForAck)
Definition: keyboard.c:87
NTSTATUS i8042ReadDataWait(IN PPORT_DEVICE_EXTENSION DeviceExtension, OUT PUCHAR Data)
Definition: readwrite.c:95
DRIVER_DISPATCH i8042KbdDeviceControl
Definition: i8042prt.h:316
VOID i8042Flush(IN PPORT_DEVICE_EXTENSION DeviceExtension)
Definition: readwrite.c:21
enum _MOUSE_TIMEOUT_STATE MOUSE_TIMEOUT_STATE
struct _PORT_DEVICE_EXTENSION * PPORT_DEVICE_EXTENSION
NTSTATUS i8042ReadData(IN PPORT_DEVICE_EXTENSION DeviceExtension, IN UCHAR StatusFlags, OUT PUCHAR Data)
Definition: readwrite.c:56
DRIVER_DISPATCH i8042KbdInternalDeviceControl
Definition: i8042prt.h:318
DRIVER_STARTIO i8042KbdStartIo
Definition: i8042prt.h:314
ULONG i8042HwFlags
Definition: hwhacks.c:22
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
KSERVICE_ROUTINE i8042MouInterruptService
Definition: i8042prt.h:367
NTSTATUS i8042MouInitialize(IN PI8042_MOUSE_EXTENSION DeviceExtension)
Definition: mouse.c:224
KSERVICE_ROUTINE i8042KbdInterruptService
Definition: i8042prt.h:320
DRIVER_DISPATCH i8042MouInternalDeviceControl
Definition: i8042prt.h:365
_I8042_MOUSE_TYPE
Definition: i8042prt.h:168
@ Intellimouse
Definition: i8042prt.h:170
@ GenericPS2
Definition: i8042prt.h:169
@ Ps2pp
Definition: i8042prt.h:172
@ IntellimouseExplorer
Definition: i8042prt.h:171
NTSTATUS DuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: misc.c:31
struct _I8042_MOUSE_EXTENSION * PI8042_MOUSE_EXTENSION
Definition: i8042prt.h:65
NTSTATUS NTAPI i8042SynchReadPort(IN PVOID Context, OUT PUCHAR Value, IN BOOLEAN WaitForAck)
Definition: readwrite.c:125
IO_WORKITEM_ROUTINE i8042SendHookWorkItem
Definition: i8042prt.h:295
VOID i8042MouHandlePs2pp(IN PI8042_MOUSE_EXTENSION DeviceExtension, IN UCHAR Input)
Definition: ps2pp.c:19
BOOLEAN i8042PacketIsr(IN PPORT_DEVICE_EXTENSION DeviceExtension, IN UCHAR Output)
Definition: i8042prt.c:271
BOOLEAN i8042IsrWritePort(IN PPORT_DEVICE_EXTENSION DeviceExtension, IN UCHAR Value, IN UCHAR SelectCmd OPTIONAL)
Definition: readwrite.c:40
DEVICE_STATE
Definition: i8042prt.h:15
@ dsSurpriseRemoved
Definition: i8042prt.h:20
@ dsStopped
Definition: i8042prt.h:16
@ dsPaused
Definition: i8042prt.h:18
@ dsStarted
Definition: i8042prt.h:17
@ dsRemoved
Definition: i8042prt.h:19
enum _I8042_MOUSE_TYPE I8042_MOUSE_TYPE
struct _I8042_DRIVER_EXTENSION I8042_DRIVER_EXTENSION
enum _I8042_MOUSE_TYPE * PI8042_MOUSE_TYPE
NTSTATUS ReadRegistryEntries(IN PUNICODE_STRING RegistryPath, OUT PI8042_SETTINGS Settings)
Definition: registry.c:21
VOID i8042MouHandle(IN PI8042_MOUSE_EXTENSION DeviceExtension, IN UCHAR Output)
Definition: mouse.c:68
struct _I8042_MOUSE_EXTENSION I8042_MOUSE_EXTENSION
BOOLEAN i8042ChangeMode(IN PPORT_DEVICE_EXTENSION DeviceExtension, IN UCHAR FlagsToDisable, IN UCHAR FlagsToEnable)
Definition: pnp.c:37
struct _I8042_KEYBOARD_EXTENSION * PI8042_KEYBOARD_EXTENSION
Definition: i8042prt.h:63
NTSTATUS NTAPI i8042SynchWritePort(IN PPORT_DEVICE_EXTENSION DeviceExtension, IN UCHAR Port, IN UCHAR Value, IN BOOLEAN WaitForAck)
Definition: readwrite.c:144
_FLAGS
Definition: i8042prt.h:452
@ FL_NOLOOP
Definition: i8042prt.h:453
@ FL_INITHACK
Definition: i8042prt.h:454
VOID NTAPI i8042InitializeHwHacks(VOID)
Definition: hwhacks.c:185
DRIVER_DISPATCH ForwardIrpAndForget
Definition: i8042prt.h:341
struct _I8042_DRIVER_EXTENSION * PI8042_DRIVER_EXTENSION
struct _INTERRUPT_DATA INTERRUPT_DATA
_MOUSE_TIMEOUT_STATE
Definition: i8042prt.h:44
@ TimeoutStart
Definition: i8042prt.h:46
@ TimeoutCancel
Definition: i8042prt.h:47
@ NoChange
Definition: i8042prt.h:45
NTSTATUS i8042ReadStatus(IN PPORT_DEVICE_EXTENSION DeviceExtension, OUT PUCHAR Status)
Definition: readwrite.c:82
struct _I8042_SETTINGS * PI8042_SETTINGS
enum _MOUSE_TIMEOUT_STATE * PMOUSE_TIMEOUT_STATE
struct _I8042_KEYBOARD_EXTENSION I8042_KEYBOARD_EXTENSION
enum _I8042_DEVICE_TYPE * PI8042_DEVICE_TYPE
DRIVER_ADD_DEVICE i8042AddDevice
Definition: i8042prt.h:324
struct _PORT_DEVICE_EXTENSION PORT_DEVICE_EXTENSION
_I8042_DEVICE_TYPE
Definition: i8042prt.h:113
@ Keyboard
Definition: i8042prt.h:115
@ Mouse
Definition: i8042prt.h:116
@ Unknown
Definition: i8042prt.h:114
@ PhysicalDeviceObject
Definition: i8042prt.h:117
enum _I8042_DEVICE_TYPE I8042_DEVICE_TYPE
struct _I8042_SETTINGS I8042_SETTINGS
struct _INTERRUPT_DATA * PINTERRUPT_DATA
BOOLEAN i8042Write(IN PPORT_DEVICE_EXTENSION DeviceExtension, IN PUCHAR addr, IN UCHAR data)
Definition: readwrite.c:199
VOID i8042MouHandleButtons(IN PI8042_MOUSE_EXTENSION DeviceExtension, IN USHORT Mask)
Definition: mouse.c:191
_In_ UINT Bytes
Definition: mmcopy.h:9
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1922
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1921
DRIVER_DISPATCH(nfs41_FsdDispatch)
enum _MOUSE_RESET_SUBSTATE MOUSE_RESET_SUBSTATE
enum _MOUSE_STATE MOUSE_STATE
enum _KEYBOARD_SCAN_STATE KEYBOARD_SCAN_STATE
unsigned short USHORT
Definition: pedump.c:61
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
enum _KINTERRUPT_MODE KINTERRUPT_MODE
@ Input
Definition: arc.h:84
@ Output
Definition: arc.h:85
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
PDEVICE_OBJECT LowerDevice
Definition: i8042prt.h:130
I8042_DEVICE_TYPE Type
Definition: i8042prt.h:122
PDEVICE_OBJECT Fdo
Definition: i8042prt.h:126
LIST_ENTRY ListEntry
Definition: pci.h:86
DEVICE_STATE PnpState
Definition: i8042prt.h:132
PDEVICE_OBJECT Pdo
Definition: i8042prt.h:128
PPORT_DEVICE_EXTENSION PortDeviceExtension
Definition: i8042prt.h:134
KSPIN_LOCK DeviceListLock
Definition: i8042prt.h:109
LIST_ENTRY DeviceListHead
Definition: i8042prt.h:108
UNICODE_STRING RegistryPath
Definition: i8042prt.h:105
PORT_DEVICE_EXTENSION Port
Definition: i8042prt.h:107
PIO_WORKITEM WorkItem
Definition: i8042prt.h:203
CONNECT_DATA KeyboardData
Definition: i8042prt.h:140
PIO_WORKITEM DebugWorkItem
Definition: i8042prt.h:163
KEYBOARD_ATTRIBUTES KeyboardAttributes
Definition: i8042prt.h:144
FDO_DEVICE_EXTENSION Common
Definition: i8042prt.h:139
INTERNAL_I8042_HOOK_KEYBOARD KeyboardHook
Definition: i8042prt.h:141
KEYBOARD_SCAN_STATE KeyboardScanState
Definition: i8042prt.h:148
UNICODE_STRING PowerInterfaceName
Definition: i8042prt.h:157
KEYBOARD_INDICATOR_PARAMETERS KeyboardIndicators
Definition: i8042prt.h:146
PKEYBOARD_INPUT_DATA KeyboardBuffer
Definition: i8042prt.h:150
PIO_WORKITEM PowerWorkItem
Definition: i8042prt.h:158
ULARGE_INTEGER MousePacketStartTime
Definition: i8042prt.h:190
FDO_DEVICE_EXTENSION Common
Definition: i8042prt.h:177
UCHAR MouseLogiBuffer[3]
Definition: i8042prt.h:197
MOUSE_ATTRIBUTES MouseAttributes
Definition: i8042prt.h:182
I8042_MOUSE_TYPE MouseType
Definition: i8042prt.h:198
MOUSE_TIMEOUT_STATE MouseTimeoutState
Definition: i8042prt.h:194
PMOUSE_INPUT_DATA MouseBuffer
Definition: i8042prt.h:187
BOOLEAN MouseTimeoutActive
Definition: i8042prt.h:195
CONNECT_DATA MouseData
Definition: i8042prt.h:178
INTERNAL_I8042_HOOK_MOUSE MouseHook
Definition: i8042prt.h:179
MOUSE_STATE MouseState
Definition: i8042prt.h:184
MOUSE_RESET_SUBSTATE MouseResetState
Definition: i8042prt.h:186
ULONG PollingIterations
Definition: i8042prt.h:36
ULONG NumberOfButtons
Definition: i8042prt.h:31
ULONG MouseDataQueueSize
Definition: i8042prt.h:28
ULONG CrashOnCtrlScroll
Definition: i8042prt.h:40
ULONG OverrideKeyboardSubtype
Definition: i8042prt.h:35
UNICODE_STRING KeyboardDeviceBaseName
Definition: i8042prt.h:27
ULONG OverrideKeyboardType
Definition: i8042prt.h:34
ULONG PollStatusIterations
Definition: i8042prt.h:33
UNICODE_STRING PointerDeviceBaseName
Definition: i8042prt.h:32
ULONG ResendIterations
Definition: i8042prt.h:38
ULONG SampleRate
Definition: i8042prt.h:39
ULONG PollingIterationsMaximum
Definition: i8042prt.h:37
ULONG KeyboardDataQueueSize
Definition: i8042prt.h:26
ULONG MouseSynchIn100ns
Definition: i8042prt.h:30
ULONG MouseResolution
Definition: i8042prt.h:29
KINTERRUPT_MODE InterruptMode
Definition: i8042prt.h:55
BOOLEAN ShareInterrupt
Definition: i8042prt.h:56
PKINTERRUPT Object
Definition: i8042prt.h:52
ULONG Vector
Definition: i8042prt.h:53
KAFFINITY Affinity
Definition: i8042prt.h:57
Definition: ketypes.h:699
Definition: typedefs.h:120
INTERRUPT_DATA KeyboardInterrupt
Definition: i8042prt.h:85
PKINTERRUPT HighestDIRQLInterrupt
Definition: i8042prt.h:88
I8042_SETTINGS Settings
Definition: i8042prt.h:81
UCHAR PacketBuffer[16]
Definition: i8042prt.h:96
PDEVICE_OBJECT CurrentIrpDevice
Definition: i8042prt.h:100
OUTPUT_PACKET Packet
Definition: i8042prt.h:92
PI8042_MOUSE_EXTENSION MouseExtension
Definition: i8042prt.h:86
KSPIN_LOCK SpinLock
Definition: i8042prt.h:89
INTERRUPT_DATA MouseInterrupt
Definition: i8042prt.h:87
BOOLEAN PacketComplete
Definition: i8042prt.h:94
PI8042_KEYBOARD_EXTENSION KeyboardExtension
Definition: i8042prt.h:84
NTSTATUS PacketResult
Definition: i8042prt.h:95
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS Settings
Definition: wdfdevice.h:2595
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _In_ LARGE_INTEGER ByteCount
Definition: iotypes.h:1099
#define IRP_MJ_CLEANUP
unsigned char UCHAR
Definition: xmlstorage.h:181