Annotation of ntddk/src/input/sermouse/sermouse.h, revision 1.1.1.1

1.1       root        1: /*++
                      2: 
                      3: Copyright (c) 1989, 1990, 1991, 1992, 1993  Microsoft Corporation
                      4: Copyright (c) 1993  Logitech Inc.
                      5: 
                      6: Module Name:
                      7: 
                      8:     sermouse.h
                      9: 
                     10: Abstract:
                     11: 
                     12:     These are the structures and defines that are used in the
                     13:     i8250 serial mouse port driver.
                     14: 
                     15: Revision History:
                     16: 
                     17: 
                     18: --*/
                     19: 
                     20: #ifndef _SERMOUSE_
                     21: #define _SERMOUSE_
                     22: 
                     23: #include <ntddmou.h>
                     24: #include "kbdmou.h"
                     25: #include "sermcfg.h"
                     26: #include "uart.h"
                     27: 
                     28: //
                     29: // Default number of buttons and sample rate for the serial mouse.
                     30: //
                     31: 
                     32: #define MOUSE_NUMBER_OF_BUTTONS     2
                     33: #define MOUSE_SAMPLE_RATE           40    // 1200 baud
                     34: 
                     35: 
                     36: //
                     37: // Protocol handler state constants.
                     38: //
                     39: 
                     40: #define STATE0    0
                     41: #define STATE1    1
                     42: #define STATE2    2
                     43: #define STATE3    3
                     44: #define STATE_MAX 4
                     45: 
                     46: //
                     47: // Useful constants.
                     48: //
                     49: 
                     50: #define MOUSE_BUTTON_1  0x01
                     51: #define MOUSE_BUTTON_2  0x02
                     52: #define MOUSE_BUTTON_3  0x04
                     53: 
                     54: //
                     55: // Conversion factor for milliseconds to microseconds.
                     56: //
                     57: 
                     58: #define MS_TO_MICROSECONDS 1000
                     59: 
                     60: //
                     61: // Protocol handler static data.
                     62: //
                     63: 
                     64: typedef struct _HANDLER_DATA {
                     65:     ULONG Error;              // Error count
                     66:     ULONG State;              // Keep the current state
                     67:     ULONG PreviousButtons;    // The previous button state
                     68:     UCHAR Raw[STATE_MAX];     // Accumulate raw data
                     69: } HANDLER_DATA, *PHANDLER_DATA;
                     70: 
                     71: 
                     72: //
                     73: // Define the protocol handler type.
                     74: //
                     75: 
                     76: typedef BOOLEAN
                     77: (*PPROTOCOL_HANDLER)(
                     78:     IN PMOUSE_INPUT_DATA CurrentInput,
                     79:     IN PHANDLER_DATA HandlerData,
                     80:     IN UCHAR Value,
                     81:     IN UCHAR LineState);
                     82: 
                     83: //
                     84: // Defines for DeviceExtension->HardwarePresent.
                     85: //
                     86: 
                     87: #define MOUSE_HARDWARE_PRESENT     1
                     88: 
                     89: //
                     90: // Serial mouse configuration information.
                     91: //
                     92: 
                     93: typedef struct _SERIAL_MOUSE_CONFIGURATION_INFORMATION {
                     94: 
                     95:     //
                     96:     // Bus interface type.
                     97:     //
                     98: 
                     99:     INTERFACE_TYPE InterfaceType;
                    100: 
                    101:     //
                    102:     // Bus Number.
                    103:     //
                    104: 
                    105:     ULONG BusNumber;
                    106: 
                    107:     //
                    108:     // The port/register resources used by this device.
                    109:     //
                    110: 
                    111:     CM_PARTIAL_RESOURCE_DESCRIPTOR PortList[1];
                    112:     ULONG PortListCount;
                    113: 
                    114:     //
                    115:     // Interrupt resources.
                    116:     //
                    117: 
                    118:     CM_PARTIAL_RESOURCE_DESCRIPTOR MouseInterrupt;
                    119: 
                    120:     //
                    121:     // The mapped address for the set of this device's registers.
                    122:     //
                    123: 
                    124:     PUCHAR DeviceRegisters[1];
                    125: 
                    126:     //
                    127:     // The external frequency at which the UART is being driven.
                    128:     //
                    129: 
                    130:     ULONG BaudClock;
                    131: 
                    132:     //
                    133:     // The saved initial UART state.
                    134:     //
                    135: 
                    136:     UART UartSaved;
                    137: 
                    138:     //
                    139:     // Set at intialization to indicate that the base register
                    140:     // address must be unmapped when the driver is unloaded.
                    141:     //
                    142: 
                    143:     BOOLEAN UnmapRegistersRequired;
                    144: 
                    145:     //
                    146:     // Flag set through the registry to force the type of hardware 
                    147:     // (bypassing NtDetect).
                    148:     //
                    149: 
                    150:     LONG OverrideHardwarePresent;
                    151: 
                    152:     //
                    153:     // Flag that indicates whether floating point context should be saved.
                    154:     //
                    155: 
                    156:     BOOLEAN FloatingSave;
                    157: 
                    158:     //
                    159:     // Mouse attributes.
                    160:     //
                    161: 
                    162:     MOUSE_ATTRIBUTES MouseAttributes;
                    163: 
                    164: } SERIAL_MOUSE_CONFIGURATION_INFORMATION,
                    165:   *PSERIAL_MOUSE_CONFIGURATION_INFORMATION;
                    166: 
                    167: //
                    168: // Port device extension.
                    169: //
                    170: 
                    171: typedef struct _DEVICE_EXTENSION {
                    172: 
                    173:     //
                    174:     // If HardwarePresent is non-zero, there is some sort of serial
                    175:     // pointing device present in the system, either a serial mouse
                    176:     // (MOUSE_HARDWARE_PRESENT) or a serial ballpoint
                    177:     // (BALLPOINT_HARDWARE_PRESENT).
                    178:     //
                    179: 
                    180:     BOOLEAN HardwarePresent;
                    181: 
                    182:     //
                    183:     // Port configuration information.
                    184:     //
                    185: 
                    186:     SERIAL_MOUSE_CONFIGURATION_INFORMATION Configuration;
                    187: 
                    188:     //
                    189:     // Reference count for number of mouse enables.
                    190:     //
                    191: 
                    192:     LONG MouseEnableCount;
                    193: 
                    194:     //
                    195:     // Pointer to the device object.
                    196:     //
                    197: 
                    198:     PDEVICE_OBJECT DeviceObject;
                    199: 
                    200:     //
                    201:     // Mouse class connection data.
                    202:     //
                    203: 
                    204:     CONNECT_DATA ConnectData;
                    205: 
                    206:     //
                    207:     // Number of input data items currently in the mouse InputData queue.
                    208:     //
                    209: 
                    210:     ULONG InputCount;
                    211: 
                    212:     //
                    213:     // Start of the port mouse input data queue (really a circular buffer).
                    214:     //
                    215: 
                    216:     PMOUSE_INPUT_DATA InputData;
                    217: 
                    218:     //
                    219:     // Insertion pointer for mouse InputData.
                    220:     //
                    221: 
                    222:     PMOUSE_INPUT_DATA DataIn;
                    223: 
                    224:     //
                    225:     // Removal pointer for mouse InputData.
                    226:     //
                    227: 
                    228:     PMOUSE_INPUT_DATA DataOut;
                    229: 
                    230:     //
                    231:     // Points one input packet past the end of the InputData buffer.
                    232:     //
                    233: 
                    234:     PMOUSE_INPUT_DATA DataEnd;
                    235: 
                    236:     //
                    237:     // Current mouse input packet.
                    238:     //
                    239: 
                    240:     MOUSE_INPUT_DATA CurrentInput;
                    241: 
                    242:     //
                    243:     // Pointer to interrupt object.
                    244:     //
                    245: 
                    246:     PKINTERRUPT InterruptObject;
                    247: 
                    248:     //
                    249:     // Mouse ISR DPC queue.
                    250:     //
                    251: 
                    252:     KDPC IsrDpc;
                    253: 
                    254:     //
                    255:     // Mouse ISR DPC recall queue.
                    256:     //
                    257: 
                    258:     KDPC IsrDpcRetry;
                    259: 
                    260:     //
                    261:     // Used by the ISR and the ISR DPC (in SerMouDpcVariableOperation calls)
                    262:     // to control processing by the ISR DPC.
                    263:     //
                    264: 
                    265:     LONG DpcInterlockVariable;
                    266: 
                    267:     //
                    268:     // Spinlock used to protect the DPC interlock variable.
                    269:     //
                    270: 
                    271:     KSPIN_LOCK SpinLock;
                    272: 
                    273:     //
                    274:     // Timer used to retry the ISR DPC routine when the class
                    275:     // driver is unable to consume all the port driver's data.
                    276:     //
                    277: 
                    278:     KTIMER DataConsumptionTimer;
                    279: 
                    280:     //
                    281:     // DPC queue for logging overrun and internal driver errors.
                    282:     //
                    283: 
                    284:     KDPC ErrorLogDpc;
                    285: 
                    286:     //
                    287:     // Request sequence number (used for error logging).
                    288:     //
                    289: 
                    290:     ULONG SequenceNumber;
                    291: 
                    292:     //
                    293:     // Pointer to the interrupt protocol handler routine.
                    294:     //
                    295: 
                    296:     PPROTOCOL_HANDLER ProtocolHandler;
                    297: 
                    298:     //
                    299:     // Static state machine handler data.
                    300:     //
                    301: 
                    302:     HANDLER_DATA HandlerData;
                    303: 
                    304:     //
                    305:     // Indicates which pointer port device this driver created (UnitId
                    306:     // is the suffix appended to the pointer port basename for the
                    307:     // call to IoCreateDevice).
                    308:     //
                    309: 
                    310:     USHORT UnitId;
                    311: 
                    312:     //
                    313:     // Indicates whether it is okay to log overflow errors.
                    314:     //
                    315: 
                    316:     BOOLEAN OkayToLogOverflow;
                    317: 
                    318: } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
                    319: 
                    320: //
                    321: // Define the port Get/SetDataQueuePointer context structures.
                    322: //
                    323: 
                    324: typedef struct _GET_DATA_POINTER_CONTEXT {
                    325:     IN PDEVICE_EXTENSION DeviceExtension;
                    326:     OUT PVOID DataIn;
                    327:     OUT PVOID DataOut;
                    328:     OUT ULONG InputCount;
                    329: } GET_DATA_POINTER_CONTEXT, *PGET_DATA_POINTER_CONTEXT;
                    330: 
                    331: typedef struct _SET_DATA_POINTER_CONTEXT {
                    332:     IN PDEVICE_EXTENSION DeviceExtension;
                    333:     IN ULONG InputCount;
                    334:     IN PVOID DataOut;
                    335: } SET_DATA_POINTER_CONTEXT, *PSET_DATA_POINTER_CONTEXT;
                    336: 
                    337: //
                    338: // Define the context structure and operations for SerMouDpcVariableOperation.
                    339: //
                    340: 
                    341: typedef enum _OPERATION_TYPE {
                    342:         IncrementOperation,
                    343:         DecrementOperation,
                    344:         WriteOperation,
                    345:         ReadOperation
                    346: } OPERATION_TYPE;
                    347: 
                    348: typedef struct _VARIABLE_OPERATION_CONTEXT {
                    349:     IN PLONG VariableAddress;
                    350:     IN OPERATION_TYPE Operation;
                    351:     IN OUT PLONG NewValue;
                    352: } VARIABLE_OPERATION_CONTEXT, *PVARIABLE_OPERATION_CONTEXT;
                    353: 
                    354: //
                    355: // Function prototypes.
                    356: //
                    357: 
                    358: 
                    359: NTSTATUS
                    360: DriverEntry(
                    361:     IN PDRIVER_OBJECT DriverObject,
                    362:     IN PUNICODE_STRING RegistryPath
                    363:     );
                    364: 
                    365: VOID
                    366: SerialMouseErrorLogDpc(
                    367:     IN PKDPC Dpc,
                    368:     IN PDEVICE_OBJECT DeviceObject,
                    369:     IN PIRP Irp,
                    370:     IN PVOID Context
                    371:     );
                    372: 
                    373: NTSTATUS
                    374: SerialMouseFlush(
                    375:     IN PDEVICE_OBJECT DeviceObject,
                    376:     IN PIRP Irp
                    377:     );
                    378: NTSTATUS
                    379: SerialMouseInternalDeviceControl(
                    380:     IN PDEVICE_OBJECT DeviceObject,
                    381:     IN PIRP Irp
                    382:     );
                    383: 
                    384: BOOLEAN
                    385: SerialMouseInterruptService(
                    386:     IN PKINTERRUPT Interrupt,
                    387:     IN PVOID Context
                    388:     );
                    389: 
                    390: VOID
                    391: SerialMouseIsrDpc(
                    392:     IN PKDPC Dpc,
                    393:     IN PDEVICE_OBJECT DeviceObject,
                    394:     IN PIRP Irp,
                    395:     IN PVOID Context
                    396:     );
                    397: 
                    398: NTSTATUS
                    399: SerialMouseOpenClose(
                    400:     IN PDEVICE_OBJECT DeviceObject,
                    401:     IN PIRP Irp
                    402:     );
                    403: 
                    404: VOID
                    405: SerialMouseStartIo(
                    406:     IN PDEVICE_OBJECT DeviceObject,
                    407:     IN PIRP Irp
                    408:     );
                    409: 
                    410: VOID
                    411: SerialMouseUnload(
                    412:     IN PDRIVER_OBJECT DriverObject
                    413:     );
                    414: 
                    415: VOID
                    416: SerMouBuildResourceList(
                    417:     IN PDEVICE_EXTENSION DeviceExtension,
                    418:     OUT PCM_RESOURCE_LIST *ResourceList,
                    419:     OUT PULONG ResourceListSize
                    420:     );
                    421: 
                    422: VOID
                    423: SerMouConfiguration(
                    424:     IN PDEVICE_EXTENSION DeviceExtension,
                    425:     IN PUNICODE_STRING RegistryPath,
                    426:     IN PUNICODE_STRING DeviceName
                    427:     );
                    428: 
                    429: VOID
                    430: SerMouDisableInterrupts(
                    431:     IN PVOID Context
                    432:     );
                    433: 
                    434: VOID
                    435: SerMouDpcVariableOperation(
                    436:     IN  PVOID Context
                    437:     );
                    438: 
                    439: VOID
                    440: SerMouEnableInterrupts(
                    441:     IN PVOID Context
                    442:     );
                    443: 
                    444: VOID
                    445: SerMouGetDataQueuePointer(
                    446:     IN PVOID Context
                    447:     );
                    448: 
                    449: VOID
                    450: SerMouInitializeDataQueue(
                    451:     IN PVOID Context
                    452:     );
                    453: 
                    454: NTSTATUS
                    455: SerMouInitializeHardware(
                    456:     IN PDEVICE_OBJECT DeviceObject
                    457:     );
                    458: 
                    459: NTSTATUS
                    460: SerMouPeripheralCallout(
                    461:     IN PVOID Context,
                    462:     IN PUNICODE_STRING PathName,
                    463:     IN INTERFACE_TYPE BusType,
                    464:     IN ULONG BusNumber,
                    465:     IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
                    466:     IN CONFIGURATION_TYPE ControllerType,
                    467:     IN ULONG ControllerNumber,
                    468:     IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
                    469:     IN CONFIGURATION_TYPE PeripheralType,
                    470:     IN ULONG PeripheralNumber,
                    471:     IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation
                    472:     );
                    473: 
                    474: VOID
                    475: SerMouSendReport(
                    476:     IN PDEVICE_OBJECT DeviceObject
                    477:     );
                    478: 
                    479: VOID
                    480: SerMouServiceParameters(
                    481:     IN PDEVICE_EXTENSION DeviceExtension,
                    482:     IN PUNICODE_STRING RegistryPath,
                    483:     IN PUNICODE_STRING DeviceName
                    484:     );
                    485: 
                    486: VOID
                    487: SerMouSetDataQueuePointer(
                    488:     IN PVOID Context
                    489:     );
                    490: 
                    491: BOOLEAN
                    492: SerMouWriteDataToQueue(
                    493:     IN PDEVICE_EXTENSION DeviceExtension,
                    494:     IN PMOUSE_INPUT_DATA InputData
                    495:     );
                    496: 
                    497: #endif // _SERMOUSE_

unix.superglobalmegacorp.com

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