add UsbMouseSimulateTouchPad driver to verify the correction of dispatching AbsoluteP...
authoreric_tian <eric_tian@de2fecce-e211-0410-80a6-f3fac2684e05>
Wed, 14 Nov 2007 07:08:55 +0000 (07:08 +0000)
committereric_tian <eric_tian@de2fecce-e211-0410-80a6-f3fac2684e05>
Wed, 14 Nov 2007 07:08:55 +0000 (07:08 +0000)
git-svn-id: https://edk2.tianocore.org/svn/edk2/trunk@4297 de2fecce-e211-0410-80a6-f3fac2684e05

13 files changed:
edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/ComponentName.c [new file with mode: 0644]
edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/UsbMouseAbsolutePointerDxe.msa [new file with mode: 0644]
edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/UsbMouseSimulateTouchPad.c [new file with mode: 0644]
edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/UsbMouseSimulateTouchPad.h [new file with mode: 0644]
edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/UsbMouseSimulateTouchPadDxe.inf [new file with mode: 0644]
edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/mousehid.c [new file with mode: 0644]
edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/mousehid.h [new file with mode: 0644]
edk2/MdeModulePkg/MdeModulePkg.dsc
edk2/MdeModulePkg/Universal/Console/ConSplitterDxe/ComponentName.c
edk2/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
edk2/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h
edk2/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
edk2/MdePkg/Include/Protocol/AbsolutePointer.h

