2 USB Mouse Driver that manages USB mouse and produces Simple Pointer Protocol.
4 Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 EFI_DRIVER_BINDING_PROTOCOL gUsbMouseDriverBinding
= {
18 USBMouseDriverBindingSupported
,
19 USBMouseDriverBindingStart
,
20 USBMouseDriverBindingStop
,
27 Entrypoint of USB Mouse Driver.
29 This function is the entrypoint of USB Mouse Driver. It installs Driver Binding
30 Protocols together with Component Name Protocols.
32 @param ImageHandle The firmware allocated handle for the EFI image.
33 @param SystemTable A pointer to the EFI System Table.
35 @retval EFI_SUCCESS The entry point is executed successfully.
40 USBMouseDriverBindingEntryPoint (
41 IN EFI_HANDLE ImageHandle
,
42 IN EFI_SYSTEM_TABLE
*SystemTable
47 Status
= EfiLibInstallDriverBindingComponentName2 (
50 &gUsbMouseDriverBinding
,
52 &gUsbMouseComponentName
,
53 &gUsbMouseComponentName2
55 ASSERT_EFI_ERROR (Status
);
62 Check whether USB mouse driver supports this device.
64 @param This The USB mouse driver binding protocol.
65 @param Controller The controller handle to check.
66 @param RemainingDevicePath The remaining device path.
68 @retval EFI_SUCCESS The driver supports this controller.
69 @retval other This device isn't supported.
74 USBMouseDriverBindingSupported (
75 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
76 IN EFI_HANDLE Controller
,
77 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
81 EFI_USB_IO_PROTOCOL
*UsbIo
;
83 Status
= gBS
->OpenProtocol (
85 &gEfiUsbIoProtocolGuid
,
87 This
->DriverBindingHandle
,
89 EFI_OPEN_PROTOCOL_BY_DRIVER
91 if (EFI_ERROR (Status
)) {
96 // Use the USB I/O Protocol interface to check whether Controller is
97 // a mouse device that can be managed by this driver.
100 if (!IsUsbMouse (UsbIo
)) {
101 Status
= EFI_UNSUPPORTED
;
106 &gEfiUsbIoProtocolGuid
,
107 This
->DriverBindingHandle
,
116 Starts the mouse device with this driver.
118 This function consumes USB I/O Portocol, intializes USB mouse device,
119 installs Simple Pointer Protocol, and submits Asynchronous Interrupt
120 Transfer to manage the USB mouse device.
122 @param This The USB mouse driver binding instance.
123 @param Controller Handle of device to bind driver to.
124 @param RemainingDevicePath Optional parameter use to pick a specific child
127 @retval EFI_SUCCESS This driver supports this device.
128 @retval EFI_UNSUPPORTED This driver does not support this device.
129 @retval EFI_DEVICE_ERROR This driver cannot be started due to device Error.
130 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
131 @retval EFI_ALREADY_STARTED This driver has been started.
136 USBMouseDriverBindingStart (
137 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
138 IN EFI_HANDLE Controller
,
139 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
143 EFI_USB_IO_PROTOCOL
*UsbIo
;
144 USB_MOUSE_DEV
*UsbMouseDevice
;
145 UINT8 EndpointNumber
;
146 EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor
;
149 UINT8 PollingInterval
;
154 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
156 // Open USB I/O Protocol
158 Status
= gBS
->OpenProtocol (
160 &gEfiUsbIoProtocolGuid
,
162 This
->DriverBindingHandle
,
164 EFI_OPEN_PROTOCOL_BY_DRIVER
166 if (EFI_ERROR (Status
)) {
170 UsbMouseDevice
= AllocateZeroPool (sizeof (USB_MOUSE_DEV
));
171 ASSERT (UsbMouseDevice
!= NULL
);
173 UsbMouseDevice
->UsbIo
= UsbIo
;
174 UsbMouseDevice
->Signature
= USB_MOUSE_DEV_SIGNATURE
;
177 // Get the Device Path Protocol on Controller's handle
179 Status
= gBS
->OpenProtocol (
181 &gEfiDevicePathProtocolGuid
,
182 (VOID
**) &UsbMouseDevice
->DevicePath
,
183 This
->DriverBindingHandle
,
185 EFI_OPEN_PROTOCOL_GET_PROTOCOL
188 if (EFI_ERROR (Status
)) {
192 // Get interface & endpoint descriptor
194 UsbIo
->UsbGetInterfaceDescriptor (
196 &UsbMouseDevice
->InterfaceDescriptor
199 EndpointNumber
= UsbMouseDevice
->InterfaceDescriptor
.NumEndpoints
;
202 // Traverse endpoints to find interrupt endpoint
205 for (Index
= 0; Index
< EndpointNumber
; Index
++) {
206 UsbIo
->UsbGetEndpointDescriptor (
212 if ((EndpointDescriptor
.Attributes
& (BIT0
| BIT1
)) == USB_ENDPOINT_INTERRUPT
) {
214 // We only care interrupt endpoint here
216 CopyMem(&UsbMouseDevice
->IntEndpointDescriptor
, &EndpointDescriptor
, sizeof(EndpointDescriptor
));
224 // No interrupt endpoint found, then return unsupported.
226 Status
= EFI_UNSUPPORTED
;
230 Status
= InitializeUsbMouseDevice (UsbMouseDevice
);
231 if (EFI_ERROR (Status
)) {
233 // Fail to initialize USB mouse device.
235 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
236 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
237 (EFI_PERIPHERAL_MOUSE
| EFI_P_EC_INTERFACE_ERROR
),
238 UsbMouseDevice
->DevicePath
245 // Initialize and install EFI Simple Pointer Protocol.
247 UsbMouseDevice
->SimplePointerProtocol
.GetState
= GetMouseState
;
248 UsbMouseDevice
->SimplePointerProtocol
.Reset
= UsbMouseReset
;
249 UsbMouseDevice
->SimplePointerProtocol
.Mode
= &UsbMouseDevice
->Mode
;
251 Status
= gBS
->CreateEvent (
254 UsbMouseWaitForInput
,
256 &((UsbMouseDevice
->SimplePointerProtocol
).WaitForInput
)
258 if (EFI_ERROR (Status
)) {
262 Status
= gBS
->InstallProtocolInterface (
264 &gEfiSimplePointerProtocolGuid
,
265 EFI_NATIVE_INTERFACE
,
266 &UsbMouseDevice
->SimplePointerProtocol
269 if (EFI_ERROR (Status
)) {
274 // The next step would be submitting Asynchronous Interrupt Transfer on this mouse device.
275 // After that we will be able to get key data from it. Thus this is deemed as
276 // the enable action of the mouse, so report status code accordingly.
278 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
280 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_ENABLE
),
281 UsbMouseDevice
->DevicePath
285 // Submit Asynchronous Interrupt Transfer to manage this device.
287 EndpointAddr
= UsbMouseDevice
->IntEndpointDescriptor
.EndpointAddress
;
288 PollingInterval
= UsbMouseDevice
->IntEndpointDescriptor
.Interval
;
289 PacketSize
= (UINT8
) (UsbMouseDevice
->IntEndpointDescriptor
.MaxPacketSize
);
291 Status
= UsbIo
->UsbAsyncInterruptTransfer (
297 OnMouseInterruptComplete
,
301 if (EFI_ERROR (Status
)) {
303 // If submit error, uninstall that interface
305 gBS
->UninstallProtocolInterface (
307 &gEfiSimplePointerProtocolGuid
,
308 &UsbMouseDevice
->SimplePointerProtocol
313 UsbMouseDevice
->ControllerNameTable
= NULL
;
316 gUsbMouseComponentName
.SupportedLanguages
,
317 &UsbMouseDevice
->ControllerNameTable
,
318 L
"Generic Usb Mouse",
323 gUsbMouseComponentName2
.SupportedLanguages
,
324 &UsbMouseDevice
->ControllerNameTable
,
325 L
"Generic Usb Mouse",
329 gBS
->RestoreTPL (OldTpl
);
337 if (EFI_ERROR (Status
)) {
340 &gEfiUsbIoProtocolGuid
,
341 This
->DriverBindingHandle
,
345 if (UsbMouseDevice
!= NULL
) {
346 if ((UsbMouseDevice
->SimplePointerProtocol
).WaitForInput
!= NULL
) {
347 gBS
->CloseEvent ((UsbMouseDevice
->SimplePointerProtocol
).WaitForInput
);
350 FreePool (UsbMouseDevice
);
351 UsbMouseDevice
= NULL
;
356 gBS
->RestoreTPL (OldTpl
);
362 Stop the USB mouse device handled by this driver.
364 @param This The USB mouse driver binding protocol.
365 @param Controller The controller to release.
366 @param NumberOfChildren The number of handles in ChildHandleBuffer.
367 @param ChildHandleBuffer The array of child handle.
369 @retval EFI_SUCCESS The device was stopped.
370 @retval EFI_UNSUPPORTED Simple Pointer Protocol is not installed on Controller.
371 @retval Others Fail to uninstall protocols attached on the device.
376 USBMouseDriverBindingStop (
377 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
378 IN EFI_HANDLE Controller
,
379 IN UINTN NumberOfChildren
,
380 IN EFI_HANDLE
*ChildHandleBuffer
384 USB_MOUSE_DEV
*UsbMouseDevice
;
385 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointerProtocol
;
386 EFI_USB_IO_PROTOCOL
*UsbIo
;
388 Status
= gBS
->OpenProtocol (
390 &gEfiSimplePointerProtocolGuid
,
391 (VOID
**) &SimplePointerProtocol
,
392 This
->DriverBindingHandle
,
394 EFI_OPEN_PROTOCOL_GET_PROTOCOL
397 if (EFI_ERROR (Status
)) {
398 return EFI_UNSUPPORTED
;
401 UsbMouseDevice
= USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (SimplePointerProtocol
);
403 UsbIo
= UsbMouseDevice
->UsbIo
;
406 // The key data input from this device will be disabled.
408 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
410 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_DISABLE
),
411 UsbMouseDevice
->DevicePath
415 // Delete the Asynchronous Interrupt Transfer from this device
417 UsbIo
->UsbAsyncInterruptTransfer (
419 UsbMouseDevice
->IntEndpointDescriptor
.EndpointAddress
,
421 UsbMouseDevice
->IntEndpointDescriptor
.Interval
,
427 Status
= gBS
->UninstallProtocolInterface (
429 &gEfiSimplePointerProtocolGuid
,
430 &UsbMouseDevice
->SimplePointerProtocol
432 if (EFI_ERROR (Status
)) {
438 &gEfiUsbIoProtocolGuid
,
439 This
->DriverBindingHandle
,
444 // Free all resources.
446 gBS
->CloseEvent (UsbMouseDevice
->SimplePointerProtocol
.WaitForInput
);
448 if (UsbMouseDevice
->DelayedRecoveryEvent
!= NULL
) {
449 gBS
->CloseEvent (UsbMouseDevice
->DelayedRecoveryEvent
);
450 UsbMouseDevice
->DelayedRecoveryEvent
= NULL
;
453 if (UsbMouseDevice
->ControllerNameTable
!= NULL
) {
454 FreeUnicodeStringTable (UsbMouseDevice
->ControllerNameTable
);
457 FreePool (UsbMouseDevice
);
465 Uses USB I/O to check whether the device is a USB mouse device.
467 @param UsbIo Pointer to a USB I/O protocol instance.
469 @retval TRUE Device is a USB mouse device.
470 @retval FALSE Device is a not USB mouse device.
475 IN EFI_USB_IO_PROTOCOL
*UsbIo
479 EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor
;
482 // Get the default interface descriptor
484 Status
= UsbIo
->UsbGetInterfaceDescriptor (
489 if (EFI_ERROR (Status
)) {
493 if ((InterfaceDescriptor
.InterfaceClass
== CLASS_HID
) &&
494 (InterfaceDescriptor
.InterfaceSubClass
== SUBCLASS_BOOT
) &&
495 (InterfaceDescriptor
.InterfaceProtocol
== PROTOCOL_MOUSE
)
505 Initialize the USB mouse device.
507 This function retrieves and parses HID report descriptor, and
508 initializes state of USB_MOUSE_DEV. Then it sets indefinite idle
509 rate for the device. Finally it creates event for delayed recovery,
510 which deals with device error.
512 @param UsbMouseDev Device instance to be initialized.
514 @retval EFI_SUCCESS USB mouse device successfully initialized..
515 @retval EFI_UNSUPPORTED HID descriptor type is not report descriptor.
516 @retval Other USB mouse device was not initialized successfully.
520 InitializeUsbMouseDevice (
521 IN OUT USB_MOUSE_DEV
*UsbMouseDev
524 EFI_USB_IO_PROTOCOL
*UsbIo
;
527 EFI_USB_HID_DESCRIPTOR
*MouseHidDesc
;
531 EFI_USB_CONFIG_DESCRIPTOR ConfigDesc
;
533 UINT32 TransferResult
;
538 UsbIo
= UsbMouseDev
->UsbIo
;
541 // Get the current configuration descriptor. Note that it doesn't include other descriptors.
543 Status
= UsbIo
->UsbGetConfigDescriptor (
547 if (EFI_ERROR (Status
)) {
552 // By issuing Get_Descriptor(Configuration) request with total length, we get the Configuration descriptor,
553 // all Interface descriptors, all Endpoint descriptors, and the HID descriptor for each interface.
555 Buf
= AllocateZeroPool (ConfigDesc
.TotalLength
);
557 return EFI_OUT_OF_RESOURCES
;
560 Status
= UsbGetDescriptor (
562 (UINT16
)((USB_DESC_TYPE_CONFIG
<< 8) | (ConfigDesc
.ConfigurationValue
- 1)),
564 ConfigDesc
.TotalLength
,
568 if (EFI_ERROR (Status
)) {
575 Head
= (USB_DESC_HEAD
*)Buf
;
579 // Get HID descriptor from the receipt of Get_Descriptor(Configuration) request.
580 // This algorithm is based on the fact that the HID descriptor shall be interleaved
581 // between the interface and endpoint descriptors for HID interfaces.
583 while (Total
< ConfigDesc
.TotalLength
) {
584 if (Head
->Type
== USB_DESC_TYPE_INTERFACE
) {
585 if ((((USB_INTERFACE_DESCRIPTOR
*)Head
)->InterfaceNumber
== UsbMouseDev
->InterfaceDescriptor
.InterfaceNumber
) &&
586 (((USB_INTERFACE_DESCRIPTOR
*)Head
)->AlternateSetting
== UsbMouseDev
->InterfaceDescriptor
.AlternateSetting
)) {
590 if ((Start
== TRUE
) && (Head
->Type
== USB_DESC_TYPE_ENDPOINT
)) {
593 if ((Start
== TRUE
) && (Head
->Type
== USB_DESC_TYPE_HID
)) {
594 MouseHidDesc
= (EFI_USB_HID_DESCRIPTOR
*)Head
;
597 Total
= Total
+ (UINT16
)Head
->Len
;
598 Head
= (USB_DESC_HEAD
*)((UINT8
*)Buf
+ Total
);
601 if (MouseHidDesc
== NULL
) {
603 return EFI_UNSUPPORTED
;
607 // Get report descriptor
609 if (MouseHidDesc
->HidClassDesc
[0].DescriptorType
!= USB_DESC_TYPE_REPORT
) {
611 return EFI_UNSUPPORTED
;
614 ReportDesc
= AllocateZeroPool (MouseHidDesc
->HidClassDesc
[0].DescriptorLength
);
615 ASSERT (ReportDesc
!= NULL
);
617 Status
= UsbGetReportDescriptor (
619 UsbMouseDev
->InterfaceDescriptor
.InterfaceNumber
,
620 MouseHidDesc
->HidClassDesc
[0].DescriptorLength
,
624 if (EFI_ERROR (Status
)) {
626 FreePool (ReportDesc
);
631 // Parse report descriptor
633 Status
= ParseMouseReportDescriptor (
636 MouseHidDesc
->HidClassDesc
[0].DescriptorLength
639 if (EFI_ERROR (Status
)) {
641 FreePool (ReportDesc
);
646 // Check the presence of left and right buttons,
647 // and initialize fields of EFI_SIMPLE_POINTER_MODE.
649 if (UsbMouseDev
->NumberOfButtons
>= 1) {
650 UsbMouseDev
->Mode
.LeftButton
= TRUE
;
652 if (UsbMouseDev
->NumberOfButtons
> 1) {
653 UsbMouseDev
->Mode
.RightButton
= TRUE
;
655 UsbMouseDev
->Mode
.ResolutionX
= 8;
656 UsbMouseDev
->Mode
.ResolutionY
= 8;
657 UsbMouseDev
->Mode
.ResolutionZ
= 0;
660 // Set boot protocol for the USB mouse.
661 // This driver only supports boot protocol.
663 UsbGetProtocolRequest (
665 UsbMouseDev
->InterfaceDescriptor
.InterfaceNumber
,
668 if (Protocol
!= BOOT_PROTOCOL
) {
669 Status
= UsbSetProtocolRequest (
671 UsbMouseDev
->InterfaceDescriptor
.InterfaceNumber
,
675 if (EFI_ERROR (Status
)) {
677 FreePool (ReportDesc
);
683 // ReportId is zero, which means the idle rate applies to all input reports.
687 // Duration is zero, which means the duration is infinite.
688 // so the endpoint will inhibit reporting forever,
689 // and only reporting when a change is detected in the report data.
694 UsbMouseDev
->InterfaceDescriptor
.InterfaceNumber
,
700 FreePool (ReportDesc
);
703 // Create event for delayed recovery, which deals with device error.
705 if (UsbMouseDev
->DelayedRecoveryEvent
!= NULL
) {
706 gBS
->CloseEvent (UsbMouseDev
->DelayedRecoveryEvent
);
707 UsbMouseDev
->DelayedRecoveryEvent
= 0;
711 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
713 USBMouseRecoveryHandler
,
715 &UsbMouseDev
->DelayedRecoveryEvent
723 Handler function for USB mouse's asynchronous interrupt transfer.
725 This function is the handler function for USB mouse's asynchronous interrupt transfer
726 to manage the mouse. It parses data returned from asynchronous interrupt transfer, and
727 get button and movement state.
729 @param Data A pointer to a buffer that is filled with key data which is
730 retrieved via asynchronous interrupt transfer.
731 @param DataLength Indicates the size of the data buffer.
732 @param Context Pointing to USB_KB_DEV instance.
733 @param Result Indicates the result of the asynchronous interrupt transfer.
735 @retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.
736 @retval EFI_DEVICE_ERROR Hardware error occurs.
741 OnMouseInterruptComplete (
748 USB_MOUSE_DEV
*UsbMouseDevice
;
749 EFI_USB_IO_PROTOCOL
*UsbIo
;
753 UsbMouseDevice
= (USB_MOUSE_DEV
*) Context
;
754 UsbIo
= UsbMouseDevice
->UsbIo
;
756 if (Result
!= EFI_USB_NOERROR
) {
758 // Some errors happen during the process
760 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
761 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
762 (EFI_PERIPHERAL_MOUSE
| EFI_P_EC_INPUT_ERROR
),
763 UsbMouseDevice
->DevicePath
766 if ((Result
& EFI_USB_ERR_STALL
) == EFI_USB_ERR_STALL
) {
767 EndpointAddr
= UsbMouseDevice
->IntEndpointDescriptor
.EndpointAddress
;
769 UsbClearEndpointHalt (
777 // Delete & Submit this interrupt again
778 // Handler of DelayedRecoveryEvent triggered by timer will re-submit the interrupt.
780 UsbIo
->UsbAsyncInterruptTransfer (
782 UsbMouseDevice
->IntEndpointDescriptor
.EndpointAddress
,
790 // EFI_USB_INTERRUPT_DELAY is defined in USB standard for error handling.
793 UsbMouseDevice
->DelayedRecoveryEvent
,
795 EFI_USB_INTERRUPT_DELAY
797 return EFI_DEVICE_ERROR
;
801 // If no error and no data, just return EFI_SUCCESS.
803 if (DataLength
== 0 || Data
== NULL
) {
807 UsbMouseDevice
->StateChanged
= TRUE
;
811 // USB HID Specification specifies following data format:
812 // Byte Bits Description
816 // 4 to 7 Device-specific
817 // 1 0 to 7 X displacement
818 // 2 0 to 7 Y displacement
819 // 3 to n 0 to 7 Device specific (optional)
821 UsbMouseDevice
->State
.LeftButton
= (BOOLEAN
) ((*(UINT8
*) Data
& BIT0
) != 0);
822 UsbMouseDevice
->State
.RightButton
= (BOOLEAN
) ((*(UINT8
*) Data
& BIT1
) != 0);
823 UsbMouseDevice
->State
.RelativeMovementX
+= *((INT8
*) Data
+ 1);
824 UsbMouseDevice
->State
.RelativeMovementY
+= *((INT8
*) Data
+ 2);
826 if (DataLength
> 3) {
827 UsbMouseDevice
->State
.RelativeMovementZ
+= *((INT8
*) Data
+ 3);
834 Retrieves the current state of a pointer device.
836 @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL instance.
837 @param MouseState A pointer to the state information on the pointer device.
839 @retval EFI_SUCCESS The state of the pointer device was returned in State.
840 @retval EFI_NOT_READY The state of the pointer device has not changed since the last call to
842 @retval EFI_DEVICE_ERROR A device error occurred while attempting to retrieve the pointer device's
844 @retval EFI_INVALID_PARAMETER MouseState is NULL.
850 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
851 OUT EFI_SIMPLE_POINTER_STATE
*MouseState
854 USB_MOUSE_DEV
*MouseDev
;
856 if (MouseState
== NULL
) {
857 return EFI_INVALID_PARAMETER
;
860 MouseDev
= USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (This
);
862 if (!MouseDev
->StateChanged
) {
863 return EFI_NOT_READY
;
867 // Retrieve mouse state from USB_MOUSE_DEV, which was filled by OnMouseInterruptComplete()
872 sizeof (EFI_SIMPLE_POINTER_STATE
)
876 // Clear previous move state
878 MouseDev
->State
.RelativeMovementX
= 0;
879 MouseDev
->State
.RelativeMovementY
= 0;
880 MouseDev
->State
.RelativeMovementZ
= 0;
882 MouseDev
->StateChanged
= FALSE
;
889 Resets the pointer device hardware.
891 @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL instance.
892 @param ExtendedVerification Indicates that the driver may perform a more exhaustive
893 verification operation of the device during reset.
895 @retval EFI_SUCCESS The device was reset.
896 @retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset.
902 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
903 IN BOOLEAN ExtendedVerification
906 USB_MOUSE_DEV
*UsbMouseDevice
;
908 UsbMouseDevice
= USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (This
);
910 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
912 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_RESET
),
913 UsbMouseDevice
->DevicePath
917 // Clear mouse state.
920 &UsbMouseDevice
->State
,
921 sizeof (EFI_SIMPLE_POINTER_STATE
)
923 UsbMouseDevice
->StateChanged
= FALSE
;
929 Event notification function for EFI_SIMPLE_POINTER_PROTOCOL.WaitForInput event.
931 @param Event Event to be signaled when there's input from mouse.
932 @param Context Points to USB_MOUSE_DEV instance.
937 UsbMouseWaitForInput (
942 USB_MOUSE_DEV
*UsbMouseDev
;
944 UsbMouseDev
= (USB_MOUSE_DEV
*) Context
;
947 // If there's input from mouse, signal the event.
949 if (UsbMouseDev
->StateChanged
) {
950 gBS
->SignalEvent (Event
);
955 Handler for Delayed Recovery event.
957 This function is the handler for Delayed Recovery event triggered
959 After a device error occurs, the event would be triggered
960 with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY
961 is defined in USB standard for error handling.
963 @param Event The Delayed Recovery event.
964 @param Context Points to the USB_MOUSE_DEV instance.
969 USBMouseRecoveryHandler (
974 USB_MOUSE_DEV
*UsbMouseDev
;
975 EFI_USB_IO_PROTOCOL
*UsbIo
;
977 UsbMouseDev
= (USB_MOUSE_DEV
*) Context
;
979 UsbIo
= UsbMouseDev
->UsbIo
;
982 // Re-submit Asynchronous Interrupt Transfer for recovery.
984 UsbIo
->UsbAsyncInterruptTransfer (
986 UsbMouseDev
->IntEndpointDescriptor
.EndpointAddress
,
988 UsbMouseDev
->IntEndpointDescriptor
.Interval
,
989 UsbMouseDev
->IntEndpointDescriptor
.MaxPacketSize
,
990 OnMouseInterruptComplete
,