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