]> git.proxmox.com Git - mirror_edk2.git/blobdiff - PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c
NetworkPkg: Add IN/OUT modifier.
[mirror_edk2.git] / PcAtChipsetPkg / IsaAcpiDxe / PcatIsaAcpi.c
index 39655479fb0ba66c5877d5daa837c2e8f38e7ad4..ea1180f3abf072e9c8e72438bcce45225a1643da 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   EFI PCAT ISA ACPI Driver for a Generic PC Platform\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved. <BR>\r
+Copyright (c) 2006 - 2010, 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
@@ -73,6 +73,10 @@ PcatIsaAcpiDriverBindingSupported (
   EFI_STATUS           Status;\r
   EFI_PCI_IO_PROTOCOL  *PciIo;\r
   PCI_TYPE00           Pci;\r
+  UINTN                SegmentNumber;\r
+  UINTN                BusNumber;\r
+  UINTN                DeviceNumber;\r
+  UINTN                FunctionNumber;\r
 \r
   //\r
   // Get PciIo protocol instance\r
@@ -110,10 +114,25 @@ PcatIsaAcpiDriverBindingSupported (
         //\r
         // See if this is an Intel PCI to ISA bridge in Positive Decode Mode\r
         //\r
-        if (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA_PDECODE &&\r
-            Pci.Hdr.VendorId == 0x8086 && \r
-            (Pci.Hdr.DeviceId & 0xF000) == 0x7000) {\r
-          Status = EFI_SUCCESS;\r
+        if (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA_PDECODE && \r
+            Pci.Hdr.VendorId     == 0x8086                          ) {\r
+          //\r
+          // See if this is on Function #0 to avoid false positives on \r
+          // PCI_CLASS_BRIDGE_OTHER that has the same value as \r
+          // PCI_CLASS_BRIDGE_ISA_PDECODE\r
+          //\r
+          Status = PciIo->GetLocation (\r
+                            PciIo, \r
+                            &SegmentNumber, \r
+                            &BusNumber, \r
+                            &DeviceNumber, \r
+                            &FunctionNumber\r
+                            );\r
+          if (!EFI_ERROR (Status) && FunctionNumber == 0) {\r
+            Status = EFI_SUCCESS;\r
+          } else {\r
+            Status = EFI_UNSUPPORTED;\r
+          }\r
         }\r
       } \r
     }\r
@@ -152,7 +171,11 @@ PcatIsaAcpiDriverBindingStart (
   EFI_STATUS           Status;\r
   EFI_PCI_IO_PROTOCOL  *PciIo;\r
   PCAT_ISA_ACPI_DEV    *PcatIsaAcpiDev;\r
-    \r
+  UINT64               Supports;\r
+  BOOLEAN              Enabled;\r
+\r
+  Enabled = FALSE;\r
+  Supports = 0;\r
   PcatIsaAcpiDev = NULL;\r
   //\r
   // Open the PCI I/O Protocol Interface\r
@@ -170,10 +193,30 @@ PcatIsaAcpiDriverBindingStart (
     goto Done;\r
   }\r
 \r
+  //\r
+  // Get supported PCI attributes\r
+  //\r
+  Status = PciIo->Attributes (\r
+                    PciIo,\r
+                    EfiPciIoAttributeOperationSupported,\r
+                    0,\r
+                    &Supports\r
+                    );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  Supports &= (EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_IO_16);\r
+  if (Supports == 0 || Supports == (EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_IO_16)) {\r
+    Status = EFI_UNSUPPORTED;\r
+    goto Done;\r
+  }  \r
+\r
+  Enabled = TRUE;\r
   Status = PciIo->Attributes (\r
                     PciIo, \r
                     EfiPciIoAttributeOperationEnable, \r
-                    EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO, \r
+                    EFI_PCI_DEVICE_ENABLE | Supports | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO, \r
                     NULL \r
                     );\r
   if (EFI_ERROR (Status)) {\r
@@ -223,11 +266,11 @@ PcatIsaAcpiDriverBindingStart (
 \r
 Done:\r
   if (EFI_ERROR (Status)) {\r
-    if (PciIo) {\r
+    if (PciIo != NULL && Enabled) {\r
       PciIo->Attributes (\r
                PciIo, \r
                EfiPciIoAttributeOperationDisable, \r
-               EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO,\r
+               EFI_PCI_DEVICE_ENABLE | Supports | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO,\r
                NULL \r
                );\r
     }\r
@@ -273,6 +316,7 @@ PcatIsaAcpiDriverBindingStop (
   EFI_STATUS             Status;\r
   EFI_ISA_ACPI_PROTOCOL  *IsaAcpi;\r
   PCAT_ISA_ACPI_DEV      *PcatIsaAcpiDev;\r
+  UINT64                 Supports;\r
   \r
   //\r
   // Get the ISA ACPI Protocol Interface\r
@@ -294,10 +338,25 @@ PcatIsaAcpiDriverBindingStop (
   //\r
   PcatIsaAcpiDev = PCAT_ISA_ACPI_DEV_FROM_THIS (IsaAcpi);\r
 \r
+  //\r
+  // Get supported PCI attributes\r
+  //\r
+  Status = PcatIsaAcpiDev->PciIo->Attributes (\r
+                                    PcatIsaAcpiDev->PciIo,\r
+                                    EfiPciIoAttributeOperationSupported,\r
+                                    0,\r
+                                    &Supports\r
+                                    );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Supports &= (EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_IO_16);\r
+\r
   PcatIsaAcpiDev->PciIo->Attributes (\r
                            PcatIsaAcpiDev->PciIo, \r
                            EfiPciIoAttributeOperationDisable, \r
-                           EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO,\r
+                           EFI_PCI_DEVICE_ENABLE | Supports | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO,\r
                            NULL \r
                            );\r
  \r