2 USB Mouse Driver that manages USB mouse and produces Absolute Pointer Protocol.
4 Copyright (c) 2004 - 2010, 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.
15 #include "UsbMouseAbsolutePointer.h"
17 EFI_DRIVER_BINDING_PROTOCOL gUsbMouseAbsolutePointerDriverBinding
= {
18 USBMouseAbsolutePointerDriverBindingSupported
,
19 USBMouseAbsolutePointerDriverBindingStart
,
20 USBMouseAbsolutePointerDriverBindingStop
,
27 Entrypoint of USB Mouse Absolute Pointer 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 USBMouseAbsolutePointerDriverBindingEntryPoint (
41 IN EFI_HANDLE ImageHandle
,
42 IN EFI_SYSTEM_TABLE
*SystemTable
47 Status
= EfiLibInstallDriverBindingComponentName2 (
50 &gUsbMouseAbsolutePointerDriverBinding
,
52 &gUsbMouseAbsolutePointerComponentName
,
53 &gUsbMouseAbsolutePointerComponentName2
55 ASSERT_EFI_ERROR (Status
);
62 Check whether USB Mouse Absolute Pointer Driver supports this device.
64 @param This The 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 USBMouseAbsolutePointerDriverBindingSupported (
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 Absolute Pointer Protocol, and submits Asynchronous Interrupt
120 Transfer to manage the USB mouse device.
122 @param This The 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 USBMouseAbsolutePointerDriverBindingStart (
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_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDevice
;
145 UINT8 EndpointNumber
;
146 EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor
;
149 UINT8 PollingInterval
;
154 // Open USB I/O Protocol
156 Status
= gBS
->OpenProtocol (
158 &gEfiUsbIoProtocolGuid
,
160 This
->DriverBindingHandle
,
162 EFI_OPEN_PROTOCOL_BY_DRIVER
164 if (EFI_ERROR (Status
)) {
168 UsbMouseAbsolutePointerDevice
= AllocateZeroPool (sizeof (USB_MOUSE_ABSOLUTE_POINTER_DEV
));
169 ASSERT (UsbMouseAbsolutePointerDevice
!= NULL
);
171 UsbMouseAbsolutePointerDevice
->UsbIo
= UsbIo
;
172 UsbMouseAbsolutePointerDevice
->Signature
= USB_MOUSE_ABSOLUTE_POINTER_DEV_SIGNATURE
;
175 // Get the Device Path Protocol on Controller's handle
177 Status
= gBS
->OpenProtocol (
179 &gEfiDevicePathProtocolGuid
,
180 (VOID
**) &UsbMouseAbsolutePointerDevice
->DevicePath
,
181 This
->DriverBindingHandle
,
183 EFI_OPEN_PROTOCOL_GET_PROTOCOL
186 if (EFI_ERROR (Status
)) {
190 // Get interface & endpoint descriptor
192 UsbIo
->UsbGetInterfaceDescriptor (
194 &UsbMouseAbsolutePointerDevice
->InterfaceDescriptor
197 EndpointNumber
= UsbMouseAbsolutePointerDevice
->InterfaceDescriptor
.NumEndpoints
;
200 // Traverse endpoints to find interrupt endpoint
203 for (Index
= 0; Index
< EndpointNumber
; Index
++) {
204 UsbIo
->UsbGetEndpointDescriptor (
210 if ((EndpointDescriptor
.Attributes
& (BIT0
| BIT1
)) == USB_ENDPOINT_INTERRUPT
) {
212 // We only care interrupt endpoint here
214 CopyMem (&UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
, &EndpointDescriptor
, sizeof(EndpointDescriptor
));
222 // No interrupt endpoint found, then return unsupported.
224 Status
= EFI_UNSUPPORTED
;
228 Status
= InitializeUsbMouseDevice (UsbMouseAbsolutePointerDevice
);
229 if (EFI_ERROR (Status
)) {
231 // Fail to initialize USB mouse device.
233 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
234 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
235 (EFI_PERIPHERAL_MOUSE
| EFI_P_EC_INTERFACE_ERROR
),
236 UsbMouseAbsolutePointerDevice
->DevicePath
243 // Initialize and install EFI Absolute Pointer Protocol.
245 UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
.GetState
= GetMouseAbsolutePointerState
;
246 UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
.Reset
= UsbMouseAbsolutePointerReset
;
247 UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
.Mode
= &UsbMouseAbsolutePointerDevice
->Mode
;
249 Status
= gBS
->CreateEvent (
252 UsbMouseAbsolutePointerWaitForInput
,
253 UsbMouseAbsolutePointerDevice
,
254 &((UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
).WaitForInput
)
256 if (EFI_ERROR (Status
)) {
260 Status
= gBS
->InstallProtocolInterface (
262 &gEfiAbsolutePointerProtocolGuid
,
263 EFI_NATIVE_INTERFACE
,
264 &UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
267 if (EFI_ERROR (Status
)) {
272 // The next step would be submitting Asynchronous Interrupt Transfer on this mouse device.
273 // After that we will be able to get key data from it. Thus this is deemed as
274 // the enable action of the mouse, so report status code accordingly.
276 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
278 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_ENABLE
),
279 UsbMouseAbsolutePointerDevice
->DevicePath
283 // Submit Asynchronous Interrupt Transfer to manage this device.
285 EndpointAddr
= UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
.EndpointAddress
;
286 PollingInterval
= UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
.Interval
;
287 PacketSize
= (UINT8
) (UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
.MaxPacketSize
);
289 Status
= UsbIo
->UsbAsyncInterruptTransfer (
295 OnMouseInterruptComplete
,
296 UsbMouseAbsolutePointerDevice
299 if (EFI_ERROR (Status
)) {
301 // If submit error, uninstall that interface
303 gBS
->UninstallProtocolInterface (
305 &gEfiAbsolutePointerProtocolGuid
,
306 &UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
311 UsbMouseAbsolutePointerDevice
->ControllerNameTable
= NULL
;
314 gUsbMouseAbsolutePointerComponentName
.SupportedLanguages
,
315 &UsbMouseAbsolutePointerDevice
->ControllerNameTable
,
316 L
"Generic Usb Mouse Absolute Pointer",
321 gUsbMouseAbsolutePointerComponentName2
.SupportedLanguages
,
322 &UsbMouseAbsolutePointerDevice
->ControllerNameTable
,
323 L
"Generic Usb Mouse Absolute Pointer",
333 if (EFI_ERROR (Status
)) {
336 &gEfiUsbIoProtocolGuid
,
337 This
->DriverBindingHandle
,
341 if (UsbMouseAbsolutePointerDevice
!= NULL
) {
342 if ((UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
).WaitForInput
!= NULL
) {
343 gBS
->CloseEvent ((UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
).WaitForInput
);
346 FreePool (UsbMouseAbsolutePointerDevice
);
347 UsbMouseAbsolutePointerDevice
= NULL
;
356 Stop the USB mouse device handled by this driver.
358 @param This The driver binding protocol.
359 @param Controller The controller to release.
360 @param NumberOfChildren The number of handles in ChildHandleBuffer.
361 @param ChildHandleBuffer The array of child handle.
363 @retval EFI_SUCCESS The device was stopped.
364 @retval EFI_UNSUPPORTED Absolute Pointer Protocol is not installed on Controller.
365 @retval Others Fail to uninstall protocols attached on the device.
370 USBMouseAbsolutePointerDriverBindingStop (
371 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
372 IN EFI_HANDLE Controller
,
373 IN UINTN NumberOfChildren
,
374 IN EFI_HANDLE
*ChildHandleBuffer
378 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDevice
;
379 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointerProtocol
;
380 EFI_USB_IO_PROTOCOL
*UsbIo
;
382 Status
= gBS
->OpenProtocol (
384 &gEfiAbsolutePointerProtocolGuid
,
385 (VOID
**) &AbsolutePointerProtocol
,
386 This
->DriverBindingHandle
,
388 EFI_OPEN_PROTOCOL_GET_PROTOCOL
391 if (EFI_ERROR (Status
)) {
392 return EFI_UNSUPPORTED
;
395 UsbMouseAbsolutePointerDevice
= USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL (AbsolutePointerProtocol
);
397 UsbIo
= UsbMouseAbsolutePointerDevice
->UsbIo
;
400 // The key data input from this device will be disabled.
402 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
404 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_DISABLE
),
405 UsbMouseAbsolutePointerDevice
->DevicePath
409 // Delete the Asynchronous Interrupt Transfer from this device
411 UsbIo
->UsbAsyncInterruptTransfer (
413 UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
.EndpointAddress
,
415 UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
.Interval
,
421 Status
= gBS
->UninstallProtocolInterface (
423 &gEfiAbsolutePointerProtocolGuid
,
424 &UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
426 if (EFI_ERROR (Status
)) {
432 &gEfiUsbIoProtocolGuid
,
433 This
->DriverBindingHandle
,
438 // Free all resources.
440 gBS
->CloseEvent (UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
.WaitForInput
);
442 if (UsbMouseAbsolutePointerDevice
->DelayedRecoveryEvent
!= NULL
) {
443 gBS
->CloseEvent (UsbMouseAbsolutePointerDevice
->DelayedRecoveryEvent
);
444 UsbMouseAbsolutePointerDevice
->DelayedRecoveryEvent
= NULL
;
447 if (UsbMouseAbsolutePointerDevice
->ControllerNameTable
!= NULL
) {
448 FreeUnicodeStringTable (UsbMouseAbsolutePointerDevice
->ControllerNameTable
);
451 FreePool (UsbMouseAbsolutePointerDevice
);
459 Uses USB I/O to check whether the device is a USB mouse device.
461 @param UsbIo Pointer to a USB I/O protocol instance.
463 @retval TRUE Device is a USB mouse device.
464 @retval FALSE Device is a not USB mouse device.
469 IN EFI_USB_IO_PROTOCOL
*UsbIo
473 EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor
;
476 // Get the default interface descriptor
478 Status
= UsbIo
->UsbGetInterfaceDescriptor (
483 if (EFI_ERROR (Status
)) {
487 if ((InterfaceDescriptor
.InterfaceClass
== CLASS_HID
) &&
488 (InterfaceDescriptor
.InterfaceSubClass
== SUBCLASS_BOOT
) &&
489 (InterfaceDescriptor
.InterfaceProtocol
== PROTOCOL_MOUSE
)
499 Initialize the USB mouse device.
501 This function retrieves and parses HID report descriptor, and
502 initializes state of USB_MOUSE_ABSOLUTE_POINTER_DEV. Then it sets indefinite idle
503 rate for the device. Finally it creates event for delayed recovery,
504 which deals with device error.
506 @param UsbMouseAbsolutePointerDev Device instance to be initialized.
508 @retval EFI_SUCCESS USB mouse device successfully initialized.
509 @retval EFI_UNSUPPORTED HID descriptor type is not report descriptor.
510 @retval Other USB mouse device was not initialized successfully.
514 InitializeUsbMouseDevice (
515 IN USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDev
518 EFI_USB_IO_PROTOCOL
*UsbIo
;
521 EFI_USB_HID_DESCRIPTOR MouseHidDesc
;
526 UsbIo
= UsbMouseAbsolutePointerDev
->UsbIo
;
529 // Get HID descriptor
531 Status
= UsbGetHidDescriptor (
533 UsbMouseAbsolutePointerDev
->InterfaceDescriptor
.InterfaceNumber
,
536 if (EFI_ERROR (Status
)) {
541 // Get report descriptor
543 if (MouseHidDesc
.HidClassDesc
[0].DescriptorType
!= USB_DESC_TYPE_REPORT
) {
544 return EFI_UNSUPPORTED
;
547 ReportDesc
= AllocateZeroPool (MouseHidDesc
.HidClassDesc
[0].DescriptorLength
);
548 ASSERT (ReportDesc
!= NULL
);
550 Status
= UsbGetReportDescriptor (
552 UsbMouseAbsolutePointerDev
->InterfaceDescriptor
.InterfaceNumber
,
553 MouseHidDesc
.HidClassDesc
[0].DescriptorLength
,
557 if (EFI_ERROR (Status
)) {
558 FreePool (ReportDesc
);
563 // Parse report descriptor
565 Status
= ParseMouseReportDescriptor (
566 UsbMouseAbsolutePointerDev
,
568 MouseHidDesc
.HidClassDesc
[0].DescriptorLength
571 if (EFI_ERROR (Status
)) {
572 FreePool (ReportDesc
);
576 UsbMouseAbsolutePointerDev
->Mode
.AbsoluteMaxX
= 1024;
577 UsbMouseAbsolutePointerDev
->Mode
.AbsoluteMaxY
= 1024;
578 UsbMouseAbsolutePointerDev
->Mode
.AbsoluteMaxZ
= 0;
579 UsbMouseAbsolutePointerDev
->Mode
.AbsoluteMinX
= 0;
580 UsbMouseAbsolutePointerDev
->Mode
.AbsoluteMinY
= 0;
581 UsbMouseAbsolutePointerDev
->Mode
.AbsoluteMinZ
= 0;
582 UsbMouseAbsolutePointerDev
->Mode
.Attributes
= 0x3;
585 // Set boot protocol for the USB mouse.
586 // This driver only supports boot protocol.
588 UsbGetProtocolRequest (
590 UsbMouseAbsolutePointerDev
->InterfaceDescriptor
.InterfaceNumber
,
593 if (Protocol
!= BOOT_PROTOCOL
) {
594 Status
= UsbSetProtocolRequest (
600 if (EFI_ERROR (Status
)) {
601 FreePool (ReportDesc
);
607 // ReportId is zero, which means the idle rate applies to all input reports.
611 // Duration is zero, which means the duration is infinite.
612 // so the endpoint will inhibit reporting forever,
613 // and only reporting when a change is detected in the report data.
618 UsbMouseAbsolutePointerDev
->InterfaceDescriptor
.InterfaceNumber
,
623 FreePool (ReportDesc
);
626 // Create event for delayed recovery, which deals with device error.
628 if (UsbMouseAbsolutePointerDev
->DelayedRecoveryEvent
!= NULL
) {
629 gBS
->CloseEvent (UsbMouseAbsolutePointerDev
->DelayedRecoveryEvent
);
630 UsbMouseAbsolutePointerDev
->DelayedRecoveryEvent
= 0;
634 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
636 USBMouseRecoveryHandler
,
637 UsbMouseAbsolutePointerDev
,
638 &UsbMouseAbsolutePointerDev
->DelayedRecoveryEvent
646 Handler function for USB mouse's asynchronous interrupt transfer.
648 This function is the handler function for USB mouse's asynchronous interrupt transfer
649 to manage the mouse. It parses data returned from asynchronous interrupt transfer, and
650 get button and movement state.
652 @param Data A pointer to a buffer that is filled with key data which is
653 retrieved via asynchronous interrupt transfer.
654 @param DataLength Indicates the size of the data buffer.
655 @param Context Pointing to USB_KB_DEV instance.
656 @param Result Indicates the result of the asynchronous interrupt transfer.
658 @retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.
659 @retval EFI_DEVICE_ERROR Hardware error occurs.
664 OnMouseInterruptComplete (
671 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDevice
;
672 EFI_USB_IO_PROTOCOL
*UsbIo
;
676 UsbMouseAbsolutePointerDevice
= (USB_MOUSE_ABSOLUTE_POINTER_DEV
*) Context
;
677 UsbIo
= UsbMouseAbsolutePointerDevice
->UsbIo
;
679 if (Result
!= EFI_USB_NOERROR
) {
681 // Some errors happen during the process
683 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
684 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
685 (EFI_PERIPHERAL_MOUSE
| EFI_P_EC_INPUT_ERROR
),
686 UsbMouseAbsolutePointerDevice
->DevicePath
689 if ((Result
& EFI_USB_ERR_STALL
) == EFI_USB_ERR_STALL
) {
690 EndpointAddr
= UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
.EndpointAddress
;
692 UsbClearEndpointHalt (
700 // Delete & Submit this interrupt again
701 // Handler of DelayedRecoveryEvent triggered by timer will re-submit the interrupt.
703 UsbIo
->UsbAsyncInterruptTransfer (
705 UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
.EndpointAddress
,
713 // EFI_USB_INTERRUPT_DELAY is defined in USB standard for error handling.
716 UsbMouseAbsolutePointerDevice
->DelayedRecoveryEvent
,
718 EFI_USB_INTERRUPT_DELAY
720 return EFI_DEVICE_ERROR
;
724 // If no error and no data, just return EFI_SUCCESS.
726 if (DataLength
== 0 || Data
== NULL
) {
730 UsbMouseAbsolutePointerDevice
->StateChanged
= TRUE
;
734 // USB HID Specification specifies following data format:
735 // Byte Bits Description
739 // 4 to 7 Device-specific
740 // 1 0 to 7 X displacement
741 // 2 0 to 7 Y displacement
742 // 3 to n 0 to 7 Device specific (optional)
744 UsbMouseAbsolutePointerDevice
->State
.CurrentX
+= *((INT8
*) Data
+ 1);
745 UsbMouseAbsolutePointerDevice
->State
.CurrentY
+= *((INT8
*) Data
+ 2);
747 if (DataLength
> 3) {
748 UsbMouseAbsolutePointerDevice
->State
.CurrentZ
+= *((INT8
*) Data
+ 3);
750 UsbMouseAbsolutePointerDevice
->State
.ActiveButtons
= *(UINT8
*) Data
& (BIT0
| BIT1
);
756 Retrieves the current state of a pointer device.
758 @param This A pointer to the EFI_ABSOLUTE_POINTER_PROTOCOL instance.
759 @param MouseState A pointer to the state information on the pointer device.
761 @retval EFI_SUCCESS The state of the pointer device was returned in State.
762 @retval EFI_NOT_READY The state of the pointer device has not changed since the last call to
764 @retval EFI_DEVICE_ERROR A device error occurred while attempting to retrieve the pointer device's
766 @retval EFI_INVALID_PARAMETER State is NULL.
771 GetMouseAbsolutePointerState (
772 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
773 OUT EFI_ABSOLUTE_POINTER_STATE
*State
776 USB_MOUSE_ABSOLUTE_POINTER_DEV
*MouseAbsolutePointerDev
;
779 return EFI_INVALID_PARAMETER
;
782 MouseAbsolutePointerDev
= USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL (This
);
784 if (!MouseAbsolutePointerDev
->StateChanged
) {
785 return EFI_NOT_READY
;
789 // Retrieve mouse state from USB_MOUSE_ABSOLUTE_POINTER_DEV,
790 // which was filled by OnMouseInterruptComplete()
794 &MouseAbsolutePointerDev
->State
,
795 sizeof (EFI_ABSOLUTE_POINTER_STATE
)
799 // Clear previous move state
801 MouseAbsolutePointerDev
->State
.CurrentX
= 0;
802 MouseAbsolutePointerDev
->State
.CurrentY
= 0;
803 MouseAbsolutePointerDev
->State
.CurrentZ
= 0;
804 MouseAbsolutePointerDev
->State
.ActiveButtons
= 0;
806 MouseAbsolutePointerDev
->StateChanged
= FALSE
;
813 Resets the pointer device hardware.
815 @param This A pointer to the EFI_ABSOLUTE_POINTER_PROTOCOL instance.
816 @param ExtendedVerification Indicates that the driver may perform a more exhaustive
817 verification operation of the device during reset.
819 @retval EFI_SUCCESS The device was reset.
820 @retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset.
825 UsbMouseAbsolutePointerReset (
826 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
827 IN BOOLEAN ExtendedVerification
830 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDevice
;
832 UsbMouseAbsolutePointerDevice
= USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL (This
);
834 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
836 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_RESET
),
837 UsbMouseAbsolutePointerDevice
->DevicePath
841 // Clear mouse state.
844 &UsbMouseAbsolutePointerDevice
->State
,
845 sizeof (EFI_ABSOLUTE_POINTER_STATE
)
847 UsbMouseAbsolutePointerDevice
->StateChanged
= FALSE
;
853 Event notification function for EFI_ABSOLUTE_POINTER_PROTOCOL.WaitForInput event.
855 @param Event Event to be signaled when there's input from mouse.
856 @param Context Points to USB_MOUSE_ABSOLUTE_POINTER_DEV instance.
861 UsbMouseAbsolutePointerWaitForInput (
866 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDev
;
868 UsbMouseAbsolutePointerDev
= (USB_MOUSE_ABSOLUTE_POINTER_DEV
*) Context
;
871 // If there's input from mouse, signal the event.
873 if (UsbMouseAbsolutePointerDev
->StateChanged
) {
874 gBS
->SignalEvent (Event
);
879 Handler for Delayed Recovery event.
881 This function is the handler for Delayed Recovery event triggered
883 After a device error occurs, the event would be triggered
884 with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY
885 is defined in USB standard for error handling.
887 @param Event The Delayed Recovery event.
888 @param Context Points to the USB_MOUSE_ABSOLUTE_POINTER_DEV instance.
893 USBMouseRecoveryHandler (
898 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDev
;
899 EFI_USB_IO_PROTOCOL
*UsbIo
;
901 UsbMouseAbsolutePointerDev
= (USB_MOUSE_ABSOLUTE_POINTER_DEV
*) Context
;
903 UsbIo
= UsbMouseAbsolutePointerDev
->UsbIo
;
906 // Re-submit Asynchronous Interrupt Transfer for recovery.
908 UsbIo
->UsbAsyncInterruptTransfer (
910 UsbMouseAbsolutePointerDev
->IntEndpointDescriptor
.EndpointAddress
,
912 UsbMouseAbsolutePointerDev
->IntEndpointDescriptor
.Interval
,
913 UsbMouseAbsolutePointerDev
->IntEndpointDescriptor
.MaxPacketSize
,
914 OnMouseInterruptComplete
,
915 UsbMouseAbsolutePointerDev