TianoCore EDK2 master
Loading...
Searching...
No Matches
UsbMouse.c
Go to the documentation of this file.
1
9#include "UsbMouse.h"
10
11EFI_DRIVER_BINDING_PROTOCOL gUsbMouseDriverBinding = {
15 0xa,
16 NULL,
17 NULL
18};
19
33EFIAPI
35 IN EFI_HANDLE ImageHandle,
36 IN EFI_SYSTEM_TABLE *SystemTable
37 )
38{
39 EFI_STATUS Status;
40
42 ImageHandle,
43 SystemTable,
44 &gUsbMouseDriverBinding,
45 ImageHandle,
46 &gUsbMouseComponentName,
47 &gUsbMouseComponentName2
48 );
49 ASSERT_EFI_ERROR (Status);
50
51 return EFI_SUCCESS;
52}
53
66EFIAPI
69 IN EFI_HANDLE Controller,
70 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
71 )
72{
73 EFI_STATUS Status;
75
76 Status = gBS->OpenProtocol (
77 Controller,
78 &gEfiUsbIoProtocolGuid,
79 (VOID **)&UsbIo,
80 This->DriverBindingHandle,
81 Controller,
82 EFI_OPEN_PROTOCOL_BY_DRIVER
83 );
84 if (EFI_ERROR (Status)) {
85 return Status;
86 }
87
88 //
89 // Use the USB I/O Protocol interface to check whether Controller is
90 // a mouse device that can be managed by this driver.
91 //
92 Status = EFI_SUCCESS;
93 if (!IsUsbMouse (UsbIo)) {
94 Status = EFI_UNSUPPORTED;
95 }
96
97 gBS->CloseProtocol (
98 Controller,
99 &gEfiUsbIoProtocolGuid,
100 This->DriverBindingHandle,
101 Controller
102 );
103
104 return Status;
105}
106
127EFIAPI
130 IN EFI_HANDLE Controller,
131 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
132 )
133{
134 EFI_STATUS Status;
135 EFI_USB_IO_PROTOCOL *UsbIo;
136 USB_MOUSE_DEV *UsbMouseDevice;
137 UINT8 EndpointNumber;
138 EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
139 UINT8 Index;
140 UINT8 EndpointAddr;
141 UINT8 PollingInterval;
142 UINT8 PacketSize;
143 BOOLEAN Found;
144 EFI_TPL OldTpl;
145
146 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
147 //
148 // Open USB I/O Protocol
149 //
150 Status = gBS->OpenProtocol (
151 Controller,
152 &gEfiUsbIoProtocolGuid,
153 (VOID **)&UsbIo,
154 This->DriverBindingHandle,
155 Controller,
156 EFI_OPEN_PROTOCOL_BY_DRIVER
157 );
158 if (EFI_ERROR (Status)) {
159 goto ErrorExit1;
160 }
161
162 UsbMouseDevice = AllocateZeroPool (sizeof (USB_MOUSE_DEV));
163 ASSERT (UsbMouseDevice != NULL);
164
165 UsbMouseDevice->UsbIo = UsbIo;
166 UsbMouseDevice->Signature = USB_MOUSE_DEV_SIGNATURE;
167
168 //
169 // Get the Device Path Protocol on Controller's handle
170 //
171 Status = gBS->OpenProtocol (
172 Controller,
173 &gEfiDevicePathProtocolGuid,
174 (VOID **)&UsbMouseDevice->DevicePath,
175 This->DriverBindingHandle,
176 Controller,
177 EFI_OPEN_PROTOCOL_GET_PROTOCOL
178 );
179
180 if (EFI_ERROR (Status)) {
181 goto ErrorExit;
182 }
183
184 //
185 // Report Status Code here since USB mouse will be detected next.
186 //
189 (EFI_PERIPHERAL_MOUSE | EFI_P_PC_PRESENCE_DETECT),
190 UsbMouseDevice->DevicePath
191 );
192
193 //
194 // Get interface & endpoint descriptor
195 //
196 UsbIo->UsbGetInterfaceDescriptor (
197 UsbIo,
198 &UsbMouseDevice->InterfaceDescriptor
199 );
200
201 EndpointNumber = UsbMouseDevice->InterfaceDescriptor.NumEndpoints;
202
203 //
204 // Traverse endpoints to find interrupt endpoint IN
205 //
206 Found = FALSE;
207 for (Index = 0; Index < EndpointNumber; Index++) {
208 UsbIo->UsbGetEndpointDescriptor (
209 UsbIo,
210 Index,
211 &EndpointDescriptor
212 );
213
214 if (((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) &&
215 ((EndpointDescriptor.EndpointAddress & USB_ENDPOINT_DIR_IN) != 0))
216 {
217 //
218 // We only care interrupt endpoint here
219 //
220 CopyMem (&UsbMouseDevice->IntEndpointDescriptor, &EndpointDescriptor, sizeof (EndpointDescriptor));
221 Found = TRUE;
222 break;
223 }
224 }
225
226 if (!Found) {
227 //
228 // Report Status Code to indicate that there is no USB mouse
229 //
231 EFI_ERROR_CODE | EFI_ERROR_MINOR,
232 (EFI_PERIPHERAL_MOUSE | EFI_P_EC_NOT_DETECTED)
233 );
234 //
235 // No interrupt endpoint found, then return unsupported.
236 //
237 Status = EFI_UNSUPPORTED;
238 goto ErrorExit;
239 }
240
241 //
242 // Report Status Code here since USB mouse has be detected.
243 //
246 (EFI_PERIPHERAL_MOUSE | EFI_P_PC_DETECTED),
247 UsbMouseDevice->DevicePath
248 );
249
250 Status = InitializeUsbMouseDevice (UsbMouseDevice);
251 if (EFI_ERROR (Status)) {
252 //
253 // Fail to initialize USB mouse device.
254 //
256 EFI_ERROR_CODE | EFI_ERROR_MINOR,
257 (EFI_PERIPHERAL_MOUSE | EFI_P_EC_INTERFACE_ERROR),
258 UsbMouseDevice->DevicePath
259 );
260
261 goto ErrorExit;
262 }
263
264 //
265 // Initialize and install EFI Simple Pointer Protocol.
266 //
267 UsbMouseDevice->SimplePointerProtocol.GetState = GetMouseState;
268 UsbMouseDevice->SimplePointerProtocol.Reset = UsbMouseReset;
269 UsbMouseDevice->SimplePointerProtocol.Mode = &UsbMouseDevice->Mode;
270
271 Status = gBS->CreateEvent (
272 EVT_NOTIFY_WAIT,
273 TPL_NOTIFY,
275 UsbMouseDevice,
276 &((UsbMouseDevice->SimplePointerProtocol).WaitForInput)
277 );
278 if (EFI_ERROR (Status)) {
279 goto ErrorExit;
280 }
281
282 Status = gBS->InstallProtocolInterface (
283 &Controller,
284 &gEfiSimplePointerProtocolGuid,
286 &UsbMouseDevice->SimplePointerProtocol
287 );
288
289 if (EFI_ERROR (Status)) {
290 goto ErrorExit;
291 }
292
293 //
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.
297 //
300 (EFI_PERIPHERAL_MOUSE | EFI_P_PC_ENABLE),
301 UsbMouseDevice->DevicePath
302 );
303
304 //
305 // Submit Asynchronous Interrupt Transfer to manage this device.
306 //
307 EndpointAddr = UsbMouseDevice->IntEndpointDescriptor.EndpointAddress;
308 PollingInterval = UsbMouseDevice->IntEndpointDescriptor.Interval;
309 PacketSize = (UINT8)(UsbMouseDevice->IntEndpointDescriptor.MaxPacketSize);
310
311 Status = UsbIo->UsbAsyncInterruptTransfer (
312 UsbIo,
313 EndpointAddr,
314 TRUE,
315 PollingInterval,
316 PacketSize,
318 UsbMouseDevice
319 );
320
321 if (EFI_ERROR (Status)) {
322 //
323 // If submit error, uninstall that interface
324 //
325 gBS->UninstallProtocolInterface (
326 Controller,
327 &gEfiSimplePointerProtocolGuid,
328 &UsbMouseDevice->SimplePointerProtocol
329 );
330 goto ErrorExit;
331 }
332
333 UsbMouseDevice->ControllerNameTable = NULL;
335 "eng",
336 gUsbMouseComponentName.SupportedLanguages,
337 &UsbMouseDevice->ControllerNameTable,
338 L"Generic Usb Mouse",
339 TRUE
340 );
342 "en",
343 gUsbMouseComponentName2.SupportedLanguages,
344 &UsbMouseDevice->ControllerNameTable,
345 L"Generic Usb Mouse",
346 FALSE
347 );
348
349 gBS->RestoreTPL (OldTpl);
350
351 return EFI_SUCCESS;
352
353 //
354 // Error handler
355 //
356ErrorExit:
357 if (EFI_ERROR (Status)) {
358 gBS->CloseProtocol (
359 Controller,
360 &gEfiUsbIoProtocolGuid,
361 This->DriverBindingHandle,
362 Controller
363 );
364
365 if (UsbMouseDevice != NULL) {
366 if ((UsbMouseDevice->SimplePointerProtocol).WaitForInput != NULL) {
367 gBS->CloseEvent ((UsbMouseDevice->SimplePointerProtocol).WaitForInput);
368 }
369
370 FreePool (UsbMouseDevice);
371 UsbMouseDevice = NULL;
372 }
373 }
374
375ErrorExit1:
376 gBS->RestoreTPL (OldTpl);
377 return Status;
378}
379
394EFIAPI
397 IN EFI_HANDLE Controller,
398 IN UINTN NumberOfChildren,
399 IN EFI_HANDLE *ChildHandleBuffer
400 )
401{
402 EFI_STATUS Status;
403 USB_MOUSE_DEV *UsbMouseDevice;
404 EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
405 EFI_USB_IO_PROTOCOL *UsbIo;
406
407 Status = gBS->OpenProtocol (
408 Controller,
409 &gEfiSimplePointerProtocolGuid,
410 (VOID **)&SimplePointerProtocol,
411 This->DriverBindingHandle,
412 Controller,
413 EFI_OPEN_PROTOCOL_GET_PROTOCOL
414 );
415
416 if (EFI_ERROR (Status)) {
417 return EFI_UNSUPPORTED;
418 }
419
420 UsbMouseDevice = USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (SimplePointerProtocol);
421
422 UsbIo = UsbMouseDevice->UsbIo;
423
424 //
425 // The key data input from this device will be disabled.
426 //
429 (EFI_PERIPHERAL_MOUSE | EFI_P_PC_DISABLE),
430 UsbMouseDevice->DevicePath
431 );
432
433 //
434 // Delete the Asynchronous Interrupt Transfer from this device
435 //
436 UsbIo->UsbAsyncInterruptTransfer (
437 UsbIo,
438 UsbMouseDevice->IntEndpointDescriptor.EndpointAddress,
439 FALSE,
440 UsbMouseDevice->IntEndpointDescriptor.Interval,
441 0,
442 NULL,
443 NULL
444 );
445
446 Status = gBS->UninstallProtocolInterface (
447 Controller,
448 &gEfiSimplePointerProtocolGuid,
449 &UsbMouseDevice->SimplePointerProtocol
450 );
451 if (EFI_ERROR (Status)) {
452 return Status;
453 }
454
455 gBS->CloseProtocol (
456 Controller,
457 &gEfiUsbIoProtocolGuid,
458 This->DriverBindingHandle,
459 Controller
460 );
461
462 //
463 // Free all resources.
464 //
465 gBS->CloseEvent (UsbMouseDevice->SimplePointerProtocol.WaitForInput);
466
467 if (UsbMouseDevice->DelayedRecoveryEvent != NULL) {
468 gBS->CloseEvent (UsbMouseDevice->DelayedRecoveryEvent);
469 UsbMouseDevice->DelayedRecoveryEvent = NULL;
470 }
471
472 if (UsbMouseDevice->ControllerNameTable != NULL) {
473 FreeUnicodeStringTable (UsbMouseDevice->ControllerNameTable);
474 }
475
476 FreePool (UsbMouseDevice);
477
478 return EFI_SUCCESS;
479}
480
490BOOLEAN
493 )
494{
495 EFI_STATUS Status;
496 EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
497
498 //
499 // Get the default interface descriptor
500 //
501 Status = UsbIo->UsbGetInterfaceDescriptor (
502 UsbIo,
503 &InterfaceDescriptor
504 );
505
506 if (EFI_ERROR (Status)) {
507 return FALSE;
508 }
509
510 if ((InterfaceDescriptor.InterfaceClass == CLASS_HID) &&
511 (InterfaceDescriptor.InterfaceSubClass == SUBCLASS_BOOT) &&
512 (InterfaceDescriptor.InterfaceProtocol == PROTOCOL_MOUSE)
513 )
514 {
515 return TRUE;
516 }
517
518 return FALSE;
519}
520
538 IN OUT USB_MOUSE_DEV *UsbMouseDev
539 )
540{
541 EFI_USB_IO_PROTOCOL *UsbIo;
542 UINT8 Protocol;
543 EFI_STATUS Status;
544 EFI_USB_HID_DESCRIPTOR *MouseHidDesc;
545 UINT8 *ReportDesc;
546 EFI_USB_CONFIG_DESCRIPTOR ConfigDesc;
547 VOID *Buf;
548 UINT32 TransferResult;
549 UINT16 Total;
550 USB_DESC_HEAD *Head;
551 BOOLEAN Start;
552
553 UsbIo = UsbMouseDev->UsbIo;
554
555 //
556 // Get the current configuration descriptor. Note that it doesn't include other descriptors.
557 //
558 Status = UsbIo->UsbGetConfigDescriptor (
559 UsbIo,
560 &ConfigDesc
561 );
562 if (EFI_ERROR (Status)) {
563 return Status;
564 }
565
566 //
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.
569 //
570 Buf = AllocateZeroPool (ConfigDesc.TotalLength);
571 if (Buf == NULL) {
572 return EFI_OUT_OF_RESOURCES;
573 }
574
575 Status = UsbGetDescriptor (
576 UsbIo,
577 (UINT16)((USB_DESC_TYPE_CONFIG << 8) | (ConfigDesc.ConfigurationValue - 1)),
578 0,
579 ConfigDesc.TotalLength,
580 Buf,
581 &TransferResult
582 );
583 if (EFI_ERROR (Status)) {
584 FreePool (Buf);
585 return Status;
586 }
587
588 Total = 0;
589 Start = FALSE;
590 Head = (USB_DESC_HEAD *)Buf;
591 MouseHidDesc = NULL;
592
593 //
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.
597 //
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))
602 {
603 Start = TRUE;
604 }
605 }
606
607 if (Start && (Head->Type == USB_DESC_TYPE_ENDPOINT)) {
608 break;
609 }
610
611 if (Start && (Head->Type == USB_DESC_TYPE_HID)) {
612 MouseHidDesc = (EFI_USB_HID_DESCRIPTOR *)Head;
613 break;
614 }
615
616 Total = Total + (UINT16)Head->Len;
617 Head = (USB_DESC_HEAD *)((UINT8 *)Buf + Total);
618 }
619
620 if (MouseHidDesc == NULL) {
621 FreePool (Buf);
622 return EFI_UNSUPPORTED;
623 }
624
625 //
626 // Get report descriptor
627 //
628 if (MouseHidDesc->HidClassDesc[0].DescriptorType != USB_DESC_TYPE_REPORT) {
629 FreePool (Buf);
630 return EFI_UNSUPPORTED;
631 }
632
633 ReportDesc = AllocateZeroPool (MouseHidDesc->HidClassDesc[0].DescriptorLength);
634 ASSERT (ReportDesc != NULL);
635
636 Status = UsbGetReportDescriptor (
637 UsbIo,
638 UsbMouseDev->InterfaceDescriptor.InterfaceNumber,
639 MouseHidDesc->HidClassDesc[0].DescriptorLength,
640 ReportDesc
641 );
642
643 if (EFI_ERROR (Status)) {
644 FreePool (Buf);
645 FreePool (ReportDesc);
646 return Status;
647 }
648
649 //
650 // Parse report descriptor
651 //
653 UsbMouseDev,
654 ReportDesc,
655 MouseHidDesc->HidClassDesc[0].DescriptorLength
656 );
657
658 if (EFI_ERROR (Status)) {
659 FreePool (Buf);
660 FreePool (ReportDesc);
661 return Status;
662 }
663
664 //
665 // Check the presence of left and right buttons,
666 // and initialize fields of EFI_SIMPLE_POINTER_MODE.
667 //
668 if (UsbMouseDev->NumberOfButtons >= 1) {
669 UsbMouseDev->Mode.LeftButton = TRUE;
670 }
671
672 if (UsbMouseDev->NumberOfButtons > 1) {
673 UsbMouseDev->Mode.RightButton = TRUE;
674 }
675
676 UsbMouseDev->Mode.ResolutionX = 8;
677 UsbMouseDev->Mode.ResolutionY = 8;
678 UsbMouseDev->Mode.ResolutionZ = 0;
679
680 //
681 // Set boot protocol for the USB mouse.
682 // This driver only supports boot protocol.
683 //
685 UsbIo,
686 UsbMouseDev->InterfaceDescriptor.InterfaceNumber,
687 &Protocol
688 );
689 if (Protocol != BOOT_PROTOCOL) {
690 Status = UsbSetProtocolRequest (
691 UsbIo,
692 UsbMouseDev->InterfaceDescriptor.InterfaceNumber,
693 BOOT_PROTOCOL
694 );
695
696 if (EFI_ERROR (Status)) {
697 FreePool (Buf);
698 FreePool (ReportDesc);
699 return Status;
700 }
701 }
702
703 FreePool (Buf);
704 FreePool (ReportDesc);
705
706 //
707 // Create event for delayed recovery, which deals with device error.
708 //
709 if (UsbMouseDev->DelayedRecoveryEvent != NULL) {
710 gBS->CloseEvent (UsbMouseDev->DelayedRecoveryEvent);
711 UsbMouseDev->DelayedRecoveryEvent = 0;
712 }
713
714 gBS->CreateEvent (
715 EVT_TIMER | EVT_NOTIFY_SIGNAL,
716 TPL_NOTIFY,
718 UsbMouseDev,
719 &UsbMouseDev->DelayedRecoveryEvent
720 );
721
722 return EFI_SUCCESS;
723}
724
743EFIAPI
745 IN VOID *Data,
746 IN UINTN DataLength,
747 IN VOID *Context,
748 IN UINT32 Result
749 )
750{
751 USB_MOUSE_DEV *UsbMouseDevice;
752 EFI_USB_IO_PROTOCOL *UsbIo;
753 UINT8 EndpointAddr;
754 UINT32 UsbResult;
755
756 UsbMouseDevice = (USB_MOUSE_DEV *)Context;
757 UsbIo = UsbMouseDevice->UsbIo;
758
759 if (Result != EFI_USB_NOERROR) {
760 //
761 // Some errors happen during the process
762 //
764 EFI_ERROR_CODE | EFI_ERROR_MINOR,
765 (EFI_PERIPHERAL_MOUSE | EFI_P_EC_INPUT_ERROR),
766 UsbMouseDevice->DevicePath
767 );
768
769 if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {
770 EndpointAddr = UsbMouseDevice->IntEndpointDescriptor.EndpointAddress;
771
773 UsbIo,
774 EndpointAddr,
775 &UsbResult
776 );
777 }
778
779 //
780 // Delete & Submit this interrupt again
781 // Handler of DelayedRecoveryEvent triggered by timer will re-submit the interrupt.
782 //
783 UsbIo->UsbAsyncInterruptTransfer (
784 UsbIo,
785 UsbMouseDevice->IntEndpointDescriptor.EndpointAddress,
786 FALSE,
787 0,
788 0,
789 NULL,
790 NULL
791 );
792 //
793 // EFI_USB_INTERRUPT_DELAY is defined in USB standard for error handling.
794 //
795 gBS->SetTimer (
796 UsbMouseDevice->DelayedRecoveryEvent,
798 EFI_USB_INTERRUPT_DELAY
799 );
800 return EFI_DEVICE_ERROR;
801 }
802
803 //
804 // If no error and no data, just return EFI_SUCCESS.
805 //
806 if ((DataLength == 0) || (Data == NULL)) {
807 return EFI_SUCCESS;
808 }
809
810 //
811 // Check mouse Data
812 // USB HID Specification specifies following data format:
813 // Byte Bits Description
814 // 0 0 Button 1
815 // 1 Button 2
816 // 2 Button 3
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)
821 //
822 if (DataLength < 3) {
823 return EFI_DEVICE_ERROR;
824 }
825
826 UsbMouseDevice->StateChanged = TRUE;
827
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);
832
833 if (DataLength > 3) {
834 UsbMouseDevice->State.RelativeMovementZ += *((INT8 *)Data + 3);
835 }
836
837 return EFI_SUCCESS;
838}
839
855EFIAPI
858 OUT EFI_SIMPLE_POINTER_STATE *MouseState
859 )
860{
861 USB_MOUSE_DEV *MouseDev;
862
863 if (MouseState == NULL) {
864 return EFI_INVALID_PARAMETER;
865 }
866
867 MouseDev = USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (This);
868
869 if (!MouseDev->StateChanged) {
870 return EFI_NOT_READY;
871 }
872
873 //
874 // Retrieve mouse state from USB_MOUSE_DEV, which was filled by OnMouseInterruptComplete()
875 //
876 CopyMem (
877 MouseState,
878 &MouseDev->State,
880 );
881
882 //
883 // Clear previous move state
884 //
885 MouseDev->State.RelativeMovementX = 0;
886 MouseDev->State.RelativeMovementY = 0;
887 MouseDev->State.RelativeMovementZ = 0;
888
889 MouseDev->StateChanged = FALSE;
890
891 return EFI_SUCCESS;
892}
893
906EFIAPI
909 IN BOOLEAN ExtendedVerification
910 )
911{
912 USB_MOUSE_DEV *UsbMouseDevice;
913
914 UsbMouseDevice = USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (This);
915
918 (EFI_PERIPHERAL_MOUSE | EFI_P_PC_RESET),
919 UsbMouseDevice->DevicePath
920 );
921
922 //
923 // Clear mouse state.
924 //
925 ZeroMem (
926 &UsbMouseDevice->State,
928 );
929 UsbMouseDevice->StateChanged = FALSE;
930
931 return EFI_SUCCESS;
932}
933
941VOID
942EFIAPI
944 IN EFI_EVENT Event,
945 IN VOID *Context
946 )
947{
948 USB_MOUSE_DEV *UsbMouseDev;
949
950 UsbMouseDev = (USB_MOUSE_DEV *)Context;
951
952 //
953 // If there's input from mouse, signal the event.
954 //
955 if (UsbMouseDev->StateChanged) {
956 gBS->SignalEvent (Event);
957 }
958}
959
973VOID
974EFIAPI
976 IN EFI_EVENT Event,
977 IN VOID *Context
978 )
979{
980 USB_MOUSE_DEV *UsbMouseDev;
981 EFI_USB_IO_PROTOCOL *UsbIo;
982
983 UsbMouseDev = (USB_MOUSE_DEV *)Context;
984
985 UsbIo = UsbMouseDev->UsbIo;
986
987 //
988 // Re-submit Asynchronous Interrupt Transfer for recovery.
989 //
990 UsbIo->UsbAsyncInterruptTransfer (
991 UsbIo,
992 UsbMouseDev->IntEndpointDescriptor.EndpointAddress,
993 TRUE,
994 UsbMouseDev->IntEndpointDescriptor.Interval,
995 UsbMouseDev->IntEndpointDescriptor.MaxPacketSize,
997 UsbMouseDev
998 );
999}
UINT64 UINTN
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define REPORT_STATUS_CODE(Type, Value)
#define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type, Value, DevicePathParameter)
#define EFI_ERROR_MINOR
Definition: PiStatusCode.h:58
#define EFI_PROGRESS_CODE
Definition: PiStatusCode.h:43
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
UINTN EFI_TPL
Definition: UefiBaseType.h:41
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
EFI_STATUS EFIAPI AddUnicodeString2(IN CONST CHAR8 *Language, IN CONST CHAR8 *SupportedLanguages, IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable, IN CONST CHAR16 *UnicodeString, IN BOOLEAN Iso639Language)
Definition: UefiLib.c:1087
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
EFI_STATUS EFIAPI FreeUnicodeStringTable(IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable)
Definition: UefiLib.c:1257
@ EFI_NATIVE_INTERFACE
Definition: UefiSpec.h:1193
@ TimerRelative
Definition: UefiSpec.h:539
EFI_STATUS EFIAPI UsbGetReportDescriptor(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, IN UINT16 DescriptorLength, OUT UINT8 *DescriptorBuffer)
Definition: Hid.c:102
EFI_STATUS EFIAPI UsbSetProtocolRequest(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, IN UINT8 Protocol)
Definition: Hid.c:210
EFI_STATUS EFIAPI UsbGetProtocolRequest(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, OUT UINT8 *Protocol)
Definition: Hid.c:157
EFI_STATUS EFIAPI UsbClearEndpointHalt(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Endpoint, OUT UINT32 *Status)
Definition: UsbDxeLib.c:595
EFI_STATUS EFIAPI UsbGetDescriptor(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT16 Value, IN UINT16 Index, IN UINT16 DescriptorLength, OUT VOID *Descriptor, OUT UINT32 *Status)
Definition: UsbDxeLib.c:41
EFI_STATUS InitializeUsbMouseDevice(IN OUT USB_MOUSE_DEV *UsbMouseDev)
Definition: UsbMouse.c:537
EFI_STATUS EFIAPI USBMouseDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: UsbMouse.c:67
BOOLEAN IsUsbMouse(IN EFI_USB_IO_PROTOCOL *UsbIo)
Definition: UsbMouse.c:491
EFI_STATUS EFIAPI OnMouseInterruptComplete(IN VOID *Data, IN UINTN DataLength, IN VOID *Context, IN UINT32 Result)
Definition: UsbMouse.c:744
EFI_STATUS EFIAPI USBMouseDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: UsbMouse.c:395
VOID EFIAPI USBMouseRecoveryHandler(IN EFI_EVENT Event, IN VOID *Context)
Definition: UsbMouse.c:975
EFI_STATUS EFIAPI UsbMouseReset(IN EFI_SIMPLE_POINTER_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
Definition: UsbMouse.c:907
VOID EFIAPI UsbMouseWaitForInput(IN EFI_EVENT Event, IN VOID *Context)
Definition: UsbMouse.c:943
EFI_STATUS EFIAPI USBMouseDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: UsbMouse.c:128
EFI_STATUS EFIAPI GetMouseState(IN EFI_SIMPLE_POINTER_PROTOCOL *This, OUT EFI_SIMPLE_POINTER_STATE *MouseState)
Definition: UsbMouse.c:856
EFI_STATUS EFIAPI USBMouseDriverBindingEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: UsbMouse.c:34
EFI_STATUS ParseMouseReportDescriptor(OUT USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointer, IN UINT8 *ReportDescriptor, IN UINTN ReportSize)
Definition: MouseHid.c:242
EFI_SIMPLE_POINTER_MODE * Mode