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 Protocol, initializes 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 IN
209 for (Index
= 0; Index
< EndpointNumber
; Index
++) {
210 UsbIo
->UsbGetEndpointDescriptor (
216 if (((EndpointDescriptor
.Attributes
& (BIT0
| BIT1
)) == USB_ENDPOINT_INTERRUPT
) &&
217 ((EndpointDescriptor
.EndpointAddress
& USB_ENDPOINT_DIR_IN
) != 0)) {
219 // We only care interrupt endpoint here
221 CopyMem(&UsbMouseDevice
->IntEndpointDescriptor
, &EndpointDescriptor
, sizeof(EndpointDescriptor
));
229 // Report Status Code to indicate that there is no USB mouse
232 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
233 (EFI_PERIPHERAL_MOUSE
| EFI_P_EC_NOT_DETECTED
)
236 // No interrupt endpoint found, then return unsupported.
238 Status
= EFI_UNSUPPORTED
;
243 // Report Status Code here since USB mouse has be detected.
245 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
247 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_DETECTED
),
248 UsbMouseDevice
->DevicePath
251 Status
= InitializeUsbMouseDevice (UsbMouseDevice
);
252 if (EFI_ERROR (Status
)) {
254 // Fail to initialize USB mouse device.
256 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
257 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
258 (EFI_PERIPHERAL_MOUSE
| EFI_P_EC_INTERFACE_ERROR
),
259 UsbMouseDevice
->DevicePath
266 // Initialize and install EFI Simple Pointer Protocol.
268 UsbMouseDevice
->SimplePointerProtocol
.GetState
= GetMouseState
;
269 UsbMouseDevice
->SimplePointerProtocol
.Reset
= UsbMouseReset
;
270 UsbMouseDevice
->SimplePointerProtocol
.Mode
= &UsbMouseDevice
->Mode
;
272 Status
= gBS
->CreateEvent (
275 UsbMouseWaitForInput
,
277 &((UsbMouseDevice
->SimplePointerProtocol
).WaitForInput
)
279 if (EFI_ERROR (Status
)) {
283 Status
= gBS
->InstallProtocolInterface (
285 &gEfiSimplePointerProtocolGuid
,
286 EFI_NATIVE_INTERFACE
,
287 &UsbMouseDevice
->SimplePointerProtocol
290 if (EFI_ERROR (Status
)) {
295 // The next step would be submitting Asynchronous Interrupt Transfer on this mouse device.
296 // After that we will be able to get key data from it. Thus this is deemed as
297 // the enable action of the mouse, so report status code accordingly.
299 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
301 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_ENABLE
),
302 UsbMouseDevice
->DevicePath
306 // Submit Asynchronous Interrupt Transfer to manage this device.
308 EndpointAddr
= UsbMouseDevice
->IntEndpointDescriptor
.EndpointAddress
;
309 PollingInterval
= UsbMouseDevice
->IntEndpointDescriptor
.Interval
;
310 PacketSize
= (UINT8
) (UsbMouseDevice
->IntEndpointDescriptor
.MaxPacketSize
);
312 Status
= UsbIo
->UsbAsyncInterruptTransfer (
318 OnMouseInterruptComplete
,
322 if (EFI_ERROR (Status
)) {
324 // If submit error, uninstall that interface
326 gBS
->UninstallProtocolInterface (
328 &gEfiSimplePointerProtocolGuid
,
329 &UsbMouseDevice
->SimplePointerProtocol
334 UsbMouseDevice
->ControllerNameTable
= NULL
;
337 gUsbMouseComponentName
.SupportedLanguages
,
338 &UsbMouseDevice
->ControllerNameTable
,
339 L
"Generic Usb Mouse",
344 gUsbMouseComponentName2
.SupportedLanguages
,
345 &UsbMouseDevice
->ControllerNameTable
,
346 L
"Generic Usb Mouse",
350 gBS
->RestoreTPL (OldTpl
);
358 if (EFI_ERROR (Status
)) {
361 &gEfiUsbIoProtocolGuid
,
362 This
->DriverBindingHandle
,
366 if (UsbMouseDevice
!= NULL
) {
367 if ((UsbMouseDevice
->SimplePointerProtocol
).WaitForInput
!= NULL
) {
368 gBS
->CloseEvent ((UsbMouseDevice
->SimplePointerProtocol
).WaitForInput
);
371 FreePool (UsbMouseDevice
);
372 UsbMouseDevice
= NULL
;
377 gBS
->RestoreTPL (OldTpl
);
383 Stop the USB mouse device handled by this driver.
385 @param This The USB mouse driver binding protocol.
386 @param Controller The controller to release.
387 @param NumberOfChildren The number of handles in ChildHandleBuffer.
388 @param ChildHandleBuffer The array of child handle.
390 @retval EFI_SUCCESS The device was stopped.
391 @retval EFI_UNSUPPORTED Simple Pointer Protocol is not installed on Controller.
392 @retval Others Fail to uninstall protocols attached on the device.
397 USBMouseDriverBindingStop (
398 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
399 IN EFI_HANDLE Controller
,
400 IN UINTN NumberOfChildren
,
401 IN EFI_HANDLE
*ChildHandleBuffer
405 USB_MOUSE_DEV
*UsbMouseDevice
;
406 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointerProtocol
;
407 EFI_USB_IO_PROTOCOL
*UsbIo
;
409 Status
= gBS
->OpenProtocol (
411 &gEfiSimplePointerProtocolGuid
,
412 (VOID
**) &SimplePointerProtocol
,
413 This
->DriverBindingHandle
,
415 EFI_OPEN_PROTOCOL_GET_PROTOCOL
418 if (EFI_ERROR (Status
)) {
419 return EFI_UNSUPPORTED
;
422 UsbMouseDevice
= USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (SimplePointerProtocol
);
424 UsbIo
= UsbMouseDevice
->UsbIo
;
427 // The key data input from this device will be disabled.
429 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
431 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_DISABLE
),
432 UsbMouseDevice
->DevicePath
436 // Delete the Asynchronous Interrupt Transfer from this device
438 UsbIo
->UsbAsyncInterruptTransfer (
440 UsbMouseDevice
->IntEndpointDescriptor
.EndpointAddress
,
442 UsbMouseDevice
->IntEndpointDescriptor
.Interval
,
448 Status
= gBS
->UninstallProtocolInterface (
450 &gEfiSimplePointerProtocolGuid
,
451 &UsbMouseDevice
->SimplePointerProtocol
453 if (EFI_ERROR (Status
)) {
459 &gEfiUsbIoProtocolGuid
,
460 This
->DriverBindingHandle
,
465 // Free all resources.
467 gBS
->CloseEvent (UsbMouseDevice
->SimplePointerProtocol
.WaitForInput
);
469 if (UsbMouseDevice
->DelayedRecoveryEvent
!= NULL
) {
470 gBS
->CloseEvent (UsbMouseDevice
->DelayedRecoveryEvent
);
471 UsbMouseDevice
->DelayedRecoveryEvent
= NULL
;
474 if (UsbMouseDevice
->ControllerNameTable
!= NULL
) {
475 FreeUnicodeStringTable (UsbMouseDevice
->ControllerNameTable
);
478 FreePool (UsbMouseDevice
);
486 Uses USB I/O to check whether the device is a USB mouse device.
488 @param UsbIo Pointer to a USB I/O protocol instance.
490 @retval TRUE Device is a USB mouse device.
491 @retval FALSE Device is a not USB mouse device.
496 IN EFI_USB_IO_PROTOCOL
*UsbIo
500 EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor
;
503 // Get the default interface descriptor
505 Status
= UsbIo
->UsbGetInterfaceDescriptor (
510 if (EFI_ERROR (Status
)) {
514 if ((InterfaceDescriptor
.InterfaceClass
== CLASS_HID
) &&
515 (InterfaceDescriptor
.InterfaceSubClass
== SUBCLASS_BOOT
) &&
516 (InterfaceDescriptor
.InterfaceProtocol
== PROTOCOL_MOUSE
)
526 Initialize the USB mouse device.
528 This function retrieves and parses HID report descriptor, and
529 initializes state of USB_MOUSE_DEV. Then it sets indefinite idle
530 rate for the device. Finally it creates event for delayed recovery,
531 which deals with device error.
533 @param UsbMouseDev Device instance to be initialized.
535 @retval EFI_SUCCESS USB mouse device successfully initialized..
536 @retval EFI_UNSUPPORTED HID descriptor type is not report descriptor.
537 @retval Other USB mouse device was not initialized successfully.
541 InitializeUsbMouseDevice (
542 IN OUT USB_MOUSE_DEV
*UsbMouseDev
545 EFI_USB_IO_PROTOCOL
*UsbIo
;
548 EFI_USB_HID_DESCRIPTOR
*MouseHidDesc
;
550 EFI_USB_CONFIG_DESCRIPTOR ConfigDesc
;
552 UINT32 TransferResult
;
557 UsbIo
= UsbMouseDev
->UsbIo
;
560 // Get the current configuration descriptor. Note that it doesn't include other descriptors.
562 Status
= UsbIo
->UsbGetConfigDescriptor (
566 if (EFI_ERROR (Status
)) {
571 // By issuing Get_Descriptor(Configuration) request with total length, we get the Configuration descriptor,
572 // all Interface descriptors, all Endpoint descriptors, and the HID descriptor for each interface.
574 Buf
= AllocateZeroPool (ConfigDesc
.TotalLength
);
576 return EFI_OUT_OF_RESOURCES
;
579 Status
= UsbGetDescriptor (
581 (UINT16
)((USB_DESC_TYPE_CONFIG
<< 8) | (ConfigDesc
.ConfigurationValue
- 1)),
583 ConfigDesc
.TotalLength
,
587 if (EFI_ERROR (Status
)) {
594 Head
= (USB_DESC_HEAD
*)Buf
;
598 // Get HID descriptor from the receipt of Get_Descriptor(Configuration) request.
599 // This algorithm is based on the fact that the HID descriptor shall be interleaved
600 // between the interface and endpoint descriptors for HID interfaces.
602 while (Total
< ConfigDesc
.TotalLength
) {
603 if (Head
->Type
== USB_DESC_TYPE_INTERFACE
) {
604 if ((((USB_INTERFACE_DESCRIPTOR
*)Head
)->InterfaceNumber
== UsbMouseDev
->InterfaceDescriptor
.InterfaceNumber
) &&
605 (((USB_INTERFACE_DESCRIPTOR
*)Head
)->AlternateSetting
== UsbMouseDev
->InterfaceDescriptor
.AlternateSetting
)) {
609 if (Start
&& (Head
->Type
== USB_DESC_TYPE_ENDPOINT
)) {
612 if (Start
&& (Head
->Type
== USB_DESC_TYPE_HID
)) {
613 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
;
671 if (UsbMouseDev
->NumberOfButtons
> 1) {
672 UsbMouseDev
->Mode
.RightButton
= TRUE
;
674 UsbMouseDev
->Mode
.ResolutionX
= 8;
675 UsbMouseDev
->Mode
.ResolutionY
= 8;
676 UsbMouseDev
->Mode
.ResolutionZ
= 0;
679 // Set boot protocol for the USB mouse.
680 // This driver only supports boot protocol.
682 UsbGetProtocolRequest (
684 UsbMouseDev
->InterfaceDescriptor
.InterfaceNumber
,
687 if (Protocol
!= BOOT_PROTOCOL
) {
688 Status
= UsbSetProtocolRequest (
690 UsbMouseDev
->InterfaceDescriptor
.InterfaceNumber
,
694 if (EFI_ERROR (Status
)) {
696 FreePool (ReportDesc
);
702 FreePool (ReportDesc
);
705 // Create event for delayed recovery, which deals with device error.
707 if (UsbMouseDev
->DelayedRecoveryEvent
!= NULL
) {
708 gBS
->CloseEvent (UsbMouseDev
->DelayedRecoveryEvent
);
709 UsbMouseDev
->DelayedRecoveryEvent
= 0;
713 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
715 USBMouseRecoveryHandler
,
717 &UsbMouseDev
->DelayedRecoveryEvent
725 Handler function for USB mouse's asynchronous interrupt transfer.
727 This function is the handler function for USB mouse's asynchronous interrupt transfer
728 to manage the mouse. It parses data returned from asynchronous interrupt transfer, and
729 get button and movement state.
731 @param Data A pointer to a buffer that is filled with key data which is
732 retrieved via asynchronous interrupt transfer.
733 @param DataLength Indicates the size of the data buffer.
734 @param Context Pointing to USB_KB_DEV instance.
735 @param Result Indicates the result of the asynchronous interrupt transfer.
737 @retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.
738 @retval EFI_DEVICE_ERROR Hardware error occurs.
743 OnMouseInterruptComplete (
750 USB_MOUSE_DEV
*UsbMouseDevice
;
751 EFI_USB_IO_PROTOCOL
*UsbIo
;
755 UsbMouseDevice
= (USB_MOUSE_DEV
*) Context
;
756 UsbIo
= UsbMouseDevice
->UsbIo
;
758 if (Result
!= EFI_USB_NOERROR
) {
760 // Some errors happen during the process
762 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
763 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
764 (EFI_PERIPHERAL_MOUSE
| EFI_P_EC_INPUT_ERROR
),
765 UsbMouseDevice
->DevicePath
768 if ((Result
& EFI_USB_ERR_STALL
) == EFI_USB_ERR_STALL
) {
769 EndpointAddr
= UsbMouseDevice
->IntEndpointDescriptor
.EndpointAddress
;
771 UsbClearEndpointHalt (
779 // Delete & Submit this interrupt again
780 // Handler of DelayedRecoveryEvent triggered by timer will re-submit the interrupt.
782 UsbIo
->UsbAsyncInterruptTransfer (
784 UsbMouseDevice
->IntEndpointDescriptor
.EndpointAddress
,
792 // EFI_USB_INTERRUPT_DELAY is defined in USB standard for error handling.
795 UsbMouseDevice
->DelayedRecoveryEvent
,
797 EFI_USB_INTERRUPT_DELAY
799 return EFI_DEVICE_ERROR
;
803 // If no error and no data, just return EFI_SUCCESS.
805 if (DataLength
== 0 || Data
== NULL
) {
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 if (DataLength
< 3) {
822 return EFI_DEVICE_ERROR
;
825 UsbMouseDevice
->StateChanged
= TRUE
;
827 UsbMouseDevice
->State
.LeftButton
= (BOOLEAN
) ((*(UINT8
*) Data
& BIT0
) != 0);
828 UsbMouseDevice
->State
.RightButton
= (BOOLEAN
) ((*(UINT8
*) Data
& BIT1
) != 0);
829 UsbMouseDevice
->State
.RelativeMovementX
+= *((INT8
*) Data
+ 1);
830 UsbMouseDevice
->State
.RelativeMovementY
+= *((INT8
*) Data
+ 2);
832 if (DataLength
> 3) {
833 UsbMouseDevice
->State
.RelativeMovementZ
+= *((INT8
*) Data
+ 3);
840 Retrieves the current state of a pointer device.
842 @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL instance.
843 @param MouseState A pointer to the state information on the pointer device.
845 @retval EFI_SUCCESS The state of the pointer device was returned in State.
846 @retval EFI_NOT_READY The state of the pointer device has not changed since the last call to
848 @retval EFI_DEVICE_ERROR A device error occurred while attempting to retrieve the pointer device's
850 @retval EFI_INVALID_PARAMETER MouseState is NULL.
856 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
857 OUT EFI_SIMPLE_POINTER_STATE
*MouseState
860 USB_MOUSE_DEV
*MouseDev
;
862 if (MouseState
== NULL
) {
863 return EFI_INVALID_PARAMETER
;
866 MouseDev
= USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (This
);
868 if (!MouseDev
->StateChanged
) {
869 return EFI_NOT_READY
;
873 // Retrieve mouse state from USB_MOUSE_DEV, which was filled by OnMouseInterruptComplete()
878 sizeof (EFI_SIMPLE_POINTER_STATE
)
882 // Clear previous move state
884 MouseDev
->State
.RelativeMovementX
= 0;
885 MouseDev
->State
.RelativeMovementY
= 0;
886 MouseDev
->State
.RelativeMovementZ
= 0;
888 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
,