i8042prt.h revision 35396ee506ef68dd1c161f1ef2c3c0b68a146ff2
/*++
Copyright (c) 1990, 1991, 1992, 1993 Microsoft Corporation
Module Name:
Abstract:
These are the structures and defines that are used in the
Intel i8042 port driver.
Revision History:
--*/
#ifndef _I8042PRT_
#define _I8042PRT_
#include <ntddkbd.h>
#include <ntddmou.h>
#include "kbdmou.h"
#include "i8042cfg.h"
#ifdef PNP_IDENTIFY
#include "devdesc.h"
#endif
//VBOX begin
#include <VBox/VBoxGuest.h>
#include <VBox/VBoxGuestLib.h>
/* debug printf */
# define OSDBGPRINT(a) DbgPrint a
/* dprintf */
# ifdef LOG_TO_BACKDOOR
# define dprintf(a) RTLogBackdoorPrintf a
# else
# define dprintf(a) OSDBGPRINT(a)
# endif
#else
# define dprintf(a) do {} while (0)
#endif
/* dprintf2 - extended logging. */
#if 0
#else
# define dprintf2(a) do { } while (0)
#endif
//VBOX end
//
// Define the timer values.
//
#define I8042_ASYNC_NO_TIMEOUT -1
#define I8042_ASYNC_TIMEOUT 3
//
// Define the default number of entries in the input data queue.
//
#define DATA_QUEUE_SIZE 100
//
// Define the default stall value.
//
#define I8042_STALL_DEFAULT 50
//
// Define the default "sync time" used to determine when the start
// of a new mouse data packet is expected. The value is in units
// of 100 nanoseconds.
//
//
// Define booleans.
//
#define WAIT_FOR_ACKNOWLEDGE TRUE
#define NO_WAIT_FOR_ACKNOWLEDGE FALSE
#define AND_OPERATION TRUE
#define OR_OPERATION FALSE
#define ENABLE_OPERATION TRUE
#define DISABLE_OPERATION FALSE
//
// Default keyboard scan code mode.
//
#define KEYBOARD_SCAN_CODE_SET 0x01
//
// Default number of function keys, number of LED indicators, and total
// number of keys located on the known types of keyboard.
//
#ifndef JAPAN
#define NUM_KNOWN_KEYBOARD_TYPES 4
#else
// NLS Keyboard Support Code.
#define NUM_KNOWN_KEYBOARD_TYPES 16
#endif
#define KEYBOARD_TYPE_DEFAULT 4
#define KEYBOARD_INDICATORS_DEFAULT 0
typedef struct _KEYBOARD_TYPE_INFORMATION {
static const
{12, 3, 102}, // Olivetti M24 102-key keyboard (and compatibles)
{10, 3, 84}, // All AT type keyboards (84-86 keys)
{12, 3, 101} // Enhanced 101- or 102-key keyboards (and compatibles)
#ifdef JAPAN
// NLS Keyboard Support Code.
,
{ 0, 0, 0},
{ 0, 0, 0},
{12, 3, 106}, // TYPE=7 IBM-J 5576-002 keyboard
{ 0, 0, 0},
{ 0, 0, 0},
{ 0, 0, 0},
{ 0, 0, 0},
{ 0, 0, 0},
{ 0, 0, 0},
{ 0, 0, 0},
{ 0, 0, 0},
{12, 4, 105} // TYPE=16 AX keyboard
#endif
};
//
// Minimum, maximum, and default values for keyboard typematic rate and delay.
//
#define KEYBOARD_TYPEMATIC_RATE_MINIMUM 2
#define KEYBOARD_TYPEMATIC_RATE_MAXIMUM 30
#define KEYBOARD_TYPEMATIC_RATE_DEFAULT 30
#define KEYBOARD_TYPEMATIC_DELAY_MINIMUM 250
#define KEYBOARD_TYPEMATIC_DELAY_MAXIMUM 1000
#define KEYBOARD_TYPEMATIC_DELAY_DEFAULT 250
//
// Define the 8042 mouse status bits.
//
#define LEFT_BUTTON_DOWN 0x01
#define RIGHT_BUTTON_DOWN 0x02
#define MIDDLE_BUTTON_DOWN 0x04
#define X_DATA_SIGN 0x10
#define Y_DATA_SIGN 0x20
#define X_OVERFLOW 0x40
#define Y_OVERFLOW 0x80
//
// Define the maximum positive and negative values for mouse motion.
//
#define MOUSE_MAXIMUM_POSITIVE_DELTA 0x000000FF
#define MOUSE_MAXIMUM_NEGATIVE_DELTA 0xFFFFFF00
//
// Default number of buttons and sample rate for the i8042 mouse.
//
#define MOUSE_NUMBER_OF_BUTTONS 2
#define MOUSE_SAMPLE_RATE 60
//
// Define the mouse resolution specifier. Note that (2**MOUSE_RESOLUTION)
// specifies counts-per-millimeter. Counts-per-centimeter is
// (counts-per-millimeter * 10).
//
#define MOUSE_RESOLUTION 3
//
// Defines for DeviceExtension->HardwarePresent.
//
#define KEYBOARD_HARDWARE_PRESENT 0x01
#define MOUSE_HARDWARE_PRESENT 0x02
#define BALLPOINT_HARDWARE_PRESENT 0x04
#define WHEELMOUSE_HARDWARE_PRESENT 0x08
//
// registers.
//
#define I8X_GET_STATUS_BYTE(Address) \
#define I8X_GET_DATA_BYTE(Address) \
//
// Define commands to the 8042 controller.
//
#define I8042_READ_CONTROLLER_COMMAND_BYTE 0x20
#define I8042_WRITE_CONTROLLER_COMMAND_BYTE 0x60
#define I8042_DISABLE_MOUSE_DEVICE 0xA7
#define I8042_ENABLE_MOUSE_DEVICE 0xA8
#define I8042_AUXILIARY_DEVICE_TEST 0xA9
#define I8042_KEYBOARD_DEVICE_TEST 0xAB
#define I8042_DISABLE_KEYBOARD_DEVICE 0xAD
#define I8042_ENABLE_KEYBOARD_DEVICE 0xAE
#define I8042_WRITE_TO_AUXILIARY_DEVICE 0xD4
//
// Define the 8042 Controller Command Byte.
//
#define CCB_ENABLE_KEYBOARD_INTERRUPT 0x01
#define CCB_ENABLE_MOUSE_INTERRUPT 0x02
#define CCB_DISABLE_KEYBOARD_DEVICE 0x10
#define CCB_DISABLE_MOUSE_DEVICE 0x20
#define CCB_KEYBOARD_TRANSLATE_MODE 0x40
//
// Define the 8042 Controller Status Register bits.
//
#define OUTPUT_BUFFER_FULL 0x01
#define INPUT_BUFFER_FULL 0x02
#define MOUSE_OUTPUT_BUFFER_FULL 0x20
//
// Define the 8042 responses.
//
#define ACKNOWLEDGE 0xFA
#define RESEND 0xFE
//
// Define commands to the keyboard (through the 8042 data port).
//
#define SET_KEYBOARD_INDICATORS 0xED
#define SELECT_SCAN_CODE_SET 0xF0
#define READ_KEYBOARD_ID 0xF2
#define SET_KEYBOARD_TYPEMATIC 0xF3
#define SET_ALL_TYPEMATIC_MAKE_BREAK 0xFA
#define KEYBOARD_RESET 0xFF
//
// Define the keyboard responses.
//
#define KEYBOARD_COMPLETE_SUCCESS 0xAA
#define KEYBOARD_COMPLETE_FAILURE 0xFC
#define KEYBOARD_BREAK_CODE 0xF0
//
// Define commands to the mouse (through the 8042 data port).
//
#define SET_MOUSE_RESOLUTION 0xE8
#define SET_MOUSE_SAMPLING_RATE 0xF3
#define MOUSE_RESET 0xFF
#define ENABLE_MOUSE_TRANSMISSION 0xF4
#define SET_MOUSE_SCALING_1TO1 0xE6
#define READ_MOUSE_STATUS 0xE9
#define GET_DEVICE_ID 0xF2
//
// Define the mouse responses.
//
#define MOUSE_COMPLETE 0xAA
#define MOUSE_ID_BYTE 0x00
#define WHEELMOUSE_ID_BYTE 0x03
//
//
typedef enum _I8042_IO_PORT_TYPE {
DataPort = 0,
//
// Define the device types attached to the i8042 controller.
//
typedef enum _I8042_DEVICE_TYPE {
//
// Define the keyboard output states.
//
typedef enum _KEYBOARD_STATE {
Idle,
//
// Define the keyboard scan code input states.
//
typedef enum _KEYBOARD_SCAN_STATE {
//
// Define the mouse states.
//
typedef enum _MOUSE_STATE {
} MOUSE_STATE;
//
// Define the keyboard set request packet.
//
typedef struct _KEYBOARD_SET_PACKET {
//
// Intel i8042 configuration information.
//
typedef struct _I8042_CONFIGURATION_INFORMATION {
//
// Bus interface type.
//
//
// Bus Number.
//
//
//
//
// Keyboard interrupt resources.
//
//
// Mouse interrupt resources.
//
//
// Flag that indicates whether floating point context should be saved.
//
//
// Number of retries allowed.
//
//
// Number of polling iterations allowed.
//
//
// Maximum number of polling iterations allowed.
//
//
// Maximum number of times to check the Status register in
// the ISR before deciding the interrupt is spurious.
//
//
// Microseconds to stall in KeStallExecutionProcessor calls.
//
//
// Keyboard attributes.
//
//
// Initial values of keyboard typematic rate and delay.
//
//
// Current indicator (LED) setting.
//
//
// Mouse attributes.
//
//
// Boolean flags determines whether we should try and detect the wheel
// on the mouse or not
//
//
// Define the keyboard portion of the port device extension.
//
typedef struct _PORT_KEYBOARD_EXTENSION {
//
// Keyboard class connection data.
//
//
// Number of input data items currently in the keyboard InputData queue.
//
//
// Start of the port keyboard input data queue (really a circular buffer).
//
//
// Insertion pointer for keyboard InputData.
//
//
// Removal pointer for keyboard InputData.
//
//
// Points one input packet past the end of the InputData buffer.
//
//
// Current keyboard input packet.
//
//
// Current keyboard scan input state.
//
//
// Current keyboard output packet (for set requests).
//
//
// Current resend count.
//
//
// Request sequence number (used for error logging).
//
//
// Timer used to retry the ISR DPC routine when the class
// driver is unable to consume all the port driver's data.
//
//
// Indicates which keyboard port device this driver created (UnitId
// is the suffix appended to the keyboard port basename for the
// call to IoCreateDevice).
//
//
// Indicates whether it is okay to log overflow errors.
//
//
// Define the mouse portion of the port device extension.
//
typedef struct _PORT_MOUSE_EXTENSION {
//
// Mouse class connection data.
//
//
// Number of input data items currently in the mouse InputData queue.
//
//
// Start of the port mouse input data queue (really a circular buffer).
//
//
// Insertion pointer for mouse InputData.
//
//
// Removal pointer for mouse InputData.
//
//
// Points one input packet past the end of the InputData buffer.
//
//
// Current mouse input packet.
//
//
// Current mouse input state.
//
//
// Current mouse sign and overflow data.
//
//
// Previous mouse sign and overflow data.
//
//
// Previous mouse button data.
//
//
// Request sequence number (used for error logging).
//
//
// Timer used to retry the ISR DPC routine when the class
// driver is unable to consume all the port driver's data.
//
//
// The tick count (since system boot) at which the mouse last interrupted.
// Retrieved via KeQueryTickCount. Used to determine whether a byte of
// the mouse data packet has been lost. Allows the driver to synch
// up with the true mouse input state.
//
//
// Indicates which pointer port device this driver created (UnitId
// is the suffix appended to the pointer port basename for the
// call to IoCreateDevice).
//
//
// Indicates whether it is okay to log overflow errors.
//
//
// Number of interval timer ticks to wait before deciding that the
// next mouse interrupt is for the start of a new packet. Used to
// synch up again if a byte of the mouse packet gets lost.
//
//
// Keep track of last byte of data received from mouse so we can detect
// the two-byte string which indicates a potential reset
//
//
// Port device extension.
//
typedef struct _DEVICE_EXTENSION {
//
//
//
// Reference count for number of keyboard enables.
//
//
// Reference count for number of mouse enables.
//
//
// Pointer to the device object.
//
//
// The mapped addresses for this device's registers.
//
//
// Keyboard-specific port connection data.
//
//
// Mouse-specific port connection data.
//
//
// Port configuration information.
//
//
// i8042 keyboard and mouse interrupt objects.
//
//
// DPC queue for completion of requests that fail by exceeding
// the maximum number of retries.
//
//
// DPC queue for logging overrun and internal driver errors.
//
//
// Keyboard ISR DPC queue.
//
//
// Keyboard ISR DPC recall queue.
//
//
// Used by the ISR and the ISR DPC (in I8xDpcVariableOperation calls)
// to control processing by the ISR DPC.
//
//
// Mouse ISR DPC queue.
//
//
// Mouse ISR DPC recall queue.
//
//
// Used by the ISR and the ISR DPC (in I8xDpcVariableOperation calls)
// to control processing by the ISR DPC.
//
//
// DPC queue for command timeouts.
//
//
// Timer used to timeout i8042 commands.
//
//
// Timer count used by the command time out routine.
//
//
// Set at intialization to indicate that the register
// addresses must be unmapped when the driver is unloaded.
//
// Fujitsu Sep.08.1994
// We want to write debugging information to the file except stop error.
// 7 6 5 4 3 2 1 0 bit
// | | | | | +--- Right Shift Key
// | | | | +----- Right Ctrl Key
// | | | +------- Right Alt Key
// | | +----------- Left Shift Key
// | +------------- Left Ctrl Key
// +--------------- Left Alt Key
#endif
// VBOX begin
// VBOX end
//
// Temporary structure used during initialization
//
typedef struct _INIT_EXTENSION {
#ifdef PNP_IDENTIFY
#endif
//
// Define the port InitializeDataQueue context structure.
//
typedef struct _I8042_INITIALIZE_DATA_CONTEXT {
//
// Define the port TransmitControllerCommandByte context structure.
//
typedef struct _I8042_TRANSMIT_CCB_CONTEXT {
//
// Define the port DeviceEnableDisable context structure.
//
typedef struct _I8042_DEVICE_ENABLE_DISABLE_CONTEXT {
//
// Define the port Get/SetDataQueuePointer context structures.
//
typedef struct _GET_DATA_POINTER_CONTEXT {
typedef struct _SET_DATA_POINTER_CONTEXT {
//
// Define the port timer context structure.
//
typedef struct _TIMER_CONTEXT {
//
// Define the port KeyboardInitiate context structure.
//
typedef struct _KEYBOARD_INITIATE_CONTEXT {
//
// Statically allocate the (known) scancode-to-indicator-light mapping.
// This information is returned by the
// IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION device control request.
//
#define KEYBOARD_NUMBER_OF_INDICATORS 3
{0x3A, KEYBOARD_CAPS_LOCK_ON},
{0x45, KEYBOARD_NUM_LOCK_ON},
{0x46, KEYBOARD_SCROLL_LOCK_ON}};
//
// Define the context structure and operations for I8xDpcVariableOperation.
//
typedef enum _OPERATION_TYPE {
typedef struct _VARIABLE_OPERATION_CONTEXT {
//
// Function prototypes.
//
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
#if DBG
...
);
extern ULONG i8042Debug;
#define I8xPrint(x) I8xDebugPrint x
#else
#define I8xPrint(x)
#endif
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
#ifdef JAPAN
);
#if defined(i386)
// Fujitsu Sep.08.1994
// We want to write debugging information to the file except stop error.
);
#endif // i386
#endif // JAPAN
#endif // _I8042PRT_