]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/QemuVideoDxe/Driver.c
OvmfPkg: don't assign PCI BARs above 4GiB when CSM enabled
[mirror_edk2.git] / OvmfPkg / QemuVideoDxe / Driver.c
index 8e02700d396020a78a79f7c77b33f44d1139a79e..522110ef4e098b5b60527036bec60f326bad1df8 100644 (file)
@@ -2,15 +2,9 @@
   This driver is a sample implementation of the Graphics Output Protocol for\r
   the QEMU (Cirrus Logic 5446) video controller.\r
 \r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
 \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
-  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
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -207,6 +201,7 @@ QemuVideoControllerDriverStart (
   PCI_TYPE00                        Pci;\r
   QEMU_VIDEO_CARD                   *Card;\r
   EFI_PCI_IO_PROTOCOL               *ChildPciIo;\r
+  UINT64                            SupportedVgaIo;\r
 \r
   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
 \r
@@ -283,13 +278,32 @@ QemuVideoControllerDriverStart (
     goto ClosePciIo;\r
   }\r
 \r
+  //\r
+  // Get supported PCI attributes\r
+  //\r
+  Status = Private->PciIo->Attributes (\r
+                             Private->PciIo,\r
+                             EfiPciIoAttributeOperationSupported,\r
+                             0,\r
+                             &SupportedVgaIo\r
+                             );\r
+  if (EFI_ERROR (Status)) {\r
+    goto ClosePciIo;\r
+  }\r
+\r
+  SupportedVgaIo &= (UINT64)(EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16);\r
+  if (SupportedVgaIo == 0) {\r
+    Status = EFI_UNSUPPORTED;\r
+    goto ClosePciIo;\r
+  }\r
+\r
   //\r
   // Set new PCI attributes\r
   //\r
   Status = Private->PciIo->Attributes (\r
                             Private->PciIo,\r
                             EfiPciIoAttributeOperationEnable,\r
-                            EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO,\r
+                            EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | SupportedVgaIo,\r
                             NULL\r
                             );\r
   if (EFI_ERROR (Status)) {\r
@@ -988,18 +1002,5 @@ InitializeQemuVideo (
              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  //\r
-  // Install EFI Driver Supported EFI Version Protocol required for\r
-  // EFI drivers that are on PCI and other plug in cards.\r
-  //\r
-  gQemuVideoDriverSupportedEfiVersion.FirmwareVersion = PcdGet32 (PcdDriverSupportedEfiVersion);\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &ImageHandle,\r
-                  &gEfiDriverSupportedEfiVersionProtocolGuid,\r
-                  &gQemuVideoDriverSupportedEfiVersion,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
   return Status;\r
 }\r