]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c
Enhance the ConPlatform driver's matching algorithm to manage the console controller...
[mirror_edk2.git] / MdeModulePkg / Universal / Console / ConPlatformDxe / ConPlatform.c
index 0644ee38b9397986730c5cea23301d42b1d5a255..ab65e7e16f75543ea0437cc993cb6805cb501788 100644 (file)
@@ -2,7 +2,7 @@
   Console Platform DXE Driver, install Console Device Guids and update Console\r
   Environment Variables.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 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
@@ -771,6 +771,53 @@ ConPlatformGetVariable (
   return Buffer;\r
 }\r
 \r
+/**\r
+  Function returns TRUE when the two input device paths point to the two\r
+  GOP child handles that have the same parent.\r
+\r
+  @param Left    A pointer to a device path data structure.\r
+  @param Right   A pointer to a device path data structure.\r
+\r
+  @retval TRUE  Left and Right share the same parent.\r
+  @retval FALSE Left and Right don't share the same parent or either of them is not\r
+                a GOP device path.\r
+**/\r
+BOOLEAN\r
+IsGopSibling (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Left,\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Right\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *NodeLeft;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NodeRight;\r
+\r
+  for (NodeLeft = Left; !IsDevicePathEndType (NodeLeft); NodeLeft = NextDevicePathNode (NodeLeft)) {\r
+    if (DevicePathType (NodeLeft) == ACPI_DEVICE_PATH && DevicePathSubType (NodeLeft) == ACPI_ADR_DP) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (IsDevicePathEndType (NodeLeft)) {\r
+    return FALSE;\r
+  }\r
+\r
+  for (NodeRight = Right; !IsDevicePathEndType (NodeRight); NodeRight = NextDevicePathNode (NodeRight)) {\r
+    if (DevicePathType (NodeRight) == ACPI_DEVICE_PATH && DevicePathSubType (NodeRight) == ACPI_ADR_DP) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (IsDevicePathEndType (NodeRight)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (((UINTN) NodeLeft - (UINTN) Left) != ((UINTN) NodeRight - (UINTN) Right)) {\r
+    return FALSE;\r
+  }\r
+\r
+  return (BOOLEAN) (CompareMem (Left, Right, (UINTN) NodeLeft - (UINTN) Left) == 0);\r
+}\r
+\r
 /**\r
   Function compares a device path data structure to that of all the nodes of a\r
   second device path instance.\r
@@ -830,7 +877,7 @@ ConPlatformMatchDevicePaths (
   // Search for the match of 'Single' in 'Multi'\r
   //\r
   while (DevicePathInst != NULL) {\r
-    if (CompareMem (Single, DevicePathInst, Size) == 0) {\r
+    if ((CompareMem (Single, DevicePathInst, Size) == 0) || IsGopSibling (Single, DevicePathInst)) {\r
       if (!Delete) {\r
         //\r
         // If Delete is FALSE, return EFI_SUCCESS if Single is found in Multi.\r