xref: /reactos/drivers/input/inport/inport.h (revision 3adf4508)
1 /*
2  * PROJECT:     ReactOS InPort (Bus) Mouse Driver
3  * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE:     Main header file
5  * COPYRIGHT:   Copyright 2020 Dmitry Borisov (di.sean@protonmail.com)
6  */
7 
8 #ifndef _INPORT_H_
9 #define _INPORT_H_
10 
11 #include <wdm.h>
12 #include <wmilib.h>
13 #include <wmistr.h>
14 #include <kbdmou.h>
15 
16 #include <section_attribs.h>
17 
18 #define INPORT_TAG 'tPnI'
19 
20 typedef enum
21 {
22     dsStopped,
23     dsStarted,
24     dsRemoved
25 } INPORT_DEVICE_STATE;
26 
27 typedef enum
28 {
29     NecBusMouse,
30     MsInPortMouse,
31     LogitechBusMouse
32 } INPORT_MOUSE_TYPE;
33 
34 typedef struct _INPORT_RAW_DATA
35 {
36     CHAR DeltaX;
37     CHAR DeltaY;
38     UCHAR Buttons;
39     ULONG ButtonDiff;
40 } INPORT_RAW_DATA, *PINPORT_RAW_DATA;
41 
42 typedef struct _INPORT_DEVICE_EXTENSION
43 {
44     PDEVICE_OBJECT Self;
45     PDEVICE_OBJECT Pdo;
46     PDEVICE_OBJECT Ldo;
47     INPORT_DEVICE_STATE State;
48     IO_REMOVE_LOCK RemoveLock;
49     WMILIB_CONTEXT WmiLibInfo;
50     PUCHAR IoBase;
51     INPORT_MOUSE_TYPE MouseType;
52 
53     /* Interrupt */
54     PKINTERRUPT InterruptObject;
55     ULONG InterruptVector;
56     KIRQL InterruptLevel;
57     KINTERRUPT_MODE InterruptMode;
58     BOOLEAN InterruptShared;
59     KAFFINITY InterruptAffinity;
60 
61     /* Movement data and state of the mouse buttons */
62     INPORT_RAW_DATA RawData;
63 
64     /* Mouclass */
65     CONNECT_DATA ConnectData;
66     PDEVICE_OBJECT ClassDeviceObject;
67     PVOID ClassService;
68 
69     /* Mouse packet */
70     MOUSE_INPUT_DATA MouseInputData;
71 
72     /* Previous state */
73     ULONG MouseButtonState;
74 
75     /* Mouse device attributes */
76     MOUSE_ATTRIBUTES MouseAttributes;
77 } INPORT_DEVICE_EXTENSION, *PINPORT_DEVICE_EXTENSION;
78 
79 CODE_SEG("INIT")
80 DRIVER_INITIALIZE DriverEntry;
81 
82 CODE_SEG("PAGE")
83 DRIVER_UNLOAD InPortUnload;
84 
85 CODE_SEG("PAGE")
86 DRIVER_ADD_DEVICE InPortAddDevice;
87 
88 _Dispatch_type_(IRP_MJ_CREATE)
89 _Dispatch_type_(IRP_MJ_CLOSE)
90 CODE_SEG("PAGE")
91 DRIVER_DISPATCH_PAGED InPortCreateClose;
92 
93 _Dispatch_type_(IRP_MJ_INTERNAL_DEVICE_CONTROL)
94 DRIVER_DISPATCH_RAISED InPortInternalDeviceControl;
95 
96 _Dispatch_type_(IRP_MJ_POWER)
97 DRIVER_DISPATCH_RAISED InPortPower;
98 
99 _Dispatch_type_(IRP_MJ_SYSTEM_CONTROL)
100 CODE_SEG("PAGE")
101 DRIVER_DISPATCH_PAGED InPortWmi;
102 
103 _Dispatch_type_(IRP_MJ_PNP)
104 CODE_SEG("PAGE")
105 DRIVER_DISPATCH_PAGED InPortPnp;
106 
107 KSERVICE_ROUTINE InPortIsr;
108 
109 IO_DPC_ROUTINE InPortDpcForIsr;
110 
111 KSYNCHRONIZE_ROUTINE InPortStartMouse;
112 
113 KSYNCHRONIZE_ROUTINE InPortStopMouse;
114 
115 CODE_SEG("PAGE")
116 NTSTATUS
117 NTAPI
118 InPortStartDevice(
119     _In_ PDEVICE_OBJECT DeviceObject,
120     _Inout_ PIRP Irp);
121 
122 CODE_SEG("PAGE")
123 NTSTATUS
124 NTAPI
125 InPortRemoveDevice(
126     _In_ PDEVICE_OBJECT DeviceObject,
127     _Inout_ PIRP Irp);
128 
129 CODE_SEG("PAGE")
130 VOID
131 NTAPI
132 InPortInitializeMouse(
133     _In_ PINPORT_DEVICE_EXTENSION DeviceExtension);
134 
135 CODE_SEG("PAGE")
136 NTSTATUS
137 NTAPI
138 InPortWmiRegistration(
139     _Inout_ PINPORT_DEVICE_EXTENSION DeviceExtension);
140 
141 CODE_SEG("PAGE")
142 NTSTATUS
143 NTAPI
144 InPortWmiDeRegistration(
145     _Inout_ PINPORT_DEVICE_EXTENSION DeviceExtension);
146 
147 CODE_SEG("PAGE")
148 NTSTATUS
149 NTAPI
150 InPortQueryWmiRegInfo(
151     _Inout_ PDEVICE_OBJECT DeviceObject,
152     _Inout_ PULONG RegFlags,
153     _Inout_ PUNICODE_STRING InstanceName,
154     _Out_opt_ PUNICODE_STRING *RegistryPath,
155     _Inout_ PUNICODE_STRING MofResourceName,
156     _Out_opt_ PDEVICE_OBJECT *Pdo);
157 
158 CODE_SEG("PAGE")
159 NTSTATUS
160 NTAPI
161 InPortQueryWmiDataBlock(
162     _Inout_ PDEVICE_OBJECT DeviceObject,
163     _Inout_ PIRP Irp,
164     _In_ ULONG GuidIndex,
165     _In_ ULONG InstanceIndex,
166     _In_ ULONG InstanceCount,
167     _Out_opt_ PULONG InstanceLengthArray,
168     _In_ ULONG BufferAvail,
169     _Out_opt_ PUCHAR Buffer);
170 
171 extern UNICODE_STRING DriverRegistryPath;
172 
173 #endif /* _INPORT_H_ */
174