]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update ConPlatform driver to support GOP driver which creates multiple children.
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 14 Oct 2010 04:49:31 +0000 (04:49 +0000)
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 14 Oct 2010 04:49:31 +0000 (04:49 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10936 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf

index 597ec1fec976fa4eeb756e2c3d447d38fac5bdb6..0644ee38b9397986730c5cea23301d42b1d5a255 100644 (file)
@@ -450,22 +450,25 @@ ConPlatformTextOutDriverBindingStart (
     }\r
   } else {\r
     //\r
-    // If it is not a hot-plug device, first append the device path to the\r
-    // ConOutDev environment variable\r
+    // If it is not a hot-plug device, append the device path to \r
+    // the ConOutDev and ErrOutDev environment variable.\r
+    // For GOP device path, append the sibling device path as well.\r
     //\r
-    ConPlatformUpdateDeviceVariable (\r
-      L"ConOutDev",\r
-      DevicePath,\r
-      Append\r
-      );\r
-    //\r
-    // Then append the device path to the ErrOutDev environment variable\r
-    //\r
-    ConPlatformUpdateDeviceVariable (\r
-      L"ErrOutDev",\r
-      DevicePath,\r
-      Append\r
-      );\r
+    if (!ConPlatformUpdateGopCandidate (DevicePath)) {\r
+      ConPlatformUpdateDeviceVariable (\r
+        L"ConOutDev",\r
+        DevicePath,\r
+        Append\r
+        );\r
+      //\r
+      // Then append the device path to the ErrOutDev environment variable\r
+      //\r
+      ConPlatformUpdateDeviceVariable (\r
+        L"ErrOutDev",\r
+        DevicePath,\r
+        Append\r
+        );\r
+    }\r
 \r
     //\r
     // If the device path is an instance in the ConOut environment variable,\r
@@ -1022,3 +1025,79 @@ IsHotPlugDevice (
   return FALSE;\r
 }\r
 \r
+/**\r
+  Update ConOutDev and ErrOutDev variables to add the device path of\r
+  GOP controller itself and the sibling controllers.\r
+\r
+  @param  DevicePath            Pointer to device's device path.\r
+\r
+  @retval TRUE                  The devcie is a GOP device.\r
+  @retval FALSE                 The devcie is not a GOP device.\r
+\r
+**/\r
+BOOLEAN\r
+ConPlatformUpdateGopCandidate (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL    *DevicePath\r
+  )\r
+{\r
+  EFI_STATUS                           Status;\r
+  EFI_HANDLE                           PciHandle;\r
+  EFI_HANDLE                           GopHandle;\r
+  EFI_OPEN_PROTOCOL_INFORMATION_ENTRY  *OpenInfoBuffer;\r
+  UINTN                                EntryCount;\r
+  UINTN                                Index;\r
+  EFI_DEVICE_PATH_PROTOCOL             *ChildDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL             *TempDevicePath;\r
+\r
+  //\r
+  // Check whether it's a GOP device.\r
+  //\r
+  TempDevicePath = DevicePath;\r
+  Status = gBS->LocateDevicePath (&gEfiGraphicsOutputProtocolGuid, &TempDevicePath, &GopHandle);\r
+  if (EFI_ERROR (Status)) {\r
+    return FALSE;\r
+  }\r
+  //\r
+  // Get the parent PciIo handle in order to find all the children\r
+  //\r
+  Status = gBS->LocateDevicePath (&gEfiPciIoProtocolGuid, &DevicePath, &PciHandle);\r
+  if (EFI_ERROR (Status)) {\r
+    return FALSE;\r
+  }\r
+\r
+  Status = gBS->OpenProtocolInformation (\r
+                  PciHandle,\r
+                  &gEfiPciIoProtocolGuid,\r
+                  &OpenInfoBuffer,\r
+                  &EntryCount\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return FALSE;\r
+  }\r
+\r
+  for (Index = 0; Index < EntryCount; Index++) {\r
+    //\r
+    // Query all the children created by the GOP driver\r
+    //\r
+    if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
+      Status = gBS->OpenProtocol (\r
+                      OpenInfoBuffer[Index].ControllerHandle,\r
+                      &gEfiDevicePathProtocolGuid,\r
+                      (VOID **) &ChildDevicePath,\r
+                      NULL,\r
+                      NULL,\r
+                      EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                      );\r
+      if (!EFI_ERROR (Status)) {\r
+        //\r
+        // Append the device path to ConOutDev and ErrOutDev\r
+        //\r
+        ConPlatformUpdateDeviceVariable (L"ConOutDev", ChildDevicePath, Append);\r
+        ConPlatformUpdateDeviceVariable (L"ErrOutDev", ChildDevicePath, Append);\r
+      }\r
+    }\r
+  }\r
+  FreePool (OpenInfoBuffer);\r
+\r
+  return TRUE;\r
+}\r
index 28261730ab04f9bf94a67582c1c12096389a1ef7..b04dce73e371908a4d246cef7980809c6d20d815 100644 (file)
@@ -20,6 +20,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/SimpleTextOut.h>\r
 #include <Protocol/DevicePath.h>\r
 #include <Protocol/SimpleTextIn.h>\r
+#include <Protocol/PciIo.h>\r
+#include <Protocol/GraphicsOutput.h>\r
 \r
 #include <Guid/GlobalVariable.h>\r
 #include <Guid/ConsoleInDevice.h>\r
@@ -422,5 +424,19 @@ ConPlatformComponentNameGetControllerName (
   OUT CHAR16                                          **ControllerName\r
   );\r
 \r
+/**\r
+  Update ConOutDev and ErrOutDev variables to add the device path of\r
+  GOP controller itself and the sibling controllers.\r
+\r
+  @param  DevicePath            Pointer to device's device path.\r
+\r
+  @retval TRUE                  The devcie is a GOP device.\r
+  @retval FALSE                 The devcie is not a GOP device.\r
+\r
+**/\r
+BOOLEAN\r
+ConPlatformUpdateGopCandidate (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL    *DevicePath\r
+  );\r
 \r
 #endif\r
index 9c789906baebc04ee269121dd236aa5961a59b11..83fae1ead733154146bf797b9d7fdfeccb19cb23 100644 (file)
@@ -87,4 +87,5 @@
   gEfiDevicePathProtocolGuid                    ## TO_START\r
   gEfiSimpleTextInProtocolGuid                  ## TO_START\r
   gEfiSimpleTextOutProtocolGuid                 ## TO_START\r
-  
\ No newline at end of file
+  gEfiPciIoProtocolGuid                         ## TO_START\r
+  gEfiGraphicsOutputProtocolGuid                ## TO_START
\ No newline at end of file