3 Usb Mouse Driver Binding and Implement SIMPLE_POINTER_PROTOCOL Protocol.
5 Copyright (c) 2004 - 2008, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include <Library/DebugLib.h>
19 #include <IndustryStandard/Usb.h>
26 The USB Mouse driver entry pointer.
28 @param ImageHandle The driver image handle.
29 @param SystemTable The system table.
31 @return EFI_SUCCESS The component name protocol is installed.
32 @return Others Failed to init the usb driver.
37 USBMouseDriverBindingEntryPoint (
38 IN EFI_HANDLE ImageHandle
,
39 IN EFI_SYSTEM_TABLE
*SystemTable
43 Test to see if this driver supports ControllerHandle. Any ControllerHandle
44 that has UsbIoProtocol installed will be supported.
46 @param This Protocol instance pointer.
47 @param Controller Handle of device to test.
48 @param RemainingDevicePath Not used.
50 @retval EFI_SUCCESS This driver supports this device.
51 @retval EFI_UNSUPPORTED This driver does not support this device.
56 USBMouseDriverBindingSupported (
57 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
58 IN EFI_HANDLE Controller
,
59 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
63 Starting the Usb Mouse Driver.
65 @param This Protocol instance pointer.
66 @param Controller Handle of device to test
67 @param RemainingDevicePath Not used
69 @retval EFI_SUCCESS This driver supports this device.
70 @retval EFI_UNSUPPORTED This driver does not support this device.
71 @retval EFI_DEVICE_ERROR This driver cannot be started due to device Error.
72 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
73 @retval EFI_ALREADY_STARTED Thios driver has been started.
78 USBMouseDriverBindingStart (
79 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
80 IN EFI_HANDLE Controller
,
81 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
85 Stop this driver on ControllerHandle. Support stoping any child handles
86 created by this driver.
88 @param This Protocol instance pointer.
89 @param Controller Handle of device to stop driver on.
90 @param NumberOfChildren Number of Children in the ChildHandleBuffer.
91 @param ChildHandleBuffer List of handles for the children we need to stop.
93 @retval EFI_SUCCESS The controller or children are stopped.
94 @retval Other Failed to stop the driver.
99 USBMouseDriverBindingStop (
100 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
101 IN EFI_HANDLE Controller
,
102 IN UINTN NumberOfChildren
,
103 IN EFI_HANDLE
*ChildHandleBuffer
106 EFI_GUID gEfiUsbMouseDriverGuid
= {
107 0x290156b5, 0x6a05, 0x4ac0, {0xb8, 0x0, 0x51, 0x27, 0x55, 0xad, 0x14, 0x29}
110 EFI_DRIVER_BINDING_PROTOCOL gUsbMouseDriverBinding
= {
111 USBMouseDriverBindingSupported
,
112 USBMouseDriverBindingStart
,
113 USBMouseDriverBindingStop
,
120 Tell if a Usb Controller is a mouse.
122 @param UsbIo Protocol instance pointer.
124 @retval TRUE It is a mouse.
125 @retval FALSE It is not a mouse.
130 IN EFI_USB_IO_PROTOCOL
*UsbIo
134 Initialize the Usb Mouse Device.
136 @param UsbMouseDev Device instance to be initialized.
138 @retval EFI_SUCCESS Success.
139 @retval EFI_OUT_OF_RESOURCES Can't allocate memory.
140 @retval Other Init error.
144 InitializeUsbMouseDevice (
145 IN USB_MOUSE_DEV
*UsbMouseDev
149 Event notification function for SIMPLE_POINTER.WaitForInput event
150 Signal the event if there is input from mouse.
152 @param Event Wait Event.
153 @param Context Passed parameter to event handler.
158 UsbMouseWaitForInput (
164 It is called whenever there is data received from async interrupt
167 @param Data Data received.
168 @param DataLength Length of Data.
169 @param Context Passed in context.
170 @param Result Async Interrupt Transfer result.
172 @return EFI_SUCCESS Receive data successfully.
173 @return EFI_DEVICE_ERROR USB async interrupt transfer fails.
178 OnMouseInterruptComplete (
186 Get the mouse state, see SIMPLE POINTER PROTOCOL.
188 @param This Protocol instance pointer.
189 @param MouseState Current mouse state.
191 @return EFI_SUCCESS Get usb mouse status successfully.
192 @return EFI_DEVICE_ERROR The parameter is error.
193 @return EFI_NOT_READY Mouse status doesn't change.
199 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
200 OUT EFI_SIMPLE_POINTER_STATE
*MouseState
204 Reset the mouse device, see SIMPLE POINTER PROTOCOL.
206 @param This Protocol instance pointer.
207 @param ExtendedVerification Ignored here.
209 @return EFI_SUCCESS Reset usb mouse successfully.
215 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
216 IN BOOLEAN ExtendedVerification
221 The USB Mouse driver entry pointer.
223 @param ImageHandle The driver image handle.
224 @param SystemTable The system table.
226 @return EFI_SUCCESS The component name protocol is installed.
227 @return Others Failed to init the usb driver.
232 USBMouseDriverBindingEntryPoint (
233 IN EFI_HANDLE ImageHandle
,
234 IN EFI_SYSTEM_TABLE
*SystemTable
237 return EfiLibInstallDriverBindingComponentName2 (
240 &gUsbMouseDriverBinding
,
242 &gUsbMouseComponentName
,
243 &gUsbMouseComponentName2
249 Test to see if this driver supports ControllerHandle. Any ControllerHandle
250 that has UsbIoProtocol installed will be supported.
252 @param This Protocol instance pointer.
253 @param Controller Handle of device to test
254 @param RemainingDevicePath Not used.
256 @retval EFI_SUCCESS This driver supports this device.
257 @retval EFI_UNSUPPORTED This driver does not support this device.
262 USBMouseDriverBindingSupported (
263 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
264 IN EFI_HANDLE Controller
,
265 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
268 EFI_STATUS OpenStatus
;
269 EFI_USB_IO_PROTOCOL
*UsbIo
;
272 OpenStatus
= gBS
->OpenProtocol (
274 &gEfiUsbIoProtocolGuid
,
276 This
->DriverBindingHandle
,
278 EFI_OPEN_PROTOCOL_BY_DRIVER
280 if (EFI_ERROR (OpenStatus
) && (OpenStatus
!= EFI_ALREADY_STARTED
)) {
281 return EFI_UNSUPPORTED
;
284 if (OpenStatus
== EFI_ALREADY_STARTED
) {
285 return EFI_ALREADY_STARTED
;
289 // Use the USB I/O protocol interface to see the Controller is
290 // the Mouse controller that can be managed by this driver.
292 Status
= EFI_SUCCESS
;
293 if (!IsUsbMouse (UsbIo
)) {
294 Status
= EFI_UNSUPPORTED
;
299 &gEfiUsbIoProtocolGuid
,
300 This
->DriverBindingHandle
,
308 Starting the Usb Mouse Driver.
310 @param This Protocol instance pointer.
311 @param Controller Handle of device to test.
312 @param RemainingDevicePath Not used.
314 @retval EFI_SUCCESS This driver supports this device.
315 @retval EFI_UNSUPPORTED This driver does not support this device.
316 @retval EFI_DEVICE_ERROR This driver cannot be started due to device Error.
317 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
318 @retval EFI_ALREADY_STARTED Thios driver has been started.
323 USBMouseDriverBindingStart (
324 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
325 IN EFI_HANDLE Controller
,
326 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
330 EFI_USB_IO_PROTOCOL
*UsbIo
;
331 EFI_USB_ENDPOINT_DESCRIPTOR
*EndpointDesc
;
332 USB_MOUSE_DEV
*UsbMouseDevice
;
333 UINT8 EndpointNumber
;
336 UINT8 PollingInterval
;
339 UsbMouseDevice
= NULL
;
340 Status
= EFI_SUCCESS
;
342 Status
= gBS
->OpenProtocol (
344 &gEfiUsbIoProtocolGuid
,
346 This
->DriverBindingHandle
,
348 EFI_OPEN_PROTOCOL_BY_DRIVER
350 if (EFI_ERROR (Status
)) {
354 UsbMouseDevice
= AllocateZeroPool (sizeof (USB_MOUSE_DEV
));
355 if (UsbMouseDevice
== NULL
) {
356 Status
= EFI_OUT_OF_RESOURCES
;
360 UsbMouseDevice
->UsbIo
= UsbIo
;
362 UsbMouseDevice
->Signature
= USB_MOUSE_DEV_SIGNATURE
;
364 UsbMouseDevice
->InterfaceDescriptor
= AllocatePool (sizeof (EFI_USB_INTERFACE_DESCRIPTOR
));
365 if (UsbMouseDevice
->InterfaceDescriptor
== NULL
) {
366 Status
= EFI_OUT_OF_RESOURCES
;
370 EndpointDesc
= AllocatePool (sizeof (EFI_USB_ENDPOINT_DESCRIPTOR
));
371 if (EndpointDesc
== NULL
) {
372 Status
= EFI_OUT_OF_RESOURCES
;
376 // Get the Device Path Protocol on Controller's handle
378 Status
= gBS
->OpenProtocol (
380 &gEfiDevicePathProtocolGuid
,
381 (VOID
**) &UsbMouseDevice
->DevicePath
,
382 This
->DriverBindingHandle
,
384 EFI_OPEN_PROTOCOL_GET_PROTOCOL
387 if (EFI_ERROR (Status
)) {
391 // Get interface & endpoint descriptor
393 UsbIo
->UsbGetInterfaceDescriptor (
395 UsbMouseDevice
->InterfaceDescriptor
398 EndpointNumber
= UsbMouseDevice
->InterfaceDescriptor
->NumEndpoints
;
400 for (Index
= 0; Index
< EndpointNumber
; Index
++) {
401 UsbIo
->UsbGetEndpointDescriptor (
407 if ((EndpointDesc
->Attributes
& 0x03) == 0x03) {
410 // We only care interrupt endpoint here
412 UsbMouseDevice
->IntEndpointDescriptor
= EndpointDesc
;
416 if (UsbMouseDevice
->IntEndpointDescriptor
== NULL
) {
418 // No interrupt endpoint, then error
420 Status
= EFI_UNSUPPORTED
;
424 Status
= InitializeUsbMouseDevice (UsbMouseDevice
);
425 if (EFI_ERROR (Status
)) {
426 MouseReportStatusCode (
427 UsbMouseDevice
->DevicePath
,
428 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
429 PcdGet32 (PcdStatusCodeValueMouseInterfaceError
)
435 UsbMouseDevice
->SimplePointerProtocol
.GetState
= GetMouseState
;
436 UsbMouseDevice
->SimplePointerProtocol
.Reset
= UsbMouseReset
;
437 UsbMouseDevice
->SimplePointerProtocol
.Mode
= &UsbMouseDevice
->Mode
;
439 Status
= gBS
->CreateEvent (
442 UsbMouseWaitForInput
,
444 &((UsbMouseDevice
->SimplePointerProtocol
).WaitForInput
)
446 if (EFI_ERROR (Status
)) {
450 Status
= gBS
->InstallProtocolInterface (
452 &gEfiSimplePointerProtocolGuid
,
453 EFI_NATIVE_INTERFACE
,
454 &UsbMouseDevice
->SimplePointerProtocol
457 if (EFI_ERROR (Status
)) {
458 Status
= EFI_DEVICE_ERROR
;
463 // After Enabling Async Interrupt Transfer on this mouse Device
464 // we will be able to get key data from it. Thus this is deemed as
465 // the enable action of the mouse
468 MouseReportStatusCode (
469 UsbMouseDevice
->DevicePath
,
471 PcdGet32 (PcdStatusCodeValueMouseEnable
)
475 // submit async interrupt transfer
477 EndpointAddr
= UsbMouseDevice
->IntEndpointDescriptor
->EndpointAddress
;
478 PollingInterval
= UsbMouseDevice
->IntEndpointDescriptor
->Interval
;
479 PacketSize
= (UINT8
) (UsbMouseDevice
->IntEndpointDescriptor
->MaxPacketSize
);
481 Status
= UsbIo
->UsbAsyncInterruptTransfer (
487 OnMouseInterruptComplete
,
491 if (!EFI_ERROR (Status
)) {
493 UsbMouseDevice
->ControllerNameTable
= NULL
;
496 gUsbMouseComponentName
.SupportedLanguages
,
497 &UsbMouseDevice
->ControllerNameTable
,
498 L
"Generic Usb Mouse",
503 gUsbMouseComponentName2
.SupportedLanguages
,
504 &UsbMouseDevice
->ControllerNameTable
,
505 L
"Generic Usb Mouse",
514 // If submit error, uninstall that interface
516 Status
= EFI_DEVICE_ERROR
;
517 gBS
->UninstallProtocolInterface (
519 &gEfiSimplePointerProtocolGuid
,
520 &UsbMouseDevice
->SimplePointerProtocol
524 if (EFI_ERROR (Status
)) {
527 &gEfiUsbIoProtocolGuid
,
528 This
->DriverBindingHandle
,
532 if (UsbMouseDevice
!= NULL
) {
533 if (UsbMouseDevice
->InterfaceDescriptor
!= NULL
) {
534 gBS
->FreePool (UsbMouseDevice
->InterfaceDescriptor
);
537 if (UsbMouseDevice
->IntEndpointDescriptor
!= NULL
) {
538 gBS
->FreePool (UsbMouseDevice
->IntEndpointDescriptor
);
541 if ((UsbMouseDevice
->SimplePointerProtocol
).WaitForInput
!= NULL
) {
542 gBS
->CloseEvent ((UsbMouseDevice
->SimplePointerProtocol
).WaitForInput
);
545 gBS
->FreePool (UsbMouseDevice
);
546 UsbMouseDevice
= NULL
;
555 Stop this driver on ControllerHandle. Support stoping any child handles
556 created by this driver.
558 @param This Protocol instance pointer.
559 @param Controller Handle of device to stop driver on.
560 @param NumberOfChildren Number of Children in the ChildHandleBuffer.
561 @param ChildHandleBuffer List of handles for the children we need to stop.
563 @retval EFI_SUCCESS The controller or children are stopped.
564 @retval Other Failed to stop the driver.
569 USBMouseDriverBindingStop (
570 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
571 IN EFI_HANDLE Controller
,
572 IN UINTN NumberOfChildren
,
573 IN EFI_HANDLE
*ChildHandleBuffer
577 USB_MOUSE_DEV
*UsbMouseDevice
;
578 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointerProtocol
;
579 EFI_USB_IO_PROTOCOL
*UsbIo
;
582 // Get our context back.
584 Status
= gBS
->OpenProtocol (
586 &gEfiSimplePointerProtocolGuid
,
587 (VOID
**) &SimplePointerProtocol
,
588 This
->DriverBindingHandle
,
590 EFI_OPEN_PROTOCOL_GET_PROTOCOL
593 if (EFI_ERROR (Status
)) {
594 return EFI_UNSUPPORTED
;
597 UsbMouseDevice
= USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (SimplePointerProtocol
);
601 &gEfiSimplePointerProtocolGuid
,
602 This
->DriverBindingHandle
,
606 UsbIo
= UsbMouseDevice
->UsbIo
;
609 // Uninstall the Asyn Interrupt Transfer from this device
610 // will disable the mouse data input from this device
612 MouseReportStatusCode (
613 UsbMouseDevice
->DevicePath
,
615 PcdGet32 (PcdStatusCodeValueMouseDisable
)
619 // Delete Mouse Async Interrupt Transfer
621 UsbIo
->UsbAsyncInterruptTransfer (
623 UsbMouseDevice
->IntEndpointDescriptor
->EndpointAddress
,
625 UsbMouseDevice
->IntEndpointDescriptor
->Interval
,
631 gBS
->CloseEvent (UsbMouseDevice
->SimplePointerProtocol
.WaitForInput
);
633 if (UsbMouseDevice
->DelayedRecoveryEvent
!= NULL
) {
634 gBS
->CloseEvent (UsbMouseDevice
->DelayedRecoveryEvent
);
635 UsbMouseDevice
->DelayedRecoveryEvent
= 0;
638 Status
= gBS
->UninstallProtocolInterface (
640 &gEfiSimplePointerProtocolGuid
,
641 &UsbMouseDevice
->SimplePointerProtocol
643 if (EFI_ERROR (Status
)) {
649 &gEfiUsbIoProtocolGuid
,
650 This
->DriverBindingHandle
,
654 gBS
->FreePool (UsbMouseDevice
->InterfaceDescriptor
);
655 gBS
->FreePool (UsbMouseDevice
->IntEndpointDescriptor
);
657 if (UsbMouseDevice
->ControllerNameTable
!= NULL
) {
658 FreeUnicodeStringTable (UsbMouseDevice
->ControllerNameTable
);
661 gBS
->FreePool (UsbMouseDevice
);
669 Tell if a Usb Controller is a mouse.
671 @param UsbIo Protocol instance pointer.
673 @retval TRUE It is a mouse.
674 @retval FALSE It is not a mouse.
679 IN EFI_USB_IO_PROTOCOL
*UsbIo
683 EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor
;
686 // Get the Default interface descriptor, now we only
687 // suppose it is interface 1
689 Status
= UsbIo
->UsbGetInterfaceDescriptor (
694 if (EFI_ERROR (Status
)) {
698 if ((InterfaceDescriptor
.InterfaceClass
== CLASS_HID
) &&
699 (InterfaceDescriptor
.InterfaceSubClass
== SUBCLASS_BOOT
) &&
700 (InterfaceDescriptor
.InterfaceProtocol
== PROTOCOL_MOUSE
)
710 Initialize the Usb Mouse Device.
712 @param UsbMouseDev Device instance to be initialized.
714 @retval EFI_SUCCESS Success.
715 @retval EFI_OUT_OF_RESOURCES Can't allocate memory.
716 @retval Other Init error.
720 InitializeUsbMouseDevice (
721 IN USB_MOUSE_DEV
*UsbMouseDev
724 EFI_USB_IO_PROTOCOL
*UsbIo
;
727 EFI_USB_HID_DESCRIPTOR MouseHidDesc
;
730 UsbIo
= UsbMouseDev
->UsbIo
;
733 // Get HID descriptor
735 Status
= UsbGetHidDescriptor (
737 UsbMouseDev
->InterfaceDescriptor
->InterfaceNumber
,
741 if (EFI_ERROR (Status
)) {
746 // Get Report descriptor
748 if (MouseHidDesc
.HidClassDesc
[0].DescriptorType
!= 0x22) {
749 return EFI_UNSUPPORTED
;
752 ReportDesc
= AllocateZeroPool (MouseHidDesc
.HidClassDesc
[0].DescriptorLength
);
753 if (ReportDesc
== NULL
) {
754 return EFI_OUT_OF_RESOURCES
;
757 Status
= UsbGetReportDescriptor (
759 UsbMouseDev
->InterfaceDescriptor
->InterfaceNumber
,
760 MouseHidDesc
.HidClassDesc
[0].DescriptorLength
,
764 if (EFI_ERROR (Status
)) {
765 gBS
->FreePool (ReportDesc
);
770 // Parse report descriptor
772 Status
= ParseMouseReportDescriptor (
775 MouseHidDesc
.HidClassDesc
[0].DescriptorLength
778 if (EFI_ERROR (Status
)) {
779 gBS
->FreePool (ReportDesc
);
783 if (UsbMouseDev
->NumberOfButtons
>= 1) {
784 UsbMouseDev
->Mode
.LeftButton
= TRUE
;
787 if (UsbMouseDev
->NumberOfButtons
> 1) {
788 UsbMouseDev
->Mode
.RightButton
= TRUE
;
791 UsbMouseDev
->Mode
.ResolutionX
= 8;
792 UsbMouseDev
->Mode
.ResolutionY
= 8;
793 UsbMouseDev
->Mode
.ResolutionZ
= 0;
795 // Here we just assume interface 0 is the mouse interface
797 UsbGetProtocolRequest (
803 if (Protocol
!= BOOT_PROTOCOL
) {
804 Status
= UsbSetProtocolRequest (
810 if (EFI_ERROR (Status
)) {
811 gBS
->FreePool (ReportDesc
);
812 return EFI_DEVICE_ERROR
;
817 // Set indefinite Idle rate for USB Mouse
826 gBS
->FreePool (ReportDesc
);
828 if (UsbMouseDev
->DelayedRecoveryEvent
!= NULL
) {
829 gBS
->CloseEvent (UsbMouseDev
->DelayedRecoveryEvent
);
830 UsbMouseDev
->DelayedRecoveryEvent
= 0;
833 Status
= gBS
->CreateEvent (
834 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
836 USBMouseRecoveryHandler
,
838 &UsbMouseDev
->DelayedRecoveryEvent
846 It is called whenever there is data received from async interrupt
849 @param Data Data received.
850 @param DataLength Length of Data.
851 @param Context Passed in context.
852 @param Result Async Interrupt Transfer result.
854 @return EFI_SUCCESS Receive data successfully.
855 @return EFI_DEVICE_ERROR USB async interrupt transfer fails.
860 OnMouseInterruptComplete (
867 USB_MOUSE_DEV
*UsbMouseDevice
;
868 EFI_USB_IO_PROTOCOL
*UsbIo
;
872 UsbMouseDevice
= (USB_MOUSE_DEV
*) Context
;
873 UsbIo
= UsbMouseDevice
->UsbIo
;
875 if (Result
!= EFI_USB_NOERROR
) {
877 // Some errors happen during the process
879 MouseReportStatusCode (
880 UsbMouseDevice
->DevicePath
,
881 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
882 PcdGet32 (PcdStatusCodeValueMouseInputError
)
885 if ((Result
& EFI_USB_ERR_STALL
) == EFI_USB_ERR_STALL
) {
886 EndpointAddr
= UsbMouseDevice
->IntEndpointDescriptor
->EndpointAddress
;
888 UsbClearEndpointHalt (
895 UsbIo
->UsbAsyncInterruptTransfer (
897 UsbMouseDevice
->IntEndpointDescriptor
->EndpointAddress
,
906 UsbMouseDevice
->DelayedRecoveryEvent
,
908 EFI_USB_INTERRUPT_DELAY
910 return EFI_DEVICE_ERROR
;
913 if (DataLength
== 0 || Data
== NULL
) {
917 UsbMouseDevice
->StateChanged
= TRUE
;
922 UsbMouseDevice
->State
.LeftButton
= (BOOLEAN
) (*(UINT8
*) Data
& 0x01);
923 UsbMouseDevice
->State
.RightButton
= (BOOLEAN
) (*(UINT8
*) Data
& 0x02);
924 UsbMouseDevice
->State
.RelativeMovementX
+= *((INT8
*) Data
+ 1);
925 UsbMouseDevice
->State
.RelativeMovementY
+= *((INT8
*) Data
+ 2);
927 if (DataLength
> 3) {
928 UsbMouseDevice
->State
.RelativeMovementZ
+= *((INT8
*) Data
+ 3);
936 Get the mouse state, see SIMPLE POINTER PROTOCOL.
938 @param This Protocol instance pointer.
939 @param MouseState Current mouse state.
941 @return EFI_SUCCESS Get usb mouse status successfully.
942 @return EFI_DEVICE_ERROR The parameter is error.
943 @return EFI_NOT_READY Mouse status doesn't change.
949 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
950 OUT EFI_SIMPLE_POINTER_STATE
*MouseState
953 USB_MOUSE_DEV
*MouseDev
;
955 if (MouseState
== NULL
) {
956 return EFI_DEVICE_ERROR
;
959 MouseDev
= USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (This
);
961 if (!MouseDev
->StateChanged
) {
962 return EFI_NOT_READY
;
968 sizeof (EFI_SIMPLE_POINTER_STATE
)
972 // Clear previous move state
974 MouseDev
->State
.RelativeMovementX
= 0;
975 MouseDev
->State
.RelativeMovementY
= 0;
976 MouseDev
->State
.RelativeMovementZ
= 0;
978 MouseDev
->StateChanged
= FALSE
;
985 Reset the mouse device, see SIMPLE POINTER PROTOCOL.
987 @param This Protocol instance pointer.
988 @param ExtendedVerification Ignored here.
990 @return EFI_SUCCESS Reset usb mouse successfully.
996 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
997 IN BOOLEAN ExtendedVerification
1000 USB_MOUSE_DEV
*UsbMouseDevice
;
1002 UsbMouseDevice
= USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (This
);
1004 MouseReportStatusCode (
1005 UsbMouseDevice
->DevicePath
,
1007 PcdGet32 (PcdStatusCodeValueMouseReset
)
1012 &UsbMouseDevice
->State
,
1013 sizeof (EFI_SIMPLE_POINTER_STATE
)
1015 UsbMouseDevice
->StateChanged
= FALSE
;
1022 Event notification function for SIMPLE_POINTER.WaitForInput event
1023 Signal the event if there is input from mouse.
1025 @param Event Wait Event
1026 @param Context Passed parameter to event handler
1031 UsbMouseWaitForInput (
1036 USB_MOUSE_DEV
*UsbMouseDev
;
1038 UsbMouseDev
= (USB_MOUSE_DEV
*) Context
;
1041 // Someone is waiting on the mouse event, if there's
1042 // input from mouse, signal the event
1044 if (UsbMouseDev
->StateChanged
) {
1045 gBS
->SignalEvent (Event
);
1051 Timer handler for Delayed Recovery timer.
1053 @param Event The Delayed Recovery event.
1054 @param Context Points to the USB_KB_DEV instance.
1060 USBMouseRecoveryHandler (
1065 USB_MOUSE_DEV
*UsbMouseDev
;
1066 EFI_USB_IO_PROTOCOL
*UsbIo
;
1068 UsbMouseDev
= (USB_MOUSE_DEV
*) Context
;
1070 UsbIo
= UsbMouseDev
->UsbIo
;
1072 UsbIo
->UsbAsyncInterruptTransfer (
1074 UsbMouseDev
->IntEndpointDescriptor
->EndpointAddress
,
1076 UsbMouseDev
->IntEndpointDescriptor
->Interval
,
1077 UsbMouseDev
->IntEndpointDescriptor
->MaxPacketSize
,
1078 OnMouseInterruptComplete
,
1085 Report Status Code in Usb Bot Driver.
1087 @param DevicePath Use this to get Device Path
1088 @param CodeType Status Code Type
1089 @param CodeValue Status Code Value
1095 MouseReportStatusCode (
1096 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
1097 IN EFI_STATUS_CODE_TYPE CodeType
,
1098 IN EFI_STATUS_CODE_VALUE Value
1101 REPORT_STATUS_CODE_WITH_DEVICE_PATH (