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
);
56 Check whether USB mouse driver supports this device.
58 @param This The USB mouse driver binding protocol.
59 @param Controller The controller handle to check.
60 @param RemainingDevicePath The remaining device path.
62 @retval EFI_SUCCESS The driver supports this controller.
63 @retval other This device isn't supported.
68 USBMouseDriverBindingSupported (
69 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
70 IN EFI_HANDLE Controller
,
71 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
75 EFI_USB_IO_PROTOCOL
*UsbIo
;
77 Status
= gBS
->OpenProtocol (
79 &gEfiUsbIoProtocolGuid
,
81 This
->DriverBindingHandle
,
83 EFI_OPEN_PROTOCOL_BY_DRIVER
85 if (EFI_ERROR (Status
)) {
90 // Use the USB I/O Protocol interface to check whether Controller is
91 // a mouse device that can be managed by this driver.
94 if (!IsUsbMouse (UsbIo
)) {
95 Status
= EFI_UNSUPPORTED
;
100 &gEfiUsbIoProtocolGuid
,
101 This
->DriverBindingHandle
,
110 Starts the mouse device with this driver.
112 This function consumes USB I/O Portocol, intializes USB mouse device,
113 installs Simple Pointer Protocol, and submits Asynchronous Interrupt
114 Transfer to manage the USB mouse device.
116 @param This The USB mouse driver binding instance.
117 @param Controller Handle of device to bind driver to.
118 @param RemainingDevicePath Optional parameter use to pick a specific child
121 @retval EFI_SUCCESS This driver supports this device.
122 @retval EFI_UNSUPPORTED This driver does not support this device.
123 @retval EFI_DEVICE_ERROR This driver cannot be started due to device Error.
124 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
125 @retval EFI_ALREADY_STARTED This driver has been started.
130 USBMouseDriverBindingStart (
131 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
132 IN EFI_HANDLE Controller
,
133 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
137 EFI_USB_IO_PROTOCOL
*UsbIo
;
138 USB_MOUSE_DEV
*UsbMouseDevice
;
139 UINT8 EndpointNumber
;
140 EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor
;
143 UINT8 PollingInterval
;
148 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
150 // Open USB I/O Protocol
152 Status
= gBS
->OpenProtocol (
154 &gEfiUsbIoProtocolGuid
,
156 This
->DriverBindingHandle
,
158 EFI_OPEN_PROTOCOL_BY_DRIVER
160 if (EFI_ERROR (Status
)) {
164 UsbMouseDevice
= AllocateZeroPool (sizeof (USB_MOUSE_DEV
));
165 ASSERT (UsbMouseDevice
!= NULL
);
167 UsbMouseDevice
->UsbIo
= UsbIo
;
168 UsbMouseDevice
->Signature
= USB_MOUSE_DEV_SIGNATURE
;
171 // Get the Device Path Protocol on Controller's handle
173 Status
= gBS
->OpenProtocol (
175 &gEfiDevicePathProtocolGuid
,
176 (VOID
**) &UsbMouseDevice
->DevicePath
,
177 This
->DriverBindingHandle
,
179 EFI_OPEN_PROTOCOL_GET_PROTOCOL
182 if (EFI_ERROR (Status
)) {
187 // Report Status Code here since USB mouse will be detected next.
189 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
191 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_PRESENCE_DETECT
),
192 UsbMouseDevice
->DevicePath
196 // Get interface & endpoint descriptor
198 UsbIo
->UsbGetInterfaceDescriptor (
200 &UsbMouseDevice
->InterfaceDescriptor
203 EndpointNumber
= UsbMouseDevice
->InterfaceDescriptor
.NumEndpoints
;
206 // Traverse endpoints to find interrupt endpoint
209 for (Index
= 0; Index
< EndpointNumber
; Index
++) {
210 UsbIo
->UsbGetEndpointDescriptor (
216 if ((EndpointDescriptor
.Attributes
& (BIT0
| BIT1
)) == USB_ENDPOINT_INTERRUPT
) {
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
);
382 Stop the USB mouse device handled by this driver.
384 @param This The USB mouse driver binding protocol.
385 @param Controller The controller to release.
386 @param NumberOfChildren The number of handles in ChildHandleBuffer.
387 @param ChildHandleBuffer The array of child handle.
389 @retval EFI_SUCCESS The device was stopped.
390 @retval EFI_UNSUPPORTED Simple Pointer Protocol is not installed on Controller.
391 @retval Others Fail to uninstall protocols attached on the device.
396 USBMouseDriverBindingStop (
397 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
398 IN EFI_HANDLE Controller
,
399 IN UINTN NumberOfChildren
,
400 IN EFI_HANDLE
*ChildHandleBuffer
404 USB_MOUSE_DEV
*UsbMouseDevice
;
405 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointerProtocol
;
406 EFI_USB_IO_PROTOCOL
*UsbIo
;
408 Status
= gBS
->OpenProtocol (
410 &gEfiSimplePointerProtocolGuid
,
411 (VOID
**) &SimplePointerProtocol
,
412 This
->DriverBindingHandle
,
414 EFI_OPEN_PROTOCOL_GET_PROTOCOL
417 if (EFI_ERROR (Status
)) {
418 return EFI_UNSUPPORTED
;
421 UsbMouseDevice
= USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (SimplePointerProtocol
);
423 UsbIo
= UsbMouseDevice
->UsbIo
;
426 // The key data input from this device will be disabled.
428 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
430 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_DISABLE
),
431 UsbMouseDevice
->DevicePath
435 // Delete the Asynchronous Interrupt Transfer from this device
437 UsbIo
->UsbAsyncInterruptTransfer (
439 UsbMouseDevice
->IntEndpointDescriptor
.EndpointAddress
,
441 UsbMouseDevice
->IntEndpointDescriptor
.Interval
,
447 Status
= gBS
->UninstallProtocolInterface (
449 &gEfiSimplePointerProtocolGuid
,
450 &UsbMouseDevice
->SimplePointerProtocol
452 if (EFI_ERROR (Status
)) {
458 &gEfiUsbIoProtocolGuid
,
459 This
->DriverBindingHandle
,
464 // Free all resources.
466 gBS
->CloseEvent (UsbMouseDevice
->SimplePointerProtocol
.WaitForInput
);
468 if (UsbMouseDevice
->DelayedRecoveryEvent
!= NULL
) {
469 gBS
->CloseEvent (UsbMouseDevice
->DelayedRecoveryEvent
);
470 UsbMouseDevice
->DelayedRecoveryEvent
= NULL
;
473 if (UsbMouseDevice
->ControllerNameTable
!= NULL
) {
474 FreeUnicodeStringTable (UsbMouseDevice
->ControllerNameTable
);
477 FreePool (UsbMouseDevice
);
485 Uses USB I/O to check whether the device is a USB mouse device.
487 @param UsbIo Pointer to a USB I/O protocol instance.
489 @retval TRUE Device is a USB mouse device.
490 @retval FALSE Device is a not USB mouse device.
495 IN EFI_USB_IO_PROTOCOL
*UsbIo
499 EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor
;
502 // Get the default interface descriptor
504 Status
= UsbIo
->UsbGetInterfaceDescriptor (
509 if (EFI_ERROR (Status
)) {
513 if ((InterfaceDescriptor
.InterfaceClass
== CLASS_HID
) &&
514 (InterfaceDescriptor
.InterfaceSubClass
== SUBCLASS_BOOT
) &&
515 (InterfaceDescriptor
.InterfaceProtocol
== PROTOCOL_MOUSE
)
525 Initialize the USB mouse device.
527 This function retrieves and parses HID report descriptor, and
528 initializes state of USB_MOUSE_DEV. Then it sets indefinite idle
529 rate for the device. Finally it creates event for delayed recovery,
530 which deals with device error.
532 @param UsbMouseDev Device instance to be initialized.
534 @retval EFI_SUCCESS USB mouse device successfully initialized..
535 @retval EFI_UNSUPPORTED HID descriptor type is not report descriptor.
536 @retval Other USB mouse device was not initialized successfully.
540 InitializeUsbMouseDevice (
541 IN OUT USB_MOUSE_DEV
*UsbMouseDev
544 EFI_USB_IO_PROTOCOL
*UsbIo
;
547 EFI_USB_HID_DESCRIPTOR
*MouseHidDesc
;
549 EFI_USB_CONFIG_DESCRIPTOR ConfigDesc
;
551 UINT32 TransferResult
;
556 UsbIo
= UsbMouseDev
->UsbIo
;
559 // Get the current configuration descriptor. Note that it doesn't include other descriptors.
561 Status
= UsbIo
->UsbGetConfigDescriptor (
565 if (EFI_ERROR (Status
)) {
570 // By issuing Get_Descriptor(Configuration) request with total length, we get the Configuration descriptor,
571 // all Interface descriptors, all Endpoint descriptors, and the HID descriptor for each interface.
573 Buf
= AllocateZeroPool (ConfigDesc
.TotalLength
);
575 return EFI_OUT_OF_RESOURCES
;
578 Status
= UsbGetDescriptor (
580 (UINT16
)((USB_DESC_TYPE_CONFIG
<< 8) | (ConfigDesc
.ConfigurationValue
- 1)),
582 ConfigDesc
.TotalLength
,
586 if (EFI_ERROR (Status
)) {
593 Head
= (USB_DESC_HEAD
*)Buf
;
597 // Get HID descriptor from the receipt of Get_Descriptor(Configuration) request.
598 // This algorithm is based on the fact that the HID descriptor shall be interleaved
599 // between the interface and endpoint descriptors for HID interfaces.
601 while (Total
< ConfigDesc
.TotalLength
) {
602 if (Head
->Type
== USB_DESC_TYPE_INTERFACE
) {
603 if ((((USB_INTERFACE_DESCRIPTOR
*)Head
)->InterfaceNumber
== UsbMouseDev
->InterfaceDescriptor
.InterfaceNumber
) &&
604 (((USB_INTERFACE_DESCRIPTOR
*)Head
)->AlternateSetting
== UsbMouseDev
->InterfaceDescriptor
.AlternateSetting
)) {
608 if (Start
&& (Head
->Type
== USB_DESC_TYPE_ENDPOINT
)) {
611 if (Start
&& (Head
->Type
== USB_DESC_TYPE_HID
)) {
612 MouseHidDesc
= (EFI_USB_HID_DESCRIPTOR
*)Head
;
615 Total
= Total
+ (UINT16
)Head
->Len
;
616 Head
= (USB_DESC_HEAD
*)((UINT8
*)Buf
+ Total
);
619 if (MouseHidDesc
== NULL
) {
621 return EFI_UNSUPPORTED
;
625 // Get report descriptor
627 if (MouseHidDesc
->HidClassDesc
[0].DescriptorType
!= USB_DESC_TYPE_REPORT
) {
629 return EFI_UNSUPPORTED
;
632 ReportDesc
= AllocateZeroPool (MouseHidDesc
->HidClassDesc
[0].DescriptorLength
);
633 ASSERT (ReportDesc
!= NULL
);
635 Status
= UsbGetReportDescriptor (
637 UsbMouseDev
->InterfaceDescriptor
.InterfaceNumber
,
638 MouseHidDesc
->HidClassDesc
[0].DescriptorLength
,
642 if (EFI_ERROR (Status
)) {
644 FreePool (ReportDesc
);
649 // Parse report descriptor
651 Status
= ParseMouseReportDescriptor (
654 MouseHidDesc
->HidClassDesc
[0].DescriptorLength
657 if (EFI_ERROR (Status
)) {
659 FreePool (ReportDesc
);
664 // Check the presence of left and right buttons,
665 // and initialize fields of EFI_SIMPLE_POINTER_MODE.
667 if (UsbMouseDev
->NumberOfButtons
>= 1) {
668 UsbMouseDev
->Mode
.LeftButton
= TRUE
;
670 if (UsbMouseDev
->NumberOfButtons
> 1) {
671 UsbMouseDev
->Mode
.RightButton
= TRUE
;
673 UsbMouseDev
->Mode
.ResolutionX
= 8;
674 UsbMouseDev
->Mode
.ResolutionY
= 8;
675 UsbMouseDev
->Mode
.ResolutionZ
= 0;
678 // Set boot protocol for the USB mouse.
679 // This driver only supports boot protocol.
681 UsbGetProtocolRequest (
683 UsbMouseDev
->InterfaceDescriptor
.InterfaceNumber
,
686 if (Protocol
!= BOOT_PROTOCOL
) {
687 Status
= UsbSetProtocolRequest (
689 UsbMouseDev
->InterfaceDescriptor
.InterfaceNumber
,
693 if (EFI_ERROR (Status
)) {
695 FreePool (ReportDesc
);
701 FreePool (ReportDesc
);
704 // Create event for delayed recovery, which deals with device error.
706 if (UsbMouseDev
->DelayedRecoveryEvent
!= NULL
) {
707 gBS
->CloseEvent (UsbMouseDev
->DelayedRecoveryEvent
);
708 UsbMouseDev
->DelayedRecoveryEvent
= 0;
712 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
714 USBMouseRecoveryHandler
,
716 &UsbMouseDev
->DelayedRecoveryEvent
724 Handler function for USB mouse's asynchronous interrupt transfer.
726 This function is the handler function for USB mouse's asynchronous interrupt transfer
727 to manage the mouse. It parses data returned from asynchronous interrupt transfer, and
728 get button and movement state.
730 @param Data A pointer to a buffer that is filled with key data which is
731 retrieved via asynchronous interrupt transfer.
732 @param DataLength Indicates the size of the data buffer.
733 @param Context Pointing to USB_KB_DEV instance.
734 @param Result Indicates the result of the asynchronous interrupt transfer.
736 @retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.
737 @retval EFI_DEVICE_ERROR Hardware error occurs.
742 OnMouseInterruptComplete (
749 USB_MOUSE_DEV
*UsbMouseDevice
;
750 EFI_USB_IO_PROTOCOL
*UsbIo
;
754 UsbMouseDevice
= (USB_MOUSE_DEV
*) Context
;
755 UsbIo
= UsbMouseDevice
->UsbIo
;
757 if (Result
!= EFI_USB_NOERROR
) {
759 // Some errors happen during the process
761 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
762 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
763 (EFI_PERIPHERAL_MOUSE
| EFI_P_EC_INPUT_ERROR
),
764 UsbMouseDevice
->DevicePath
767 if ((Result
& EFI_USB_ERR_STALL
) == EFI_USB_ERR_STALL
) {
768 EndpointAddr
= UsbMouseDevice
->IntEndpointDescriptor
.EndpointAddress
;
770 UsbClearEndpointHalt (
778 // Delete & Submit this interrupt again
779 // Handler of DelayedRecoveryEvent triggered by timer will re-submit the interrupt.
781 UsbIo
->UsbAsyncInterruptTransfer (
783 UsbMouseDevice
->IntEndpointDescriptor
.EndpointAddress
,
791 // EFI_USB_INTERRUPT_DELAY is defined in USB standard for error handling.
794 UsbMouseDevice
->DelayedRecoveryEvent
,
796 EFI_USB_INTERRUPT_DELAY
798 return EFI_DEVICE_ERROR
;
802 // If no error and no data, just return EFI_SUCCESS.
804 if (DataLength
== 0 || Data
== NULL
) {
810 // USB HID Specification specifies following data format:
811 // Byte Bits Description
815 // 4 to 7 Device-specific
816 // 1 0 to 7 X displacement
817 // 2 0 to 7 Y displacement
818 // 3 to n 0 to 7 Device specific (optional)
820 if (DataLength
< 3) {
821 return EFI_DEVICE_ERROR
;
824 UsbMouseDevice
->StateChanged
= TRUE
;
826 UsbMouseDevice
->State
.LeftButton
= (BOOLEAN
) ((*(UINT8
*) Data
& BIT0
) != 0);
827 UsbMouseDevice
->State
.RightButton
= (BOOLEAN
) ((*(UINT8
*) Data
& BIT1
) != 0);
828 UsbMouseDevice
->State
.RelativeMovementX
+= *((INT8
*) Data
+ 1);
829 UsbMouseDevice
->State
.RelativeMovementY
+= *((INT8
*) Data
+ 2);
831 if (DataLength
> 3) {
832 UsbMouseDevice
->State
.RelativeMovementZ
+= *((INT8
*) Data
+ 3);
839 Retrieves the current state of a pointer device.
841 @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL instance.
842 @param MouseState A pointer to the state information on the pointer device.
844 @retval EFI_SUCCESS The state of the pointer device was returned in State.
845 @retval EFI_NOT_READY The state of the pointer device has not changed since the last call to
847 @retval EFI_DEVICE_ERROR A device error occurred while attempting to retrieve the pointer device's
849 @retval EFI_INVALID_PARAMETER MouseState is NULL.
855 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
856 OUT EFI_SIMPLE_POINTER_STATE
*MouseState
859 USB_MOUSE_DEV
*MouseDev
;
861 if (MouseState
== NULL
) {
862 return EFI_INVALID_PARAMETER
;
865 MouseDev
= USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (This
);
867 if (!MouseDev
->StateChanged
) {
868 return EFI_NOT_READY
;
872 // Retrieve mouse state from USB_MOUSE_DEV, which was filled by OnMouseInterruptComplete()
877 sizeof (EFI_SIMPLE_POINTER_STATE
)
881 // Clear previous move state
883 MouseDev
->State
.RelativeMovementX
= 0;
884 MouseDev
->State
.RelativeMovementY
= 0;
885 MouseDev
->State
.RelativeMovementZ
= 0;
887 MouseDev
->StateChanged
= FALSE
;
894 Resets the pointer device hardware.
896 @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL instance.
897 @param ExtendedVerification Indicates that the driver may perform a more exhaustive
898 verification operation of the device during reset.
900 @retval EFI_SUCCESS The device was reset.
901 @retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset.
907 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
908 IN BOOLEAN ExtendedVerification
911 USB_MOUSE_DEV
*UsbMouseDevice
;
913 UsbMouseDevice
= USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (This
);
915 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
917 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_RESET
),
918 UsbMouseDevice
->DevicePath
922 // Clear mouse state.
925 &UsbMouseDevice
->State
,
926 sizeof (EFI_SIMPLE_POINTER_STATE
)
928 UsbMouseDevice
->StateChanged
= FALSE
;
934 Event notification function for EFI_SIMPLE_POINTER_PROTOCOL.WaitForInput event.
936 @param Event Event to be signaled when there's input from mouse.
937 @param Context Points to USB_MOUSE_DEV instance.
942 UsbMouseWaitForInput (
947 USB_MOUSE_DEV
*UsbMouseDev
;
949 UsbMouseDev
= (USB_MOUSE_DEV
*) Context
;
952 // If there's input from mouse, signal the event.
954 if (UsbMouseDev
->StateChanged
) {
955 gBS
->SignalEvent (Event
);
960 Handler for Delayed Recovery event.
962 This function is the handler for Delayed Recovery event triggered
964 After a device error occurs, the event would be triggered
965 with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY
966 is defined in USB standard for error handling.
968 @param Event The Delayed Recovery event.
969 @param Context Points to the USB_MOUSE_DEV instance.
974 USBMouseRecoveryHandler (
979 USB_MOUSE_DEV
*UsbMouseDev
;
980 EFI_USB_IO_PROTOCOL
*UsbIo
;
982 UsbMouseDev
= (USB_MOUSE_DEV
*) Context
;
984 UsbIo
= UsbMouseDev
->UsbIo
;
987 // Re-submit Asynchronous Interrupt Transfer for recovery.
989 UsbIo
->UsbAsyncInterruptTransfer (
991 UsbMouseDev
->IntEndpointDescriptor
.EndpointAddress
,
993 UsbMouseDev
->IntEndpointDescriptor
.Interval
,
994 UsbMouseDev
->IntEndpointDescriptor
.MaxPacketSize
,
995 OnMouseInterruptComplete
,