]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Bus/Pci/PciBus/Dxe/PciIo.c
The reasons for the changes made are:
[mirror_edk2.git] / EdkModulePkg / Bus / Pci / PciBus / Dxe / PciIo.c
index 28fbaca67a121eeec1bcb3c81cb0919d46503111..e01d6aa7f0cb291f55c1da03a686a9198248dd17 100644 (file)
@@ -369,7 +369,7 @@ Returns:
 \r
   PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
 \r
-  if (Width < 0 || Width >= EfiPciIoWidthMaximum) {\r
+  if (Width < 0 || Width > EfiPciIoWidthUint64) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -378,10 +378,6 @@ Returns:
     return EFI_UNSUPPORTED;\r
   }\r
 \r
-  if (Width > EfiPciIoWidthUint64) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
   Status = PciIoDevice->PciRootBridgeIo->PollIo (\r
                                           PciIoDevice->PciRootBridgeIo,\r
                                           (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
@@ -1509,12 +1505,26 @@ Returns:
   Command       = 0;\r
   BridgeControl = 0;\r
 \r
+  //\r
+  // Check VGA and VGA16, they can not be set at the same time\r
+  //\r
+  if (((Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO)         &&\r
+       (Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO_16))         ||\r
+      ((Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO)         &&\r
+       (Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16)) ||\r
+      ((Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO) &&\r
+       (Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO_16))         ||\r
+      ((Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO) &&\r
+       (Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16)) ) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
   //\r
   // For PPB & P2C, set relevant attribute bits\r
   //\r
   if (IS_PCI_BRIDGE (&PciIoDevice->Pci) || IS_CARDBUS_BRIDGE (&PciIoDevice->Pci)) {\r
 \r
-    if (Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO) {\r
+    if (Attributes & (EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16)) {\r
       BridgeControl |= EFI_PCI_BRIDGE_CONTROL_VGA;\r
     }\r
 \r
@@ -1522,18 +1532,23 @@ Returns:
       BridgeControl |= EFI_PCI_BRIDGE_CONTROL_ISA;\r
     }\r
 \r
-    if (Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO) {\r
+    if (Attributes & (EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO | EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16)) {\r
       Command |= EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO;\r
     }\r
 \r
+    if (Attributes & (EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16)) {\r
+      BridgeControl |= EFI_PCI_BRIDGE_CONTROL_VGA_16;\r
+    }\r
+\r
   } else {\r
     //\r
     // Do with the attributes on VGA\r
+    // Only for VGA's legacy resource, we just can enable once.\r
     //\r
-    if ((Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO) || \r
-        (IS_PCI_VGA(&PciIoDevice->Pci) && \r
-         ((Attributes & EFI_PCI_IO_ATTRIBUTE_IO) || \r
-          (Attributes & EFI_PCI_IO_ATTRIBUTE_MEMORY)))) {\r
+    if (Attributes &\r
+        (EFI_PCI_IO_ATTRIBUTE_VGA_IO    |\r
+         EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 |\r
+         EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY)) {\r
       //\r
       // Check if a VGA has been enabled before enabling a new one\r
       //\r
@@ -1554,7 +1569,7 @@ Returns:
     //\r
     // Do with the attributes on GFX\r
     //\r
-    if (Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO) {\r
+    if (Attributes & (EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO | EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16)) {\r
 \r
       if (Operation == EfiPciIoAttributeOperationEnable) {\r
         //\r