/** @file\r
Helper routine and corresponding data struct used by USB Mouse Driver.\r
\r
-Copyright (c) 2004 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
#ifndef _EFI_USB_MOUSE_H_\r
#define _EFI_USB_MOUSE_H_\r
\r
-\r
#include <Uefi.h>\r
\r
#include <Protocol/SimplePointer.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
#include <Library/UefiLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
-#include <Library/PcdLib.h>\r
#include <Library/UefiUsbLib.h>\r
#include <Library/DebugLib.h>\r
\r
#include <IndustryStandard/Usb.h>\r
\r
-#define CLASS_HID 3\r
-#define SUBCLASS_BOOT 1\r
-#define PROTOCOL_MOUSE 2\r
+#define CLASS_HID 3\r
+#define SUBCLASS_BOOT 1\r
+#define PROTOCOL_MOUSE 2\r
\r
-#define BOOT_PROTOCOL 0\r
-#define REPORT_PROTOCOL 1\r
+#define BOOT_PROTOCOL 0\r
+#define REPORT_PROTOCOL 1\r
\r
-#define USB_MOUSE_DEV_SIGNATURE SIGNATURE_32 ('u', 'm', 'o', 'u')\r
+#define USB_MOUSE_DEV_SIGNATURE SIGNATURE_32 ('u', 'm', 'o', 'u')\r
+\r
+//\r
+// A common header for usb standard descriptor.\r
+// Each stand descriptor has a length and type.\r
+//\r
+#pragma pack(1)\r
+typedef struct {\r
+ UINT8 Len;\r
+ UINT8 Type;\r
+} USB_DESC_HEAD;\r
+#pragma pack()\r
\r
///\r
/// Button range and status\r
///\r
typedef struct {\r
- BOOLEAN ButtonDetected;\r
- UINT8 ButtonMinIndex;\r
- UINT8 ButtonMaxIndex;\r
- UINT8 Reserved;\r
+ BOOLEAN ButtonDetected;\r
+ UINT8 ButtonMinIndex;\r
+ UINT8 ButtonMaxIndex;\r
+ UINT8 Reserved;\r
} USB_MOUSE_BUTTON_DATA;\r
\r
///\r
/// Device instance of USB mouse.\r
///\r
typedef struct {\r
- UINTN Signature;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- EFI_EVENT DelayedRecoveryEvent;\r
- EFI_USB_IO_PROTOCOL *UsbIo;\r
- EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;\r
- EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor;\r
- UINT8 NumberOfButtons;\r
- INT32 XLogicMax;\r
- INT32 XLogicMin;\r
- INT32 YLogicMax;\r
- INT32 YLogicMin;\r
- EFI_SIMPLE_POINTER_PROTOCOL SimplePointerProtocol;\r
- EFI_SIMPLE_POINTER_STATE State;\r
- EFI_SIMPLE_POINTER_MODE Mode;\r
- BOOLEAN StateChanged;\r
- USB_MOUSE_BUTTON_DATA PrivateData;\r
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
+ UINTN Signature;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ EFI_EVENT DelayedRecoveryEvent;\r
+ EFI_USB_IO_PROTOCOL *UsbIo;\r
+ EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;\r
+ EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor;\r
+ UINT8 NumberOfButtons;\r
+ INT32 XLogicMax;\r
+ INT32 XLogicMin;\r
+ INT32 YLogicMax;\r
+ INT32 YLogicMin;\r
+ EFI_SIMPLE_POINTER_PROTOCOL SimplePointerProtocol;\r
+ EFI_SIMPLE_POINTER_STATE State;\r
+ EFI_SIMPLE_POINTER_MODE Mode;\r
+ BOOLEAN StateChanged;\r
+ USB_MOUSE_BUTTON_DATA PrivateData;\r
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
} USB_MOUSE_DEV;\r
\r
///\r
/// General HID Item structure\r
///\r
+\r
+typedef union {\r
+ UINT8 Uint8;\r
+ UINT16 Uint16;\r
+ UINT32 Uint32;\r
+ INT8 Int8;\r
+ INT16 Int16;\r
+ INT32 Int32;\r
+ UINT8 *LongData;\r
+} HID_DATA;\r
+\r
typedef struct {\r
- UINT16 Format;\r
- UINT8 Size;\r
- UINT8 Type;\r
- UINT8 Tag;\r
- union {\r
- UINT8 U8;\r
- UINT16 U16;\r
- UINT32 U32;\r
- INT8 I8;\r
- INT16 I16;\r
- INT32 I32;\r
- UINT8 *LongData;\r
- } Data;\r
+ UINT16 Format;\r
+ UINT8 Size;\r
+ UINT8 Type;\r
+ UINT8 Tag;\r
+ HID_DATA Data;\r
} HID_ITEM;\r
\r
#define USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL(a) \\r
EFI_STATUS\r
EFIAPI\r
USBMouseDriverBindingSupported (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Controller,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
);\r
\r
/**\r
Starts the mouse device with this driver.\r
\r
- This function consumes USB I/O Portocol, intializes USB mouse device,\r
+ This function consumes USB I/O Protocol, initializes USB mouse device,\r
installs Simple Pointer Protocol, and submits Asynchronous Interrupt\r
Transfer to manage the USB mouse device.\r
\r
EFI_STATUS\r
EFIAPI\r
USBMouseDriverBindingStart (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Controller,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
);\r
\r
/**\r
EFI_STATUS\r
EFIAPI\r
USBMouseDriverBindingStop (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Controller,\r
- IN UINTN NumberOfChildren,\r
- IN EFI_HANDLE *ChildHandleBuffer\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
);\r
\r
//\r
languages specified in SupportedLanguages. The\r
number of languages supported by a driver is up\r
to the driver writer. Language is specified\r
- in RFC 3066 or ISO 639-2 language code format.\r
+ in RFC 4646 or ISO 639-2 language code format.\r
@param DriverName A pointer to the Unicode string to return.\r
This Unicode string is the name of the\r
driver specified by This in the language\r
languages specified in SupportedLanguages. The\r
number of languages supported by a driver is up\r
to the driver writer. Language is specified in\r
- RFC 3066 or ISO 639-2 language code format.\r
+ RFC 4646 or ISO 639-2 language code format.\r
@param ControllerName A pointer to the Unicode string to return.\r
This Unicode string is the name of the\r
controller specified by ControllerHandle and\r
the language specified by Language for the\r
driver specified by This was returned in\r
DriverName.\r
- @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+ @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
EFI_HANDLE.\r
@retval EFI_INVALID_PARAMETER Language is NULL.\r
EFI_STATUS\r
EFIAPI\r
UsbMouseComponentNameGetControllerName (\r
- IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
- IN EFI_HANDLE ControllerHandle,\r
- IN EFI_HANDLE ChildHandle OPTIONAL,\r
- IN CHAR8 *Language,\r
- OUT CHAR16 **ControllerName\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ );\r
+\r
+//\r
+// Functions of EFI_SIMPLE_POINTER_PROTOCOL\r
+//\r
+\r
+/**\r
+ Retrieves the current state of a pointer device.\r
+\r
+ @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL instance.\r
+ @param MouseState A pointer to the state information on the pointer device.\r
+\r
+ @retval EFI_SUCCESS The state of the pointer device was returned in State.\r
+ @retval EFI_NOT_READY The state of the pointer device has not changed since the last call to\r
+ GetState().\r
+ @retval EFI_DEVICE_ERROR A device error occurred while attempting to retrieve the pointer device's\r
+ current state.\r
+ @retval EFI_INVALID_PARAMETER MouseState is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetMouseState (\r
+ IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r
+ OUT EFI_SIMPLE_POINTER_STATE *MouseState\r
+ );\r
+\r
+/**\r
+ Resets the pointer device hardware.\r
+\r
+ @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL instance.\r
+ @param ExtendedVerification Indicates that the driver may perform a more exhaustive\r
+ verification operation of the device during reset.\r
+\r
+ @retval EFI_SUCCESS The device was reset.\r
+ @retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbMouseReset (\r
+ IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
+ );\r
+\r
+/**\r
+ Event notification function for SIMPLE_POINTER.WaitForInput event.\r
+\r
+ @param Event Event to be signaled when there's input from mouse.\r
+ @param Context Points to USB_MOUSE_DEV instance.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+UsbMouseWaitForInput (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
);\r
\r
//\r
**/\r
BOOLEAN\r
IsUsbMouse (\r
- IN EFI_USB_IO_PROTOCOL *UsbIo\r
+ IN EFI_USB_IO_PROTOCOL *UsbIo\r
);\r
\r
/**\r
**/\r
EFI_STATUS\r
InitializeUsbMouseDevice (\r
- IN OUT USB_MOUSE_DEV *UsbMouseDev\r
+ IN OUT USB_MOUSE_DEV *UsbMouseDev\r
);\r
\r
/**\r
EFI_STATUS\r
EFIAPI\r
OnMouseInterruptComplete (\r
- IN VOID *Data,\r
- IN UINTN DataLength,\r
- IN VOID *Context,\r
- IN UINT32 Result\r
- );\r
-\r
-/**\r
- Retrieves the current state of a pointer device.\r
- \r
- @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL instance. \r
- @param MouseState A pointer to the state information on the pointer device.\r
- \r
- @retval EFI_SUCCESS The state of the pointer device was returned in State.\r
- @retval EFI_NOT_READY The state of the pointer device has not changed since the last call to\r
- GetState(). \r
- @retval EFI_DEVICE_ERROR A device error occurred while attempting to retrieve the pointer device's\r
- current state. \r
- @retval EFI_INVALID_PARAMETER MouseState is NULL. \r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-GetMouseState (\r
- IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r
- OUT EFI_SIMPLE_POINTER_STATE *MouseState\r
- );\r
-\r
-/** \r
- Resets the pointer device hardware.\r
- \r
- @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL instance.\r
- @param ExtendedVerification Indicates that the driver may perform a more exhaustive\r
- verification operation of the device during reset.\r
- \r
- @retval EFI_SUCCESS The device was reset.\r
- @retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UsbMouseReset (\r
- IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r
- IN BOOLEAN ExtendedVerification\r
- );\r
-\r
-/**\r
- Event notification function for SIMPLE_POINTER.WaitForInput event.\r
-\r
- @param Event Event to be signaled when there's input from mouse.\r
- @param Context Points to USB_MOUSE_DEV instance.\r
- \r
-**/\r
-VOID\r
-EFIAPI\r
-UsbMouseWaitForInput (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
+ IN VOID *Data,\r
+ IN UINTN DataLength,\r
+ IN VOID *Context,\r
+ IN UINT32 Result\r
);\r
\r
/**\r
VOID\r
EFIAPI\r
USBMouseRecoveryHandler (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
);\r
\r
/**\r
**/\r
EFI_STATUS\r
ParseMouseReportDescriptor (\r
- OUT USB_MOUSE_DEV *UsbMouse,\r
- IN UINT8 *ReportDescriptor,\r
- IN UINTN ReportSize\r
+ OUT USB_MOUSE_DEV *UsbMouse,\r
+ IN UINT8 *ReportDescriptor,\r
+ IN UINTN ReportSize\r
);\r
\r
#endif\r