]>
Commit | Line | Data |
---|---|---|
ed838d0c | 1 | /** @file\r |
29129ce4 | 2 | USB Mouse Driver that manages USB mouse and produces Simple Pointer Protocol.\r |
bb80e3b2 | 3 | \r |
0309b719 | 4 | Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r |
cd5ebaa0 | 5 | This program and the accompanying materials\r |
ed838d0c | 6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
ed838d0c | 13 | **/\r |
14 | \r | |
15 | #include "UsbMouse.h"\r | |
16 | \r | |
ed838d0c | 17 | EFI_DRIVER_BINDING_PROTOCOL gUsbMouseDriverBinding = {\r |
18 | USBMouseDriverBindingSupported,\r | |
19 | USBMouseDriverBindingStart,\r | |
20 | USBMouseDriverBindingStop,\r | |
21 | 0xa,\r | |
22 | NULL,\r | |
23 | NULL\r | |
24 | };\r | |
25 | \r | |
bb80e3b2 | 26 | /**\r |
29129ce4 | 27 | Entrypoint of USB Mouse Driver.\r |
bb80e3b2 | 28 | \r |
29129ce4 | 29 | This function is the entrypoint of USB Mouse Driver. It installs Driver Binding\r |
30 | Protocols together with Component Name Protocols.\r | |
bb80e3b2 | 31 | \r |
29129ce4 | 32 | @param ImageHandle The firmware allocated handle for the EFI image.\r |
33 | @param SystemTable A pointer to the EFI System Table.\r | |
bb80e3b2 | 34 | \r |
29129ce4 | 35 | @retval EFI_SUCCESS The entry point is executed successfully.\r |
bb80e3b2 | 36 | \r |
37 | **/\r | |
ed838d0c | 38 | EFI_STATUS\r |
39 | EFIAPI\r | |
40 | USBMouseDriverBindingEntryPoint (\r | |
41 | IN EFI_HANDLE ImageHandle,\r | |
42 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
43 | )\r | |
ed838d0c | 44 | {\r |
29129ce4 | 45 | EFI_STATUS Status;\r |
46 | \r | |
47 | Status = EfiLibInstallDriverBindingComponentName2 (\r | |
48 | ImageHandle,\r | |
49 | SystemTable,\r | |
50 | &gUsbMouseDriverBinding,\r | |
51 | ImageHandle,\r | |
52 | &gUsbMouseComponentName,\r | |
53 | &gUsbMouseComponentName2\r | |
54 | );\r | |
55 | ASSERT_EFI_ERROR (Status);\r | |
56 | \r | |
57 | return EFI_SUCCESS;\r | |
ed838d0c | 58 | }\r |
59 | \r | |
60 | \r | |
61 | /**\r | |
29129ce4 | 62 | Check whether USB mouse driver supports this device.\r |
ed838d0c | 63 | \r |
29129ce4 | 64 | @param This The USB mouse driver binding protocol.\r |
65 | @param Controller The controller handle to check.\r | |
66 | @param RemainingDevicePath The remaining device path.\r | |
ed838d0c | 67 | \r |
29129ce4 | 68 | @retval EFI_SUCCESS The driver supports this controller.\r |
69 | @retval other This device isn't supported.\r | |
ed838d0c | 70 | \r |
71 | **/\r | |
72 | EFI_STATUS\r | |
73 | EFIAPI\r | |
74 | USBMouseDriverBindingSupported (\r | |
75 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
76 | IN EFI_HANDLE Controller,\r | |
77 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
78 | )\r | |
79 | {\r | |
ed838d0c | 80 | EFI_STATUS Status;\r |
29129ce4 | 81 | EFI_USB_IO_PROTOCOL *UsbIo;\r |
ed838d0c | 82 | \r |
29129ce4 | 83 | Status = gBS->OpenProtocol (\r |
84 | Controller,\r | |
85 | &gEfiUsbIoProtocolGuid,\r | |
86 | (VOID **) &UsbIo,\r | |
87 | This->DriverBindingHandle,\r | |
88 | Controller,\r | |
89 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
90 | );\r | |
91 | if (EFI_ERROR (Status)) {\r | |
92 | return Status;\r | |
ed838d0c | 93 | }\r |
94 | \r | |
95 | //\r | |
29129ce4 | 96 | // Use the USB I/O Protocol interface to check whether Controller is\r |
97 | // a mouse device that can be managed by this driver.\r | |
ed838d0c | 98 | //\r |
99 | Status = EFI_SUCCESS;\r | |
100 | if (!IsUsbMouse (UsbIo)) {\r | |
101 | Status = EFI_UNSUPPORTED;\r | |
102 | }\r | |
103 | \r | |
104 | gBS->CloseProtocol (\r | |
105 | Controller,\r | |
106 | &gEfiUsbIoProtocolGuid,\r | |
107 | This->DriverBindingHandle,\r | |
108 | Controller\r | |
109 | );\r | |
29129ce4 | 110 | \r |
ed838d0c | 111 | return Status;\r |
112 | }\r | |
113 | \r | |
114 | \r | |
115 | /**\r | |
29129ce4 | 116 | Starts the mouse device with this driver.\r |
117 | \r | |
118 | This function consumes USB I/O Portocol, intializes USB mouse device,\r | |
119 | installs Simple Pointer Protocol, and submits Asynchronous Interrupt\r | |
120 | Transfer to manage the USB mouse device.\r | |
ed838d0c | 121 | \r |
29129ce4 | 122 | @param This The USB mouse driver binding instance.\r |
123 | @param Controller Handle of device to bind driver to.\r | |
124 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
125 | device to start.\r | |
ed838d0c | 126 | \r |
127 | @retval EFI_SUCCESS This driver supports this device.\r | |
128 | @retval EFI_UNSUPPORTED This driver does not support this device.\r | |
bb80e3b2 | 129 | @retval EFI_DEVICE_ERROR This driver cannot be started due to device Error.\r |
130 | @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r | |
d7db0902 | 131 | @retval EFI_ALREADY_STARTED This driver has been started.\r |
ed838d0c | 132 | \r |
133 | **/\r | |
134 | EFI_STATUS\r | |
135 | EFIAPI\r | |
136 | USBMouseDriverBindingStart (\r | |
137 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
138 | IN EFI_HANDLE Controller,\r | |
139 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
140 | )\r | |
141 | {\r | |
142 | EFI_STATUS Status;\r | |
143 | EFI_USB_IO_PROTOCOL *UsbIo;\r | |
ed838d0c | 144 | USB_MOUSE_DEV *UsbMouseDevice;\r |
145 | UINT8 EndpointNumber;\r | |
29129ce4 | 146 | EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;\r |
ed838d0c | 147 | UINT8 Index;\r |
148 | UINT8 EndpointAddr;\r | |
149 | UINT8 PollingInterval;\r | |
150 | UINT8 PacketSize;\r | |
29129ce4 | 151 | BOOLEAN Found;\r |
15cc67e6 | 152 | EFI_TPL OldTpl;\r |
ed838d0c | 153 | \r |
15cc67e6 | 154 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r |
29129ce4 | 155 | //\r |
156 | // Open USB I/O Protocol\r | |
157 | //\r | |
ed838d0c | 158 | Status = gBS->OpenProtocol (\r |
159 | Controller,\r | |
160 | &gEfiUsbIoProtocolGuid,\r | |
c52fa98c | 161 | (VOID **) &UsbIo,\r |
ed838d0c | 162 | This->DriverBindingHandle,\r |
163 | Controller,\r | |
164 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
165 | );\r | |
166 | if (EFI_ERROR (Status)) {\r | |
15cc67e6 | 167 | goto ErrorExit1;\r |
ed838d0c | 168 | }\r |
169 | \r | |
170 | UsbMouseDevice = AllocateZeroPool (sizeof (USB_MOUSE_DEV));\r | |
29129ce4 | 171 | ASSERT (UsbMouseDevice != NULL);\r |
ed838d0c | 172 | \r |
29129ce4 | 173 | UsbMouseDevice->UsbIo = UsbIo;\r |
174 | UsbMouseDevice->Signature = USB_MOUSE_DEV_SIGNATURE;\r | |
ed838d0c | 175 | \r |
ed838d0c | 176 | //\r |
177 | // Get the Device Path Protocol on Controller's handle\r | |
178 | //\r | |
179 | Status = gBS->OpenProtocol (\r | |
180 | Controller,\r | |
181 | &gEfiDevicePathProtocolGuid,\r | |
182 | (VOID **) &UsbMouseDevice->DevicePath,\r | |
183 | This->DriverBindingHandle,\r | |
184 | Controller,\r | |
185 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
186 | );\r | |
187 | \r | |
188 | if (EFI_ERROR (Status)) {\r | |
189 | goto ErrorExit;\r | |
190 | }\r | |
191 | //\r | |
192 | // Get interface & endpoint descriptor\r | |
193 | //\r | |
194 | UsbIo->UsbGetInterfaceDescriptor (\r | |
29129ce4 | 195 | UsbIo,\r |
196 | &UsbMouseDevice->InterfaceDescriptor\r | |
197 | );\r | |
ed838d0c | 198 | \r |
29129ce4 | 199 | EndpointNumber = UsbMouseDevice->InterfaceDescriptor.NumEndpoints;\r |
ed838d0c | 200 | \r |
29129ce4 | 201 | //\r |
202 | // Traverse endpoints to find interrupt endpoint\r | |
203 | //\r | |
204 | Found = FALSE;\r | |
ed838d0c | 205 | for (Index = 0; Index < EndpointNumber; Index++) {\r |
206 | UsbIo->UsbGetEndpointDescriptor (\r | |
29129ce4 | 207 | UsbIo,\r |
208 | Index,\r | |
209 | &EndpointDescriptor\r | |
210 | );\r | |
ed838d0c | 211 | \r |
29129ce4 | 212 | if ((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) {\r |
ed838d0c | 213 | //\r |
214 | // We only care interrupt endpoint here\r | |
215 | //\r | |
29129ce4 | 216 | CopyMem(&UsbMouseDevice->IntEndpointDescriptor, &EndpointDescriptor, sizeof(EndpointDescriptor));\r |
217 | Found = TRUE;\r | |
218 | break;\r | |
ed838d0c | 219 | }\r |
220 | }\r | |
221 | \r | |
29129ce4 | 222 | if (!Found) {\r |
ed838d0c | 223 | //\r |
29129ce4 | 224 | // No interrupt endpoint found, then return unsupported.\r |
ed838d0c | 225 | //\r |
226 | Status = EFI_UNSUPPORTED;\r | |
227 | goto ErrorExit;\r | |
228 | }\r | |
229 | \r | |
230 | Status = InitializeUsbMouseDevice (UsbMouseDevice);\r | |
231 | if (EFI_ERROR (Status)) {\r | |
29129ce4 | 232 | //\r |
233 | // Fail to initialize USB mouse device.\r | |
234 | //\r | |
235 | REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r | |
ed838d0c | 236 | EFI_ERROR_CODE | EFI_ERROR_MINOR,\r |
f9876ecf | 237 | (EFI_PERIPHERAL_MOUSE | EFI_P_EC_INTERFACE_ERROR),\r |
29129ce4 | 238 | UsbMouseDevice->DevicePath\r |
ed838d0c | 239 | );\r |
240 | \r | |
241 | goto ErrorExit;\r | |
242 | }\r | |
243 | \r | |
29129ce4 | 244 | //\r |
245 | // Initialize and install EFI Simple Pointer Protocol.\r | |
246 | //\r | |
ed838d0c | 247 | UsbMouseDevice->SimplePointerProtocol.GetState = GetMouseState;\r |
248 | UsbMouseDevice->SimplePointerProtocol.Reset = UsbMouseReset;\r | |
249 | UsbMouseDevice->SimplePointerProtocol.Mode = &UsbMouseDevice->Mode;\r | |
250 | \r | |
251 | Status = gBS->CreateEvent (\r | |
252 | EVT_NOTIFY_WAIT,\r | |
253 | TPL_NOTIFY,\r | |
254 | UsbMouseWaitForInput,\r | |
255 | UsbMouseDevice,\r | |
256 | &((UsbMouseDevice->SimplePointerProtocol).WaitForInput)\r | |
257 | );\r | |
258 | if (EFI_ERROR (Status)) {\r | |
259 | goto ErrorExit;\r | |
260 | }\r | |
261 | \r | |
262 | Status = gBS->InstallProtocolInterface (\r | |
263 | &Controller,\r | |
264 | &gEfiSimplePointerProtocolGuid,\r | |
265 | EFI_NATIVE_INTERFACE,\r | |
266 | &UsbMouseDevice->SimplePointerProtocol\r | |
267 | );\r | |
268 | \r | |
269 | if (EFI_ERROR (Status)) {\r | |
ed838d0c | 270 | goto ErrorExit;\r |
271 | }\r | |
272 | \r | |
273 | //\r | |
29129ce4 | 274 | // The next step would be submitting Asynchronous Interrupt Transfer on this mouse device.\r |
275 | // After that we will be able to get key data from it. Thus this is deemed as\r | |
276 | // the enable action of the mouse, so report status code accordingly.\r | |
ed838d0c | 277 | //\r |
29129ce4 | 278 | REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r |
ed838d0c | 279 | EFI_PROGRESS_CODE,\r |
f9876ecf | 280 | (EFI_PERIPHERAL_MOUSE | EFI_P_PC_ENABLE),\r |
29129ce4 | 281 | UsbMouseDevice->DevicePath\r |
ed838d0c | 282 | );\r |
283 | \r | |
284 | //\r | |
29129ce4 | 285 | // Submit Asynchronous Interrupt Transfer to manage this device.\r |
ed838d0c | 286 | //\r |
29129ce4 | 287 | EndpointAddr = UsbMouseDevice->IntEndpointDescriptor.EndpointAddress;\r |
288 | PollingInterval = UsbMouseDevice->IntEndpointDescriptor.Interval;\r | |
289 | PacketSize = (UINT8) (UsbMouseDevice->IntEndpointDescriptor.MaxPacketSize);\r | |
ed838d0c | 290 | \r |
291 | Status = UsbIo->UsbAsyncInterruptTransfer (\r | |
292 | UsbIo,\r | |
293 | EndpointAddr,\r | |
294 | TRUE,\r | |
295 | PollingInterval,\r | |
296 | PacketSize,\r | |
297 | OnMouseInterruptComplete,\r | |
298 | UsbMouseDevice\r | |
299 | );\r | |
300 | \r | |
29129ce4 | 301 | if (EFI_ERROR (Status)) {\r |
302 | //\r | |
303 | // If submit error, uninstall that interface\r | |
304 | //\r | |
305 | gBS->UninstallProtocolInterface (\r | |
306 | Controller,\r | |
307 | &gEfiSimplePointerProtocolGuid,\r | |
308 | &UsbMouseDevice->SimplePointerProtocol\r | |
309 | );\r | |
310 | goto ErrorExit;\r | |
ed838d0c | 311 | }\r |
29129ce4 | 312 | \r |
313 | UsbMouseDevice->ControllerNameTable = NULL;\r | |
314 | AddUnicodeString2 (\r | |
315 | "eng",\r | |
316 | gUsbMouseComponentName.SupportedLanguages,\r | |
317 | &UsbMouseDevice->ControllerNameTable,\r | |
318 | L"Generic Usb Mouse",\r | |
319 | TRUE\r | |
320 | );\r | |
321 | AddUnicodeString2 (\r | |
322 | "en",\r | |
323 | gUsbMouseComponentName2.SupportedLanguages,\r | |
324 | &UsbMouseDevice->ControllerNameTable,\r | |
325 | L"Generic Usb Mouse",\r | |
326 | FALSE\r | |
327 | );\r | |
ed838d0c | 328 | \r |
15cc67e6 | 329 | gBS->RestoreTPL (OldTpl);\r |
330 | \r | |
29129ce4 | 331 | return EFI_SUCCESS;\r |
ed838d0c | 332 | \r |
29129ce4 | 333 | //\r |
334 | // Error handler\r | |
335 | //\r | |
ed838d0c | 336 | ErrorExit:\r |
337 | if (EFI_ERROR (Status)) {\r | |
338 | gBS->CloseProtocol (\r | |
339 | Controller,\r | |
340 | &gEfiUsbIoProtocolGuid,\r | |
341 | This->DriverBindingHandle,\r | |
342 | Controller\r | |
343 | );\r | |
344 | \r | |
345 | if (UsbMouseDevice != NULL) {\r | |
ed838d0c | 346 | if ((UsbMouseDevice->SimplePointerProtocol).WaitForInput != NULL) {\r |
347 | gBS->CloseEvent ((UsbMouseDevice->SimplePointerProtocol).WaitForInput);\r | |
348 | }\r | |
349 | \r | |
29129ce4 | 350 | FreePool (UsbMouseDevice);\r |
ed838d0c | 351 | UsbMouseDevice = NULL;\r |
352 | }\r | |
353 | }\r | |
354 | \r | |
15cc67e6 | 355 | ErrorExit1:\r |
356 | gBS->RestoreTPL (OldTpl);\r | |
ed838d0c | 357 | return Status;\r |
358 | }\r | |
359 | \r | |
360 | \r | |
361 | /**\r | |
29129ce4 | 362 | Stop the USB mouse device handled by this driver.\r |
ed838d0c | 363 | \r |
29129ce4 | 364 | @param This The USB mouse driver binding protocol.\r |
365 | @param Controller The controller to release.\r | |
366 | @param NumberOfChildren The number of handles in ChildHandleBuffer.\r | |
367 | @param ChildHandleBuffer The array of child handle.\r | |
ed838d0c | 368 | \r |
29129ce4 | 369 | @retval EFI_SUCCESS The device was stopped.\r |
370 | @retval EFI_UNSUPPORTED Simple Pointer Protocol is not installed on Controller.\r | |
371 | @retval Others Fail to uninstall protocols attached on the device.\r | |
ed838d0c | 372 | \r |
373 | **/\r | |
374 | EFI_STATUS\r | |
375 | EFIAPI\r | |
376 | USBMouseDriverBindingStop (\r | |
377 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
378 | IN EFI_HANDLE Controller,\r | |
379 | IN UINTN NumberOfChildren,\r | |
380 | IN EFI_HANDLE *ChildHandleBuffer\r | |
381 | )\r | |
382 | {\r | |
383 | EFI_STATUS Status;\r | |
384 | USB_MOUSE_DEV *UsbMouseDevice;\r | |
385 | EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;\r | |
386 | EFI_USB_IO_PROTOCOL *UsbIo;\r | |
387 | \r | |
ed838d0c | 388 | Status = gBS->OpenProtocol (\r |
389 | Controller,\r | |
390 | &gEfiSimplePointerProtocolGuid,\r | |
c52fa98c | 391 | (VOID **) &SimplePointerProtocol,\r |
ed838d0c | 392 | This->DriverBindingHandle,\r |
393 | Controller,\r | |
394 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
395 | );\r | |
396 | \r | |
397 | if (EFI_ERROR (Status)) {\r | |
398 | return EFI_UNSUPPORTED;\r | |
399 | }\r | |
400 | \r | |
401 | UsbMouseDevice = USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (SimplePointerProtocol);\r | |
402 | \r | |
ed838d0c | 403 | UsbIo = UsbMouseDevice->UsbIo;\r |
404 | \r | |
405 | //\r | |
29129ce4 | 406 | // The key data input from this device will be disabled.\r |
ed838d0c | 407 | //\r |
29129ce4 | 408 | REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r |
ed838d0c | 409 | EFI_PROGRESS_CODE,\r |
f9876ecf | 410 | (EFI_PERIPHERAL_MOUSE | EFI_P_PC_DISABLE),\r |
29129ce4 | 411 | UsbMouseDevice->DevicePath\r |
ed838d0c | 412 | );\r |
413 | \r | |
414 | //\r | |
29129ce4 | 415 | // Delete the Asynchronous Interrupt Transfer from this device\r |
ed838d0c | 416 | //\r |
417 | UsbIo->UsbAsyncInterruptTransfer (\r | |
29129ce4 | 418 | UsbIo,\r |
419 | UsbMouseDevice->IntEndpointDescriptor.EndpointAddress,\r | |
420 | FALSE,\r | |
421 | UsbMouseDevice->IntEndpointDescriptor.Interval,\r | |
422 | 0,\r | |
423 | NULL,\r | |
424 | NULL\r | |
425 | );\r | |
ed838d0c | 426 | \r |
427 | Status = gBS->UninstallProtocolInterface (\r | |
428 | Controller,\r | |
429 | &gEfiSimplePointerProtocolGuid,\r | |
430 | &UsbMouseDevice->SimplePointerProtocol\r | |
431 | );\r | |
432 | if (EFI_ERROR (Status)) {\r | |
433 | return Status;\r | |
434 | }\r | |
435 | \r | |
436 | gBS->CloseProtocol (\r | |
29129ce4 | 437 | Controller,\r |
438 | &gEfiUsbIoProtocolGuid,\r | |
439 | This->DriverBindingHandle,\r | |
440 | Controller\r | |
441 | );\r | |
442 | \r | |
443 | //\r | |
444 | // Free all resources.\r | |
445 | //\r | |
446 | gBS->CloseEvent (UsbMouseDevice->SimplePointerProtocol.WaitForInput);\r | |
ed838d0c | 447 | \r |
29129ce4 | 448 | if (UsbMouseDevice->DelayedRecoveryEvent != NULL) {\r |
449 | gBS->CloseEvent (UsbMouseDevice->DelayedRecoveryEvent);\r | |
450 | UsbMouseDevice->DelayedRecoveryEvent = NULL;\r | |
451 | }\r | |
ed838d0c | 452 | \r |
bb80e3b2 | 453 | if (UsbMouseDevice->ControllerNameTable != NULL) {\r |
ed838d0c | 454 | FreeUnicodeStringTable (UsbMouseDevice->ControllerNameTable);\r |
455 | }\r | |
456 | \r | |
29129ce4 | 457 | FreePool (UsbMouseDevice);\r |
ed838d0c | 458 | \r |
459 | return EFI_SUCCESS;\r | |
460 | \r | |
461 | }\r | |
462 | \r | |
463 | \r | |
464 | /**\r | |
29129ce4 | 465 | Uses USB I/O to check whether the device is a USB mouse device.\r |
ed838d0c | 466 | \r |
29129ce4 | 467 | @param UsbIo Pointer to a USB I/O protocol instance.\r |
ed838d0c | 468 | \r |
29129ce4 | 469 | @retval TRUE Device is a USB mouse device.\r |
470 | @retval FALSE Device is a not USB mouse device.\r | |
ed838d0c | 471 | \r |
472 | **/\r | |
473 | BOOLEAN\r | |
474 | IsUsbMouse (\r | |
475 | IN EFI_USB_IO_PROTOCOL *UsbIo\r | |
476 | )\r | |
477 | {\r | |
478 | EFI_STATUS Status;\r | |
479 | EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;\r | |
480 | \r | |
481 | //\r | |
29129ce4 | 482 | // Get the default interface descriptor\r |
ed838d0c | 483 | //\r |
484 | Status = UsbIo->UsbGetInterfaceDescriptor (\r | |
485 | UsbIo,\r | |
486 | &InterfaceDescriptor\r | |
487 | );\r | |
488 | \r | |
489 | if (EFI_ERROR (Status)) {\r | |
490 | return FALSE;\r | |
491 | }\r | |
492 | \r | |
493 | if ((InterfaceDescriptor.InterfaceClass == CLASS_HID) &&\r | |
494 | (InterfaceDescriptor.InterfaceSubClass == SUBCLASS_BOOT) &&\r | |
495 | (InterfaceDescriptor.InterfaceProtocol == PROTOCOL_MOUSE)\r | |
496 | ) {\r | |
497 | return TRUE;\r | |
498 | }\r | |
499 | \r | |
500 | return FALSE;\r | |
501 | }\r | |
502 | \r | |
503 | \r | |
504 | /**\r | |
29129ce4 | 505 | Initialize the USB mouse device.\r |
506 | \r | |
507 | This function retrieves and parses HID report descriptor, and\r | |
508 | initializes state of USB_MOUSE_DEV. Then it sets indefinite idle\r | |
509 | rate for the device. Finally it creates event for delayed recovery,\r | |
510 | which deals with device error.\r | |
ed838d0c | 511 | \r |
bb80e3b2 | 512 | @param UsbMouseDev Device instance to be initialized.\r |
ed838d0c | 513 | \r |
29129ce4 | 514 | @retval EFI_SUCCESS USB mouse device successfully initialized..\r |
515 | @retval EFI_UNSUPPORTED HID descriptor type is not report descriptor.\r | |
516 | @retval Other USB mouse device was not initialized successfully.\r | |
ed838d0c | 517 | \r |
518 | **/\r | |
ed838d0c | 519 | EFI_STATUS\r |
520 | InitializeUsbMouseDevice (\r | |
29129ce4 | 521 | IN OUT USB_MOUSE_DEV *UsbMouseDev\r |
ed838d0c | 522 | )\r |
523 | {\r | |
0309b719 | 524 | EFI_USB_IO_PROTOCOL *UsbIo;\r |
525 | UINT8 Protocol;\r | |
526 | EFI_STATUS Status;\r | |
527 | EFI_USB_HID_DESCRIPTOR *MouseHidDesc;\r | |
528 | UINT8 *ReportDesc;\r | |
529 | UINT8 ReportId;\r | |
530 | UINT8 Duration;\r | |
531 | EFI_USB_CONFIG_DESCRIPTOR ConfigDesc;\r | |
532 | VOID *Buf;\r | |
533 | UINT32 TransferResult;\r | |
534 | UINT16 Total;\r | |
535 | USB_DESC_HEAD *Head;\r | |
536 | BOOLEAN Start;\r | |
ed838d0c | 537 | \r |
538 | UsbIo = UsbMouseDev->UsbIo;\r | |
539 | \r | |
540 | //\r | |
0309b719 | 541 | // Get the current configuration descriptor. Note that it doesn't include other descriptors.\r |
ed838d0c | 542 | //\r |
0309b719 | 543 | Status = UsbIo->UsbGetConfigDescriptor (\r |
544 | UsbIo,\r | |
545 | &ConfigDesc\r | |
546 | );\r | |
547 | if (EFI_ERROR (Status)) {\r | |
548 | return Status;\r | |
549 | }\r | |
550 | \r | |
551 | //\r | |
552 | // By issuing Get_Descriptor(Configuration) request with total length, we get the Configuration descriptor,\r | |
553 | // all Interface descriptors, all Endpoint descriptors, and the HID descriptor for each interface.\r | |
554 | //\r | |
555 | Buf = AllocateZeroPool (ConfigDesc.TotalLength);\r | |
556 | if (Buf == NULL) {\r | |
557 | return EFI_OUT_OF_RESOURCES;\r | |
558 | }\r | |
559 | \r | |
560 | Status = UsbGetDescriptor (\r | |
29129ce4 | 561 | UsbIo,\r |
0309b719 | 562 | (UINT16)((USB_DESC_TYPE_CONFIG << 8) | (ConfigDesc.ConfigurationValue - 1)),\r |
563 | 0,\r | |
564 | ConfigDesc.TotalLength,\r | |
565 | Buf,\r | |
566 | &TransferResult\r | |
29129ce4 | 567 | );\r |
ed838d0c | 568 | if (EFI_ERROR (Status)) {\r |
0309b719 | 569 | FreePool (Buf);\r |
ed838d0c | 570 | return Status;\r |
571 | }\r | |
572 | \r | |
0309b719 | 573 | Total = 0;\r |
574 | Start = FALSE;\r | |
575 | Head = (USB_DESC_HEAD *)Buf; \r | |
576 | MouseHidDesc = NULL;\r | |
577 | \r | |
578 | //\r | |
579 | // Get HID descriptor from the receipt of Get_Descriptor(Configuration) request.\r | |
580 | // This algorithm is based on the fact that the HID descriptor shall be interleaved\r | |
581 | // between the interface and endpoint descriptors for HID interfaces.\r | |
582 | //\r | |
583 | while (Total < ConfigDesc.TotalLength) {\r | |
584 | if (Head->Type == USB_DESC_TYPE_INTERFACE) {\r | |
585 | if ((((USB_INTERFACE_DESCRIPTOR *)Head)->InterfaceNumber == UsbMouseDev->InterfaceDescriptor.InterfaceNumber) &&\r | |
586 | (((USB_INTERFACE_DESCRIPTOR *)Head)->AlternateSetting == UsbMouseDev->InterfaceDescriptor.AlternateSetting)) {\r | |
587 | Start = TRUE;\r | |
588 | }\r | |
589 | }\r | |
af3a71b8 | 590 | if (Start && (Head->Type == USB_DESC_TYPE_ENDPOINT)) {\r |
0309b719 | 591 | break;\r |
592 | }\r | |
af3a71b8 | 593 | if (Start && (Head->Type == USB_DESC_TYPE_HID)) {\r |
0309b719 | 594 | MouseHidDesc = (EFI_USB_HID_DESCRIPTOR *)Head;\r |
595 | break;\r | |
596 | }\r | |
ab742719 | 597 | Total = Total + (UINT16)Head->Len;\r |
598 | Head = (USB_DESC_HEAD*)((UINT8 *)Buf + Total);\r | |
0309b719 | 599 | }\r |
600 | \r | |
601 | if (MouseHidDesc == NULL) {\r | |
602 | FreePool (Buf);\r | |
603 | return EFI_UNSUPPORTED;\r | |
604 | }\r | |
605 | \r | |
ed838d0c | 606 | //\r |
29129ce4 | 607 | // Get report descriptor\r |
ed838d0c | 608 | //\r |
0309b719 | 609 | if (MouseHidDesc->HidClassDesc[0].DescriptorType != USB_DESC_TYPE_REPORT) {\r |
610 | FreePool (Buf);\r | |
ed838d0c | 611 | return EFI_UNSUPPORTED;\r |
612 | }\r | |
613 | \r | |
0309b719 | 614 | ReportDesc = AllocateZeroPool (MouseHidDesc->HidClassDesc[0].DescriptorLength);\r |
29129ce4 | 615 | ASSERT (ReportDesc != NULL);\r |
ed838d0c | 616 | \r |
617 | Status = UsbGetReportDescriptor (\r | |
29129ce4 | 618 | UsbIo,\r |
619 | UsbMouseDev->InterfaceDescriptor.InterfaceNumber,\r | |
0309b719 | 620 | MouseHidDesc->HidClassDesc[0].DescriptorLength,\r |
29129ce4 | 621 | ReportDesc\r |
622 | );\r | |
ed838d0c | 623 | \r |
624 | if (EFI_ERROR (Status)) {\r | |
0309b719 | 625 | FreePool (Buf);\r |
29129ce4 | 626 | FreePool (ReportDesc);\r |
ed838d0c | 627 | return Status;\r |
628 | }\r | |
629 | \r | |
630 | //\r | |
631 | // Parse report descriptor\r | |
632 | //\r | |
633 | Status = ParseMouseReportDescriptor (\r | |
29129ce4 | 634 | UsbMouseDev,\r |
635 | ReportDesc,\r | |
0309b719 | 636 | MouseHidDesc->HidClassDesc[0].DescriptorLength\r |
29129ce4 | 637 | );\r |
ed838d0c | 638 | \r |
639 | if (EFI_ERROR (Status)) {\r | |
0309b719 | 640 | FreePool (Buf);\r |
29129ce4 | 641 | FreePool (ReportDesc);\r |
ed838d0c | 642 | return Status;\r |
643 | }\r | |
644 | \r | |
29129ce4 | 645 | //\r |
646 | // Check the presence of left and right buttons,\r | |
647 | // and initialize fields of EFI_SIMPLE_POINTER_MODE.\r | |
648 | //\r | |
ed838d0c | 649 | if (UsbMouseDev->NumberOfButtons >= 1) {\r |
650 | UsbMouseDev->Mode.LeftButton = TRUE;\r | |
651 | }\r | |
ed838d0c | 652 | if (UsbMouseDev->NumberOfButtons > 1) {\r |
653 | UsbMouseDev->Mode.RightButton = TRUE;\r | |
654 | }\r | |
ed838d0c | 655 | UsbMouseDev->Mode.ResolutionX = 8;\r |
656 | UsbMouseDev->Mode.ResolutionY = 8;\r | |
657 | UsbMouseDev->Mode.ResolutionZ = 0;\r | |
29129ce4 | 658 | \r |
ed838d0c | 659 | //\r |
29129ce4 | 660 | // Set boot protocol for the USB mouse.\r |
661 | // This driver only supports boot protocol.\r | |
ed838d0c | 662 | //\r |
663 | UsbGetProtocolRequest (\r | |
664 | UsbIo,\r | |
29129ce4 | 665 | UsbMouseDev->InterfaceDescriptor.InterfaceNumber,\r |
ed838d0c | 666 | &Protocol\r |
667 | );\r | |
ed838d0c | 668 | if (Protocol != BOOT_PROTOCOL) {\r |
669 | Status = UsbSetProtocolRequest (\r | |
29129ce4 | 670 | UsbIo,\r |
83040701 | 671 | UsbMouseDev->InterfaceDescriptor.InterfaceNumber,\r |
29129ce4 | 672 | BOOT_PROTOCOL\r |
673 | );\r | |
ed838d0c | 674 | \r |
675 | if (EFI_ERROR (Status)) {\r | |
0309b719 | 676 | FreePool (Buf);\r |
29129ce4 | 677 | FreePool (ReportDesc);\r |
678 | return Status;\r | |
ed838d0c | 679 | }\r |
680 | }\r | |
681 | \r | |
682 | //\r | |
29129ce4 | 683 | // ReportId is zero, which means the idle rate applies to all input reports.\r |
684 | //\r | |
685 | ReportId = 0;\r | |
ed838d0c | 686 | //\r |
29129ce4 | 687 | // Duration is zero, which means the duration is infinite.\r |
688 | // so the endpoint will inhibit reporting forever,\r | |
689 | // and only reporting when a change is detected in the report data.\r | |
690 | //\r | |
691 | Duration = 0;\r | |
ed838d0c | 692 | UsbSetIdleRequest (\r |
693 | UsbIo,\r | |
29129ce4 | 694 | UsbMouseDev->InterfaceDescriptor.InterfaceNumber,\r |
695 | ReportId,\r | |
696 | Duration\r | |
ed838d0c | 697 | );\r |
698 | \r | |
0309b719 | 699 | FreePool (Buf);\r |
29129ce4 | 700 | FreePool (ReportDesc);\r |
ed838d0c | 701 | \r |
29129ce4 | 702 | //\r |
703 | // Create event for delayed recovery, which deals with device error.\r | |
704 | //\r | |
bb80e3b2 | 705 | if (UsbMouseDev->DelayedRecoveryEvent != NULL) {\r |
ed838d0c | 706 | gBS->CloseEvent (UsbMouseDev->DelayedRecoveryEvent);\r |
707 | UsbMouseDev->DelayedRecoveryEvent = 0;\r | |
708 | }\r | |
709 | \r | |
29129ce4 | 710 | gBS->CreateEvent (\r |
711 | EVT_TIMER | EVT_NOTIFY_SIGNAL,\r | |
712 | TPL_NOTIFY,\r | |
713 | USBMouseRecoveryHandler,\r | |
714 | UsbMouseDev,\r | |
715 | &UsbMouseDev->DelayedRecoveryEvent\r | |
716 | );\r | |
ed838d0c | 717 | \r |
718 | return EFI_SUCCESS;\r | |
719 | }\r | |
720 | \r | |
721 | \r | |
722 | /**\r | |
29129ce4 | 723 | Handler function for USB mouse's asynchronous interrupt transfer.\r |
724 | \r | |
725 | This function is the handler function for USB mouse's asynchronous interrupt transfer\r | |
726 | to manage the mouse. It parses data returned from asynchronous interrupt transfer, and\r | |
727 | get button and movement state.\r | |
ed838d0c | 728 | \r |
29129ce4 | 729 | @param Data A pointer to a buffer that is filled with key data which is\r |
730 | retrieved via asynchronous interrupt transfer.\r | |
731 | @param DataLength Indicates the size of the data buffer.\r | |
732 | @param Context Pointing to USB_KB_DEV instance.\r | |
733 | @param Result Indicates the result of the asynchronous interrupt transfer.\r | |
ed838d0c | 734 | \r |
29129ce4 | 735 | @retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.\r |
736 | @retval EFI_DEVICE_ERROR Hardware error occurs.\r | |
ed838d0c | 737 | \r |
738 | **/\r | |
ed838d0c | 739 | EFI_STATUS\r |
740 | EFIAPI\r | |
741 | OnMouseInterruptComplete (\r | |
742 | IN VOID *Data,\r | |
743 | IN UINTN DataLength,\r | |
744 | IN VOID *Context,\r | |
745 | IN UINT32 Result\r | |
746 | )\r | |
747 | {\r | |
748 | USB_MOUSE_DEV *UsbMouseDevice;\r | |
749 | EFI_USB_IO_PROTOCOL *UsbIo;\r | |
750 | UINT8 EndpointAddr;\r | |
751 | UINT32 UsbResult;\r | |
752 | \r | |
753 | UsbMouseDevice = (USB_MOUSE_DEV *) Context;\r | |
754 | UsbIo = UsbMouseDevice->UsbIo;\r | |
755 | \r | |
756 | if (Result != EFI_USB_NOERROR) {\r | |
757 | //\r | |
758 | // Some errors happen during the process\r | |
759 | //\r | |
29129ce4 | 760 | REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r |
ed838d0c | 761 | EFI_ERROR_CODE | EFI_ERROR_MINOR,\r |
f9876ecf | 762 | (EFI_PERIPHERAL_MOUSE | EFI_P_EC_INPUT_ERROR),\r |
29129ce4 | 763 | UsbMouseDevice->DevicePath\r |
ed838d0c | 764 | );\r |
765 | \r | |
766 | if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {\r | |
29129ce4 | 767 | EndpointAddr = UsbMouseDevice->IntEndpointDescriptor.EndpointAddress;\r |
ed838d0c | 768 | \r |
769 | UsbClearEndpointHalt (\r | |
770 | UsbIo,\r | |
771 | EndpointAddr,\r | |
772 | &UsbResult\r | |
773 | );\r | |
774 | }\r | |
775 | \r | |
29129ce4 | 776 | //\r |
777 | // Delete & Submit this interrupt again\r | |
778 | // Handler of DelayedRecoveryEvent triggered by timer will re-submit the interrupt. \r | |
779 | //\r | |
ed838d0c | 780 | UsbIo->UsbAsyncInterruptTransfer (\r |
29129ce4 | 781 | UsbIo,\r |
782 | UsbMouseDevice->IntEndpointDescriptor.EndpointAddress,\r | |
783 | FALSE,\r | |
784 | 0,\r | |
785 | 0,\r | |
786 | NULL,\r | |
787 | NULL\r | |
788 | );\r | |
789 | //\r | |
790 | // EFI_USB_INTERRUPT_DELAY is defined in USB standard for error handling.\r | |
791 | //\r | |
ed838d0c | 792 | gBS->SetTimer (\r |
29129ce4 | 793 | UsbMouseDevice->DelayedRecoveryEvent,\r |
794 | TimerRelative,\r | |
795 | EFI_USB_INTERRUPT_DELAY\r | |
796 | );\r | |
ed838d0c | 797 | return EFI_DEVICE_ERROR;\r |
798 | }\r | |
799 | \r | |
29129ce4 | 800 | //\r |
801 | // If no error and no data, just return EFI_SUCCESS.\r | |
802 | //\r | |
ed838d0c | 803 | if (DataLength == 0 || Data == NULL) {\r |
804 | return EFI_SUCCESS;\r | |
805 | }\r | |
806 | \r | |
807 | UsbMouseDevice->StateChanged = TRUE;\r | |
808 | \r | |
809 | //\r | |
810 | // Check mouse Data\r | |
29129ce4 | 811 | // USB HID Specification specifies following data format:\r |
812 | // Byte Bits Description\r | |
813 | // 0 0 Button 1\r | |
814 | // 1 Button 2\r | |
815 | // 2 Button 3\r | |
816 | // 4 to 7 Device-specific\r | |
817 | // 1 0 to 7 X displacement\r | |
818 | // 2 0 to 7 Y displacement\r | |
819 | // 3 to n 0 to 7 Device specific (optional)\r | |
820 | //\r | |
821 | UsbMouseDevice->State.LeftButton = (BOOLEAN) ((*(UINT8 *) Data & BIT0) != 0);\r | |
822 | UsbMouseDevice->State.RightButton = (BOOLEAN) ((*(UINT8 *) Data & BIT1) != 0);\r | |
ed838d0c | 823 | UsbMouseDevice->State.RelativeMovementX += *((INT8 *) Data + 1);\r |
824 | UsbMouseDevice->State.RelativeMovementY += *((INT8 *) Data + 2);\r | |
825 | \r | |
826 | if (DataLength > 3) {\r | |
827 | UsbMouseDevice->State.RelativeMovementZ += *((INT8 *) Data + 3);\r | |
828 | }\r | |
829 | \r | |
830 | return EFI_SUCCESS;\r | |
831 | }\r | |
832 | \r | |
ed838d0c | 833 | /**\r |
29129ce4 | 834 | Retrieves the current state of a pointer device.\r |
835 | \r | |
836 | @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL instance. \r | |
837 | @param MouseState A pointer to the state information on the pointer device.\r | |
838 | \r | |
839 | @retval EFI_SUCCESS The state of the pointer device was returned in State.\r | |
840 | @retval EFI_NOT_READY The state of the pointer device has not changed since the last call to\r | |
841 | GetState(). \r | |
842 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to retrieve the pointer device's\r | |
843 | current state. \r | |
844 | @retval EFI_INVALID_PARAMETER MouseState is NULL. \r | |
ed838d0c | 845 | \r |
846 | **/\r | |
ed838d0c | 847 | EFI_STATUS\r |
848 | EFIAPI\r | |
849 | GetMouseState (\r | |
850 | IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r | |
851 | OUT EFI_SIMPLE_POINTER_STATE *MouseState\r | |
852 | )\r | |
853 | {\r | |
854 | USB_MOUSE_DEV *MouseDev;\r | |
855 | \r | |
856 | if (MouseState == NULL) {\r | |
29129ce4 | 857 | return EFI_INVALID_PARAMETER;\r |
ed838d0c | 858 | }\r |
859 | \r | |
860 | MouseDev = USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (This);\r | |
861 | \r | |
862 | if (!MouseDev->StateChanged) {\r | |
863 | return EFI_NOT_READY;\r | |
864 | }\r | |
865 | \r | |
29129ce4 | 866 | //\r |
867 | // Retrieve mouse state from USB_MOUSE_DEV, which was filled by OnMouseInterruptComplete()\r | |
868 | //\r | |
ed838d0c | 869 | CopyMem (\r |
870 | MouseState,\r | |
871 | &MouseDev->State,\r | |
872 | sizeof (EFI_SIMPLE_POINTER_STATE)\r | |
873 | );\r | |
874 | \r | |
875 | //\r | |
876 | // Clear previous move state\r | |
877 | //\r | |
878 | MouseDev->State.RelativeMovementX = 0;\r | |
879 | MouseDev->State.RelativeMovementY = 0;\r | |
880 | MouseDev->State.RelativeMovementZ = 0;\r | |
881 | \r | |
882 | MouseDev->StateChanged = FALSE;\r | |
883 | \r | |
884 | return EFI_SUCCESS;\r | |
885 | }\r | |
886 | \r | |
887 | \r | |
29129ce4 | 888 | /** \r |
889 | Resets the pointer device hardware.\r | |
890 | \r | |
891 | @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL instance.\r | |
892 | @param ExtendedVerification Indicates that the driver may perform a more exhaustive\r | |
893 | verification operation of the device during reset.\r | |
894 | \r | |
895 | @retval EFI_SUCCESS The device was reset.\r | |
896 | @retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset.\r | |
ed838d0c | 897 | \r |
898 | **/\r | |
ed838d0c | 899 | EFI_STATUS\r |
900 | EFIAPI\r | |
901 | UsbMouseReset (\r | |
902 | IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r | |
903 | IN BOOLEAN ExtendedVerification\r | |
904 | )\r | |
905 | {\r | |
906 | USB_MOUSE_DEV *UsbMouseDevice;\r | |
ed838d0c | 907 | \r |
908 | UsbMouseDevice = USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (This);\r | |
909 | \r | |
29129ce4 | 910 | REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r |
ed838d0c | 911 | EFI_PROGRESS_CODE,\r |
f9876ecf | 912 | (EFI_PERIPHERAL_MOUSE | EFI_P_PC_RESET),\r |
29129ce4 | 913 | UsbMouseDevice->DevicePath\r |
ed838d0c | 914 | );\r |
915 | \r | |
29129ce4 | 916 | //\r |
917 | // Clear mouse state.\r | |
918 | //\r | |
ed838d0c | 919 | ZeroMem (\r |
920 | &UsbMouseDevice->State,\r | |
921 | sizeof (EFI_SIMPLE_POINTER_STATE)\r | |
922 | );\r | |
923 | UsbMouseDevice->StateChanged = FALSE;\r | |
924 | \r | |
925 | return EFI_SUCCESS;\r | |
926 | }\r | |
927 | \r | |
ed838d0c | 928 | /**\r |
7772b176 | 929 | Event notification function for EFI_SIMPLE_POINTER_PROTOCOL.WaitForInput event.\r |
ed838d0c | 930 | \r |
29129ce4 | 931 | @param Event Event to be signaled when there's input from mouse.\r |
932 | @param Context Points to USB_MOUSE_DEV instance.\r | |
bb80e3b2 | 933 | \r |
ed838d0c | 934 | **/\r |
ed838d0c | 935 | VOID\r |
936 | EFIAPI\r | |
937 | UsbMouseWaitForInput (\r | |
938 | IN EFI_EVENT Event,\r | |
939 | IN VOID *Context\r | |
940 | )\r | |
941 | {\r | |
942 | USB_MOUSE_DEV *UsbMouseDev;\r | |
943 | \r | |
944 | UsbMouseDev = (USB_MOUSE_DEV *) Context;\r | |
945 | \r | |
946 | //\r | |
29129ce4 | 947 | // If there's input from mouse, signal the event.\r |
ed838d0c | 948 | //\r |
949 | if (UsbMouseDev->StateChanged) {\r | |
950 | gBS->SignalEvent (Event);\r | |
951 | }\r | |
952 | }\r | |
953 | \r | |
ed838d0c | 954 | /**\r |
29129ce4 | 955 | Handler for Delayed Recovery event.\r |
ed838d0c | 956 | \r |
29129ce4 | 957 | This function is the handler for Delayed Recovery event triggered\r |
958 | by timer.\r | |
959 | After a device error occurs, the event would be triggered\r | |
960 | with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY\r | |
961 | is defined in USB standard for error handling.\r | |
ed838d0c | 962 | \r |
29129ce4 | 963 | @param Event The Delayed Recovery event.\r |
964 | @param Context Points to the USB_MOUSE_DEV instance.\r | |
ed838d0c | 965 | \r |
966 | **/\r | |
967 | VOID\r | |
968 | EFIAPI\r | |
969 | USBMouseRecoveryHandler (\r | |
970 | IN EFI_EVENT Event,\r | |
971 | IN VOID *Context\r | |
972 | )\r | |
973 | {\r | |
974 | USB_MOUSE_DEV *UsbMouseDev;\r | |
975 | EFI_USB_IO_PROTOCOL *UsbIo;\r | |
976 | \r | |
977 | UsbMouseDev = (USB_MOUSE_DEV *) Context;\r | |
978 | \r | |
979 | UsbIo = UsbMouseDev->UsbIo;\r | |
980 | \r | |
29129ce4 | 981 | //\r |
982 | // Re-submit Asynchronous Interrupt Transfer for recovery.\r | |
983 | //\r | |
ed838d0c | 984 | UsbIo->UsbAsyncInterruptTransfer (\r |
29129ce4 | 985 | UsbIo,\r |
986 | UsbMouseDev->IntEndpointDescriptor.EndpointAddress,\r | |
987 | TRUE,\r | |
988 | UsbMouseDev->IntEndpointDescriptor.Interval,\r | |
989 | UsbMouseDev->IntEndpointDescriptor.MaxPacketSize,\r | |
990 | OnMouseInterruptComplete,\r | |
991 | UsbMouseDev\r | |
992 | );\r | |
ed838d0c | 993 | }\r |