44 &gUsbMouseAbsolutePointerDriverBinding,
46 &gUsbMouseAbsolutePointerComponentName,
47 &gUsbMouseAbsolutePointerComponentName2
76 Status =
gBS->OpenProtocol (
78 &gEfiUsbIoProtocolGuid,
80 This->DriverBindingHandle,
82 EFI_OPEN_PROTOCOL_BY_DRIVER
84 if (EFI_ERROR (Status)) {
94 Status = EFI_UNSUPPORTED;
99 &gEfiUsbIoProtocolGuid,
100 This->DriverBindingHandle,
137 UINT8 EndpointNumber;
141 UINT8 PollingInterval;
146 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
150 Status =
gBS->OpenProtocol (
152 &gEfiUsbIoProtocolGuid,
154 This->DriverBindingHandle,
156 EFI_OPEN_PROTOCOL_BY_DRIVER
158 if (EFI_ERROR (Status)) {
163 ASSERT (UsbMouseAbsolutePointerDevice !=
NULL);
165 UsbMouseAbsolutePointerDevice->UsbIo = UsbIo;
166 UsbMouseAbsolutePointerDevice->Signature = USB_MOUSE_ABSOLUTE_POINTER_DEV_SIGNATURE;
171 Status =
gBS->OpenProtocol (
173 &gEfiDevicePathProtocolGuid,
174 (VOID **)&UsbMouseAbsolutePointerDevice->DevicePath,
175 This->DriverBindingHandle,
177 EFI_OPEN_PROTOCOL_GET_PROTOCOL
180 if (EFI_ERROR (Status)) {
189 (EFI_PERIPHERAL_MOUSE | EFI_P_PC_PRESENCE_DETECT),
190 UsbMouseAbsolutePointerDevice->DevicePath
196 UsbIo->UsbGetInterfaceDescriptor (
198 &UsbMouseAbsolutePointerDevice->InterfaceDescriptor
201 EndpointNumber = UsbMouseAbsolutePointerDevice->InterfaceDescriptor.NumEndpoints;
207 for (Index = 0; Index < EndpointNumber; Index++) {
208 UsbIo->UsbGetEndpointDescriptor (
214 if (((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) &&
215 ((EndpointDescriptor.EndpointAddress & USB_ENDPOINT_DIR_IN) != 0))
220 CopyMem (&UsbMouseAbsolutePointerDevice->IntEndpointDescriptor, &EndpointDescriptor, sizeof (EndpointDescriptor));
232 (EFI_PERIPHERAL_MOUSE | EFI_P_EC_NOT_DETECTED)
237 Status = EFI_UNSUPPORTED;
246 (EFI_PERIPHERAL_MOUSE | EFI_P_PC_DETECTED),
247 UsbMouseAbsolutePointerDevice->DevicePath
251 if (EFI_ERROR (Status)) {
257 (EFI_PERIPHERAL_MOUSE | EFI_P_EC_INTERFACE_ERROR),
258 UsbMouseAbsolutePointerDevice->DevicePath
269 UsbMouseAbsolutePointerDevice->AbsolutePointerProtocol.
Mode = &UsbMouseAbsolutePointerDevice->Mode;
271 Status =
gBS->CreateEvent (
275 UsbMouseAbsolutePointerDevice,
276 &((UsbMouseAbsolutePointerDevice->AbsolutePointerProtocol).WaitForInput)
278 if (EFI_ERROR (Status)) {
282 Status =
gBS->InstallProtocolInterface (
284 &gEfiAbsolutePointerProtocolGuid,
286 &UsbMouseAbsolutePointerDevice->AbsolutePointerProtocol
289 if (EFI_ERROR (Status)) {
300 (EFI_PERIPHERAL_MOUSE | EFI_P_PC_ENABLE),
301 UsbMouseAbsolutePointerDevice->DevicePath
307 EndpointAddr = UsbMouseAbsolutePointerDevice->IntEndpointDescriptor.EndpointAddress;
308 PollingInterval = UsbMouseAbsolutePointerDevice->IntEndpointDescriptor.Interval;
309 PacketSize = (UINT8)(UsbMouseAbsolutePointerDevice->IntEndpointDescriptor.MaxPacketSize);
311 Status = UsbIo->UsbAsyncInterruptTransfer (
318 UsbMouseAbsolutePointerDevice
321 if (EFI_ERROR (Status)) {
325 gBS->UninstallProtocolInterface (
327 &gEfiAbsolutePointerProtocolGuid,
328 &UsbMouseAbsolutePointerDevice->AbsolutePointerProtocol
333 UsbMouseAbsolutePointerDevice->ControllerNameTable =
NULL;
337 &UsbMouseAbsolutePointerDevice->ControllerNameTable,
338 L
"Generic Usb Mouse Absolute Pointer",
344 &UsbMouseAbsolutePointerDevice->ControllerNameTable,
345 L
"Generic Usb Mouse Absolute Pointer",
349 gBS->RestoreTPL (OldTpl);
356 if (EFI_ERROR (Status)) {
359 &gEfiUsbIoProtocolGuid,
360 This->DriverBindingHandle,
364 if (UsbMouseAbsolutePointerDevice !=
NULL) {
365 if ((UsbMouseAbsolutePointerDevice->AbsolutePointerProtocol).WaitForInput !=
NULL) {
366 gBS->CloseEvent ((UsbMouseAbsolutePointerDevice->AbsolutePointerProtocol).WaitForInput);
369 FreePool (UsbMouseAbsolutePointerDevice);
370 UsbMouseAbsolutePointerDevice =
NULL;
375 gBS->RestoreTPL (OldTpl);
407 Status =
gBS->OpenProtocol (
409 &gEfiAbsolutePointerProtocolGuid,
410 (VOID **)&AbsolutePointerProtocol,
411 This->DriverBindingHandle,
413 EFI_OPEN_PROTOCOL_GET_PROTOCOL
416 if (EFI_ERROR (Status)) {
417 return EFI_UNSUPPORTED;
420 UsbMouseAbsolutePointerDevice = USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL (AbsolutePointerProtocol);
422 UsbIo = UsbMouseAbsolutePointerDevice->UsbIo;
429 (EFI_PERIPHERAL_MOUSE | EFI_P_PC_DISABLE),
430 UsbMouseAbsolutePointerDevice->DevicePath
436 UsbIo->UsbAsyncInterruptTransfer (
438 UsbMouseAbsolutePointerDevice->IntEndpointDescriptor.EndpointAddress,
440 UsbMouseAbsolutePointerDevice->IntEndpointDescriptor.Interval,
446 Status =
gBS->UninstallProtocolInterface (
448 &gEfiAbsolutePointerProtocolGuid,
449 &UsbMouseAbsolutePointerDevice->AbsolutePointerProtocol
451 if (EFI_ERROR (Status)) {
457 &gEfiUsbIoProtocolGuid,
458 This->DriverBindingHandle,
465 gBS->CloseEvent (UsbMouseAbsolutePointerDevice->AbsolutePointerProtocol.
WaitForInput);
467 if (UsbMouseAbsolutePointerDevice->DelayedRecoveryEvent !=
NULL) {
468 gBS->CloseEvent (UsbMouseAbsolutePointerDevice->DelayedRecoveryEvent);
469 UsbMouseAbsolutePointerDevice->DelayedRecoveryEvent =
NULL;
472 if (UsbMouseAbsolutePointerDevice->ControllerNameTable !=
NULL) {
476 FreePool (UsbMouseAbsolutePointerDevice);
501 Status = UsbIo->UsbGetInterfaceDescriptor (
506 if (EFI_ERROR (Status)) {
510 if ((InterfaceDescriptor.InterfaceClass == CLASS_HID) &&
511 (InterfaceDescriptor.InterfaceSubClass == SUBCLASS_BOOT) &&
512 (InterfaceDescriptor.InterfaceProtocol == PROTOCOL_MOUSE)
548 UINT32 TransferResult;
553 UsbIo = UsbMouseAbsolutePointerDev->UsbIo;
558 Status = UsbIo->UsbGetConfigDescriptor (
562 if (EFI_ERROR (Status)) {
572 return EFI_OUT_OF_RESOURCES;
577 (UINT16)((USB_DESC_TYPE_CONFIG << 8) | (ConfigDesc.ConfigurationValue - 1)),
579 ConfigDesc.TotalLength,
583 if (EFI_ERROR (Status)) {
598 while (Total < ConfigDesc.TotalLength) {
599 if (Head->Type == USB_DESC_TYPE_INTERFACE) {
600 if ((((
USB_INTERFACE_DESCRIPTOR *)Head)->InterfaceNumber == UsbMouseAbsolutePointerDev->InterfaceDescriptor.InterfaceNumber) &&
601 (((
USB_INTERFACE_DESCRIPTOR *)Head)->AlternateSetting == UsbMouseAbsolutePointerDev->InterfaceDescriptor.AlternateSetting))
607 if (Start && (Head->Type == USB_DESC_TYPE_ENDPOINT)) {
611 if (Start && (Head->Type == USB_DESC_TYPE_HID)) {
616 Total = Total + (UINT16)Head->Len;
620 if (MouseHidDesc ==
NULL) {
622 return EFI_UNSUPPORTED;
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);
638 UsbMouseAbsolutePointerDev->InterfaceDescriptor.InterfaceNumber,
639 MouseHidDesc->HidClassDesc[0].DescriptorLength,
643 if (EFI_ERROR (Status)) {
653 UsbMouseAbsolutePointerDev,
655 MouseHidDesc->HidClassDesc[0].DescriptorLength
658 if (EFI_ERROR (Status)) {
664 UsbMouseAbsolutePointerDev->Mode.AbsoluteMaxX = 1024;
665 UsbMouseAbsolutePointerDev->Mode.AbsoluteMaxY = 1024;
666 UsbMouseAbsolutePointerDev->Mode.AbsoluteMaxZ = 0;
667 UsbMouseAbsolutePointerDev->Mode.AbsoluteMinX = 0;
668 UsbMouseAbsolutePointerDev->Mode.AbsoluteMinY = 0;
669 UsbMouseAbsolutePointerDev->Mode.AbsoluteMinZ = 0;
670 UsbMouseAbsolutePointerDev->Mode.Attributes = 0x3;
675 UsbMouseAbsolutePointerDev->State.CurrentX =
676 DivU64x32 (UsbMouseAbsolutePointerDev->Mode.AbsoluteMaxX + UsbMouseAbsolutePointerDev->Mode.AbsoluteMinX, 2);
677 UsbMouseAbsolutePointerDev->State.CurrentY =
678 DivU64x32 (UsbMouseAbsolutePointerDev->Mode.AbsoluteMaxY + UsbMouseAbsolutePointerDev->Mode.AbsoluteMinY, 2);
686 UsbMouseAbsolutePointerDev->InterfaceDescriptor.InterfaceNumber,
689 if (Protocol != BOOT_PROTOCOL) {
692 UsbMouseAbsolutePointerDev->InterfaceDescriptor.InterfaceNumber,
696 if (EFI_ERROR (Status)) {
709 if (UsbMouseAbsolutePointerDev->DelayedRecoveryEvent !=
NULL) {
710 gBS->CloseEvent (UsbMouseAbsolutePointerDev->DelayedRecoveryEvent);
711 UsbMouseAbsolutePointerDev->DelayedRecoveryEvent = 0;
715 EVT_TIMER | EVT_NOTIFY_SIGNAL,
718 UsbMouseAbsolutePointerDev,
719 &UsbMouseAbsolutePointerDev->DelayedRecoveryEvent
757 UsbIo = UsbMouseAbsolutePointerDevice->UsbIo;
759 if (Result != EFI_USB_NOERROR) {
765 (EFI_PERIPHERAL_MOUSE | EFI_P_EC_INPUT_ERROR),
766 UsbMouseAbsolutePointerDevice->DevicePath
769 if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {
770 EndpointAddr = UsbMouseAbsolutePointerDevice->IntEndpointDescriptor.EndpointAddress;
783 UsbIo->UsbAsyncInterruptTransfer (
785 UsbMouseAbsolutePointerDevice->IntEndpointDescriptor.EndpointAddress,
796 UsbMouseAbsolutePointerDevice->DelayedRecoveryEvent,
798 EFI_USB_INTERRUPT_DELAY
800 return EFI_DEVICE_ERROR;
806 if ((DataLength == 0) || (Data ==
NULL)) {
822 if (DataLength < 3) {
823 return EFI_DEVICE_ERROR;
826 UsbMouseAbsolutePointerDevice->StateChanged =
TRUE;
828 UsbMouseAbsolutePointerDevice->State.
ActiveButtons = *(UINT8 *)Data & (BIT0 | BIT1 | BIT2);
830 UsbMouseAbsolutePointerDevice->State.
CurrentX =
833 (INT64)UsbMouseAbsolutePointerDevice->State.
CurrentX + *((INT8 *)Data + 1),
838 UsbMouseAbsolutePointerDevice->State.
CurrentY =
841 (INT64)UsbMouseAbsolutePointerDevice->State.
CurrentY + *((INT8 *)Data + 2),
846 if (DataLength > 3) {
847 UsbMouseAbsolutePointerDevice->State.
CurrentZ =
850 (INT64)UsbMouseAbsolutePointerDevice->State.
CurrentZ + *((INT8 *)Data + 1),
884 return EFI_INVALID_PARAMETER;
887 MouseAbsolutePointerDev = USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL (This);
889 if (!MouseAbsolutePointerDev->StateChanged) {
890 return EFI_NOT_READY;
899 &MouseAbsolutePointerDev->State,
903 MouseAbsolutePointerDev->StateChanged =
FALSE;
923 IN BOOLEAN ExtendedVerification
928 UsbMouseAbsolutePointerDevice = USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL (This);
932 (EFI_PERIPHERAL_MOUSE | EFI_P_PC_RESET),
933 UsbMouseAbsolutePointerDevice->DevicePath
940 &UsbMouseAbsolutePointerDevice->State,
947 UsbMouseAbsolutePointerDevice->State.
CurrentX =
949 UsbMouseAbsolutePointerDevice->State.
CurrentY =
952 UsbMouseAbsolutePointerDevice->StateChanged =
FALSE;
978 if (UsbMouseAbsolutePointerDev->StateChanged) {
979 gBS->SignalEvent (Event);
1008 UsbIo = UsbMouseAbsolutePointerDev->UsbIo;
1013 UsbIo->UsbAsyncInterruptTransfer (
1015 UsbMouseAbsolutePointerDev->IntEndpointDescriptor.EndpointAddress,
1017 UsbMouseAbsolutePointerDev->IntEndpointDescriptor.Interval,
1018 UsbMouseAbsolutePointerDev->IntEndpointDescriptor.MaxPacketSize,
1020 UsbMouseAbsolutePointerDev
UINT64 EFIAPI DivU64x32(IN UINT64 Dividend, IN UINT32 Divisor)
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 ASSERT_EFI_ERROR(StatusParameter)
#define REPORT_STATUS_CODE(Type, Value)
#define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type, Value, DevicePathParameter)
#define EFI_PROGRESS_CODE
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)
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)
EFI_STATUS EFIAPI UsbGetReportDescriptor(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, IN UINT16 DescriptorLength, OUT UINT8 *DescriptorBuffer)
EFI_STATUS EFIAPI UsbSetProtocolRequest(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, IN UINT8 Protocol)
EFI_STATUS EFIAPI UsbGetProtocolRequest(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, OUT UINT8 *Protocol)
EFI_STATUS EFIAPI UsbClearEndpointHalt(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Endpoint, OUT UINT32 *Status)
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)
EFI_STATUS EFIAPI USBMouseAbsolutePointerDriverBindingEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID EFIAPI UsbMouseAbsolutePointerWaitForInput(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI USBMouseAbsolutePointerDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
BOOLEAN IsUsbMouse(IN EFI_USB_IO_PROTOCOL *UsbIo)
EFI_STATUS EFIAPI OnMouseInterruptComplete(IN VOID *Data, IN UINTN DataLength, IN VOID *Context, IN UINT32 Result)
VOID EFIAPI USBMouseRecoveryHandler(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI USBMouseAbsolutePointerDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS EFIAPI USBMouseAbsolutePointerDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS InitializeUsbMouseDevice(IN USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDev)
EFI_STATUS EFIAPI UsbMouseAbsolutePointerReset(IN EFI_ABSOLUTE_POINTER_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
EFI_STATUS EFIAPI GetMouseAbsolutePointerState(IN EFI_ABSOLUTE_POINTER_PROTOCOL *This, OUT EFI_ABSOLUTE_POINTER_STATE *State)
EFI_STATUS ParseMouseReportDescriptor(OUT USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointer, IN UINT8 *ReportDescriptor, IN UINTN ReportSize)
EFI_ABSOLUTE_POINTER_MODE * Mode
CHAR8 * SupportedLanguages
CHAR8 * SupportedLanguages
UINT64 AbsoluteMinX
The Absolute Minimum of the device on the x-axis.
UINT64 AbsoluteMinZ
The Absolute Minimum of the device on the z-axis.
UINT64 AbsoluteMinY
The Absolute Minimum of the device on the y axis.