2 USB Mouse Driver that manages USB mouse and produces Simple Pointer Protocol.
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 EFI_DRIVER_BINDING_PROTOCOL gUsbMouseDriverBinding
= {
12 USBMouseDriverBindingSupported
,
13 USBMouseDriverBindingStart
,
14 USBMouseDriverBindingStop
,
21 Entrypoint of USB Mouse Driver.
23 This function is the entrypoint of USB Mouse Driver. It installs Driver Binding
24 Protocols together with Component Name Protocols.
26 @param ImageHandle The firmware allocated handle for the EFI image.
27 @param SystemTable A pointer to the EFI System Table.
29 @retval EFI_SUCCESS The entry point is executed successfully.
34 USBMouseDriverBindingEntryPoint (
35 IN EFI_HANDLE ImageHandle
,
36 IN EFI_SYSTEM_TABLE
*SystemTable
41 Status
= EfiLibInstallDriverBindingComponentName2 (
44 &gUsbMouseDriverBinding
,
46 &gUsbMouseComponentName
,
47 &gUsbMouseComponentName2
49 ASSERT_EFI_ERROR (Status
);
55 Check whether USB mouse driver supports this device.
57 @param This The USB mouse driver binding protocol.
58 @param Controller The controller handle to check.
59 @param RemainingDevicePath The remaining device path.
61 @retval EFI_SUCCESS The driver supports this controller.
62 @retval other This device isn't supported.
67 USBMouseDriverBindingSupported (
68 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
69 IN EFI_HANDLE Controller
,
70 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
74 EFI_USB_IO_PROTOCOL
*UsbIo
;
76 Status
= gBS
->OpenProtocol (
78 &gEfiUsbIoProtocolGuid
,
80 This
->DriverBindingHandle
,
82 EFI_OPEN_PROTOCOL_BY_DRIVER
84 if (EFI_ERROR (Status
)) {
89 // Use the USB I/O Protocol interface to check whether Controller is
90 // a mouse device that can be managed by this driver.
93 if (!IsUsbMouse (UsbIo
)) {
94 Status
= EFI_UNSUPPORTED
;
99 &gEfiUsbIoProtocolGuid
,
100 This
->DriverBindingHandle
,
108 Starts the mouse device with this driver.
110 This function consumes USB I/O Protocol, initializes USB mouse device,
111 installs Simple Pointer Protocol, and submits Asynchronous Interrupt
112 Transfer to manage the USB mouse device.
114 @param This The USB mouse driver binding instance.
115 @param Controller Handle of device to bind driver to.
116 @param RemainingDevicePath Optional parameter use to pick a specific child
119 @retval EFI_SUCCESS This driver supports this device.
120 @retval EFI_UNSUPPORTED This driver does not support this device.
121 @retval EFI_DEVICE_ERROR This driver cannot be started due to device Error.
122 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
123 @retval EFI_ALREADY_STARTED This driver has been started.
128 USBMouseDriverBindingStart (
129 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
130 IN EFI_HANDLE Controller
,
131 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
135 EFI_USB_IO_PROTOCOL
*UsbIo
;
136 USB_MOUSE_DEV
*UsbMouseDevice
;
137 UINT8 EndpointNumber
;
138 EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor
;
141 UINT8 PollingInterval
;
146 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
148 // Open USB I/O Protocol
150 Status
= gBS
->OpenProtocol (
152 &gEfiUsbIoProtocolGuid
,
154 This
->DriverBindingHandle
,
156 EFI_OPEN_PROTOCOL_BY_DRIVER
158 if (EFI_ERROR (Status
)) {
162 UsbMouseDevice
= AllocateZeroPool (sizeof (USB_MOUSE_DEV
));
163 ASSERT (UsbMouseDevice
!= NULL
);
165 UsbMouseDevice
->UsbIo
= UsbIo
;
166 UsbMouseDevice
->Signature
= USB_MOUSE_DEV_SIGNATURE
;
169 // Get the Device Path Protocol on Controller's handle
171 Status
= gBS
->OpenProtocol (
173 &gEfiDevicePathProtocolGuid
,
174 (VOID
**)&UsbMouseDevice
->DevicePath
,
175 This
->DriverBindingHandle
,
177 EFI_OPEN_PROTOCOL_GET_PROTOCOL
180 if (EFI_ERROR (Status
)) {
185 // Report Status Code here since USB mouse will be detected next.
187 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
189 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_PRESENCE_DETECT
),
190 UsbMouseDevice
->DevicePath
194 // Get interface & endpoint descriptor
196 UsbIo
->UsbGetInterfaceDescriptor (
198 &UsbMouseDevice
->InterfaceDescriptor
201 EndpointNumber
= UsbMouseDevice
->InterfaceDescriptor
.NumEndpoints
;
204 // Traverse endpoints to find interrupt endpoint IN
207 for (Index
= 0; Index
< EndpointNumber
; Index
++) {
208 UsbIo
->UsbGetEndpointDescriptor (
214 if (((EndpointDescriptor
.Attributes
& (BIT0
| BIT1
)) == USB_ENDPOINT_INTERRUPT
) &&
215 ((EndpointDescriptor
.EndpointAddress
& USB_ENDPOINT_DIR_IN
) != 0))
218 // We only care interrupt endpoint here
220 CopyMem (&UsbMouseDevice
->IntEndpointDescriptor
, &EndpointDescriptor
, sizeof (EndpointDescriptor
));
228 // Report Status Code to indicate that there is no USB mouse
231 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
232 (EFI_PERIPHERAL_MOUSE
| EFI_P_EC_NOT_DETECTED
)
235 // No interrupt endpoint found, then return unsupported.
237 Status
= EFI_UNSUPPORTED
;
242 // Report Status Code here since USB mouse has be detected.
244 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
246 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_DETECTED
),
247 UsbMouseDevice
->DevicePath
250 Status
= InitializeUsbMouseDevice (UsbMouseDevice
);
251 if (EFI_ERROR (Status
)) {
253 // Fail to initialize USB mouse device.
255 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
256 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
257 (EFI_PERIPHERAL_MOUSE
| EFI_P_EC_INTERFACE_ERROR
),
258 UsbMouseDevice
->DevicePath
265 // Initialize and install EFI Simple Pointer Protocol.
267 UsbMouseDevice
->SimplePointerProtocol
.GetState
= GetMouseState
;
268 UsbMouseDevice
->SimplePointerProtocol
.Reset
= UsbMouseReset
;
269 UsbMouseDevice
->SimplePointerProtocol
.Mode
= &UsbMouseDevice
->Mode
;
271 Status
= gBS
->CreateEvent (
274 UsbMouseWaitForInput
,
276 &((UsbMouseDevice
->SimplePointerProtocol
).WaitForInput
)
278 if (EFI_ERROR (Status
)) {
282 Status
= gBS
->InstallProtocolInterface (
284 &gEfiSimplePointerProtocolGuid
,
285 EFI_NATIVE_INTERFACE
,
286 &UsbMouseDevice
->SimplePointerProtocol
289 if (EFI_ERROR (Status
)) {
294 // The next step would be submitting Asynchronous Interrupt Transfer on this mouse device.
295 // After that we will be able to get key data from it. Thus this is deemed as
296 // the enable action of the mouse, so report status code accordingly.
298 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
300 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_ENABLE
),
301 UsbMouseDevice
->DevicePath
305 // Submit Asynchronous Interrupt Transfer to manage this device.
307 EndpointAddr
= UsbMouseDevice
->IntEndpointDescriptor
.EndpointAddress
;
308 PollingInterval
= UsbMouseDevice
->IntEndpointDescriptor
.Interval
;
309 PacketSize
= (UINT8
)(UsbMouseDevice
->IntEndpointDescriptor
.MaxPacketSize
);
311 Status
= UsbIo
->UsbAsyncInterruptTransfer (
317 OnMouseInterruptComplete
,
321 if (EFI_ERROR (Status
)) {
323 // If submit error, uninstall that interface
325 gBS
->UninstallProtocolInterface (
327 &gEfiSimplePointerProtocolGuid
,
328 &UsbMouseDevice
->SimplePointerProtocol
333 UsbMouseDevice
->ControllerNameTable
= NULL
;
336 gUsbMouseComponentName
.SupportedLanguages
,
337 &UsbMouseDevice
->ControllerNameTable
,
338 L
"Generic Usb Mouse",
343 gUsbMouseComponentName2
.SupportedLanguages
,
344 &UsbMouseDevice
->ControllerNameTable
,
345 L
"Generic Usb Mouse",
349 gBS
->RestoreTPL (OldTpl
);
357 if (EFI_ERROR (Status
)) {
360 &gEfiUsbIoProtocolGuid
,
361 This
->DriverBindingHandle
,
365 if (UsbMouseDevice
!= NULL
) {
366 if ((UsbMouseDevice
->SimplePointerProtocol
).WaitForInput
!= NULL
) {
367 gBS
->CloseEvent ((UsbMouseDevice
->SimplePointerProtocol
).WaitForInput
);
370 FreePool (UsbMouseDevice
);
371 UsbMouseDevice
= NULL
;
376 gBS
->RestoreTPL (OldTpl
);
381 Stop the USB mouse device handled by this driver.
383 @param This The USB mouse driver binding protocol.
384 @param Controller The controller to release.
385 @param NumberOfChildren The number of handles in ChildHandleBuffer.
386 @param ChildHandleBuffer The array of child handle.
388 @retval EFI_SUCCESS The device was stopped.
389 @retval EFI_UNSUPPORTED Simple Pointer Protocol is not installed on Controller.
390 @retval Others Fail to uninstall protocols attached on the device.
395 USBMouseDriverBindingStop (
396 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
397 IN EFI_HANDLE Controller
,
398 IN UINTN NumberOfChildren
,
399 IN EFI_HANDLE
*ChildHandleBuffer
403 USB_MOUSE_DEV
*UsbMouseDevice
;
404 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointerProtocol
;
405 EFI_USB_IO_PROTOCOL
*UsbIo
;
407 Status
= gBS
->OpenProtocol (
409 &gEfiSimplePointerProtocolGuid
,
410 (VOID
**)&SimplePointerProtocol
,
411 This
->DriverBindingHandle
,
413 EFI_OPEN_PROTOCOL_GET_PROTOCOL
416 if (EFI_ERROR (Status
)) {
417 return EFI_UNSUPPORTED
;
420 UsbMouseDevice
= USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (SimplePointerProtocol
);
422 UsbIo
= UsbMouseDevice
->UsbIo
;
425 // The key data input from this device will be disabled.
427 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
429 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_DISABLE
),
430 UsbMouseDevice
->DevicePath
434 // Delete the Asynchronous Interrupt Transfer from this device
436 UsbIo
->UsbAsyncInterruptTransfer (
438 UsbMouseDevice
->IntEndpointDescriptor
.EndpointAddress
,
440 UsbMouseDevice
->IntEndpointDescriptor
.Interval
,
446 Status
= gBS
->UninstallProtocolInterface (
448 &gEfiSimplePointerProtocolGuid
,
449 &UsbMouseDevice
->SimplePointerProtocol
451 if (EFI_ERROR (Status
)) {
457 &gEfiUsbIoProtocolGuid
,
458 This
->DriverBindingHandle
,
463 // Free all resources.
465 gBS
->CloseEvent (UsbMouseDevice
->SimplePointerProtocol
.WaitForInput
);
467 if (UsbMouseDevice
->DelayedRecoveryEvent
!= NULL
) {
468 gBS
->CloseEvent (UsbMouseDevice
->DelayedRecoveryEvent
);
469 UsbMouseDevice
->DelayedRecoveryEvent
= NULL
;
472 if (UsbMouseDevice
->ControllerNameTable
!= NULL
) {
473 FreeUnicodeStringTable (UsbMouseDevice
->ControllerNameTable
);
476 FreePool (UsbMouseDevice
);
482 Uses USB I/O to check whether the device is a USB mouse device.
484 @param UsbIo Pointer to a USB I/O protocol instance.
486 @retval TRUE Device is a USB mouse device.
487 @retval FALSE Device is a not USB mouse device.
492 IN EFI_USB_IO_PROTOCOL
*UsbIo
496 EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor
;
499 // Get the default interface descriptor
501 Status
= UsbIo
->UsbGetInterfaceDescriptor (
506 if (EFI_ERROR (Status
)) {
510 if ((InterfaceDescriptor
.InterfaceClass
== CLASS_HID
) &&
511 (InterfaceDescriptor
.InterfaceSubClass
== SUBCLASS_BOOT
) &&
512 (InterfaceDescriptor
.InterfaceProtocol
== PROTOCOL_MOUSE
)
522 Initialize the USB mouse device.
524 This function retrieves and parses HID report descriptor, and
525 initializes state of USB_MOUSE_DEV. Then it sets indefinite idle
526 rate for the device. Finally it creates event for delayed recovery,
527 which deals with device error.
529 @param UsbMouseDev Device instance to be initialized.
531 @retval EFI_SUCCESS USB mouse device successfully initialized..
532 @retval EFI_UNSUPPORTED HID descriptor type is not report descriptor.
533 @retval Other USB mouse device was not initialized successfully.
537 InitializeUsbMouseDevice (
538 IN OUT USB_MOUSE_DEV
*UsbMouseDev
541 EFI_USB_IO_PROTOCOL
*UsbIo
;
544 EFI_USB_HID_DESCRIPTOR
*MouseHidDesc
;
546 EFI_USB_CONFIG_DESCRIPTOR ConfigDesc
;
548 UINT32 TransferResult
;
553 UsbIo
= UsbMouseDev
->UsbIo
;
556 // Get the current configuration descriptor. Note that it doesn't include other descriptors.
558 Status
= UsbIo
->UsbGetConfigDescriptor (
562 if (EFI_ERROR (Status
)) {
567 // By issuing Get_Descriptor(Configuration) request with total length, we get the Configuration descriptor,
568 // all Interface descriptors, all Endpoint descriptors, and the HID descriptor for each interface.
570 Buf
= AllocateZeroPool (ConfigDesc
.TotalLength
);
572 return EFI_OUT_OF_RESOURCES
;
575 Status
= UsbGetDescriptor (
577 (UINT16
)((USB_DESC_TYPE_CONFIG
<< 8) | (ConfigDesc
.ConfigurationValue
- 1)),
579 ConfigDesc
.TotalLength
,
583 if (EFI_ERROR (Status
)) {
590 Head
= (USB_DESC_HEAD
*)Buf
;
594 // Get HID descriptor from the receipt of Get_Descriptor(Configuration) request.
595 // This algorithm is based on the fact that the HID descriptor shall be interleaved
596 // between the interface and endpoint descriptors for HID interfaces.
598 while (Total
< ConfigDesc
.TotalLength
) {
599 if (Head
->Type
== USB_DESC_TYPE_INTERFACE
) {
600 if ((((USB_INTERFACE_DESCRIPTOR
*)Head
)->InterfaceNumber
== UsbMouseDev
->InterfaceDescriptor
.InterfaceNumber
) &&
601 (((USB_INTERFACE_DESCRIPTOR
*)Head
)->AlternateSetting
== UsbMouseDev
->InterfaceDescriptor
.AlternateSetting
))
607 if (Start
&& (Head
->Type
== USB_DESC_TYPE_ENDPOINT
)) {
611 if (Start
&& (Head
->Type
== USB_DESC_TYPE_HID
)) {
612 MouseHidDesc
= (EFI_USB_HID_DESCRIPTOR
*)Head
;
616 Total
= Total
+ (UINT16
)Head
->Len
;
617 Head
= (USB_DESC_HEAD
*)((UINT8
*)Buf
+ Total
);
620 if (MouseHidDesc
== NULL
) {
622 return EFI_UNSUPPORTED
;
626 // Get report descriptor
628 if (MouseHidDesc
->HidClassDesc
[0].DescriptorType
!= USB_DESC_TYPE_REPORT
) {
630 return EFI_UNSUPPORTED
;
633 ReportDesc
= AllocateZeroPool (MouseHidDesc
->HidClassDesc
[0].DescriptorLength
);
634 ASSERT (ReportDesc
!= NULL
);
636 Status
= UsbGetReportDescriptor (
638 UsbMouseDev
->InterfaceDescriptor
.InterfaceNumber
,
639 MouseHidDesc
->HidClassDesc
[0].DescriptorLength
,
643 if (EFI_ERROR (Status
)) {
645 FreePool (ReportDesc
);
650 // Parse report descriptor
652 Status
= ParseMouseReportDescriptor (
655 MouseHidDesc
->HidClassDesc
[0].DescriptorLength
658 if (EFI_ERROR (Status
)) {
660 FreePool (ReportDesc
);
665 // Check the presence of left and right buttons,
666 // and initialize fields of EFI_SIMPLE_POINTER_MODE.
668 if (UsbMouseDev
->NumberOfButtons
>= 1) {
669 UsbMouseDev
->Mode
.LeftButton
= TRUE
;
672 if (UsbMouseDev
->NumberOfButtons
> 1) {
673 UsbMouseDev
->Mode
.RightButton
= TRUE
;
676 UsbMouseDev
->Mode
.ResolutionX
= 8;
677 UsbMouseDev
->Mode
.ResolutionY
= 8;
678 UsbMouseDev
->Mode
.ResolutionZ
= 0;
681 // Set boot protocol for the USB mouse.
682 // This driver only supports boot protocol.
684 UsbGetProtocolRequest (
686 UsbMouseDev
->InterfaceDescriptor
.InterfaceNumber
,
689 if (Protocol
!= BOOT_PROTOCOL
) {
690 Status
= UsbSetProtocolRequest (
692 UsbMouseDev
->InterfaceDescriptor
.InterfaceNumber
,
696 if (EFI_ERROR (Status
)) {
698 FreePool (ReportDesc
);
704 FreePool (ReportDesc
);
707 // Create event for delayed recovery, which deals with device error.
709 if (UsbMouseDev
->DelayedRecoveryEvent
!= NULL
) {
710 gBS
->CloseEvent (UsbMouseDev
->DelayedRecoveryEvent
);
711 UsbMouseDev
->DelayedRecoveryEvent
= 0;
715 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
717 USBMouseRecoveryHandler
,
719 &UsbMouseDev
->DelayedRecoveryEvent
726 Handler function for USB mouse's asynchronous interrupt transfer.
728 This function is the handler function for USB mouse's asynchronous interrupt transfer
729 to manage the mouse. It parses data returned from asynchronous interrupt transfer, and
730 get button and movement state.
732 @param Data A pointer to a buffer that is filled with key data which is
733 retrieved via asynchronous interrupt transfer.
734 @param DataLength Indicates the size of the data buffer.
735 @param Context Pointing to USB_KB_DEV instance.
736 @param Result Indicates the result of the asynchronous interrupt transfer.
738 @retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.
739 @retval EFI_DEVICE_ERROR Hardware error occurs.
744 OnMouseInterruptComplete (
751 USB_MOUSE_DEV
*UsbMouseDevice
;
752 EFI_USB_IO_PROTOCOL
*UsbIo
;
756 UsbMouseDevice
= (USB_MOUSE_DEV
*)Context
;
757 UsbIo
= UsbMouseDevice
->UsbIo
;
759 if (Result
!= EFI_USB_NOERROR
) {
761 // Some errors happen during the process
763 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
764 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
765 (EFI_PERIPHERAL_MOUSE
| EFI_P_EC_INPUT_ERROR
),
766 UsbMouseDevice
->DevicePath
769 if ((Result
& EFI_USB_ERR_STALL
) == EFI_USB_ERR_STALL
) {
770 EndpointAddr
= UsbMouseDevice
->IntEndpointDescriptor
.EndpointAddress
;
772 UsbClearEndpointHalt (
780 // Delete & Submit this interrupt again
781 // Handler of DelayedRecoveryEvent triggered by timer will re-submit the interrupt.
783 UsbIo
->UsbAsyncInterruptTransfer (
785 UsbMouseDevice
->IntEndpointDescriptor
.EndpointAddress
,
793 // EFI_USB_INTERRUPT_DELAY is defined in USB standard for error handling.
796 UsbMouseDevice
->DelayedRecoveryEvent
,
798 EFI_USB_INTERRUPT_DELAY
800 return EFI_DEVICE_ERROR
;
804 // If no error and no data, just return EFI_SUCCESS.
806 if ((DataLength
== 0) || (Data
== NULL
)) {
812 // USB HID Specification specifies following data format:
813 // Byte Bits Description
817 // 4 to 7 Device-specific
818 // 1 0 to 7 X displacement
819 // 2 0 to 7 Y displacement
820 // 3 to n 0 to 7 Device specific (optional)
822 if (DataLength
< 3) {
823 return EFI_DEVICE_ERROR
;
826 UsbMouseDevice
->StateChanged
= TRUE
;
828 UsbMouseDevice
->State
.LeftButton
= (BOOLEAN
)((*(UINT8
*)Data
& BIT0
) != 0);
829 UsbMouseDevice
->State
.RightButton
= (BOOLEAN
)((*(UINT8
*)Data
& BIT1
) != 0);
830 UsbMouseDevice
->State
.RelativeMovementX
+= *((INT8
*)Data
+ 1);
831 UsbMouseDevice
->State
.RelativeMovementY
+= *((INT8
*)Data
+ 2);
833 if (DataLength
> 3) {
834 UsbMouseDevice
->State
.RelativeMovementZ
+= *((INT8
*)Data
+ 3);
841 Retrieves the current state of a pointer device.
843 @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL instance.
844 @param MouseState A pointer to the state information on the pointer device.
846 @retval EFI_SUCCESS The state of the pointer device was returned in State.
847 @retval EFI_NOT_READY The state of the pointer device has not changed since the last call to
849 @retval EFI_DEVICE_ERROR A device error occurred while attempting to retrieve the pointer device's
851 @retval EFI_INVALID_PARAMETER MouseState is NULL.
857 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
858 OUT EFI_SIMPLE_POINTER_STATE
*MouseState
861 USB_MOUSE_DEV
*MouseDev
;
863 if (MouseState
== NULL
) {
864 return EFI_INVALID_PARAMETER
;
867 MouseDev
= USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (This
);
869 if (!MouseDev
->StateChanged
) {
870 return EFI_NOT_READY
;
874 // Retrieve mouse state from USB_MOUSE_DEV, which was filled by OnMouseInterruptComplete()
879 sizeof (EFI_SIMPLE_POINTER_STATE
)
883 // Clear previous move state
885 MouseDev
->State
.RelativeMovementX
= 0;
886 MouseDev
->State
.RelativeMovementY
= 0;
887 MouseDev
->State
.RelativeMovementZ
= 0;
889 MouseDev
->StateChanged
= FALSE
;
895 Resets the pointer device hardware.
897 @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL instance.
898 @param ExtendedVerification Indicates that the driver may perform a more exhaustive
899 verification operation of the device during reset.
901 @retval EFI_SUCCESS The device was reset.
902 @retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset.
908 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
909 IN BOOLEAN ExtendedVerification
912 USB_MOUSE_DEV
*UsbMouseDevice
;
914 UsbMouseDevice
= USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (This
);
916 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
918 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_RESET
),
919 UsbMouseDevice
->DevicePath
923 // Clear mouse state.
926 &UsbMouseDevice
->State
,
927 sizeof (EFI_SIMPLE_POINTER_STATE
)
929 UsbMouseDevice
->StateChanged
= FALSE
;
935 Event notification function for EFI_SIMPLE_POINTER_PROTOCOL.WaitForInput event.
937 @param Event Event to be signaled when there's input from mouse.
938 @param Context Points to USB_MOUSE_DEV instance.
943 UsbMouseWaitForInput (
948 USB_MOUSE_DEV
*UsbMouseDev
;
950 UsbMouseDev
= (USB_MOUSE_DEV
*)Context
;
953 // If there's input from mouse, signal the event.
955 if (UsbMouseDev
->StateChanged
) {
956 gBS
->SignalEvent (Event
);
961 Handler for Delayed Recovery event.
963 This function is the handler for Delayed Recovery event triggered
965 After a device error occurs, the event would be triggered
966 with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY
967 is defined in USB standard for error handling.
969 @param Event The Delayed Recovery event.
970 @param Context Points to the USB_MOUSE_DEV instance.
975 USBMouseRecoveryHandler (
980 USB_MOUSE_DEV
*UsbMouseDev
;
981 EFI_USB_IO_PROTOCOL
*UsbIo
;
983 UsbMouseDev
= (USB_MOUSE_DEV
*)Context
;
985 UsbIo
= UsbMouseDev
->UsbIo
;
988 // Re-submit Asynchronous Interrupt Transfer for recovery.
990 UsbIo
->UsbAsyncInterruptTransfer (
992 UsbMouseDev
->IntEndpointDescriptor
.EndpointAddress
,
994 UsbMouseDev
->IntEndpointDescriptor
.Interval
,
995 UsbMouseDev
->IntEndpointDescriptor
.MaxPacketSize
,
996 OnMouseInterruptComplete
,