]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.h
IntelFsp2WrapperPkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Bus / Isa / Ps2MouseDxe / Ps2Mouse.h
CommitLineData
77833d0b
RN
1/** @file\r
2 PS/2 Mouse driver header file.\r
3\r
4Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
9d510e61 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
77833d0b
RN
6\r
7**/\r
8\r
9#ifndef _PS2MOUSE_H_\r
10#define _PS2MOUSE_H_\r
11\r
12#include <Uefi.h>\r
13\r
14#include <Protocol/SimplePointer.h>\r
15#include <Protocol/SuperIo.h>\r
16#include <Protocol/DevicePath.h>\r
17\r
18#include <Library/DevicePathLib.h>\r
19#include <Library/DebugLib.h>\r
20#include <Library/UefiDriverEntryPoint.h>\r
21#include <Library/UefiLib.h>\r
22#include <Library/BaseMemoryLib.h>\r
23#include <Library/MemoryAllocationLib.h>\r
24#include <Library/UefiBootServicesTableLib.h>\r
25#include <Library/ReportStatusCodeLib.h>\r
26#include <Library/PcdLib.h>\r
27#include <Library/IoLib.h>\r
28\r
29//\r
30// Global Variables\r
31//\r
32extern EFI_DRIVER_BINDING_PROTOCOL gPS2MouseDriver;\r
33extern EFI_COMPONENT_NAME_PROTOCOL gPs2MouseComponentName;\r
34extern EFI_COMPONENT_NAME2_PROTOCOL gPs2MouseComponentName2;\r
35\r
36//\r
37// PS/2 mouse sample rate\r
38//\r
39typedef enum {\r
40 SampleRate10,\r
41 SampleRate20,\r
42 SampleRate40,\r
43 SampleRate60,\r
44 SampleRate80,\r
45 SampleRate100,\r
46 SampleRate200,\r
47 MaxSampleRate\r
48} MOUSE_SR;\r
49\r
50//\r
51// PS/2 mouse resolution\r
52//\r
53typedef enum {\r
54 MouseResolution1,\r
55 MouseResolution2,\r
56 MouseResolution4,\r
57 MouseResolution8,\r
58 MaxResolution\r
59} MOUSE_RE;\r
60\r
61//\r
62// PS/2 mouse scaling\r
63//\r
64typedef enum {\r
65 Scaling1,\r
66 Scaling2\r
67} MOUSE_SF;\r
68\r
69//\r
70// Driver Private Data\r
71//\r
72#define PS2_MOUSE_DEV_SIGNATURE SIGNATURE_32 ('p', 's', '2', 'm')\r
73\r
74typedef struct {\r
75 UINTN Signature;\r
76\r
77 EFI_HANDLE Handle;\r
78 EFI_SIMPLE_POINTER_PROTOCOL SimplePointerProtocol;\r
79 EFI_SIMPLE_POINTER_STATE State;\r
80 EFI_SIMPLE_POINTER_MODE Mode;\r
81 BOOLEAN StateChanged;\r
82\r
83 //\r
84 // PS2 Mouse device specific information\r
85 //\r
86 MOUSE_SR SampleRate;\r
87 MOUSE_RE Resolution;\r
88 MOUSE_SF Scaling;\r
89 UINT8 DataPackageSize;\r
90\r
91 EFI_EVENT TimerEvent;\r
92\r
93 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
94 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
95} PS2_MOUSE_DEV;\r
96\r
97#define PS2_MOUSE_DEV_FROM_THIS(a) CR (a, PS2_MOUSE_DEV, SimplePointerProtocol, PS2_MOUSE_DEV_SIGNATURE)\r
98\r
99//\r
100// Function prototypes\r
101//\r
102/**\r
103 Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
104 than contains a IsaIo protocol can be supported.\r
105\r
106 @param This Protocol instance pointer.\r
107 @param ControllerHandle Handle of device to test\r
108 @param RemainingDevicePath Optional parameter use to pick a specific child\r
109 device to start.\r
110\r
111 @retval EFI_SUCCESS This driver supports this device\r
112 @retval EFI_ALREADY_STARTED This driver is already running on this device\r
113 @retval other This driver does not support this device\r
114\r
115**/\r
116EFI_STATUS\r
117EFIAPI\r
118PS2MouseDriverSupported (\r
119 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
120 IN EFI_HANDLE Controller,\r
121 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
122 );\r
123\r
124/**\r
125 Start this driver on ControllerHandle by opening a IsaIo\r
126 protocol, creating PS2_MOUSE_ABSOLUTE_POINTER_DEV device and install gEfiAbsolutePointerProtocolGuid\r
1d031e75 127 finally.\r
77833d0b
RN
128\r
129 @param This Protocol instance pointer.\r
130 @param ControllerHandle Handle of device to bind driver to\r
131 @param RemainingDevicePath Optional parameter use to pick a specific child\r
132 device to start.\r
133\r
134 @retval EFI_SUCCESS This driver is added to ControllerHandle\r
135 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
136 @retval other This driver does not support this device\r
137\r
138**/\r
139EFI_STATUS\r
140EFIAPI\r
141PS2MouseDriverStart (\r
142 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
143 IN EFI_HANDLE Controller,\r
144 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
145 );\r
146\r
147/**\r
ed356b9e 148 Stop this driver on ControllerHandle. Support stopping any child handles\r
77833d0b
RN
149 created by this driver.\r
150\r
151 @param This Protocol instance pointer.\r
152 @param ControllerHandle Handle of device to stop driver on\r
153 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
154 children is zero stop the entire bus driver.\r
155 @param ChildHandleBuffer List of Child Handles to Stop.\r
156\r
157 @retval EFI_SUCCESS This driver is removed ControllerHandle\r
158 @retval other This driver was not removed from this device\r
159\r
160**/\r
161EFI_STATUS\r
162EFIAPI\r
163PS2MouseDriverStop (\r
164 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
165 IN EFI_HANDLE Controller,\r
166 IN UINTN NumberOfChildren,\r
167 IN EFI_HANDLE *ChildHandleBuffer\r
168 );\r
169\r
170//\r
171// EFI Component Name Functions\r
172//\r
173/**\r
174 Retrieves a Unicode string that is the user readable name of the driver.\r
175\r
176 This function retrieves the user readable name of a driver in the form of a\r
177 Unicode string. If the driver specified by This has a user readable name in\r
178 the language specified by Language, then a pointer to the driver name is\r
179 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
180 by This does not support the language specified by Language,\r
181 then EFI_UNSUPPORTED is returned.\r
182\r
183 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
184 EFI_COMPONENT_NAME_PROTOCOL instance.\r
185\r
186 @param Language[in] A pointer to a Null-terminated ASCII string\r
187 array indicating the language. This is the\r
188 language of the driver name that the caller is\r
189 requesting, and it must match one of the\r
190 languages specified in SupportedLanguages. The\r
191 number of languages supported by a driver is up\r
192 to the driver writer. Language is specified\r
193 in RFC 4646 or ISO 639-2 language code format.\r
194\r
195 @param DriverName[out] A pointer to the Unicode string to return.\r
196 This Unicode string is the name of the\r
197 driver specified by This in the language\r
198 specified by Language.\r
199\r
200 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
201 This and the language specified by Language was\r
202 returned in DriverName.\r
203\r
204 @retval EFI_INVALID_PARAMETER Language is NULL.\r
205\r
206 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
207\r
208 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
209 the language specified by Language.\r
210\r
211**/\r
212EFI_STATUS\r
213EFIAPI\r
214Ps2MouseComponentNameGetDriverName (\r
215 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
216 IN CHAR8 *Language,\r
217 OUT CHAR16 **DriverName\r
218 );\r
219\r
220\r
221/**\r
222 Retrieves a Unicode string that is the user readable name of the controller\r
223 that is being managed by a driver.\r
224\r
225 This function retrieves the user readable name of the controller specified by\r
226 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
227 driver specified by This has a user readable name in the language specified by\r
228 Language, then a pointer to the controller name is returned in ControllerName,\r
229 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
230 managing the controller specified by ControllerHandle and ChildHandle,\r
231 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
232 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
233\r
234 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
235 EFI_COMPONENT_NAME_PROTOCOL instance.\r
236\r
237 @param ControllerHandle[in] The handle of a controller that the driver\r
238 specified by This is managing. This handle\r
239 specifies the controller whose name is to be\r
240 returned.\r
241\r
242 @param ChildHandle[in] The handle of the child controller to retrieve\r
243 the name of. This is an optional parameter that\r
244 may be NULL. It will be NULL for device\r
245 drivers. It will also be NULL for a bus drivers\r
246 that wish to retrieve the name of the bus\r
247 controller. It will not be NULL for a bus\r
248 driver that wishes to retrieve the name of a\r
249 child controller.\r
250\r
251 @param Language[in] A pointer to a Null-terminated ASCII string\r
252 array indicating the language. This is the\r
253 language of the driver name that the caller is\r
254 requesting, and it must match one of the\r
255 languages specified in SupportedLanguages. The\r
256 number of languages supported by a driver is up\r
257 to the driver writer. Language is specified in\r
258 RFC 4646 or ISO 639-2 language code format.\r
259\r
260 @param ControllerName[out] A pointer to the Unicode string to return.\r
261 This Unicode string is the name of the\r
262 controller specified by ControllerHandle and\r
263 ChildHandle in the language specified by\r
264 Language from the point of view of the driver\r
265 specified by This.\r
266\r
267 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
268 the language specified by Language for the\r
269 driver specified by This was returned in\r
270 DriverName.\r
271\r
272 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
273\r
274 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
275 EFI_HANDLE.\r
276\r
277 @retval EFI_INVALID_PARAMETER Language is NULL.\r
278\r
279 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
280\r
281 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
282 managing the controller specified by\r
283 ControllerHandle and ChildHandle.\r
284\r
285 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
286 the language specified by Language.\r
287\r
288**/\r
289EFI_STATUS\r
290EFIAPI\r
291Ps2MouseComponentNameGetControllerName (\r
292 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
293 IN EFI_HANDLE ControllerHandle,\r
294 IN EFI_HANDLE ChildHandle OPTIONAL,\r
295 IN CHAR8 *Language,\r
296 OUT CHAR16 **ControllerName\r
297 );\r
298\r
299/**\r
300 Reset the Mouse and do BAT test for it, if ExtendedVerification is TRUE and\r
ed356b9e 301 there is a mouse device connected to system.\r
77833d0b
RN
302\r
303 @param This - Pointer of simple pointer Protocol.\r
304 @param ExtendedVerification - Whether configure mouse parameters. True: do; FALSE: skip.\r
305\r
306\r
307 @retval EFI_SUCCESS - The command byte is written successfully.\r
ed356b9e 308 @retval EFI_DEVICE_ERROR - Errors occurred during resetting keyboard.\r
77833d0b
RN
309\r
310**/\r
311EFI_STATUS\r
312EFIAPI\r
313MouseReset (\r
314 IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r
315 IN BOOLEAN ExtendedVerification\r
316 );\r
317\r
318/**\r
319 Get and Clear mouse status.\r
320\r
321 @param This - Pointer of simple pointer Protocol.\r
322 @param State - Output buffer holding status.\r
323\r
324 @retval EFI_INVALID_PARAMETER Output buffer is invalid.\r
325 @retval EFI_NOT_READY Mouse is not changed status yet.\r
326 @retval EFI_SUCCESS Mouse status is changed and get successful.\r
327**/\r
328EFI_STATUS\r
329EFIAPI\r
330MouseGetState (\r
331 IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r
332 IN OUT EFI_SIMPLE_POINTER_STATE *State\r
333 );\r
334\r
335/**\r
336\r
337 Event notification function for SIMPLE_POINTER.WaitForInput event.\r
338 Signal the event if there is input from mouse.\r
339\r
340 @param Event event object\r
341 @param Context event context\r
342\r
343**/\r
344VOID\r
345EFIAPI\r
346MouseWaitForInput (\r
347 IN EFI_EVENT Event,\r
348 IN VOID *Context\r
349 );\r
350\r
351/**\r
352 Event notification function for TimerEvent event.\r
353 If mouse device is connected to system, try to get the mouse packet data.\r
354\r
355 @param Event - TimerEvent in PS2_MOUSE_DEV\r
356 @param Context - Pointer to PS2_MOUSE_DEV structure\r
357\r
358**/\r
359VOID\r
360EFIAPI\r
361PollMouse (\r
362 IN EFI_EVENT Event,\r
363 IN VOID *Context\r
364 );\r
365\r
366/**\r
367 I/O work flow of in 8042 data.\r
368\r
369 @param Data Data value\r
370\r
ed356b9e 371 @retval EFI_SUCCESS Success to execute I/O work flow\r
77833d0b
RN
372 @retval EFI_TIMEOUT Keyboard controller time out.\r
373**/\r
374EFI_STATUS\r
375In8042Data (\r
376 IN OUT UINT8 *Data\r
377 );\r
378\r
379/**\r
380 Check whether there is Ps/2 mouse device in system\r
381\r
382 @param MouseDev - Mouse Private Data Structure\r
383\r
384 @retval TRUE - Keyboard in System.\r
385 @retval FALSE - Keyboard not in System.\r
386\r
387**/\r
388BOOLEAN\r
389CheckMouseConnect (\r
390 IN PS2_MOUSE_DEV *MouseDev\r
391 );\r
392\r
393#endif\r