diff --git a/edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/ComponentName.c b/edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/ComponentName.c
new file mode 100644 (file)
index 0000000..0c5f88d
--- /dev/null
@@ -0,0 +1,377 @@
+/** @file\r
+\r
+Copyright (c) 2004 - 2007, 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
+\r
+Module Name:\r
+\r
+  UsbMouseSimulateTouchPadComponentName.c\r
+\r
+Abstract:\r
+\r
+\r
+**/\r
+\r
+#include "UsbMouseSimulateTouchPad.h"\r
+#include <Library/DebugLib.h>\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+  This function retrieves the user readable name of a driver in the form of a\r
+  Unicode string. If the driver specified by This has a user readable name in\r
+  the language specified by Language, then a pointer to the driver name is\r
+  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+  by This does not support the language specified by Language,\r
+  then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language. This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\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
+\r
+  @param  DriverName[out]       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
+                                specified by Language.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
+                                This and the language specified by Language was\r
+                                returned in DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbMouseSimulateTouchPadComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  );\r
+\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the controller\r
+  that is being managed by a driver.\r
+\r
+  This function retrieves the user readable name of the controller specified by\r
+  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+  driver specified by This has a user readable name in the language specified by\r
+  Language, then a pointer to the controller name is returned in ControllerName,\r
+  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
+  managing the controller specified by ControllerHandle and ChildHandle,\r
+  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
+  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+                                specified by This is managing.  This handle\r
+                                specifies the controller whose name is to be\r
+                                returned.\r
+\r
+  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+                                the name of.  This is an optional parameter that\r
+                                may be NULL.  It will be NULL for device\r
+                                drivers.  It will also be NULL for a bus drivers\r
+                                that wish to retrieve the name of the bus\r
+                                controller.  It will not be NULL for a bus\r
+                                driver that wishes to retrieve the name of a\r
+                                child controller.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language.  This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\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
+\r
+  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                controller specified by ControllerHandle and\r
+                                ChildHandle in the language specified by\r
+                                Language from the point of view of the driver\r
+                                specified by This.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
+                                the language specified by Language for the\r
+                                driver specified by This was returned in\r
+                                DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+                                EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
+                                managing the controller specified by\r
+                                ControllerHandle and ChildHandle.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbMouseSimulateTouchPadComponentNameGetControllerName (\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
+//\r
+// EFI Component Name Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gUsbMouseSimulateTouchPadComponentName = {\r
+  UsbMouseSimulateTouchPadComponentNameGetDriverName,\r
+  UsbMouseSimulateTouchPadComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+//\r
+// EFI Component Name 2 Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbMouseSimulateTouchPadComponentName2 = {\r
+  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UsbMouseSimulateTouchPadComponentNameGetDriverName,\r
+  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UsbMouseSimulateTouchPadComponentNameGetControllerName,\r
+  "en"\r
+};\r
+\r
+\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbMouseSimulateTouchPadDriverNameTable[] = {\r
+  { "eng;en", L"Usb Mouse Simulate TouchPad Driver" },\r
+  { NULL , NULL }\r
+};\r
+\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+  This function retrieves the user readable name of a driver in the form of a\r
+  Unicode string. If the driver specified by This has a user readable name in\r
+  the language specified by Language, then a pointer to the driver name is\r
+  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+  by This does not support the language specified by Language,\r
+  then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language. This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\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
+\r
+  @param  DriverName[out]       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
+                                specified by Language.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
+                                This and the language specified by Language was\r
+                                returned in DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbMouseSimulateTouchPadComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+{\r
+  return LookupUnicodeString2 (\r
+           Language,\r
+           This->SupportedLanguages,\r
+           mUsbMouseSimulateTouchPadDriverNameTable,\r
+           DriverName,\r
+           (BOOLEAN)(This == &gUsbMouseSimulateTouchPadComponentName)\r
+           );\r
+}\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the controller\r
+  that is being managed by a driver.\r
+\r
+  This function retrieves the user readable name of the controller specified by\r
+  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+  driver specified by This has a user readable name in the language specified by\r
+  Language, then a pointer to the controller name is returned in ControllerName,\r
+  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
+  managing the controller specified by ControllerHandle and ChildHandle,\r
+  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
+  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+                                specified by This is managing.  This handle\r
+                                specifies the controller whose name is to be\r
+                                returned.\r
+\r
+  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+                                the name of.  This is an optional parameter that\r
+                                may be NULL.  It will be NULL for device\r
+                                drivers.  It will also be NULL for a bus drivers\r
+                                that wish to retrieve the name of the bus\r
+                                controller.  It will not be NULL for a bus\r
+                                driver that wishes to retrieve the name of a\r
+                                child controller.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language.  This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\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
+\r
+  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                controller specified by ControllerHandle and\r
+                                ChildHandle in the language specified by\r
+                                Language from the point of view of the driver\r
+                                specified by This.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
+                                the language specified by Language for the\r
+                                driver specified by This was returned in\r
+                                DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+                                EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
+                                managing the controller specified by\r
+                                ControllerHandle and ChildHandle.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbMouseSimulateTouchPadComponentNameGetControllerName (\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
+  EFI_STATUS                  Status;\r
+  USB_MOUSE_SIMULATE_TOUCHPAD_DEV               *UsbMouseSimulateTouchPadDev;\r
+  EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointerProtocol;\r
+  EFI_USB_IO_PROTOCOL         *UsbIoProtocol;\r
+\r
+  //\r
+  // This is a device driver, so ChildHandle must be NULL.\r
+  //\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Check Controller's handle\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiUsbIoProtocolGuid,\r
+                  (VOID **) &UsbIoProtocol,\r
+                  gUsbMouseSimulateTouchPadDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->CloseProtocol (\r
+          ControllerHandle,\r
+          &gEfiUsbIoProtocolGuid,\r
+          gUsbMouseSimulateTouchPadDriverBinding.DriverBindingHandle,\r
+          ControllerHandle\r
+          );\r
+\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (Status != EFI_ALREADY_STARTED) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Get the device context\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                 &gEfiAbsolutePointerProtocolGuid,\r
+                  (VOID **) &AbsolutePointerProtocol,\r
+                  gUsbMouseSimulateTouchPadDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  UsbMouseSimulateTouchPadDev = USB_MOUSE_SIMULATE_TOUCHPAD_DEV_FROM_MOUSE_PROTOCOL (AbsolutePointerProtocol);\r
+\r
+  return LookupUnicodeString2 (\r
+           Language,\r
+           This->SupportedLanguages,\r
+           UsbMouseSimulateTouchPadDev->ControllerNameTable,\r
+           ControllerName,\r
+           (BOOLEAN)(This == &gUsbMouseSimulateTouchPadComponentName)\r
+           );\r
+\r
+}\r
diff --git a/edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/UsbMouseAbsolutePointerDxe.msa b/edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/UsbMouseAbsolutePointerDxe.msa
new file mode 100644 (file)
index 0000000..fad0d09
--- /dev/null
@@ -0,0 +1,73 @@
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>UsbMouseSimulateTouchPadDxe</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>4EA43463-747C-46eb-97FB-B0E5C5F05306</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component name for module UsbMouseSimulateTouchPad</Abstract>\r
+    <Description>FIX ME!</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation. </Copyright>\r
+    <License>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.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>UsbMouseSimulateTouchPadDxe</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>ReportStatusCodeLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>UsbMouseSimulateTouchPad.h</Filename>\r
+    <Filename>mousehid.c</Filename>\r
+    <Filename>UsbMouseSimulateTouchPad.c</Filename>\r
+    <Filename>ComponentName.c</Filename>\r
+    <Filename>mousehid.h</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="1E73767F-8F52-4603-AEB4-F29B510B6766"/>\r
+    <Package PackageGuid="2759ded5-bb57-4b06-af4f-c398fa552719"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiAbsolutePointerProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiUsbIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>USBMouseSimulateTouchPadDriverBindingEntryPoint</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
diff --git a/edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/UsbMouseSimulateTouchPad.c b/edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/UsbMouseSimulateTouchPad.c
new file mode 100644 (file)
index 0000000..4412881
--- /dev/null
@@ -0,0 +1,1025 @@
+/** @file\r
+\r
+Copyright (c) 2004 - 2007, 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
+\r
+  Module Name:\r
+\r
+    UsbMouseSimulateTouchPad.c\r
+\r
+  Abstract:\r
+\r
+\r
+**/\r
+\r
+#include "UsbMouseSimulateTouchPad.h"\r
+\r
+#include <Library/DebugLib.h>\r
+#include <IndustryStandard/Usb.h>\r
+\r
+#include "mousehid.h"\r
+\r
+//\r
+// Prototypes\r
+// Driver model protocol interface\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+USBMouseSimulateTouchPadDriverBindingEntryPoint (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+USBMouseSimulateTouchPadDriverBindingSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+USBMouseSimulateTouchPadDriverBindingStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+USBMouseSimulateTouchPadDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
+  IN  EFI_HANDLE                    Controller,\r
+  IN  UINTN                         NumberOfChildren,\r
+  IN  EFI_HANDLE                    *ChildHandleBuffer\r
+  );\r
+\r
+EFI_GUID  gEfiUsbMouseSimulateTouchPadDriverGuid = {\r
+  0xa579f729, 0xa71d, 0x4b45, { 0xbe, 0xd7, 0xd, 0xb0, 0xa8, 0x7c, 0x3e, 0x8d }\r
+};\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gUsbMouseSimulateTouchPadDriverBinding = {\r
+  USBMouseSimulateTouchPadDriverBindingSupported,\r
+  USBMouseSimulateTouchPadDriverBindingStart,\r
+  USBMouseSimulateTouchPadDriverBindingStop,\r
+  0x1,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+//\r
+// helper functions\r
+//\r
+STATIC\r
+BOOLEAN\r
+IsUsbMouseSimulateTouchPad (\r
+  IN  EFI_USB_IO_PROTOCOL     *UsbIo\r
+  );\r
+\r
+STATIC\r
+EFI_STATUS\r
+InitializeUsbMouseSimulateTouchPadDevice (\r
+  IN  USB_MOUSE_SIMULATE_TOUCHPAD_DEV           *UsbMouseSimulateTouchPadDev\r
+  );\r
+\r
+STATIC\r
+VOID\r
+EFIAPI\r
+UsbMouseSimulateTouchPadWaitForInput (\r
+  IN  EFI_EVENT               Event,\r
+  IN  VOID                    *Context\r
+  );\r
+\r
+//\r
+// Mouse interrupt handler\r
+//\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+OnMouseSimulateTouchPadInterruptComplete (\r
+  IN  VOID        *Data,\r
+  IN  UINTN       DataLength,\r
+  IN  VOID        *Context,\r
+  IN  UINT32      Result\r
+  );\r
+\r
+//\r
+// Mouse simulate TouchPad, Using AbsolutePointer Protocol\r
+//\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+GetMouseSimulateTouchPadState (\r
+  IN   EFI_ABSOLUTE_POINTER_PROTOCOL  *This,\r
+  OUT  EFI_ABSOLUTE_POINTER_STATE     *MouseSimulateTouchPadState\r
+  );\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UsbMouseSimulateTouchPadReset (\r
+  IN EFI_ABSOLUTE_POINTER_PROTOCOL    *This,\r
+  IN BOOLEAN                        ExtendedVerification\r
+  );\r
+\r
+//\r
+// Driver start here\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+USBMouseSimulateTouchPadDriverBindingEntryPoint (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Entry point for EFI drivers.\r
+\r
+  Arguments:\r
+   ImageHandle - EFI_HANDLE\r
+   SystemTable - EFI_SYSTEM_TABLE\r
+  Returns:\r
+    EFI_SUCCESS\r
+    others\r
+\r
+--*/\r
+{\r
+       return EfiLibInstallDriverBindingComponentName2 (\r
+           ImageHandle,\r
+           SystemTable,\r
+           &gUsbMouseSimulateTouchPadDriverBinding,\r
+           ImageHandle,\r
+           &gUsbMouseSimulateTouchPadComponentName,\r
+           &gUsbMouseSimulateTouchPadComponentName2\r
+           );\r
+}\r
+\r
+\r
+/**\r
+  Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
+  that has UsbHcProtocol installed will be supported.\r
+\r
+  @param  This                  Protocol instance pointer.\r
+  @param  Controller            Handle of device to test\r
+  @param  RemainingDevicePath   Not used\r
+\r
+  @retval EFI_SUCCESS           This driver supports this device.\r
+  @retval EFI_UNSUPPORTED       This driver does not support this device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+USBMouseSimulateTouchPadDriverBindingSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
+  )\r
+{\r
+  EFI_STATUS          OpenStatus;\r
+  EFI_USB_IO_PROTOCOL *UsbIo;\r
+  EFI_STATUS          Status;\r
+\r
+  OpenStatus = gBS->OpenProtocol (\r
+                      Controller,\r
+                      &gEfiUsbIoProtocolGuid,\r
+                      (VOID **) &UsbIo,\r
+                      This->DriverBindingHandle,\r
+                      Controller,\r
+                      EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                      );\r
+  if (EFI_ERROR (OpenStatus) && (OpenStatus != EFI_ALREADY_STARTED)) {\r
+       return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (OpenStatus == EFI_ALREADY_STARTED) {\r
+    return EFI_ALREADY_STARTED;\r
+  }\r
+  \r
+  //\r
+  // Use the USB I/O protocol interface to see the Controller is\r
+  // the Mouse controller that can be managed by this driver.\r
+  //\r
+  Status = EFI_SUCCESS;\r
+  if (!IsUsbMouseSimulateTouchPad (UsbIo)) {\r
+    Status = EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  gBS->CloseProtocol (\r
+        Controller,\r
+        &gEfiUsbIoProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        Controller\r
+        );\r
+        \r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Starting the Usb Bus Driver\r
+\r
+  @param  This                  Protocol instance pointer.\r
+  @param  Controller            Handle of device to test\r
+  @param  RemainingDevicePath   Not used\r
+\r
+  @retval EFI_SUCCESS           This driver supports this device.\r
+  @retval EFI_UNSUPPORTED       This driver does not support this device.\r
+  @retval EFI_DEVICE_ERROR      This driver cannot be started due to device Error\r
+                                EFI_OUT_OF_RESOURCES- Can't allocate memory\r
+                                resources\r
+  @retval EFI_ALREADY_STARTED   Thios driver has been started\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+USBMouseSimulateTouchPadDriverBindingStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_USB_IO_PROTOCOL         *UsbIo;\r
+  EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDesc;\r
+  USB_MOUSE_SIMULATE_TOUCHPAD_DEV               *UsbMouseSimulateTouchPadDevice;\r
+  UINT8                       EndpointNumber;\r
+  UINT8                       Index;\r
+  UINT8                       EndpointAddr;\r
+  UINT8                       PollingInterval;\r
+  UINT8                       PacketSize;\r
+\r
+  UsbMouseSimulateTouchPadDevice  = NULL;\r
+  Status          = EFI_SUCCESS;\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiUsbIoProtocolGuid,\r
+                  (VOID **) &UsbIo,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER                  \r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto ErrorExit;\r
+  }\r
+  \r
+  UsbMouseSimulateTouchPadDevice = AllocateZeroPool (sizeof (USB_MOUSE_SIMULATE_TOUCHPAD_DEV));\r
+  if (UsbMouseSimulateTouchPadDevice == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto ErrorExit;\r
+  }\r
+\r
+  UsbMouseSimulateTouchPadDevice->UsbIo               = UsbIo;\r
+\r
+  UsbMouseSimulateTouchPadDevice->Signature           = USB_MOUSE_SIMULATE_TOUCHPAD_DEV_SIGNATURE;\r
+\r
+  UsbMouseSimulateTouchPadDevice->InterfaceDescriptor = AllocatePool (sizeof (EFI_USB_INTERFACE_DESCRIPTOR));\r
+  if (UsbMouseSimulateTouchPadDevice->InterfaceDescriptor == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto ErrorExit;\r
+  }\r
+\r
+  EndpointDesc = AllocatePool (sizeof (EFI_USB_ENDPOINT_DESCRIPTOR));\r
+  if (EndpointDesc == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto ErrorExit;\r
+  }\r
+  //\r
+  // Get the Device Path Protocol on Controller's handle\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &UsbMouseSimulateTouchPadDevice->DevicePath,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto ErrorExit;\r
+  }\r
+  //\r
+  // Get interface & endpoint descriptor\r
+  //\r
+  UsbIo->UsbGetInterfaceDescriptor (\r
+          UsbIo,\r
+          UsbMouseSimulateTouchPadDevice->InterfaceDescriptor\r
+          );\r
+\r
+  EndpointNumber = UsbMouseSimulateTouchPadDevice->InterfaceDescriptor->NumEndpoints;\r
+\r
+  for (Index = 0; Index < EndpointNumber; Index++) {\r
+    UsbIo->UsbGetEndpointDescriptor (\r
+            UsbIo,\r
+            Index,\r
+            EndpointDesc\r
+            );\r
+\r
+    if ((EndpointDesc->Attributes & 0x03) == 0x03) {\r
+\r
+      //\r
+      // We only care interrupt endpoint here\r
+      //\r
+      UsbMouseSimulateTouchPadDevice->IntEndpointDescriptor = EndpointDesc;\r
+    }\r
+  }\r
+\r
+  if (UsbMouseSimulateTouchPadDevice->IntEndpointDescriptor == NULL) {\r
+    //\r
+    // No interrupt endpoint, then error\r
+    //\r
+    Status = EFI_UNSUPPORTED;\r
+    goto ErrorExit;\r
+  }\r
+\r
+  Status = InitializeUsbMouseSimulateTouchPadDevice (UsbMouseSimulateTouchPadDevice);\r
+  if (EFI_ERROR (Status)) {\r
+    MouseSimulateTouchPadReportStatusCode (\r
+      UsbMouseSimulateTouchPadDevice->DevicePath,\r
+      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+      PcdGet32 (PcdStatusCodeValueMouseInterfaceError)\r
+      );\r
+\r
+    goto ErrorExit;\r
+  }\r
+\r
+       UsbMouseSimulateTouchPadDevice->AbsolutePointerProtocol.GetState = GetMouseSimulateTouchPadState;\r
+       UsbMouseSimulateTouchPadDevice->AbsolutePointerProtocol.Reset      = UsbMouseSimulateTouchPadReset;\r
+       UsbMouseSimulateTouchPadDevice->AbsolutePointerProtocol.Mode       = &UsbMouseSimulateTouchPadDevice->AbsolutePointerMode;\r
+\r
+       Status = gBS->CreateEvent (\r
+                                       EVT_NOTIFY_WAIT,\r
+                                       TPL_NOTIFY,\r
+                                       UsbMouseSimulateTouchPadWaitForInput,\r
+                                       UsbMouseSimulateTouchPadDevice,\r
+                                       &((UsbMouseSimulateTouchPadDevice->AbsolutePointerProtocol).WaitForInput)\r
+                                       );\r
+       if (EFI_ERROR (Status)) {\r
+               goto ErrorExit;\r
+       }\r
+\r
+       Status = gBS->InstallProtocolInterface (\r
+                                       &Controller,\r
+                                       &gEfiAbsolutePointerProtocolGuid,\r
+                                       EFI_NATIVE_INTERFACE,\r
+                                       &UsbMouseSimulateTouchPadDevice->AbsolutePointerProtocol\r
+                                       );\r
+\r
+       if (EFI_ERROR (Status)) {\r
+       Status = EFI_DEVICE_ERROR;\r
+       goto ErrorExit;\r
+       }\r
+\r
+  //\r
+  // After Enabling Async Interrupt Transfer on this mouse Device\r
+  // we will be able to get key data from it. Thus this is deemed as\r
+  // the enable action of the mouse\r
+  //\r
+\r
+  MouseSimulateTouchPadReportStatusCode (\r
+    UsbMouseSimulateTouchPadDevice->DevicePath,\r
+    EFI_PROGRESS_CODE,\r
+    PcdGet32 (PcdStatusCodeValueMouseEnable)\r
+    );\r
+\r
+  //\r
+  // submit async interrupt transfer\r
+  //\r
+  EndpointAddr    = UsbMouseSimulateTouchPadDevice->IntEndpointDescriptor->EndpointAddress;\r
+  PollingInterval = UsbMouseSimulateTouchPadDevice->IntEndpointDescriptor->Interval;\r
+  PacketSize      = (UINT8) (UsbMouseSimulateTouchPadDevice->IntEndpointDescriptor->MaxPacketSize);\r
+\r
+  Status = UsbIo->UsbAsyncInterruptTransfer (\r
+                    UsbIo,\r
+                    EndpointAddr,\r
+                    TRUE,\r
+                    PollingInterval,\r
+                    PacketSize,\r
+                    OnMouseSimulateTouchPadInterruptComplete,\r
+                    UsbMouseSimulateTouchPadDevice\r
+                    );\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+\r
+    UsbMouseSimulateTouchPadDevice->ControllerNameTable = NULL;\r
+    AddUnicodeString2 (\r
+      "eng",\r
+      gUsbMouseSimulateTouchPadComponentName.SupportedLanguages,\r
+      &UsbMouseSimulateTouchPadDevice->ControllerNameTable,\r
+      L"Generic Usb Mouse Simulate TouchPad",\r
+      TRUE\r
+      );\r
+    AddUnicodeString2 (\r
+      "en",\r
+      gUsbMouseSimulateTouchPadComponentName2.SupportedLanguages,\r
+      &UsbMouseSimulateTouchPadDevice->ControllerNameTable,\r
+      L"Generic Usb Mouse Simulate TouchPad2",\r
+      FALSE\r
+      );\r
+\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // If submit error, uninstall that interface\r
+  //\r
+  Status = EFI_DEVICE_ERROR;\r
+\r
+  gBS->UninstallProtocolInterface (\r
+               Controller,\r
+               &gEfiAbsolutePointerProtocolGuid,\r
+               &UsbMouseSimulateTouchPadDevice->AbsolutePointerProtocol\r
+  );\r
+\r
+ErrorExit:\r
+       DEBUG ((EFI_D_ERROR, __FUNCTION__ " driver start fail\n"));\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->CloseProtocol (\r
+          Controller,\r
+          &gEfiUsbIoProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          Controller\r
+          );\r
+\r
+    if (UsbMouseSimulateTouchPadDevice != NULL) {\r
+      if (UsbMouseSimulateTouchPadDevice->InterfaceDescriptor != NULL) {\r
+        gBS->FreePool (UsbMouseSimulateTouchPadDevice->InterfaceDescriptor);\r
+      }\r
+\r
+      if (UsbMouseSimulateTouchPadDevice->IntEndpointDescriptor != NULL) {\r
+        gBS->FreePool (UsbMouseSimulateTouchPadDevice->IntEndpointDescriptor);\r
+      }\r
+  \r
+         if ((UsbMouseSimulateTouchPadDevice->AbsolutePointerProtocol).WaitForInput != NULL) {\r
+               gBS->CloseEvent ((UsbMouseSimulateTouchPadDevice->AbsolutePointerProtocol).WaitForInput);\r
+         }\r
+\r
+      gBS->FreePool (UsbMouseSimulateTouchPadDevice);\r
+      UsbMouseSimulateTouchPadDevice = NULL;\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Stop this driver on ControllerHandle. Support stoping any child handles\r
+  created by this driver.\r
+\r
+  @param  This                  Protocol instance pointer.\r
+  @param  Controller            Handle of device to stop driver on\r
+  @param  NumberOfChildren      Number of Children in the ChildHandleBuffer\r
+  @param  ChildHandleBuffer     List of handles for the children we need to stop.\r
+\r
+  @return EFI_SUCCESS\r
+  @return EFI_DEVICE_ERROR\r
+  @return others\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+USBMouseSimulateTouchPadDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
+  IN  EFI_HANDLE                    Controller,\r
+  IN  UINTN                         NumberOfChildren,\r
+  IN  EFI_HANDLE                    *ChildHandleBuffer\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  USB_MOUSE_SIMULATE_TOUCHPAD_DEV               *UsbMouseSimulateTouchPadDevice;\r
+  EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointerProtocol;\r
+  EFI_USB_IO_PROTOCOL         *UsbIo;\r
+\r
+  //\r
+  // Get our context back.\r
+  //\r
+       Status = gBS->OpenProtocol (\r
+                       Controller,\r
+                       &gEfiAbsolutePointerProtocolGuid,\r
+                       (VOID **) &AbsolutePointerProtocol,\r
+                       This->DriverBindingHandle,\r
+                       Controller,\r
+                       EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+       );\r
+\r
+       if (EFI_ERROR (Status)) {\r
+               return EFI_UNSUPPORTED;\r
+       }\r
+  UsbMouseSimulateTouchPadDevice = USB_MOUSE_SIMULATE_TOUCHPAD_DEV_FROM_MOUSE_PROTOCOL (AbsolutePointerProtocol);\r
+\r
+  gBS->CloseProtocol (\r
+        Controller,\r
+        &gEfiAbsolutePointerProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        Controller\r
+        );\r
+\r
+  UsbIo = UsbMouseSimulateTouchPadDevice->UsbIo;\r
+\r
+  //\r
+  // Uninstall the Asyn Interrupt Transfer from this device\r
+  // will disable the mouse data input from this device\r
+  //\r
+  MouseSimulateTouchPadReportStatusCode (\r
+    UsbMouseSimulateTouchPadDevice->DevicePath,\r
+    EFI_PROGRESS_CODE,\r
+    PcdGet32 (PcdStatusCodeValueMouseDisable)\r
+    );\r
+\r
+  //\r
+  // Delete Mouse Async Interrupt Transfer\r
+  //\r
+  UsbIo->UsbAsyncInterruptTransfer (\r
+          UsbIo,\r
+          UsbMouseSimulateTouchPadDevice->IntEndpointDescriptor->EndpointAddress,\r
+          FALSE,\r
+          UsbMouseSimulateTouchPadDevice->IntEndpointDescriptor->Interval,\r
+          0,\r
+          NULL,\r
+          NULL\r
+          );\r
+\r
+  gBS->CloseEvent (UsbMouseSimulateTouchPadDevice->AbsolutePointerProtocol.WaitForInput);\r
+  \r
+  if (UsbMouseSimulateTouchPadDevice->DelayedRecoveryEvent) {\r
+    gBS->CloseEvent (UsbMouseSimulateTouchPadDevice->DelayedRecoveryEvent);\r
+    UsbMouseSimulateTouchPadDevice->DelayedRecoveryEvent = 0;\r
+  }\r
+\r
+  Status = gBS->UninstallProtocolInterface (\r
+                  Controller,\r
+                  &gEfiAbsolutePointerProtocolGuid,\r
+                  &UsbMouseSimulateTouchPadDevice->AbsolutePointerProtocol\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  gBS->CloseProtocol (\r
+        Controller,\r
+        &gEfiUsbIoProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        Controller\r
+        );\r
+\r
+  gBS->FreePool (UsbMouseSimulateTouchPadDevice->InterfaceDescriptor);\r
+  gBS->FreePool (UsbMouseSimulateTouchPadDevice->IntEndpointDescriptor);\r
+\r
+  if (UsbMouseSimulateTouchPadDevice->ControllerNameTable) {\r
+    FreeUnicodeStringTable (UsbMouseSimulateTouchPadDevice->ControllerNameTable);\r
+  }\r
+\r
+  gBS->FreePool (UsbMouseSimulateTouchPadDevice);\r
+\r
+  return EFI_SUCCESS;\r
+\r
+}\r
+\r
+\r
+/**\r
+  Tell if a Usb Controller is a mouse\r
+\r
+  @param  UsbIo                 Protocol instance pointer.\r
+\r
+  @retval TRUE                  It is a mouse\r
+  @retval FALSE                 It is not a mouse\r
+\r
+**/\r
+BOOLEAN\r
+IsUsbMouseSimulateTouchPad (\r
+  IN  EFI_USB_IO_PROTOCOL     *UsbIo\r
+  )\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_USB_INTERFACE_DESCRIPTOR  InterfaceDescriptor;\r
+\r
+  //\r
+  // Get the Default interface descriptor, now we only\r
+  // suppose it is interface 1\r
+  //\r
+  Status = UsbIo->UsbGetInterfaceDescriptor (\r
+                    UsbIo,\r
+                    &InterfaceDescriptor\r
+                    );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if ((InterfaceDescriptor.InterfaceClass == CLASS_HID) &&\r
+      (InterfaceDescriptor.InterfaceSubClass == SUBCLASS_BOOT) &&\r
+      (InterfaceDescriptor.InterfaceProtocol == PROTOCOL_MOUSE)\r
+      ) {\r
+       \r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+\r
+/**\r
+  Initialize the Usb Mouse Simulate TouchPad Device.\r
+\r
+  @param  UsbMouseSimulateTouchPadDev           Device instance to be initialized\r
+\r
+  @retval EFI_SUCCESS           Success\r
+  @retval EFI_DEVICE_ERROR      Init error. EFI_OUT_OF_RESOURCES- Can't allocate\r
+                                memory\r
+\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+InitializeUsbMouseSimulateTouchPadDevice (\r
+  IN  USB_MOUSE_SIMULATE_TOUCHPAD_DEV           *UsbMouseSimulateTouchPadDev\r
+  )\r
+{\r
+  EFI_USB_IO_PROTOCOL     *UsbIo;\r
+  UINT8                   Protocol;\r
+  EFI_STATUS              Status;\r
+  EFI_USB_HID_DESCRIPTOR  MouseHidDesc;\r
+  UINT8                   *ReportDesc;\r
+\r
+  UsbIo = UsbMouseSimulateTouchPadDev->UsbIo;\r
+\r
+  //\r
+  // Get HID descriptor\r
+  //\r
+  Status = UsbGetHidDescriptor (\r
+            UsbIo,\r
+            UsbMouseSimulateTouchPadDev->InterfaceDescriptor->InterfaceNumber,\r
+            &MouseHidDesc\r
+            );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Get Report descriptor\r
+  //\r
+  if (MouseHidDesc.HidClassDesc[0].DescriptorType != 0x22) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  ReportDesc = AllocateZeroPool (MouseHidDesc.HidClassDesc[0].DescriptorLength);\r
+  if (ReportDesc == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Status = UsbGetReportDescriptor (\r
+            UsbIo,\r
+            UsbMouseSimulateTouchPadDev->InterfaceDescriptor->InterfaceNumber,\r
+            MouseHidDesc.HidClassDesc[0].DescriptorLength,\r
+            ReportDesc\r
+            );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->FreePool (ReportDesc);\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Parse report descriptor\r
+  //\r
+  Status = ParseMouseReportDescriptor (\r
+            UsbMouseSimulateTouchPadDev,\r
+            ReportDesc,\r
+            MouseHidDesc.HidClassDesc[0].DescriptorLength\r
+            );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->FreePool (ReportDesc);\r
+    return Status;\r
+  }\r
+\r
+       UsbMouseSimulateTouchPadDev->AbsolutePointerMode.AbsoluteMaxX = 1024;\r
+       UsbMouseSimulateTouchPadDev->AbsolutePointerMode.AbsoluteMaxY = 1024;\r
+       UsbMouseSimulateTouchPadDev->AbsolutePointerMode.AbsoluteMaxZ = 0;\r
+       UsbMouseSimulateTouchPadDev->AbsolutePointerMode.AbsoluteMinX = 0;\r
+       UsbMouseSimulateTouchPadDev->AbsolutePointerMode.AbsoluteMinY = 0;\r
+       UsbMouseSimulateTouchPadDev->AbsolutePointerMode.AbsoluteMinZ = 0;\r
+       UsbMouseSimulateTouchPadDev->AbsolutePointerMode.Attributes   = 0x3;\r
+  \r
+  //\r
+  // Here we just assume interface 0 is the mouse interface\r
+  //\r
+  UsbGetProtocolRequest (\r
+    UsbIo,\r
+    0,\r
+    &Protocol\r
+    );\r
+\r
+  if (Protocol != BOOT_PROTOCOL) {\r
+    Status = UsbSetProtocolRequest (\r
+              UsbIo,\r
+              0,\r
+              BOOT_PROTOCOL\r
+              );\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      gBS->FreePool (ReportDesc);\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Set indefinite Idle rate for USB Mouse\r
+  //\r
+  UsbSetIdleRequest (\r
+    UsbIo,\r
+    0,\r
+    0,\r
+    0\r
+    );\r
+\r
+  gBS->FreePool (ReportDesc);\r
+\r
+  if (UsbMouseSimulateTouchPadDev->DelayedRecoveryEvent) {\r
+    gBS->CloseEvent (UsbMouseSimulateTouchPadDev->DelayedRecoveryEvent);\r
+    UsbMouseSimulateTouchPadDev->DelayedRecoveryEvent = 0;\r
+  }\r
+\r
+  Status = gBS->CreateEvent (\r
+                  EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
+                  TPL_NOTIFY,\r
+                  USBMouseSimulateTouchPadRecoveryHandler,\r
+                  UsbMouseSimulateTouchPadDev,\r
+                  &UsbMouseSimulateTouchPadDev->DelayedRecoveryEvent\r
+                  );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  It is called whenever there is data received from async interrupt\r
+  transfer.\r
+\r
+  @param  Data                  Data received.\r
+  @param  DataLength            Length of Data\r
+  @param  Context               Passed in context\r
+  @param  Result                Async Interrupt Transfer result\r
+\r
+  @return EFI_SUCCESS\r
+  @return EFI_DEVICE_ERROR\r
+\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+OnMouseSimulateTouchPadInterruptComplete (\r
+  IN  VOID        *Data,\r
+  IN  UINTN       DataLength,\r
+  IN  VOID        *Context,\r
+  IN  UINT32      Result\r
+  )\r
+{\r
+  USB_MOUSE_SIMULATE_TOUCHPAD_DEV       *UsbMouseSimulateTouchPadDevice;\r
+  EFI_USB_IO_PROTOCOL *UsbIo;\r
+  UINT8               EndpointAddr;\r
+  UINT32              UsbResult;\r
+\r
+  UsbMouseSimulateTouchPadDevice  = (USB_MOUSE_SIMULATE_TOUCHPAD_DEV *) Context;\r
+  UsbIo           = UsbMouseSimulateTouchPadDevice->UsbIo;\r
+\r
+  if (Result != EFI_USB_NOERROR) {\r
+    //\r
+    // Some errors happen during the process\r
+    //\r
+    MouseSimulateTouchPadReportStatusCode (\r
+      UsbMouseSimulateTouchPadDevice->DevicePath,\r
+      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+      PcdGet32 (PcdStatusCodeValueMouseInputError)\r
+      );\r
+\r
+    if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {\r
+      EndpointAddr = UsbMouseSimulateTouchPadDevice->IntEndpointDescriptor->EndpointAddress;\r
+\r
+      UsbClearEndpointHalt (\r
+        UsbIo,\r
+        EndpointAddr,\r
+        &UsbResult\r
+        );\r
+    }\r
+\r
+    UsbIo->UsbAsyncInterruptTransfer (\r
+            UsbIo,\r
+            UsbMouseSimulateTouchPadDevice->IntEndpointDescriptor->EndpointAddress,\r
+            FALSE,\r
+            0,\r
+            0,\r
+            NULL,\r
+            NULL\r
+            );\r
+\r
+    gBS->SetTimer (\r
+          UsbMouseSimulateTouchPadDevice->DelayedRecoveryEvent,\r
+          TimerRelative,\r
+          EFI_USB_INTERRUPT_DELAY\r
+          );\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  if (DataLength == 0 || Data == NULL) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+       //\r
+       //Check mouse Data\r
+       //\r
+       UsbMouseSimulateTouchPadDevice->AbsolutePointerStateChanged = TRUE;\r
+       UsbMouseSimulateTouchPadDevice->AbsolutePointerState.CurrentX += *((INT8 *) Data + 1);\r
+       UsbMouseSimulateTouchPadDevice->AbsolutePointerState.CurrentY += *((INT8 *) Data + 2);\r
+       if (DataLength > 3) {\r
+               UsbMouseSimulateTouchPadDevice->AbsolutePointerState.CurrentZ += *((INT8 *) Data + 3);\r
+       }\r
+       UsbMouseSimulateTouchPadDevice->AbsolutePointerState.ActiveButtons = *(UINT8 *)Data & 0x3;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Get the mouse state, see ABSOLUTE POINTER PROTOCOL.\r
+\r
+  @param  This                  Protocol instance pointer.\r
+  @param  MouseState            Current mouse state\r
+\r
+  @return EFI_SUCCESS\r
+  @return EFI_DEVICE_ERROR\r
+  @return EFI_NOT_READY\r
+\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+GetMouseSimulateTouchPadState (\r
+  IN   EFI_ABSOLUTE_POINTER_PROTOCOL  *This,\r
+  OUT  EFI_ABSOLUTE_POINTER_STATE     *MouseSimulateTouchPadState\r
+  )\r
+{\r
+  USB_MOUSE_SIMULATE_TOUCHPAD_DEV *MouseSimulateTouchPadDev;\r
+\r
+  if (MouseSimulateTouchPadState == NULL) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  MouseSimulateTouchPadDev = USB_MOUSE_SIMULATE_TOUCHPAD_DEV_FROM_MOUSE_PROTOCOL (This);\r
+\r
+  if (!MouseSimulateTouchPadDev->AbsolutePointerStateChanged) {\r
+    return EFI_NOT_READY;\r
+  }\r
+\r
+  CopyMem (\r
+    MouseSimulateTouchPadState,\r
+    &MouseSimulateTouchPadDev->AbsolutePointerState,\r
+    sizeof (EFI_ABSOLUTE_POINTER_STATE)\r
+    );\r
+\r
+  //\r
+  // Clear previous move state\r
+  //\r
+  MouseSimulateTouchPadDev->AbsolutePointerState.CurrentX = 0;\r
+  MouseSimulateTouchPadDev->AbsolutePointerState.CurrentY = 0;\r
+  MouseSimulateTouchPadDev->AbsolutePointerState.CurrentZ = 0;\r
+  MouseSimulateTouchPadDev->AbsolutePointerState.ActiveButtons = 0;\r
+\r
+  MouseSimulateTouchPadDev->AbsolutePointerStateChanged            = FALSE;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Reset the mouse device, see ABSOLUTE POINTER PROTOCOL.\r
+\r
+  @param  This                  Protocol instance pointer.\r
+  @param  ExtendedVerification  Ignored here/\r
+\r
+  @return EFI_SUCCESS\r
+\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UsbMouseSimulateTouchPadReset (\r
+  IN EFI_ABSOLUTE_POINTER_PROTOCOL    *This,\r
+  IN BOOLEAN                        ExtendedVerification\r
+  )\r
+{\r
+  USB_MOUSE_SIMULATE_TOUCHPAD_DEV       *UsbMouseSimulateTouchPadDevice;\r
+\r
+  UsbMouseSimulateTouchPadDevice  = USB_MOUSE_SIMULATE_TOUCHPAD_DEV_FROM_MOUSE_PROTOCOL (This);\r
+\r
+  MouseSimulateTouchPadReportStatusCode (\r
+    UsbMouseSimulateTouchPadDevice->DevicePath,\r
+    EFI_PROGRESS_CODE,\r
+    PcdGet32 (PcdStatusCodeValueMouseReset)\r
+    );\r
+\r
+  ZeroMem (\r
+    &UsbMouseSimulateTouchPadDevice->AbsolutePointerState,\r
+    sizeof (EFI_ABSOLUTE_POINTER_STATE)\r
+    );\r
+  UsbMouseSimulateTouchPadDevice->AbsolutePointerStateChanged = FALSE;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Event notification function for ABSOLUTE_POINTER.WaitForInput event\r
+  Signal the event if there is input from mouse\r
+\r
+  @param  Event                 Wait Event\r
+  @param  Context               Passed parameter to event handler\r
+ VOID\r
+\r
+**/\r
+STATIC\r
+VOID\r
+EFIAPI\r
+UsbMouseSimulateTouchPadWaitForInput (\r
+  IN  EFI_EVENT               Event,\r
+  IN  VOID                    *Context\r
+  )\r
+{\r
+  USB_MOUSE_SIMULATE_TOUCHPAD_DEV *UsbMouseSimulateTouchPadDev;\r
+\r
+  UsbMouseSimulateTouchPadDev = (USB_MOUSE_SIMULATE_TOUCHPAD_DEV *) Context;\r
+\r
+  //\r
+  // Someone is waiting on the mouse event, if there's\r
+  // input from mouse, signal the event\r
+  //\r
+  if (UsbMouseSimulateTouchPadDev->AbsolutePointerStateChanged) {\r
+    gBS->SignalEvent (Event);\r
+  }\r
+}\r
+\r
+/**\r
+  Timer handler for Delayed Recovery timer.\r
+\r
+  @param  Event                 The Delayed Recovery event.\r
+  @param  Context               Points to the USB_KB_DEV instance.\r
+\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+USBMouseSimulateTouchPadRecoveryHandler (\r
+  IN    EFI_EVENT    Event,\r
+  IN    VOID         *Context\r
+  )\r
+{\r
+  USB_MOUSE_SIMULATE_TOUCHPAD_DEV       *UsbMouseSimulateTouchPadDev;\r
+  EFI_USB_IO_PROTOCOL *UsbIo;\r
+\r
+  UsbMouseSimulateTouchPadDev = (USB_MOUSE_SIMULATE_TOUCHPAD_DEV *) Context;\r
+\r
+  UsbIo       = UsbMouseSimulateTouchPadDev->UsbIo;\r
+\r
+  UsbIo->UsbAsyncInterruptTransfer (\r
+          UsbIo,\r
+          UsbMouseSimulateTouchPadDev->IntEndpointDescriptor->EndpointAddress,\r
+          TRUE,\r
+          UsbMouseSimulateTouchPadDev->IntEndpointDescriptor->Interval,\r
+          UsbMouseSimulateTouchPadDev->IntEndpointDescriptor->MaxPacketSize,\r
+          OnMouseSimulateTouchPadInterruptComplete,\r
+          UsbMouseSimulateTouchPadDev\r
+          );\r
+}\r
+\r
+\r
+/**\r
+  Report Status Code in Usb Bot Driver\r
+\r
+  @param  DevicePath            Use this to get Device Path\r
+  @param  CodeType              Status Code Type\r
+  @param  CodeValue             Status Code Value\r
+\r
+  @return None\r
+\r
+**/\r
+VOID\r
+MouseSimulateTouchPadReportStatusCode (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePath,\r
+  IN EFI_STATUS_CODE_TYPE      CodeType,\r
+  IN EFI_STATUS_CODE_VALUE     Value\r
+  )\r
+{\r
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+    CodeType,\r
+    Value,\r
+    DevicePath\r
+    );\r
+}\r
diff --git a/edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/UsbMouseSimulateTouchPad.h b/edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/UsbMouseSimulateTouchPad.h
new file mode 100644 (file)
index 0000000..65a87f1
--- /dev/null
@@ -0,0 +1,106 @@
+/** @file\r
+\r
+Copyright (c) 2004 - 2007, 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
+\r
+  Module Name:\r
+\r
+    UsbMouseSimulateTouchPad.h\r
+\r
+  Abstract:\r
+\r
+\r
+**/\r
+\r
+#ifndef _USB_MOUSE_SIMULATE_TOUCHPAD_H\r
+#define _USB_MOUSE_SIMULATE_TOUCHPAD_H\r
+\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Protocol/AbsolutePointer.h>\r
+#include <Protocol/UsbIo.h>\r
+#include <Protocol/DevicePath.h>\r
+\r
+#include <Library/ReportStatusCodeLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/UsbLib.h>\r
+\r
+#include <IndustryStandard/Usb.h>\r
+\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
+\r
+#define USB_MOUSE_SIMULATE_TOUCHPAD_DEV_SIGNATURE EFI_SIGNATURE_32 ('u', 'm', 's', 't')\r
+\r
+typedef struct {\r
+  BOOLEAN ButtonDetected;\r
+  UINT8   ButtonMinIndex;\r
+  UINT8   ButtonMaxIndex;\r
+  UINT8   Reserved;\r
+} PRIVATE_DATA;\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
+\r
+  EFI_ABSOLUTE_POINTER_PROTOCOL AbsolutePointerProtocol;\r
+  EFI_ABSOLUTE_POINTER_STATE   AbsolutePointerState;\r
+  EFI_ABSOLUTE_POINTER_MODE            AbsolutePointerMode;\r
+  BOOLEAN                                              AbsolutePointerStateChanged;\r
+\r
+  PRIVATE_DATA                  PrivateData;\r
+  EFI_UNICODE_STRING_TABLE      *ControllerNameTable;\r
+} USB_MOUSE_SIMULATE_TOUCHPAD_DEV;\r
+\r
+#define USB_MOUSE_SIMULATE_TOUCHPAD_DEV_FROM_MOUSE_PROTOCOL(a) \\r
+    CR(a, USB_MOUSE_SIMULATE_TOUCHPAD_DEV, AbsolutePointerProtocol, USB_MOUSE_SIMULATE_TOUCHPAD_DEV_SIGNATURE)\r
+\r
+VOID\r
+EFIAPI\r
+USBMouseSimulateTouchPadRecoveryHandler (\r
+  IN    EFI_EVENT    Event,\r
+  IN    VOID         *Context\r
+  );\r
+\r
+//\r
+// Global Variables\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL   gUsbMouseSimulateTouchPadDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL   gUsbMouseSimulateTouchPadComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL  gUsbMouseSimulateTouchPadComponentName2;\r
+extern EFI_GUID                      gEfiUsbMouseSimulateTouchPadDriverGuid;\r
+\r
+VOID\r
+MouseSimulateTouchPadReportStatusCode (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePath,\r
+  IN EFI_STATUS_CODE_TYPE      CodeType,\r
+  IN EFI_STATUS_CODE_VALUE     Value\r
+  );\r
+\r
+#endif\r
diff --git a/edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/UsbMouseSimulateTouchPadDxe.inf b/edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/UsbMouseSimulateTouchPadDxe.inf
new file mode 100644 (file)
index 0000000..a1e98d6
--- /dev/null
@@ -0,0 +1,67 @@
+#/** @file\r
+# Component name for module UsbMouseSimulateTouchPad\r
+#\r
+# FIX ME!\r
+# Copyright (c) 2006, Intel Corporation. \r
+#\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
+#\r
+#\r
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = UsbMouseSimulateTouchPadDxe\r
+  FILE_GUID                      = 4EA43463-747C-46eb-97FB-B0E5C5F05306\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+  ENTRY_POINT                    = USBMouseSimulateTouchPadDriverBindingEntryPoint\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  mousehid.h\r
+  ComponentName.c\r
+  UsbMouseSimulateTouchPad.c\r
+  mousehid.c\r
+  UsbMouseSimulateTouchPad.h\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+\r
+[LibraryClasses]\r
+  MemoryAllocationLib\r
+  UefiLib\r
+  UefiBootServicesTableLib\r
+  UefiDriverEntryPoint\r
+  BaseMemoryLib\r
+  ReportStatusCodeLib\r
+  PcdLib\r
+  UsbLib\r
+\r
+[Protocols]\r
+  gEfiUsbIoProtocolGuid                         # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiDevicePathProtocolGuid                    # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiAbsolutePointerProtocolGuid                                                              # PROTOCOL ALWAYS_CONSUMED\r
+\r
+[FixedPcd]\r
+  gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueMouseInterfaceError\r
+  gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueMouseEnable\r
+  gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueMouseDisable\r
+  gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueMouseInputError\r
+  gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueMouseReset\r
+\r
+\r
diff --git a/edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/mousehid.c b/edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/mousehid.c
new file mode 100644 (file)
index 0000000..735a59e
--- /dev/null
@@ -0,0 +1,362 @@
+/** @file\r
+\r
+Copyright (c) 2004, 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
+\r
+Module Name:\r
+\r
+  Mousehid.c\r
+\r
+Abstract:\r
+  Parse mouse hid descriptor\r
+\r
+\r
+**/\r
+\r
+#include "mousehid.h"\r
+\r
+\r
+//\r
+// Get an item from report descriptor\r
+//\r
+\r
+/**\r
+  Get Next Item\r
+\r
+  @param  StartPos          Start Position\r
+  @param  EndPos            End Position\r
+  @param  HidItem           HidItem to return\r
+\r
+  @return Position\r
+\r
+**/\r
+STATIC\r
+UINT8 *\r
+GetNextItem (\r
+  IN  UINT8    *StartPos,\r
+  IN  UINT8    *EndPos,\r
+  OUT HID_ITEM *HidItem\r
+  )\r
+{\r
+  UINT8 Temp;\r
+\r
+  if ((EndPos - StartPos) <= 0) {\r
+    return NULL;\r
+  }\r
+\r
+  Temp = *StartPos;\r
+  StartPos++;\r
+  //\r
+  // bit 2,3\r
+  //\r
+  HidItem->Type = (UINT8) ((Temp >> 2) & 0x03);\r
+  //\r
+  // bit 4-7\r
+  //\r
+  HidItem->Tag = (UINT8) ((Temp >> 4) & 0x0F);\r
+\r
+  if (HidItem->Tag == HID_ITEM_TAG_LONG) {\r
+    //\r
+    // Long Items are not supported by HID rev1.0,\r
+    // although we try to parse it.\r
+    //\r
+    HidItem->Format = HID_ITEM_FORMAT_LONG;\r
+\r
+    if ((EndPos - StartPos) >= 2) {\r
+      HidItem->Size = *StartPos++;\r
+      HidItem->Tag  = *StartPos++;\r
+\r
+      if ((EndPos - StartPos) >= HidItem->Size) {\r
+        HidItem->Data.LongData = StartPos;\r
+        StartPos += HidItem->Size;\r
+        return StartPos;\r
+      }\r
+    }\r
+  } else {\r
+    HidItem->Format = HID_ITEM_FORMAT_SHORT;\r
+    //\r
+    // bit 0, 1\r
+    //\r
+    HidItem->Size   = (UINT8) (Temp & 0x03);\r
+    switch (HidItem->Size) {\r
+\r
+    case 0:\r
+      //\r
+      // No data\r
+      //\r
+      return StartPos;\r
+\r
+    case 1:\r
+      //\r
+      // One byte data\r
+      //\r
+      if ((EndPos - StartPos) >= 1) {\r
+        HidItem->Data.U8 = *StartPos++;\r
+        return StartPos;\r
+      }\r
+\r
+    case 2:\r
+      //\r
+      // Two byte data\r
+      //\r
+      if ((EndPos - StartPos) >= 2) {\r
+        CopyMem (&HidItem->Data.U16, StartPos, sizeof (UINT16));\r
+        StartPos += 2;\r
+        return StartPos;\r
+      }\r
+\r
+    case 3:\r
+      //\r
+      // 4 byte data, adjust size\r
+      //\r
+      HidItem->Size++;\r
+      if ((EndPos - StartPos) >= 4) {\r
+        CopyMem (&HidItem->Data.U32, StartPos, sizeof (UINT32));\r
+        StartPos += 4;\r
+        return StartPos;\r
+      }\r
+    }\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+\r
+/**\r
+  Get Item Data\r
+\r
+  @param  HidItem           HID_ITEM\r
+\r
+  @return HidItem Data\r
+\r
+**/\r
+STATIC\r
+UINT32\r
+GetItemData (\r
+  IN  HID_ITEM *HidItem\r
+  )\r
+{\r
+  //\r
+  // Get Data from HID_ITEM structure\r
+  //\r
+  switch (HidItem->Size) {\r
+\r
+  case 1:\r
+    return HidItem->Data.U8;\r
+\r
+  case 2:\r
+    return HidItem->Data.U16;\r
+\r
+  case 4:\r
+    return HidItem->Data.U32;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+\r
+/**\r
+  Parse Local Item\r
+\r
+  @param  UsbMouseSimulateTouchPad          USB_MOUSE_SIMULATE_TOUCHPAD_DEV\r
+  @param  LocalItem         Local Item\r
+\r
+\r
+**/\r
+STATIC\r
+VOID\r
+ParseLocalItem (\r
+  IN  USB_MOUSE_SIMULATE_TOUCHPAD_DEV   *UsbMouseSimulateTouchPad,\r
+  IN  HID_ITEM        *LocalItem\r
+  )\r
+{\r
+  UINT32  Data;\r
+\r
+  if (LocalItem->Size == 0) {\r
+    //\r
+    // No expected data for local item\r
+    //\r
+    return ;\r
+  }\r
+\r
+  Data = GetItemData (LocalItem);\r
+\r
+  switch (LocalItem->Tag) {\r
+\r
+  case HID_LOCAL_ITEM_TAG_DELIMITER:\r
+    //\r
+    // we don't support delimiter here\r
+    //\r
+    return ;\r
+\r
+  case HID_LOCAL_ITEM_TAG_USAGE:\r
+    return ;\r
+\r
+  case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:\r
+    if (UsbMouseSimulateTouchPad->PrivateData.ButtonDetected) {\r
+      UsbMouseSimulateTouchPad->PrivateData.ButtonMinIndex = (UINT8) Data;\r
+    }\r
+\r
+    return ;\r
+\r
+  case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM:\r
+    {\r
+      if (UsbMouseSimulateTouchPad->PrivateData.ButtonDetected) {\r
+        UsbMouseSimulateTouchPad->PrivateData.ButtonMaxIndex = (UINT8) Data;\r
+      }\r
+\r
+      return ;\r
+    }\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+ParseGlobalItem (\r
+  IN  USB_MOUSE_SIMULATE_TOUCHPAD_DEV   *UsbMouseSimulateTouchPad,\r
+  IN  HID_ITEM        *GlobalItem\r
+  )\r
+{\r
+  UINT8 UsagePage;\r
+\r
+  switch (GlobalItem->Tag) {\r
+  case HID_GLOBAL_ITEM_TAG_USAGE_PAGE:\r
+    {\r
+      UsagePage = (UINT8) GetItemData (GlobalItem);\r
+\r
+      //\r
+      // We only care Button Page here\r
+      //\r
+      if (UsagePage == 0x09) {\r
+        //\r
+        // Button Page\r
+        //\r
+        UsbMouseSimulateTouchPad->PrivateData.ButtonDetected = TRUE;\r
+        return ;\r
+      }\r
+      break;\r
+    }\r
+\r
+  }\r
+}\r
+\r
+\r
+\r
+/**\r
+  Parse Main Item\r
+\r
+  @param  UsbMouseSimulateTouchPad   USB_MOUSE_SIMULATE_TOUCHPAD_DEV\r
+  @param  MainItem          HID_ITEM to parse\r
+\r
+  @return VOID\r
+\r
+**/\r
+STATIC\r
+VOID\r
+ParseMainItem (\r
+  IN  USB_MOUSE_SIMULATE_TOUCHPAD_DEV   *UsbMouseSimulateTouchPad,\r
+  IN  HID_ITEM        *MainItem\r
+  )\r
+{\r
+  //\r
+  // we don't care any main items, just skip\r
+  //\r
+  return ;\r
+}\r
+\r
+\r
+/**\r
+  Parse Hid Item\r
+\r
+  @param  UsbMouseSimulateTouchPad          USB_MOUSE_SIMULATE_TOUCHPAD_DEV\r
+  @param  HidItem           HidItem to parse\r
+\r
+  @return VOID\r
+\r
+**/\r
+STATIC\r
+VOID\r
+ParseHidItem (\r
+  IN  USB_MOUSE_SIMULATE_TOUCHPAD_DEV   *UsbMouseSimulateTouchPad,\r
+  IN  HID_ITEM        *HidItem\r
+  )\r
+{\r
+  switch (HidItem->Type) {\r
+\r
+  case HID_ITEM_TYPE_MAIN:\r
+    //\r
+    // For Main Item, parse main item\r
+    //\r
+    ParseMainItem (UsbMouseSimulateTouchPad, HidItem);\r
+    break;\r
+\r
+  case HID_ITEM_TYPE_GLOBAL:\r
+    //\r
+    // For global Item, parse global item\r
+    //\r
+    ParseGlobalItem (UsbMouseSimulateTouchPad, HidItem);\r
+    break;\r
+\r
+  case HID_ITEM_TYPE_LOCAL:\r
+    //\r
+    // For Local Item, parse local item\r
+    //\r
+    ParseLocalItem (UsbMouseSimulateTouchPad, HidItem);\r
+    break;\r
+  }\r
+}\r
+//\r
+// A simple parse just read some field we are interested in\r
+//\r
+\r
+/**\r
+  Parse Mouse Report Descriptor\r
+\r
+  @param  UsbMouse          USB_MOUSE_DEV\r
+  @param  ReportDescriptor  Report descriptor to parse\r
+  @param  ReportSize        Report descriptor size\r
+\r
+  @retval EFI_DEVICE_ERROR  Report descriptor error\r
+  @retval EFI_SUCCESS       Success\r
+\r
+**/\r
+EFI_STATUS\r
+ParseMouseReportDescriptor (\r
+  IN  USB_MOUSE_SIMULATE_TOUCHPAD_DEV   *UsbMouseSimulateTouchPad,\r
+  IN  UINT8           *ReportDescriptor,\r
+  IN  UINTN           ReportSize\r
+  )\r
+{\r
+  UINT8     *DescriptorEnd;\r
+  UINT8     *ptr;\r
+  HID_ITEM  HidItem;\r
+\r
+  DescriptorEnd = ReportDescriptor + ReportSize;\r
+\r
+  ptr           = GetNextItem (ReportDescriptor, DescriptorEnd, &HidItem);\r
+\r
+  while (ptr != NULL) {\r
+    if (HidItem.Format != HID_ITEM_FORMAT_SHORT) {\r
+      //\r
+      // Long Format Item is not supported at current HID revision\r
+      //\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+\r
+    ParseHidItem (UsbMouseSimulateTouchPad, &HidItem);\r
+\r
+    ptr = GetNextItem (ptr, DescriptorEnd, &HidItem);\r
+  }\r
+\r
+  UsbMouseSimulateTouchPad->NumberOfButtons                 = (UINT8) (UsbMouseSimulateTouchPad->PrivateData.ButtonMaxIndex - UsbMouseSimulateTouchPad->PrivateData.ButtonMinIndex + 1);\r
+  UsbMouseSimulateTouchPad->XLogicMax                       = UsbMouseSimulateTouchPad->YLogicMax = 1023;\r
+  UsbMouseSimulateTouchPad->XLogicMin                       = UsbMouseSimulateTouchPad->YLogicMin = -1023;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/mousehid.h b/edk2/MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/mousehid.h
new file mode 100644 (file)
index 0000000..4a1fade
--- /dev/null
@@ -0,0 +1,85 @@
+/** @file\r
+\r
+Copyright (c) 2004, 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
+\r
+Module Name:\r
+\r
+  MouseHid.h\r
+\r
+Abstract:\r
+\r
+\r
+**/\r
+\r
+#ifndef __MOUSE_HID_H\r
+#define __MOUSE_HID_H\r
+\r
+#include "UsbMouseSimulateTouchPad.h"\r
+\r
+//\r
+// HID Item general structure\r
+//\r
+typedef struct _hid_item {\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
+} HID_ITEM;\r
+\r
+typedef struct {\r
+  UINT16  UsagePage;\r
+  INT32   LogicMin;\r
+  INT32   LogicMax;\r
+  INT32   PhysicalMin;\r
+  INT32   PhysicalMax;\r
+  UINT16  UnitExp;\r
+  UINT16 UINT;\r
+  UINT16 ReportId;\r
+  UINT16 ReportSize;\r
+  UINT16 ReportCount;\r
+} HID_GLOBAL;\r
+\r
+typedef struct {\r
+  UINT16  Usage[16];  /* usage array */\r
+  UINT16  UsageIndex;\r
+  UINT16  UsageMin;\r
+} HID_LOCAL;\r
+\r
+typedef struct {\r
+  UINT16  Type;\r
+  UINT16  Usage;\r
+} HID_COLLECTION;\r
+\r
+typedef struct {\r
+  HID_GLOBAL      Global;\r
+  HID_GLOBAL      GlobalStack[8];\r
+  UINT32          GlobalStackPtr;\r
+  HID_LOCAL       Local;\r
+  HID_COLLECTION  CollectionStack[8];\r
+  UINT32          CollectionStackPtr;\r
+} HID_PARSER;\r
+\r
+EFI_STATUS\r
+ParseMouseReportDescriptor (\r
+  IN  USB_MOUSE_SIMULATE_TOUCHPAD_DEV   *UsbMouseSimulateTouchPad,\r
+  IN  UINT8           *ReportDescriptor,\r
+  IN  UINTN           ReportSize\r
+  );\r
+\r
+#endif\r
index fa2fa94..4b8d282 100644 (file)
   MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf\r
   MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf\r
   MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouseDxe.inf\r
+  MdeModulePkg/Bus/Usb/UsbMouseSimulateTouchPadDxe/UsbMouseSimulateTouchPadDxe.inf\r
 \r
   MdeModulePkg/Universal/Variable/Pei/VariablePei.inf\r
   MdeModulePkg/Universal/Variable/Application/VariableInfo.inf\r
index 35c1273..b13a859 100644 (file)
@@ -56,6 +56,23 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gConSplitterSimplePoi
   "en"\r
 };\r
 \r
+//\r
+// EFI Component Name Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gConSplitterAbsolutePointerComponentName = {\r
+  ConSplitterComponentNameGetDriverName,\r
+  ConSplitterAbsolutePointerComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+//\r
+// EFI Component Name 2 Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gConSplitterAbsolutePointerComponentName2 = {\r
+  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) ConSplitterComponentNameGetDriverName,\r
+  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) ConSplitterAbsolutePointerComponentNameGetControllerName,\r
+  "en"\r
+};\r
 \r
 //\r
 // EFI Component Name Protocol\r
@@ -128,6 +145,17 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mConSplitterSimplePointer
   }\r
 };\r
 \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mConSplitterAbsolutePointerControllerNameTable[] = {\r
+  {\r
+    "eng;en",\r
+    (CHAR16 *)L"Primary Absolute Pointer Device"\r
+  },\r
+  {\r
+    NULL,\r
+    NULL\r
+  }\r
+};\r
+\r
 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mConSplitterConOutControllerNameTable[] = {\r
   {\r
     "eng;en",\r
@@ -422,6 +450,91 @@ ConSplitterSimplePointerComponentNameGetControllerName (
            );\r
 }\r
 \r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterAbsolutePointerComponentNameGetControllerName (\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
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the controller\r
+    that is being managed by an EFI Driver.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    ControllerHandle - The handle of a controller that the driver specified by \r
+                       This is managing.  This handle specifies the controller \r
+                       whose name is to be returned.\r
+    ChildHandle      - The handle of the child controller to retrieve the name \r
+                       of.  This is an optional parameter that may be NULL.  It \r
+                       will be NULL for device drivers.  It will also be NULL \r
+                       for a bus drivers that wish to retrieve the name of the \r
+                       bus controller.  It will not be NULL for a bus driver \r
+                       that wishes to retrieve the name of a child controller.\r
+    Language         - A pointer to RFC3066 language identifier. \r
+                       This is the language of the controller name \r
+                       that that the caller is requesting, and it must match one\r
+                       of the languages specified in SupportedLanguages.  The \r
+                       number of languages supported by a driver is up to the \r
+                       driver writer.\r
+    ControllerName   - A pointer to the Unicode string to return.  This Unicode\r
+                       string is the name of the controller specified by \r
+                       ControllerHandle and ChildHandle in the language \r
+                       specified by Language from the point of view of the \r
+                       driver specified by This. \r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the user readable name in the\r
+                            language specified by Language for the driver \r
+                            specified by This was returned in DriverName.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
+                            EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently \r
+                            managing the controller specified by \r
+                            ControllerHandle and ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer;\r
+  //\r
+  // here ChildHandle is not an Optional parameter.\r
+  //\r
+  if (ChildHandle == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiAbsolutePointerProtocolGuid,\r
+                  (VOID **) &AbsolutePointer,\r
+                  NULL,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+return LookupUnicodeString2 (\r
+       Language,\r
+       This->SupportedLanguages,\r
+       mConSplitterAbsolutePointerControllerNameTable,\r
+       ControllerName,\r
+       (BOOLEAN)(This == &gConSplitterAbsolutePointerComponentName)\r
+       );\r
+}\r
+\r
 /**\r
   Retrieves a Unicode string that is the user readable name of the controller\r
   that is being managed by a driver.\r
index f100d04..39e67c8 100644 (file)
@@ -76,6 +76,27 @@ STATIC TEXT_IN_SPLITTER_PRIVATE_DATA  mConIn = {
   (EFI_SIMPLE_POINTER_PROTOCOL **) NULL,\r
   0,\r
 \r
+  {\r
+    ConSplitterAbsolutePointerReset,\r
+    ConSplitterAbsolutePointerGetState,\r
+    (EFI_EVENT) NULL,\r
+    (EFI_ABSOLUTE_POINTER_MODE *) NULL\r
+  },\r
+\r
+  {\r
+    0,       //AbsoluteMinX\r
+    0,       //AbsoluteMinY\r
+    0,       //AbsoluteMinZ\r
+    0x10000, //AbsoluteMaxX\r
+    0x10000, //AbsoluteMaxY\r
+    0x10000, //AbsoluteMaxZ\r
+    0        //Attributes    \r
+  },\r
+  0,\r
+  (EFI_ABSOLUTE_POINTER_PROTOCOL **) NULL,\r
+  0,\r
+  FALSE,\r
+\r
   FALSE,\r
   {\r
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
@@ -240,6 +261,18 @@ EFI_DRIVER_BINDING_PROTOCOL           gConSplitterSimplePointerDriverBinding = {
   NULL\r
 };\r
 \r
+//\r
+// Driver binding instance for Absolute Pointer protocol\r
+//\r
+EFI_DRIVER_BINDING_PROTOCOL           gConSplitterAbsolutePointerDriverBinding = {\r
+  ConSplitterAbsolutePointerDriverBindingSupported,\r
+  ConSplitterAbsolutePointerDriverBindingStart,\r
+  ConSplitterAbsolutePointerDriverBindingStop,\r
+  0xa,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
 EFI_DRIVER_BINDING_PROTOCOL           gConSplitterConOutDriverBinding = {\r
   ConSplitterConOutDriverBindingSupported,\r
   ConSplitterConOutDriverBindingStart,\r
@@ -300,6 +333,16 @@ InitializeConSplitter(
              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  Status = EfiLibInstallDriverBindingComponentName2 (\r
+             ImageHandle,\r
+             SystemTable,\r
+             &gConSplitterAbsolutePointerDriverBinding,\r
+             NULL,\r
+             &gConSplitterAbsolutePointerComponentName,\r
+             &gConSplitterAbsolutePointerComponentName2\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   Status = EfiLibInstallDriverBindingComponentName2 (\r
              ImageHandle,\r
              SystemTable,\r
@@ -386,6 +429,8 @@ Returns:
                     &mConIn.TextInEx,\r
                     &gEfiSimplePointerProtocolGuid,\r
                     &mConIn.SimplePointer,\r
+                                       &gEfiAbsolutePointerProtocolGuid,\r
+                                       &mConIn.AbsolutePointer,\r
                     &gEfiPrimaryConsoleInDeviceGuid,\r
                     NULL,\r
                     NULL\r
@@ -554,6 +599,28 @@ Returns:
 \r
   InitializeListHead (&ConInPrivate->NotifyList); \r
 \r
+  //\r
+  // Allocate Buffer and Create Event for Absolute Pointer and Simple Pointer Protocols\r
+  //\r
+  ConInPrivate->AbsolutePointer.Mode = &ConInPrivate->AbsolutePointerMode;\r
+\r
+  Status = ConSplitterGrowBuffer (\r
+                                 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL *),\r
+                                 &ConInPrivate->AbsolutePointerListCount,\r
+                                 (VOID **) &ConInPrivate->AbsolutePointerList\r
+                                 );\r
+  if (EFI_ERROR (Status)) {\r
+         return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Status = gBS->CreateEvent (\r
+                         EVT_NOTIFY_WAIT,\r
+                         TPL_NOTIFY,\r
+                         ConSplitterAbsolutePointerWaitForInput,\r
+                         ConInPrivate,\r
+                         &ConInPrivate->AbsolutePointer.WaitForInput\r
+                         );\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
   ConInPrivate->SimplePointer.Mode = &ConInPrivate->SimplePointerMode;\r
 \r
@@ -787,6 +854,36 @@ Returns:
           );\r
 }\r
 \r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterAbsolutePointerDriverBindingSupported (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN  EFI_HANDLE                      ControllerHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Absolute Pointer Supported Check\r
+\r
+Arguments:\r
+  This              - Pointer to protocol.\r
+  ControllerHandle  - Controller handle.\r
+  RemainingDevicePath  - Remaining device path.\r
+\r
+Returns:\r
+\r
+  EFI_STATUS\r
+\r
+--*/\r
+{\r
+  return ConSplitterSupported (\r
+          This,\r
+          ControllerHandle,\r
+          &gEfiAbsolutePointerProtocolGuid\r
+          );\r
+}\r
+\r
 EFI_STATUS\r
 EFIAPI\r
 ConSplitterConOutDriverBindingSupported (\r
@@ -1021,6 +1118,49 @@ Returns:
   return ConSplitterSimplePointerAddDevice (&mConIn, SimplePointer);\r
 }\r
 \r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterAbsolutePointerDriverBindingStart (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN  EFI_HANDLE                      ControllerHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Start ConSplitter on ControllerHandle, and create the virtual\r
+  agrogated console device on first call Start for a ConIn handle.\r
+\r
+Arguments:\r
+  This                 - Pointer to protocol.\r
+  ControllerHandle     - Controller handle.\r
+  RemainingDevicePath  - Remaining device path.\r
+\r
+Returns:\r
+\r
+  EFI_ERROR if a AbsolutePointer protocol is not started.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                        Status;\r
+  EFI_ABSOLUTE_POINTER_PROTOCOL     *AbsolutePointer;\r
+\r
+  Status = ConSplitterStart (\r
+             This,\r
+             ControllerHandle,\r
+             mConIn.VirtualHandle,\r
+             &gEfiAbsolutePointerProtocolGuid,\r
+             &gEfiAbsolutePointerProtocolGuid,\r
+             (VOID **) &AbsolutePointer\r
+             );\r
+  \r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return ConSplitterAbsolutePointerAddDevice (&mConIn, AbsolutePointer);\r
+}\r
+\r
 EFI_STATUS\r
 EFIAPI\r
 ConSplitterConOutDriverBindingStart (\r
@@ -1341,6 +1481,51 @@ Returns:
   return ConSplitterSimplePointerDeleteDevice (&mConIn, SimplePointer);\r
 }\r
 \r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterAbsolutePointerDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN  EFI_HANDLE                      ControllerHandle,\r
+  IN  UINTN                           NumberOfChildren,\r
+  IN  EFI_HANDLE                      *ChildHandleBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+  (Standard DriverBinding Protocol Stop() function)\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                        Status;\r
+  EFI_ABSOLUTE_POINTER_PROTOCOL     *AbsolutePointer;\r
+\r
+  if (NumberOfChildren == 0) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  Status = ConSplitterStop (\r
+             This,\r
+             ControllerHandle,\r
+             mConIn.VirtualHandle,\r
+             &gEfiAbsolutePointerProtocolGuid,\r
+             &gEfiAbsolutePointerProtocolGuid,\r
+             (VOID **) &AbsolutePointer\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Delete this console input device's data structures.\r
+  //\r
+  return ConSplitterAbsolutePointerDeleteDevice (&mConIn, AbsolutePointer);\r
+}\r
+\r
 EFI_STATUS\r
 EFIAPI\r
 ConSplitterConOutDriverBindingStop (\r
@@ -1729,6 +1914,83 @@ Returns:
   return EFI_NOT_FOUND;\r
 }\r
 \r
+EFI_STATUS\r
+ConSplitterAbsolutePointerAddDevice (\r
+  IN  TEXT_IN_SPLITTER_PRIVATE_DATA     *Private,\r
+  IN  EFI_ABSOLUTE_POINTER_PROTOCOL     *AbsolutePointer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+  EFI_OUT_OF_RESOURCES\r
+  EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // If the Absolute Pointer List is full, enlarge it by calling growbuffer().\r
+  //\r
+  if (Private->CurrentNumberOfAbsolutePointers >= Private->AbsolutePointerListCount) {\r
+    Status = ConSplitterGrowBuffer (\r
+              sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL *),\r
+              &Private->AbsolutePointerListCount,\r
+              (VOID **) &Private->AbsolutePointerList\r
+              );\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+  }\r
+  //\r
+  // Add the new text-in device data structure into the Text In List.\r
+  //\r
+  Private->AbsolutePointerList[Private->CurrentNumberOfAbsolutePointers] = AbsolutePointer;\r
+  Private->CurrentNumberOfAbsolutePointers++;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+ConSplitterAbsolutePointerDeleteDevice (\r
+  IN  TEXT_IN_SPLITTER_PRIVATE_DATA     *Private,\r
+  IN  EFI_ABSOLUTE_POINTER_PROTOCOL     *AbsolutePointer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  //\r
+  // Remove the specified text-in device data structure from the Text In List,\r
+  // and rearrange the remaining data structures in the Text In List.\r
+  //\r
+  for (Index = 0; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {\r
+    if (Private->AbsolutePointerList[Index] == AbsolutePointer) {\r
+      for (Index = Index; Index < Private->CurrentNumberOfAbsolutePointers - 1; Index++) {\r
+        Private->AbsolutePointerList[Index] = Private->AbsolutePointerList[Index + 1];\r
+      }\r
+\r
+      Private->CurrentNumberOfAbsolutePointers--;\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
 STATIC\r
 EFI_STATUS\r
 ConSplitterGrowMapTable (\r
@@ -3325,8 +3587,6 @@ ConSplitterTextInUnregisterKeyNotify (
   \r
 }\r
 \r
-\r
-\r
 EFI_STATUS\r
 EFIAPI\r
 ConSplitterSimplePointerReset (\r
@@ -3552,6 +3812,198 @@ Returns:
   }\r
 }\r
 \r
+//\r
+// Absolute Pointer Protocol functions\r
+//\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterAbsolutePointerReset (\r
+  IN EFI_ABSOLUTE_POINTER_PROTOCOL   *This,\r
+  IN BOOLEAN                         ExtendedVerification\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Resets the pointer device hardware.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    ExtendedVerification  - Driver may perform diagnostics on reset.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The device was reset.\r
+    EFI_DEVICE_ERROR      - The device is not functioning correctly and could \r
+                            not be reset.\r
+                            \r
+--*/\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_STATUS                    ReturnStatus;\r
+  TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r
+  UINTN                         Index;\r
+\r
+  Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This);\r
+\r
+  Private->AbsoluteInputEventSignalState = FALSE;\r
+    \r
+  if (Private->CurrentNumberOfAbsolutePointers == 0) {\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // return the worst status met\r
+  //\r
+  for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {\r
+    Status = Private->AbsolutePointerList[Index]->Reset (\r
+                                                    Private->AbsolutePointerList[Index],\r
+                                                    ExtendedVerification\r
+                                                    );\r
+    if (EFI_ERROR (Status)) {\r
+      ReturnStatus = Status;\r
+    }\r
+  }\r
+\r
+  return ReturnStatus;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI \r
+ConSplitterAbsolutePointerGetState (\r
+  IN EFI_ABSOLUTE_POINTER_PROTOCOL   *This,\r
+  IN OUT EFI_ABSOLUTE_POINTER_STATE  *State\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves the current state of a pointer device.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    State                 - A pointer to the state information on the pointer device.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The state of the pointer device was returned in State..\r
+    EFI_NOT_READY         - The state of the pointer device has not changed since the last call to\r
+                            GetState().                                                           \r
+    EFI_DEVICE_ERROR      - A device error occurred while attempting to retrieve the pointer\r
+                            device's current state.                                         \r
+--*/\r
+{\r
+  TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r
+  EFI_STATUS                    Status;\r
+  EFI_STATUS                    ReturnStatus;\r
+  UINTN                         Index;\r
+  EFI_ABSOLUTE_POINTER_STATE    CurrentState;\r
+\r
+\r
+  Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This);\r
+  if (Private->PasswordEnabled) {\r
+    //\r
+    // If StdIn Locked return not ready\r
+    //\r
+    return EFI_NOT_READY;\r
+  }\r
+\r
+  Private->AbsoluteInputEventSignalState = FALSE;\r
+\r
+  State->CurrentX                        = 0;\r
+  State->CurrentY                        = 0;\r
+  State->CurrentZ                        = 0;\r
+  State->ActiveButtons                   = 0;\r
+    \r
+  //\r
+  // if no physical pointer device exists, return EFI_NOT_READY;\r
+  // if any physical pointer device has changed state,\r
+  // return the state and EFI_SUCCESS.\r
+  //\r
+  ReturnStatus = EFI_NOT_READY;\r
+  for (Index = 0; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {\r
+\r
+    Status = Private->AbsolutePointerList[Index]->GetState (\r
+                                                    Private->AbsolutePointerList[Index],\r
+                                                    &CurrentState\r
+                                                    );\r
+    if (!EFI_ERROR (Status)) {\r
+      if (ReturnStatus == EFI_NOT_READY) {\r
+        ReturnStatus = EFI_SUCCESS;\r
+      }\r
+\r
+      State->ActiveButtons = CurrentState.ActiveButtons;\r
+\r
+      if (!(Private->AbsolutePointerMode.AbsoluteMinX == 0 && Private->AbsolutePointerMode.AbsoluteMaxX == 0)) {\r
+        State->CurrentX = CurrentState.CurrentX;\r
+      }\r
+      if (!(Private->AbsolutePointerMode.AbsoluteMinY == 0 && Private->AbsolutePointerMode.AbsoluteMaxY == 0)) {\r
+        State->CurrentY = CurrentState.CurrentY;\r
+      }\r
+      if (!(Private->AbsolutePointerMode.AbsoluteMinZ == 0 && Private->AbsolutePointerMode.AbsoluteMaxZ == 0)) {\r
+        State->CurrentZ = CurrentState.CurrentZ;\r
+      }\r
+      \r
+    } else if (Status == EFI_DEVICE_ERROR) {\r
+      ReturnStatus = EFI_DEVICE_ERROR;\r
+    }\r
+  }\r
+\r
+  return ReturnStatus;\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+ConSplitterAbsolutePointerWaitForInput (\r
+  IN  EFI_EVENT                       Event,\r
+  IN  VOID                            *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This event agregates all the events of the pointer devices in the splitter.\r
+  If the ConIn is password locked then return.\r
+  If any events of physical pointer devices are signaled, signal the pointer\r
+  splitter event. This will cause the calling code to call\r
+  ConSplitterAbsolutePointerGetState ().\r
+\r
+Arguments:\r
+  Event   - The Event assoicated with callback.\r
+  Context - Context registered when Event was created.\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                    Status;\r
+  TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r
+  UINTN                         Index;\r
+\r
+  Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context;\r
+  if (Private->PasswordEnabled) {\r
+    //\r
+    // If StdIn Locked return not ready\r
+    //\r
+    return ;\r
+  }\r
+\r
+  //\r
+  // if AbsoluteInputEventSignalState is flagged before, \r
+  // and not cleared by Reset() or GetState(), signal it\r
+  //\r
+  if (Private->AbsoluteInputEventSignalState) {\r
+    gBS->SignalEvent (Event);\r
+    return ;\r
+  }\r
+  //\r
+  // if any physical console input device has key input, signal the event.\r
+  //\r
+  for (Index = 0; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {\r
+    Status = gBS->CheckEvent (Private->AbsolutePointerList[Index]->WaitForInput);\r
+    if (!EFI_ERROR (Status)) {\r
+      gBS->SignalEvent (Event);\r
+      Private->AbsoluteInputEventSignalState = TRUE;\r
+    }\r
+  }\r
+}\r
+\r
 EFI_STATUS\r
 EFIAPI\r
 ConSplitterTextOutReset (\r
index 4a71bb6..40bafdf 100644 (file)
@@ -21,6 +21,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/GraphicsOutput.h>\r
 #include <Guid/PrimaryConsoleInDevice.h>\r
 #include <Protocol/SimplePointer.h>\r
+#include <Protocol/AbsolutePointer.h>\r
 #include <Protocol/SimpleTextOut.h>\r
 #include <Guid/ConsoleInDevice.h>\r
 #include <Protocol/SimpleTextIn.h>\r
@@ -47,6 +48,8 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gConSplitterConInComponentName2;
 extern EFI_DRIVER_BINDING_PROTOCOL  gConSplitterSimplePointerDriverBinding;\r
 extern EFI_COMPONENT_NAME_PROTOCOL  gConSplitterSimplePointerComponentName;\r
 extern EFI_COMPONENT_NAME2_PROTOCOL gConSplitterSimplePointerComponentName2;\r
+extern EFI_COMPONENT_NAME_PROTOCOL  gConSplitterAbsolutePointerComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL gConSplitterAbsolutePointerComponentName2;\r
 extern EFI_DRIVER_BINDING_PROTOCOL  gConSplitterConOutDriverBinding;\r
 extern EFI_COMPONENT_NAME_PROTOCOL  gConSplitterConOutComponentName;\r
 extern EFI_COMPONENT_NAME2_PROTOCOL gConSplitterConOutComponentName2;\r
@@ -89,6 +92,7 @@ typedef struct _TEXT_IN_EX_SPLITTER_NOTIFY {
   EFI_KEY_NOTIFY_FUNCTION               KeyNotificationFn;\r
   LIST_ENTRY                            NotifyEntry;\r
 } TEXT_IN_EX_SPLITTER_NOTIFY;\r
+\r
 typedef struct {\r
   UINT64                         Signature;\r
   EFI_HANDLE                     VirtualHandle;\r
@@ -111,6 +115,13 @@ typedef struct {
   EFI_SIMPLE_POINTER_PROTOCOL    **PointerList;\r
   UINTN                          PointerListCount;\r
 \r
+  EFI_ABSOLUTE_POINTER_PROTOCOL         AbsolutePointer;\r
+  EFI_ABSOLUTE_POINTER_MODE             AbsolutePointerMode;\r
+  UINTN                                                         CurrentNumberOfAbsolutePointers;\r
+  EFI_ABSOLUTE_POINTER_PROTOCOL         **AbsolutePointerList;\r
+  UINTN                                                         AbsolutePointerListCount;\r
+  BOOLEAN                                               AbsoluteInputEventSignalState; \r
+\r
   BOOLEAN                        PasswordEnabled;\r
   CHAR16                         Password[MAX_STD_IN_PASSWORD];\r
   UINTN                          PwdIndex;\r
@@ -368,6 +379,111 @@ ConSplitterStdErrDriverBindingStop (
   )\r
 ;\r
 \r
+//\r
+// Driver binding functions\r
+//\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterAbsolutePointerDriverBindingSupported (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN  EFI_HANDLE                      ControllerHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterAbsolutePointerDriverBindingStart (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN  EFI_HANDLE                      ControllerHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterAbsolutePointerDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN  EFI_HANDLE                      ControllerHandle,\r
+  IN  UINTN                           NumberOfChildren,\r
+  IN  EFI_HANDLE                      *ChildHandleBuffer\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+ConSplitterAbsolutePointerAddDevice (\r
+  IN  TEXT_IN_SPLITTER_PRIVATE_DATA     *Private,\r
+  IN  EFI_ABSOLUTE_POINTER_PROTOCOL     *AbsolutePointer\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+ConSplitterAbsolutePointerDeleteDevice (\r
+  IN  TEXT_IN_SPLITTER_PRIVATE_DATA     *Private,\r
+  IN  EFI_ABSOLUTE_POINTER_PROTOCOL     *AbsolutePointer\r
+  )\r
+;\r
+\r
+//\r
+// Absolute Pointer protocol interfaces\r
+//\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterAbsolutePointerReset (\r
+  IN EFI_ABSOLUTE_POINTER_PROTOCOL   *This,\r
+  IN BOOLEAN                         ExtendedVerification\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Resets the pointer device hardware.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    ExtendedVerification  - Driver may perform diagnostics on reset.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The device was reset.\r
+    EFI_DEVICE_ERROR      - The device is not functioning correctly and could \r
+                            not be reset.\r
+                            \r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI \r
+ConSplitterAbsolutePointerGetState (\r
+  IN EFI_ABSOLUTE_POINTER_PROTOCOL   *This,\r
+  IN OUT EFI_ABSOLUTE_POINTER_STATE  *State\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves the current state of a pointer device.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    State                 - A pointer to the state information on the pointer device.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The state of the pointer device was returned in State..\r
+    EFI_NOT_READY         - The state of the pointer device has not changed since the last call to\r
+                            GetState().                                                           \r
+    EFI_DEVICE_ERROR      - A device error occurred while attempting to retrieve the pointer\r
+                            device's current state.                                         \r
+--*/\r
+;\r
+\r
+VOID\r
+EFIAPI\r
+ConSplitterAbsolutePointerWaitForInput (\r
+  IN  EFI_EVENT                       Event,\r
+  IN  VOID                            *Context\r
+  )\r
+;\r
+\r
 /**\r
   Retrieves a Unicode string that is the user readable name of the driver.\r
 \r
@@ -573,6 +689,16 @@ ConSplitterSimplePointerComponentNameGetControllerName (
   OUT CHAR16                                          **ControllerName\r
   );\r
 \r
+EFI_STATUS\r
+EFIAPI\r
+ConSplitterAbsolutePointerComponentNameGetControllerName (\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
 /**\r
   Retrieves a Unicode string that is the user readable name of the controller\r
index 9a781a5..8201f2c 100644 (file)
@@ -77,6 +77,7 @@
   gEfiSimpleTextOutProtocolGuid                 # PROTOCOL ALWAYS_PRODUCED\r
   gEfiGraphicsOutputProtocolGuid                # PROTOCOL ALWAYS_PRODUCED\r
   gEfiUgaDrawProtocolGuid                       # PROTOCOL ALWAYS_PRODUCED\r
+  gEfiAbsolutePointerProtocolGuid                                                              # PROTOCOL ALWAYS_PRODUCED\r
 \r
 [FeaturePcd.common]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport\r
index 9748c3b..3043391 100644 (file)
@@ -113,8 +113,8 @@ typedef struct {
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_ABSOLUTE_POINTER_RESET) (\r
-  IN CONST  EFI_ABSOLUTE_POINTER_PROTOCOL *This,\r
-  IN CONST  BOOLEAN                       ExtendedVerification\r
+  IN EFI_ABSOLUTE_POINTER_PROTOCOL *This,\r
+  IN BOOLEAN                       ExtendedVerification\r
 );\r
 \r
 \r
@@ -204,7 +204,7 @@ typedef struct {
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_ABSOLUTE_POINTER_GET_STATE) (\r
-  IN CONST  EFI_ABSOLUTE_POINTER_PROTOCOL *This,\r
+  IN           EFI_ABSOLUTE_POINTER_PROTOCOL *This,\r
   IN OUT    EFI_ABSOLUTE_POINTER_STATE    *State\r
 );\r
 \r