VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/i8042prt/i8042prt.h@ 4071

最後變更 在這個檔案從4071是 1,由 vboxsync 提交於 55 年 前

import

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 26.6 KB
 
1/*++
2
3Copyright (c) 1990, 1991, 1992, 1993 Microsoft Corporation
4
5Module Name:
6
7 i8042prt.h
8
9Abstract:
10
11 These are the structures and defines that are used in the
12 Intel i8042 port driver.
13
14Revision History:
15
16--*/
17
18#ifndef _I8042PRT_
19#define _I8042PRT_
20
21#include <ntddkbd.h>
22#include <ntddmou.h>
23#include "kbdmou.h"
24#include "i8042cfg.h"
25
26#ifdef PNP_IDENTIFY
27#include "devdesc.h"
28#endif
29
30//VBOX begin
31#include <VBox/VBoxGuest.h>
32#include <VBox/VBoxGuestLib.h>
33
34/* debug printf */
35# define OSDBGPRINT(a) DbgPrint a
36
37/* dprintf */
38#if (defined(DEBUG) && !defined(NO_LOGGING)) || defined(LOG_ENABLED)
39# ifdef LOG_TO_BACKDOOR
40# include <VBox/log.h>
41# define dprintf(a) RTLogBackdoorPrintf a
42# else
43# define dprintf(a) OSDBGPRINT(a)
44# endif
45#else
46# define dprintf(a) do {} while (0)
47#endif
48
49/* dprintf2 - extended logging. */
50#if 0
51# define dprintf2 dprintf
52#else
53# define dprintf2(a) do { } while (0)
54#endif
55
56//VBOX end
57
58//
59// Define the timer values.
60//
61
62#define I8042_ASYNC_NO_TIMEOUT -1
63#define I8042_ASYNC_TIMEOUT 3
64
65//
66// Define the default number of entries in the input data queue.
67//
68
69#define DATA_QUEUE_SIZE 100
70
71//
72// Define the default stall value.
73//
74
75#define I8042_STALL_DEFAULT 50
76
77//
78// Define the default "sync time" used to determine when the start
79// of a new mouse data packet is expected. The value is in units
80// of 100 nanoseconds.
81//
82
83#define MOUSE_SYNCH_PACKET_100NS 10000000UL // 1 second, in 100 ns units
84
85//
86// Define booleans.
87//
88
89#define WAIT_FOR_ACKNOWLEDGE TRUE
90#define NO_WAIT_FOR_ACKNOWLEDGE FALSE
91#define AND_OPERATION TRUE
92#define OR_OPERATION FALSE
93#define ENABLE_OPERATION TRUE
94#define DISABLE_OPERATION FALSE
95
96//
97// Default keyboard scan code mode.
98//
99
100#define KEYBOARD_SCAN_CODE_SET 0x01
101
102//
103// Default number of function keys, number of LED indicators, and total
104// number of keys located on the known types of keyboard.
105//
106
107#ifndef JAPAN
108#define NUM_KNOWN_KEYBOARD_TYPES 4
109#else
110// NLS Keyboard Support Code.
111#define NUM_KNOWN_KEYBOARD_TYPES 16
112#endif
113#define KEYBOARD_TYPE_DEFAULT 4
114#define KEYBOARD_INDICATORS_DEFAULT 0
115
116typedef struct _KEYBOARD_TYPE_INFORMATION {
117 USHORT NumberOfFunctionKeys;
118 USHORT NumberOfIndicators;
119 USHORT NumberOfKeysTotal;
120} KEYBOARD_TYPE_INFORMATION, *PKEYBOARD_TYPE_INFORMATION;
121
122static const
123KEYBOARD_TYPE_INFORMATION KeyboardTypeInformation[NUM_KNOWN_KEYBOARD_TYPES] = {
124 {10, 3, 84}, // PC/XT 83- 84-key keyboard (and compatibles)
125 {12, 3, 102}, // Olivetti M24 102-key keyboard (and compatibles)
126 {10, 3, 84}, // All AT type keyboards (84-86 keys)
127 {12, 3, 101} // Enhanced 101- or 102-key keyboards (and compatibles)
128#ifdef JAPAN
129// NLS Keyboard Support Code.
130 ,
131 { 0, 0, 0},
132 { 0, 0, 0},
133 {12, 3, 106}, // TYPE=7 IBM-J 5576-002 keyboard
134 { 0, 0, 0},
135 { 0, 0, 0},
136 { 0, 0, 0},
137 { 0, 0, 0},
138 { 0, 0, 0},
139 { 0, 0, 0},
140 { 0, 0, 0},
141 { 0, 0, 0},
142 {12, 4, 105} // TYPE=16 AX keyboard
143#endif
144};
145
146//
147// Minimum, maximum, and default values for keyboard typematic rate and delay.
148//
149
150#define KEYBOARD_TYPEMATIC_RATE_MINIMUM 2
151#define KEYBOARD_TYPEMATIC_RATE_MAXIMUM 30
152#define KEYBOARD_TYPEMATIC_RATE_DEFAULT 30
153#define KEYBOARD_TYPEMATIC_DELAY_MINIMUM 250
154#define KEYBOARD_TYPEMATIC_DELAY_MAXIMUM 1000
155#define KEYBOARD_TYPEMATIC_DELAY_DEFAULT 250
156
157//
158// Define the 8042 mouse status bits.
159//
160
161#define LEFT_BUTTON_DOWN 0x01
162#define RIGHT_BUTTON_DOWN 0x02
163#define MIDDLE_BUTTON_DOWN 0x04
164#define X_DATA_SIGN 0x10
165#define Y_DATA_SIGN 0x20
166#define X_OVERFLOW 0x40
167#define Y_OVERFLOW 0x80
168
169#define MOUSE_SIGN_OVERFLOW_MASK (X_DATA_SIGN | Y_DATA_SIGN | X_OVERFLOW | Y_OVERFLOW)
170
171//
172// Define the maximum positive and negative values for mouse motion.
173//
174
175#define MOUSE_MAXIMUM_POSITIVE_DELTA 0x000000FF
176#define MOUSE_MAXIMUM_NEGATIVE_DELTA 0xFFFFFF00
177
178//
179// Default number of buttons and sample rate for the i8042 mouse.
180//
181
182#define MOUSE_NUMBER_OF_BUTTONS 2
183#define MOUSE_SAMPLE_RATE 60
184
185//
186// Define the mouse resolution specifier. Note that (2**MOUSE_RESOLUTION)
187// specifies counts-per-millimeter. Counts-per-centimeter is
188// (counts-per-millimeter * 10).
189//
190
191#define MOUSE_RESOLUTION 3
192
193//
194// Defines for DeviceExtension->HardwarePresent.
195//
196
197#define KEYBOARD_HARDWARE_PRESENT 0x01
198#define MOUSE_HARDWARE_PRESENT 0x02
199#define BALLPOINT_HARDWARE_PRESENT 0x04
200#define WHEELMOUSE_HARDWARE_PRESENT 0x08
201
202//
203// Define macros for performing I/O on the 8042 command/status and data
204// registers.
205//
206
207#define I8X_PUT_COMMAND_BYTE(Address, Byte) \
208 WRITE_PORT_UCHAR(Address, (UCHAR) Byte)
209#define I8X_PUT_DATA_BYTE(Address, Byte) \
210 WRITE_PORT_UCHAR(Address, (UCHAR) Byte)
211#define I8X_GET_STATUS_BYTE(Address) \
212 READ_PORT_UCHAR(Address)
213#define I8X_GET_DATA_BYTE(Address) \
214 READ_PORT_UCHAR(Address)
215
216//
217// Define commands to the 8042 controller.
218//
219
220#define I8042_READ_CONTROLLER_COMMAND_BYTE 0x20
221#define I8042_WRITE_CONTROLLER_COMMAND_BYTE 0x60
222#define I8042_DISABLE_MOUSE_DEVICE 0xA7
223#define I8042_ENABLE_MOUSE_DEVICE 0xA8
224#define I8042_AUXILIARY_DEVICE_TEST 0xA9
225#define I8042_KEYBOARD_DEVICE_TEST 0xAB
226#define I8042_DISABLE_KEYBOARD_DEVICE 0xAD
227#define I8042_ENABLE_KEYBOARD_DEVICE 0xAE
228#define I8042_WRITE_TO_AUXILIARY_DEVICE 0xD4
229
230//
231// Define the 8042 Controller Command Byte.
232//
233
234#define CCB_ENABLE_KEYBOARD_INTERRUPT 0x01
235#define CCB_ENABLE_MOUSE_INTERRUPT 0x02
236#define CCB_DISABLE_KEYBOARD_DEVICE 0x10
237#define CCB_DISABLE_MOUSE_DEVICE 0x20
238#define CCB_KEYBOARD_TRANSLATE_MODE 0x40
239
240
241//
242// Define the 8042 Controller Status Register bits.
243//
244
245#define OUTPUT_BUFFER_FULL 0x01
246#define INPUT_BUFFER_FULL 0x02
247#define MOUSE_OUTPUT_BUFFER_FULL 0x20
248
249//
250// Define the 8042 responses.
251//
252
253#define ACKNOWLEDGE 0xFA
254#define RESEND 0xFE
255
256//
257// Define commands to the keyboard (through the 8042 data port).
258//
259
260#define SET_KEYBOARD_INDICATORS 0xED
261#define SELECT_SCAN_CODE_SET 0xF0
262#define READ_KEYBOARD_ID 0xF2
263#define SET_KEYBOARD_TYPEMATIC 0xF3
264#define SET_ALL_TYPEMATIC_MAKE_BREAK 0xFA
265#define KEYBOARD_RESET 0xFF
266
267//
268// Define the keyboard responses.
269//
270
271#define KEYBOARD_COMPLETE_SUCCESS 0xAA
272#define KEYBOARD_COMPLETE_FAILURE 0xFC
273#define KEYBOARD_BREAK_CODE 0xF0
274#define KEYBOARD_DEBUG_HOTKEY_ENH 0x37 // SysReq scan code for Enhanced Keyboard
275#define KEYBOARD_DEBUG_HOTKEY_AT 0x54 // SysReq scan code for 84-key Keyboard
276
277//
278// Define commands to the mouse (through the 8042 data port).
279//
280
281#define SET_MOUSE_RESOLUTION 0xE8
282#define SET_MOUSE_SAMPLING_RATE 0xF3
283#define MOUSE_RESET 0xFF
284#define ENABLE_MOUSE_TRANSMISSION 0xF4
285#define SET_MOUSE_SCALING_1TO1 0xE6
286#define READ_MOUSE_STATUS 0xE9
287#define GET_DEVICE_ID 0xF2
288
289//
290// Define the mouse responses.
291//
292
293#define MOUSE_COMPLETE 0xAA
294#define MOUSE_ID_BYTE 0x00
295#define WHEELMOUSE_ID_BYTE 0x03
296
297//
298// Define the i8042 controller input/output ports.
299//
300
301typedef enum _I8042_IO_PORT_TYPE {
302 DataPort = 0,
303 CommandPort,
304 MaximumPortCount
305
306} I8042_IO_PORT_TYPE;
307
308//
309// Define the device types attached to the i8042 controller.
310//
311
312typedef enum _I8042_DEVICE_TYPE {
313 ControllerDeviceType,
314 KeyboardDeviceType,
315 MouseDeviceType,
316 UndefinedDeviceType
317} I8042_DEVICE_TYPE;
318
319//
320// Define the keyboard output states.
321//
322
323typedef enum _KEYBOARD_STATE {
324 Idle,
325 SendFirstByte,
326 SendLastByte
327} KEYBOARD_STATE;
328
329//
330// Define the keyboard scan code input states.
331//
332
333typedef enum _KEYBOARD_SCAN_STATE {
334 Normal,
335 GotE0,
336 GotE1
337} KEYBOARD_SCAN_STATE;
338
339//
340// Define the mouse states.
341//
342
343typedef enum _MOUSE_STATE {
344 MouseIdle,
345 XMovement,
346 YMovement,
347 ZMovement,
348 MouseExpectingACK
349} MOUSE_STATE;
350
351//
352// Define the keyboard set request packet.
353//
354
355typedef struct _KEYBOARD_SET_PACKET {
356 USHORT State;
357 UCHAR FirstByte;
358 UCHAR LastByte;
359} KEYBOARD_SET_PACKET, *PKEYBOARD_SET_PACKET;
360
361//
362// Intel i8042 configuration information.
363//
364
365typedef struct _I8042_CONFIGURATION_INFORMATION {
366
367 //
368 // Bus interface type.
369 //
370
371 INTERFACE_TYPE InterfaceType;
372
373 //
374 // Bus Number.
375 //
376
377 ULONG BusNumber;
378
379 //
380 // The port/register resources used by this device.
381 //
382
383 CM_PARTIAL_RESOURCE_DESCRIPTOR PortList[MaximumPortCount];
384 ULONG PortListCount;
385
386 //
387 // Keyboard interrupt resources.
388 //
389
390 CM_PARTIAL_RESOURCE_DESCRIPTOR KeyboardInterrupt;
391
392 //
393 // Mouse interrupt resources.
394 //
395
396 CM_PARTIAL_RESOURCE_DESCRIPTOR MouseInterrupt;
397
398 //
399 // Flag that indicates whether floating point context should be saved.
400 //
401
402 BOOLEAN FloatingSave;
403
404 //
405 // Number of retries allowed.
406 //
407
408 USHORT ResendIterations;
409
410 //
411 // Number of polling iterations allowed.
412 //
413
414 USHORT PollingIterations;
415
416 //
417 // Maximum number of polling iterations allowed.
418 //
419
420 USHORT PollingIterationsMaximum;
421
422 //
423 // Maximum number of times to check the Status register in
424 // the ISR before deciding the interrupt is spurious.
425 //
426
427 USHORT PollStatusIterations;
428
429 //
430 // Microseconds to stall in KeStallExecutionProcessor calls.
431 //
432
433 USHORT StallMicroseconds;
434
435 //
436 // Keyboard attributes.
437 //
438
439 KEYBOARD_ATTRIBUTES KeyboardAttributes;
440
441 //
442 // Initial values of keyboard typematic rate and delay.
443 //
444
445 KEYBOARD_TYPEMATIC_PARAMETERS KeyRepeatCurrent;
446
447 //
448 // Current indicator (LED) setting.
449 //
450
451 KEYBOARD_INDICATOR_PARAMETERS KeyboardIndicators;
452
453 //
454 // Mouse attributes.
455 //
456
457 MOUSE_ATTRIBUTES MouseAttributes;
458
459 USHORT MouseResolution;
460
461 //
462 // Boolean flags determines whether we should try and detect the wheel
463 // on the mouse or not
464 //
465
466 ULONG EnableWheelDetection;
467
468} I8042_CONFIGURATION_INFORMATION, *PI8042_CONFIGURATION_INFORMATION;
469
470//
471// Define the keyboard portion of the port device extension.
472//
473
474typedef struct _PORT_KEYBOARD_EXTENSION {
475
476 //
477 // Keyboard class connection data.
478 //
479
480 CONNECT_DATA ConnectData;
481
482 //
483 // Number of input data items currently in the keyboard InputData queue.
484 //
485
486 ULONG InputCount;
487
488 //
489 // Start of the port keyboard input data queue (really a circular buffer).
490 //
491
492 PKEYBOARD_INPUT_DATA InputData;
493
494 //
495 // Insertion pointer for keyboard InputData.
496 //
497
498 PKEYBOARD_INPUT_DATA DataIn;
499
500 //
501 // Removal pointer for keyboard InputData.
502 //
503
504 PKEYBOARD_INPUT_DATA DataOut;
505
506 //
507 // Points one input packet past the end of the InputData buffer.
508 //
509
510 PKEYBOARD_INPUT_DATA DataEnd;
511
512 //
513 // Current keyboard input packet.
514 //
515
516 KEYBOARD_INPUT_DATA CurrentInput;
517
518 //
519 // Current keyboard scan input state.
520 //
521
522 KEYBOARD_SCAN_STATE CurrentScanState;
523
524 //
525 // Current keyboard output packet (for set requests).
526 //
527
528 KEYBOARD_SET_PACKET CurrentOutput;
529
530 //
531 // Current resend count.
532 //
533
534 USHORT ResendCount;
535
536 //
537 // Request sequence number (used for error logging).
538 //
539
540 ULONG SequenceNumber;
541
542 //
543 // Timer used to retry the ISR DPC routine when the class
544 // driver is unable to consume all the port driver's data.
545 //
546
547 KTIMER DataConsumptionTimer;
548
549 //
550 // Indicates which keyboard port device this driver created (UnitId
551 // is the suffix appended to the keyboard port basename for the
552 // call to IoCreateDevice).
553 //
554
555 USHORT UnitId;
556
557 //
558 // Indicates whether it is okay to log overflow errors.
559 //
560
561 BOOLEAN OkayToLogOverflow;
562
563} PORT_KEYBOARD_EXTENSION, *PPORT_KEYBOARD_EXTENSION;
564
565//
566// Define the mouse portion of the port device extension.
567//
568
569typedef struct _PORT_MOUSE_EXTENSION {
570
571 //
572 // Mouse class connection data.
573 //
574
575 CONNECT_DATA ConnectData;
576
577 //
578 // Number of input data items currently in the mouse InputData queue.
579 //
580
581 ULONG InputCount;
582
583 //
584 // Start of the port mouse input data queue (really a circular buffer).
585 //
586
587 PMOUSE_INPUT_DATA InputData;
588
589 //
590 // Insertion pointer for mouse InputData.
591 //
592
593 PMOUSE_INPUT_DATA DataIn;
594
595 //
596 // Removal pointer for mouse InputData.
597 //
598
599 PMOUSE_INPUT_DATA DataOut;
600
601 //
602 // Points one input packet past the end of the InputData buffer.
603 //
604
605 PMOUSE_INPUT_DATA DataEnd;
606
607 //
608 // Current mouse input packet.
609 //
610
611 MOUSE_INPUT_DATA CurrentInput;
612
613 //
614 // Current mouse input state.
615 //
616
617 USHORT InputState;
618
619 //
620 // Current mouse sign and overflow data.
621 //
622
623 UCHAR CurrentSignAndOverflow;
624
625 //
626 // Previous mouse sign and overflow data.
627 //
628
629 UCHAR PreviousSignAndOverflow;
630
631 //
632 // Previous mouse button data.
633 //
634
635 UCHAR PreviousButtons;
636
637 //
638 // Request sequence number (used for error logging).
639 //
640
641 ULONG SequenceNumber;
642
643 //
644 // Timer used to retry the ISR DPC routine when the class
645 // driver is unable to consume all the port driver's data.
646 //
647
648 KTIMER DataConsumptionTimer;
649
650 //
651 // The tick count (since system boot) at which the mouse last interrupted.
652 // Retrieved via KeQueryTickCount. Used to determine whether a byte of
653 // the mouse data packet has been lost. Allows the driver to synch
654 // up with the true mouse input state.
655 //
656
657 LARGE_INTEGER PreviousTick;
658
659 //
660 // Indicates which pointer port device this driver created (UnitId
661 // is the suffix appended to the pointer port basename for the
662 // call to IoCreateDevice).
663 //
664
665 USHORT UnitId;
666
667 //
668 // Indicates whether it is okay to log overflow errors.
669 //
670
671 BOOLEAN OkayToLogOverflow;
672
673 //
674 // Number of interval timer ticks to wait before deciding that the
675 // next mouse interrupt is for the start of a new packet. Used to
676 // synch up again if a byte of the mouse packet gets lost.
677 //
678
679 ULONG SynchTickCount;
680
681 //
682 // Keep track of last byte of data received from mouse so we can detect
683 // the two-byte string which indicates a potential reset
684 //
685
686 UCHAR LastByteReceived;
687
688} PORT_MOUSE_EXTENSION, *PPORT_MOUSE_EXTENSION;
689
690//
691// Port device extension.
692//
693
694typedef struct _DEVICE_EXTENSION {
695
696 //
697 // Indicate which hardware is actually present (keyboard and/or mouse).
698 //
699
700 ULONG HardwarePresent;
701
702 //
703 // Reference count for number of keyboard enables.
704 //
705
706 LONG KeyboardEnableCount;
707
708 //
709 // Reference count for number of mouse enables.
710 //
711
712 LONG MouseEnableCount;
713
714 //
715 // Pointer to the device object.
716 //
717
718 PDEVICE_OBJECT DeviceObject;
719
720 //
721 // The mapped addresses for this device's registers.
722 //
723
724 PUCHAR DeviceRegisters[MaximumPortCount];
725
726 //
727 // Keyboard-specific port connection data.
728 //
729
730 PORT_KEYBOARD_EXTENSION KeyboardExtension;
731
732 //
733 // Mouse-specific port connection data.
734 //
735
736 PORT_MOUSE_EXTENSION MouseExtension;
737
738 //
739 // Port configuration information.
740 //
741
742 I8042_CONFIGURATION_INFORMATION Configuration;
743
744 //
745 // i8042 keyboard and mouse interrupt objects.
746 //
747
748 PKINTERRUPT KeyboardInterruptObject;
749 PKINTERRUPT MouseInterruptObject;
750 KSPIN_LOCK SharedInterruptSpinLock;
751
752 //
753 // DPC queue for completion of requests that fail by exceeding
754 // the maximum number of retries.
755 //
756
757 KDPC RetriesExceededDpc;
758
759 //
760 // DPC queue for logging overrun and internal driver errors.
761 //
762
763 KDPC ErrorLogDpc;
764
765 //
766 // Keyboard ISR DPC queue.
767 //
768
769 KDPC KeyboardIsrDpc;
770
771 //
772 // Keyboard ISR DPC recall queue.
773 //
774
775 KDPC KeyboardIsrDpcRetry;
776
777 //
778 // Used by the ISR and the ISR DPC (in I8xDpcVariableOperation calls)
779 // to control processing by the ISR DPC.
780 //
781
782 LONG DpcInterlockKeyboard;
783
784 //
785 // Mouse ISR DPC queue.
786 //
787
788 KDPC MouseIsrDpc;
789
790 //
791 // Mouse ISR DPC recall queue.
792 //
793
794 KDPC MouseIsrDpcRetry;
795
796 //
797 // Used by the ISR and the ISR DPC (in I8xDpcVariableOperation calls)
798 // to control processing by the ISR DPC.
799 //
800
801 LONG DpcInterlockMouse;
802
803 //
804 // DPC queue for command timeouts.
805 //
806
807 KDPC TimeOutDpc;
808
809 //
810 // Timer used to timeout i8042 commands.
811 //
812
813 KTIMER CommandTimer;
814
815 //
816 // Timer count used by the command time out routine.
817 //
818
819 LONG TimerCount;
820
821 //
822 // Set at intialization to indicate that the register
823 // addresses must be unmapped when the driver is unloaded.
824 //
825
826 BOOLEAN UnmapRegistersRequired;
827
828#if defined(JAPAN) && defined(i386)
829// Fujitsu Sep.08.1994
830// We want to write debugging information to the file except stop error.
831
832 LONG Dump1Keys; // CrashDump call first press keys flag
833 // 7 6 5 4 3 2 1 0 bit
834 // | | | | | +--- Right Shift Key
835 // | | | | +----- Right Ctrl Key
836 // | | | +------- Right Alt Key
837 // | | +----------- Left Shift Key
838 // | +------------- Left Ctrl Key
839 // +--------------- Left Alt Key
840 LONG Dump2Key; // CrashDump call second twice press key no
841 LONG DumpFlags; // Key press flags
842
843#endif
844
845// VBOX begin
846 VMMDevReqMouseStatus *reqIS;
847// VBOX end
848
849} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
850
851//
852// Temporary structure used during initialization
853//
854
855typedef struct _INIT_EXTENSION {
856
857 DEVICE_EXTENSION DeviceExtension;
858
859#ifdef PNP_IDENTIFY
860 HWDESC_INFO MouseConfig;
861 HWDESC_INFO KeyboardConfig;
862#endif
863
864} INIT_EXTENSION, *PINIT_EXTENSION;
865
866//
867// Define the port InitializeDataQueue context structure.
868//
869
870typedef struct _I8042_INITIALIZE_DATA_CONTEXT {
871 IN PDEVICE_EXTENSION DeviceExtension;
872 IN CCHAR DeviceType;
873} I8042_INITIALIZE_DATA_CONTEXT, *PI8042_INITIALIZE_DATA_CONTEXT;
874
875//
876// Define the port TransmitControllerCommandByte context structure.
877//
878
879typedef struct _I8042_TRANSMIT_CCB_CONTEXT {
880 IN ULONG HardwareDisableEnableMask;
881 IN BOOLEAN AndOperation;
882 IN UCHAR ByteMask;
883 OUT NTSTATUS Status;
884} I8042_TRANSMIT_CCB_CONTEXT, *PI8042_TRANSMIT_CCB_CONTEXT;
885
886//
887// Define the port DeviceEnableDisable context structure.
888//
889
890typedef struct _I8042_DEVICE_ENABLE_DISABLE_CONTEXT {
891 IN PDEVICE_EXTENSION DeviceExtension;
892 IN ULONG EnableMask;
893 IN BOOLEAN AndOperation;
894 OUT NTSTATUS Status;
895} I8042_DEVICE_ENABLE_DISABLE_CONTEXT,
896 *PI8042_DEVICE_ENABLE_DISABLE_CONTEXT;
897
898//
899// Define the port Get/SetDataQueuePointer context structures.
900//
901
902typedef struct _GET_DATA_POINTER_CONTEXT {
903 IN PDEVICE_EXTENSION DeviceExtension;
904 IN CCHAR DeviceType;
905 OUT PVOID DataIn;
906 OUT PVOID DataOut;
907 OUT ULONG InputCount;
908} GET_DATA_POINTER_CONTEXT, *PGET_DATA_POINTER_CONTEXT;
909
910typedef struct _SET_DATA_POINTER_CONTEXT {
911 IN PDEVICE_EXTENSION DeviceExtension;
912 IN CCHAR DeviceType;
913 IN ULONG InputCount;
914 IN PVOID DataOut;
915} SET_DATA_POINTER_CONTEXT, *PSET_DATA_POINTER_CONTEXT;
916
917//
918// Define the port timer context structure.
919//
920
921typedef struct _TIMER_CONTEXT {
922 IN PDEVICE_OBJECT DeviceObject;
923 IN PLONG TimerCounter;
924 OUT LONG NewTimerCount;
925} TIMER_CONTEXT, *PTIMER_CONTEXT;
926
927//
928// Define the port KeyboardInitiate context structure.
929//
930
931typedef struct _KEYBOARD_INITIATE_CONTEXT {
932 IN PDEVICE_OBJECT DeviceObject;
933 IN UCHAR FirstByte;
934 IN UCHAR LastByte;
935} KEYBOARD_INITIATE_CONTEXT, *PKEYBOARD_INITIATE_CONTEXT;
936
937//
938// Statically allocate the (known) scancode-to-indicator-light mapping.
939// This information is returned by the
940// IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION device control request.
941//
942
943#define KEYBOARD_NUMBER_OF_INDICATORS 3
944
945static const INDICATOR_LIST IndicatorList[KEYBOARD_NUMBER_OF_INDICATORS] = {
946 {0x3A, KEYBOARD_CAPS_LOCK_ON},
947 {0x45, KEYBOARD_NUM_LOCK_ON},
948 {0x46, KEYBOARD_SCROLL_LOCK_ON}};
949
950//
951// Define the context structure and operations for I8xDpcVariableOperation.
952//
953
954typedef enum _OPERATION_TYPE {
955 IncrementOperation,
956 DecrementOperation,
957 WriteOperation,
958 ReadOperation
959} OPERATION_TYPE;
960
961typedef struct _VARIABLE_OPERATION_CONTEXT {
962 IN PLONG VariableAddress;
963 IN OPERATION_TYPE Operation;
964 IN OUT PLONG NewValue;
965} VARIABLE_OPERATION_CONTEXT, *PVARIABLE_OPERATION_CONTEXT;
966
967//
968// Function prototypes.
969//
970
971
972
973NTSTATUS
974DriverEntry(
975 IN PDRIVER_OBJECT DriverObject,
976 IN PUNICODE_STRING RegistryPath
977 );
978
979VOID
980I8042CompletionDpc(
981 IN PKDPC Dpc,
982 IN PDEVICE_OBJECT DeviceObject,
983 IN PIRP Irp,
984 IN PVOID Context
985 );
986
987VOID
988I8042ErrorLogDpc(
989 IN PKDPC Dpc,
990 IN PDEVICE_OBJECT DeviceObject,
991 IN PIRP Irp,
992 IN PVOID Context
993 );
994
995NTSTATUS
996I8042Flush(
997 IN PDEVICE_OBJECT DeviceObject,
998 IN PIRP Irp
999 );
1000
1001NTSTATUS
1002I8042InternalDeviceControl(
1003 IN PDEVICE_OBJECT DeviceObject,
1004 IN PIRP Irp
1005 );
1006
1007BOOLEAN
1008I8042KeyboardInterruptService(
1009 IN PKINTERRUPT Interrupt,
1010 IN PVOID Context
1011 );
1012
1013VOID
1014I8042KeyboardIsrDpc(
1015 IN PKDPC Dpc,
1016 IN PDEVICE_OBJECT DeviceObject,
1017 IN PIRP Irp,
1018 IN PVOID Context
1019 );
1020
1021BOOLEAN
1022I8042MouseInterruptService(
1023 IN PKINTERRUPT Interrupt,
1024 IN PVOID Context
1025 );
1026
1027VOID
1028I8042MouseIsrDpc(
1029 IN PKDPC Dpc,
1030 IN PDEVICE_OBJECT DeviceObject,
1031 IN PIRP Irp,
1032 IN PVOID Context
1033 );
1034
1035NTSTATUS
1036I8042OpenCloseDispatch(
1037 IN PDEVICE_OBJECT DeviceObject,
1038 IN PIRP Irp
1039 );
1040
1041VOID
1042I8042RetriesExceededDpc(
1043 IN PKDPC Dpc,
1044 IN PDEVICE_OBJECT DeviceObject,
1045 IN PIRP Irp,
1046 IN PVOID Context
1047 );
1048
1049VOID
1050I8042StartIo(
1051 IN PDEVICE_OBJECT DeviceObject,
1052 IN PIRP Irp
1053 );
1054
1055VOID
1056I8042TimeOutDpc(
1057 IN PKDPC Dpc,
1058 IN PDEVICE_OBJECT DeviceObject,
1059 IN PVOID SystemContext1,
1060 IN PVOID SystemContext2
1061 );
1062
1063VOID
1064I8042Unload(
1065 IN PDRIVER_OBJECT DriverObject
1066 );
1067
1068VOID
1069I8xBuildResourceList(
1070 IN PDEVICE_EXTENSION DeviceExtension,
1071 OUT PCM_RESOURCE_LIST *ResourceList,
1072 OUT PULONG ResourceListSize
1073 );
1074
1075UCHAR
1076I8xConvertTypematicParameters(
1077 IN USHORT Rate,
1078 IN USHORT Delay
1079 );
1080
1081#if DBG
1082
1083VOID
1084I8xDebugPrint(
1085 ULONG DebugPrintLevel,
1086 PCCHAR DebugMessage,
1087 ...
1088 );
1089
1090extern ULONG i8042Debug;
1091#define I8xPrint(x) I8xDebugPrint x
1092#else
1093#define I8xPrint(x)
1094#endif
1095
1096VOID
1097I8xDecrementTimer(
1098 IN PTIMER_CONTEXT Context
1099 );
1100
1101VOID
1102I8xDeviceEnableDisable(
1103 IN PVOID Context
1104 );
1105
1106VOID
1107I8xDpcVariableOperation(
1108 IN PVOID Context
1109 );
1110
1111VOID
1112I8xDrainOutputBuffer(
1113 IN PUCHAR DataAddress,
1114 IN PUCHAR CommandAddress
1115 );
1116
1117VOID
1118I8xGetByteAsynchronous(
1119 IN CCHAR DeviceType,
1120 IN PDEVICE_EXTENSION DeviceExtension,
1121 OUT PUCHAR Byte
1122 );
1123
1124NTSTATUS
1125I8xGetBytePolled(
1126 IN CCHAR DeviceType,
1127 IN PDEVICE_EXTENSION DeviceExtension,
1128 OUT PUCHAR Byte
1129 );
1130
1131NTSTATUS
1132I8xGetControllerCommand(
1133 IN ULONG HardwareDisableEnableMask,
1134 IN PDEVICE_EXTENSION DeviceExtension,
1135 OUT PUCHAR Byte
1136 );
1137
1138VOID
1139I8xGetDataQueuePointer(
1140 IN PVOID Context
1141 );
1142
1143VOID
1144I8xInitializeDataQueue(
1145 IN PVOID Context
1146 );
1147
1148VOID
1149I8xInitializeHardware(
1150 IN PDEVICE_OBJECT DeviceObject
1151 );
1152
1153NTSTATUS
1154I8xInitializeKeyboard(
1155 IN PDEVICE_OBJECT DeviceObject
1156 );
1157
1158NTSTATUS
1159I8xInitializeMouse(
1160 IN PDEVICE_OBJECT DeviceObject
1161 );
1162
1163VOID
1164I8xKeyboardConfiguration(
1165 IN PINIT_EXTENSION InitializationData,
1166 IN PUNICODE_STRING RegistryPath,
1167 IN PUNICODE_STRING KeyboardDeviceName,
1168 IN PUNICODE_STRING PointerDeviceName
1169 );
1170
1171VOID
1172I8xKeyboardInitiateIo(
1173 IN PVOID Context
1174 );
1175
1176VOID
1177I8xKeyboardInitiateWrapper(
1178 IN PVOID Context
1179 );
1180
1181NTSTATUS
1182I8xKeyboardPeripheralCallout(
1183 IN PVOID Context,
1184 IN PUNICODE_STRING PathName,
1185 IN INTERFACE_TYPE BusType,
1186 IN ULONG BusNumber,
1187 IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
1188 IN CONFIGURATION_TYPE ControllerType,
1189 IN ULONG ControllerNumber,
1190 IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
1191 IN CONFIGURATION_TYPE PeripheralType,
1192 IN ULONG PeripheralNumber,
1193 IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation
1194 );
1195
1196VOID
1197I8xLogError(
1198 IN PDEVICE_OBJECT DeviceObject,
1199 IN NTSTATUS ErrorCode,
1200 IN ULONG UniqueErrorValue,
1201 IN NTSTATUS FinalStatus,
1202 IN PULONG DumpData,
1203 IN ULONG DumpCount
1204 );
1205
1206VOID
1207I8xMouseConfiguration(
1208 IN PINIT_EXTENSION InitializationData,
1209 IN PUNICODE_STRING RegistryPath,
1210 IN PUNICODE_STRING KeyboardDeviceName,
1211 IN PUNICODE_STRING PointerDeviceName
1212 );
1213
1214NTSTATUS
1215I8xMouseEnableTransmission(
1216 IN PDEVICE_OBJECT DeviceObject
1217 );
1218
1219NTSTATUS
1220I8xMousePeripheralCallout(
1221 IN PVOID Context,
1222 IN PUNICODE_STRING PathName,
1223 IN INTERFACE_TYPE BusType,
1224 IN ULONG BusNumber,
1225 IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
1226 IN CONFIGURATION_TYPE ControllerType,
1227 IN ULONG ControllerNumber,
1228 IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
1229 IN CONFIGURATION_TYPE PeripheralType,
1230 IN ULONG PeripheralNumber,
1231 IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation
1232 );
1233
1234VOID
1235I8xPutByteAsynchronous(
1236 IN CCHAR PortType,
1237 IN PDEVICE_EXTENSION DeviceExtension,
1238 IN UCHAR Byte
1239 );
1240
1241NTSTATUS
1242I8xPutBytePolled(
1243 IN CCHAR PortType,
1244 IN BOOLEAN WaitForAcknowledge,
1245 IN CCHAR AckDeviceType,
1246 IN PDEVICE_EXTENSION DeviceExtension,
1247 IN UCHAR Byte
1248 );
1249
1250NTSTATUS
1251I8xPutControllerCommand(
1252 IN PDEVICE_EXTENSION DeviceExtension,
1253 IN UCHAR Byte
1254 );
1255
1256VOID
1257I8xServiceParameters(
1258 IN PINIT_EXTENSION InitializationData,
1259 IN PUNICODE_STRING RegistryPath,
1260 IN PUNICODE_STRING KeyboardDeviceName,
1261 IN PUNICODE_STRING PointerDeviceName
1262 );
1263
1264VOID
1265I8xSetDataQueuePointer(
1266 IN PVOID Context
1267 );
1268
1269VOID
1270I8xTransmitControllerCommand(
1271 IN PDEVICE_EXTENSION DeviceExtension,
1272 IN PVOID Context
1273 );
1274
1275BOOLEAN
1276I8xWriteDataToKeyboardQueue(
1277 IN PPORT_KEYBOARD_EXTENSION KeyboardExtension,
1278 IN PKEYBOARD_INPUT_DATA InputData
1279 );
1280
1281BOOLEAN
1282I8xWriteDataToMouseQueue(
1283 IN PPORT_MOUSE_EXTENSION MouseExtension,
1284 IN PMOUSE_INPUT_DATA InputData
1285 );
1286
1287NTSTATUS
1288I8xFindWheelMouse(
1289 IN PDEVICE_OBJECT DeviceObject
1290 );
1291
1292VOID
1293I8xQueueCurrentInput(
1294 IN PDEVICE_OBJECT DeviceObject
1295 );
1296
1297#ifdef JAPAN
1298NTSTATUS
1299I8xCreateSymbolicLink(
1300 IN PWCHAR SymbolicLinkName,
1301 IN ULONG SymbolicLinkInteger,
1302 IN PUNICODE_STRING DeviceName
1303 );
1304
1305#if defined(i386)
1306// Fujitsu Sep.08.1994
1307// We want to write debugging information to the file except stop error.
1308VOID
1309I8xServiceCrashDump(
1310 IN PDEVICE_EXTENSION DeviceExtension,
1311 IN PUNICODE_STRING RegistryPath,
1312 IN PUNICODE_STRING KeyboardDeviceName,
1313 IN PUNICODE_STRING PointerDeviceName
1314 );
1315#endif // i386
1316
1317#endif // JAPAN
1318
1319#endif // _I8042PRT_
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette