|
|
1.1 root 1: /*++
2:
3: Copyright (c) 1989, 1990, 1991, 1992, 1993 Microsoft Corporation
4:
5: Module Name:
6:
7: inport.h
8:
9: Abstract:
10:
11: These are the structures and defines that are used in the
12: Microsoft Inport mouse port driver.
13:
14: Revision History:
15:
16: --*/
17:
18: #ifndef _INPORT_
19: #define _INPORT_
20:
21: #include <ntddmou.h>
22: #include "kbdmou.h"
23: #include "inpcfg.h"
24:
25: //
26: // Default number of buttons and sample rate for the Inport mouse.
27: //
28:
29: #define MOUSE_NUMBER_OF_BUTTONS 2
30: #define MOUSE_SAMPLE_RATE_50HZ 50
31:
32: //
33: // Define the Inport chip reset value.
34: //
35:
36: #define INPORT_RESET 0x80
37:
38: //
39: // Define the data registers (pointed to by the Inport address register).
40: //
41:
42: #define INPORT_DATA_REGISTER_1 1
43: #define INPORT_DATA_REGISTER_2 2
44:
45: //
46: // Define the Inport identification register and the chip code.
47: //
48:
49: #define INPORT_ID_REGISTER 2
50: #define INPORT_ID_CODE 0xDE
51:
52: //
53: // Define the Inport mouse status register and the status bits.
54: //
55:
56: #define INPORT_STATUS_REGISTER 0
57: #define INPORT_STATUS_BUTTON3 0x01
58: #define INPORT_STATUS_BUTTON2 0x02
59: #define INPORT_STATUS_BUTTON1 0x04
60: #define INPORT_STATUS_MOVEMENT 0x40
61:
62: //
63: // Define the Inport mouse mode register and mode bits.
64: //
65:
66: #define INPORT_MODE_REGISTER 7
67: #define INPORT_MODE_0 0x00 // 0 HZ - INTR = 0
68: #define INPORT_MODE_30HZ 0x01
69: #define INPORT_MODE_50HZ 0x02
70: #define INPORT_MODE_100HZ 0x03
71: #define INPORT_MODE_200HZ 0x04
72: #define INPORT_MODE_1 0x06 // 0 HZ - INTR = 1
73: #define INPORT_DATA_INTERRUPT_ENABLE 0x08
74: #define INPORT_TIMER_INTERRUPT_ENABLE 0x10
75: #define INPORT_MODE_HOLD 0x20
76: #define INPORT_MODE_QUADRATURE 0x00
77:
78: //
79: // Inport mouse configuration information.
80: //
81:
82: typedef struct _INPORT_CONFIGURATION_INFORMATION {
83:
84: //
85: // Bus interface type.
86: //
87:
88: INTERFACE_TYPE InterfaceType;
89:
90: //
91: // Bus Number.
92: //
93:
94: ULONG BusNumber;
95:
96: //
97: // The port/register resources used by this device.
98: //
99:
100: CM_PARTIAL_RESOURCE_DESCRIPTOR PortList[1];
101: ULONG PortListCount;
102:
103: //
104: // Interrupt resources.
105: //
106:
107: CM_PARTIAL_RESOURCE_DESCRIPTOR MouseInterrupt;
108:
109: //
110: // The mapped address for the set of this device's registers.
111: //
112:
113: PUCHAR DeviceRegisters[1];
114:
115: //
116: // Set at intialization to indicate that the base register
117: // address must be unmapped when the driver is unloaded.
118: //
119:
120: BOOLEAN UnmapRegistersRequired;
121:
122: //
123: // Flag that indicates whether floating point context should be saved.
124: //
125:
126: BOOLEAN FloatingSave;
127:
128: //
129: // Mouse attributes.
130: //
131:
132: MOUSE_ATTRIBUTES MouseAttributes;
133:
134: //
135: // Inport mode register Hz specifier for mouse interrupts.
136: //
137:
138: UCHAR HzMode;
139:
140: } INPORT_CONFIGURATION_INFORMATION, *PINPORT_CONFIGURATION_INFORMATION;
141:
142: //
143: // Port device extension.
144: //
145:
146: typedef struct _DEVICE_EXTENSION {
147:
148: //
149: // If HardwarePresent is TRUE, there is an Inport mouse present in
150: // the system.
151: //
152:
153: BOOLEAN HardwarePresent;
154:
155: //
156: // Port configuration information.
157: //
158:
159: INPORT_CONFIGURATION_INFORMATION Configuration;
160:
161: //
162: // Reference count for number of mouse enables.
163: //
164:
165: LONG MouseEnableCount;
166:
167: //
168: // Pointer to the device object.
169: //
170:
171: PDEVICE_OBJECT DeviceObject;
172:
173: //
174: // Mouse class connection data.
175: //
176:
177: CONNECT_DATA ConnectData;
178:
179: //
180: // Number of input data items currently in the mouse InputData queue.
181: //
182:
183: ULONG InputCount;
184:
185: //
186: // Start of the port mouse input data queue (really a circular buffer).
187: //
188:
189: PMOUSE_INPUT_DATA InputData;
190:
191: //
192: // Insertion pointer for mouse InputData.
193: //
194:
195: PMOUSE_INPUT_DATA DataIn;
196:
197: //
198: // Removal pointer for mouse InputData.
199: //
200:
201: PMOUSE_INPUT_DATA DataOut;
202:
203: //
204: // Points one input packet past the end of the InputData buffer.
205: //
206:
207: PMOUSE_INPUT_DATA DataEnd;
208:
209: //
210: // Current mouse input packet.
211: //
212:
213: MOUSE_INPUT_DATA CurrentInput;
214:
215: //
216: // Previous mouse button state.
217: //
218:
219: UCHAR PreviousButtons;
220:
221: //
222: // Pointer to interrupt object.
223: //
224:
225: PKINTERRUPT InterruptObject;
226:
227: //
228: // Mouse ISR DPC queue.
229: //
230:
231: KDPC IsrDpc;
232:
233: //
234: // Mouse ISR DPC recall queue.
235: //
236:
237: KDPC IsrDpcRetry;
238:
239: //
240: // Used by the ISR and the ISR DPC (in InpDpcVariableOperation calls)
241: // to control processing by the ISR DPC.
242: //
243:
244: LONG DpcInterlockVariable;
245:
246: //
247: // Spinlock used to protect the DPC interlock variable.
248: //
249:
250: KSPIN_LOCK SpinLock;
251:
252: //
253: // Timer used to retry the ISR DPC routine when the class
254: // driver is unable to consume all the port driver's data.
255: //
256:
257: KTIMER DataConsumptionTimer;
258:
259: //
260: // DPC queue for logging overrun and internal driver errors.
261: //
262:
263: KDPC ErrorLogDpc;
264:
265: //
266: // Request sequence number (used for error logging).
267: //
268:
269: ULONG SequenceNumber;
270:
271: //
272: // Indicates which pointer port device this driver created (UnitId
273: // is the suffix appended to the pointer port basename for the
274: // call to IoCreateDevice).
275: //
276:
277: USHORT UnitId;
278:
279: //
280: // Indicates whether it is okay to log overflow errors.
281: //
282:
283: BOOLEAN OkayToLogOverflow;
284:
285: } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
286:
287: //
288: // Define the port Get/SetDataQueuePointer context structures.
289: //
290:
291: typedef struct _GET_DATA_POINTER_CONTEXT {
292: IN PDEVICE_EXTENSION DeviceExtension;
293: OUT PVOID DataIn;
294: OUT PVOID DataOut;
295: OUT ULONG InputCount;
296: } GET_DATA_POINTER_CONTEXT, *PGET_DATA_POINTER_CONTEXT;
297:
298: typedef struct _SET_DATA_POINTER_CONTEXT {
299: IN PDEVICE_EXTENSION DeviceExtension;
300: IN ULONG InputCount;
301: IN PVOID DataOut;
302: } SET_DATA_POINTER_CONTEXT, *PSET_DATA_POINTER_CONTEXT;
303:
304: //
305: // Define the context structure and operations for InpDpcVariableOperation.
306: //
307:
308: typedef enum _OPERATION_TYPE {
309: IncrementOperation,
310: DecrementOperation,
311: WriteOperation,
312: ReadOperation
313: } OPERATION_TYPE;
314:
315: typedef struct _VARIABLE_OPERATION_CONTEXT {
316: IN PLONG VariableAddress;
317: IN OPERATION_TYPE Operation;
318: IN OUT PLONG NewValue;
319: } VARIABLE_OPERATION_CONTEXT, *PVARIABLE_OPERATION_CONTEXT;
320:
321: //
322: // Function prototypes.
323: //
324:
325:
326: NTSTATUS
327: DriverEntry(
328: IN PDRIVER_OBJECT DriverObject,
329: IN PUNICODE_STRING RegistryPath
330: );
331:
332: VOID
333: InportErrorLogDpc(
334: IN PKDPC Dpc,
335: IN PDEVICE_OBJECT DeviceObject,
336: IN PIRP Irp,
337: IN PVOID Context
338: );
339:
340: NTSTATUS
341: InportFlush(
342: IN PDEVICE_OBJECT DeviceObject,
343: IN PIRP Irp
344: );
345:
346: NTSTATUS
347: InportInternalDeviceControl(
348: IN PDEVICE_OBJECT DeviceObject,
349: IN PIRP Irp
350: );
351:
352: BOOLEAN
353: InportInterruptService(
354: IN PKINTERRUPT Interrupt,
355: IN PVOID Context
356: );
357:
358: VOID
359: InportIsrDpc(
360: IN PKDPC Dpc,
361: IN PDEVICE_OBJECT DeviceObject,
362: IN PIRP Irp,
363: IN PVOID Context
364: );
365:
366: NTSTATUS
367: InportOpenClose(
368: IN PDEVICE_OBJECT DeviceObject,
369: IN PIRP Irp
370: );
371:
372: VOID
373: InportStartIo(
374: IN PDEVICE_OBJECT DeviceObject,
375: IN PIRP Irp
376: );
377:
378: VOID
379: InportUnload(
380: IN PDRIVER_OBJECT DriverObject
381: );
382:
383: VOID
384: InpBuildResourceList(
385: IN PDEVICE_EXTENSION DeviceExtension,
386: OUT PCM_RESOURCE_LIST *ResourceList,
387: OUT PULONG ResourceListSize
388: );
389:
390: VOID
391: InpConfiguration(
392: IN PDEVICE_EXTENSION DeviceExtension,
393: IN PUNICODE_STRING RegistryPath,
394: IN PUNICODE_STRING DeviceName
395: );
396:
397: #if DBG
398:
399: VOID
400: InpDebugPrint(
401: ULONG DebugPrintLevel,
402: PCCHAR DebugMessage,
403: ...
404: );
405: #define InpPrint(x) InpDebugPrint x
406: extern ULONG InportDebug;
407: #else
408: #define InpPrint(x)
409: #endif
410:
411: VOID
412: InpDisableInterrupts(
413: IN PVOID Context
414: );
415:
416: VOID
417: InpDpcVariableOperation(
418: IN PVOID Context
419: );
420:
421: VOID
422: InpEnableInterrupts(
423: IN PVOID Context
424: );
425:
426: VOID
427: InpGetDataQueuePointer(
428: IN PVOID Context
429: );
430:
431: VOID
432: InpInitializeDataQueue(
433: IN PVOID Context
434: );
435:
436: NTSTATUS
437: InpInitializeHardware(
438: IN PDEVICE_OBJECT DeviceObject
439: );
440:
441: NTSTATUS
442: InpPeripheralCallout(
443: IN PVOID Context,
444: IN PUNICODE_STRING PathName,
445: IN INTERFACE_TYPE BusType,
446: IN ULONG BusNumber,
447: IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
448: IN CONFIGURATION_TYPE ControllerType,
449: IN ULONG ControllerNumber,
450: IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
451: IN CONFIGURATION_TYPE PeripheralType,
452: IN ULONG PeripheralNumber,
453: IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation
454: );
455:
456: VOID
457: InpServiceParameters(
458: IN PDEVICE_EXTENSION DeviceExtension,
459: IN PUNICODE_STRING RegistryPath,
460: IN PUNICODE_STRING DeviceName
461: );
462:
463: VOID
464: InpSetDataQueuePointer(
465: IN PVOID Context
466: );
467:
468: BOOLEAN
469: InpWriteDataToQueue(
470: IN PDEVICE_EXTENSION DeviceExtension,
471: IN PMOUSE_INPUT_DATA InputData
472: );
473:
474: #endif // _INPORT_
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.