>From c799ca97b4dfb8e8c39ee93e72be92a8d1b693ff Mon Sep 17 00:00:00 2001
From: Chris Ruffin <[email protected]>
Date: Sun, 3 Nov 2013 21:40:34 -0500
Subject: [PATCH] OvmfPkg/QemuVideoDxe: use child handle to open parent
 protocols

Reorder when the child handle is created so that a parent / child
relationship is established when PciIo protocol is opened.
This resolves some issues with code which depends on the parent/child
relationship to locate the GOP protocol.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chris Ruffin <[email protected])
---
 OvmfPkg/QemuVideoDxe/Driver.c | 112 +++++++++++++++++++++---------------------
 1 file changed, 56 insertions(+), 56 deletions(-)

diff --git a/OvmfPkg/QemuVideoDxe/Driver.c b/OvmfPkg/QemuVideoDxe/Driver.c
index 1dd8899..d8b9498 100644
--- a/OvmfPkg/QemuVideoDxe/Driver.c
+++ b/OvmfPkg/QemuVideoDxe/Driver.c
@@ -2,7 +2,7 @@
   This driver is a sample implementation of the Graphics Output Protocol for
   the QEMU (Cirrus Logic 5446) video controller.

-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>

   This program and the accompanying materials
   are licensed and made available under the terms and conditions of
the BSD License
@@ -227,6 +227,59 @@ QemuVideoControllerDriverStart (
   Private->Handle     = NULL;

   //
+  // Get ParentDevicePath
+  //
+  Status = gBS->HandleProtocol (
+                  Controller,
+                  &gEfiDevicePathProtocolGuid,
+                  (VOID **) &ParentDevicePath
+                  );
+  if (EFI_ERROR (Status)) {
+    goto Error;
+  }
+
+  //
+  // Set Gop Device Path
+  //
+  if (RemainingDevicePath == NULL) {
+    ZeroMem (&AcpiDeviceNode, sizeof (ACPI_ADR_DEVICE_PATH));
+    AcpiDeviceNode.Header.Type = ACPI_DEVICE_PATH;
+    AcpiDeviceNode.Header.SubType = ACPI_ADR_DP;
+    AcpiDeviceNode.ADR = ACPI_DISPLAY_ADR (1, 0, 0, 1, 0,
ACPI_ADR_DISPLAY_TYPE_VGA, 0, 0);
+    SetDevicePathNodeLength (&AcpiDeviceNode.Header, sizeof
(ACPI_ADR_DEVICE_PATH));
+
+    Private->GopDevicePath = AppendDevicePathNode (
+                                        ParentDevicePath,
+                                        (EFI_DEVICE_PATH_PROTOCOL *)
&AcpiDeviceNode
+                                        );
+  } else if (!IsDevicePathEnd (RemainingDevicePath)) {
+    //
+    // If RemainingDevicePath isn't the End of Device Path Node,
+    // only scan the specified device by RemainingDevicePath
+    //
+    Private->GopDevicePath = AppendDevicePathNode (ParentDevicePath,
RemainingDevicePath);
+  } else {
+    //
+    // If RemainingDevicePath is the End of Device Path Node,
+    // don't create child device and return EFI_SUCCESS
+    //
+    Private->GopDevicePath = NULL;
+  }
+
+  if (Private->GopDevicePath != NULL) {
+    //
+    // Creat child handle and device path protocol firstly
+    //
+    Private->Handle = NULL;
+    Status = gBS->InstallMultipleProtocolInterfaces (
+                    &Private->Handle,
+                    &gEfiDevicePathProtocolGuid,
+                    Private->GopDevicePath,
+                    NULL
+                    );
+  }
+
+  //
   // Open PCI I/O Protocol
   //
   Status = gBS->OpenProtocol (
@@ -234,8 +287,8 @@ QemuVideoControllerDriverStart (
                   &gEfiPciIoProtocolGuid,
                   (VOID **) &Private->PciIo,
                   This->DriverBindingHandle,
-                  Controller,
-                  EFI_OPEN_PROTOCOL_BY_DRIVER
+                  Private->Handle,
+                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
                   );
   if (EFI_ERROR (Status)) {
     goto Error;
@@ -322,59 +375,6 @@ QemuVideoControllerDriverStart (
   }

   //
-  // Get ParentDevicePath
-  //
-  Status = gBS->HandleProtocol (
-                  Controller,
-                  &gEfiDevicePathProtocolGuid,
-                  (VOID **) &ParentDevicePath
-                  );
-  if (EFI_ERROR (Status)) {
-    goto Error;
-  }
-
-  //
-  // Set Gop Device Path
-  //
-  if (RemainingDevicePath == NULL) {
-    ZeroMem (&AcpiDeviceNode, sizeof (ACPI_ADR_DEVICE_PATH));
-    AcpiDeviceNode.Header.Type = ACPI_DEVICE_PATH;
-    AcpiDeviceNode.Header.SubType = ACPI_ADR_DP;
-    AcpiDeviceNode.ADR = ACPI_DISPLAY_ADR (1, 0, 0, 1, 0,
ACPI_ADR_DISPLAY_TYPE_VGA, 0, 0);
-    SetDevicePathNodeLength (&AcpiDeviceNode.Header, sizeof
(ACPI_ADR_DEVICE_PATH));
-
-    Private->GopDevicePath = AppendDevicePathNode (
-                                        ParentDevicePath,
-                                        (EFI_DEVICE_PATH_PROTOCOL *)
&AcpiDeviceNode
-                                        );
-  } else if (!IsDevicePathEnd (RemainingDevicePath)) {
-    //
-    // If RemainingDevicePath isn't the End of Device Path Node,
-    // only scan the specified device by RemainingDevicePath
-    //
-    Private->GopDevicePath = AppendDevicePathNode (ParentDevicePath,
RemainingDevicePath);
-  } else {
-    //
-    // If RemainingDevicePath is the End of Device Path Node,
-    // don't create child device and return EFI_SUCCESS
-    //
-    Private->GopDevicePath = NULL;
-  }
-
-  if (Private->GopDevicePath != NULL) {
-    //
-    // Creat child handle and device path protocol firstly
-    //
-    Private->Handle = NULL;
-    Status = gBS->InstallMultipleProtocolInterfaces (
-                    &Private->Handle,
-                    &gEfiDevicePathProtocolGuid,
-                    Private->GopDevicePath,
-                    NULL
-                    );
-  }
-
-  //
   // Construct video mode buffer
   //
   switch (Private->Variant) {

------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to