Annotation of ntddk/src/input/i8042prt/i8042prt.h, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.