]> git.proxmox.com Git - mirror_edk2.git/blobdiff - PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c
BaseTools: Fix indentation in CParser.py file
[mirror_edk2.git] / PcAtChipsetPkg / IsaAcpiDxe / PcatIsaAcpi.c
index 55fefd4ca21e8a8d14fabeaa95b164ff00695dc1..c7ea559006fe27d712e1a237dd4ae3011cd8bcf6 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   EFI PCAT ISA ACPI Driver for a Generic PC Platform\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, 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
@@ -32,7 +32,7 @@ EFI_DRIVER_BINDING_PROTOCOL gPcatIsaAcpiDriverBinding = {
   @param ImageHandle     Handle for driver image\r
   @param SystemTable     Point to EFI_SYSTEM_TABLE\r
 \r
-  @return Sucess or not for installing driver binding protocol\r
+  @return Success or not for installing driver binding protocol\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -172,11 +172,13 @@ PcatIsaAcpiDriverBindingStart (
   EFI_PCI_IO_PROTOCOL  *PciIo;\r
   PCAT_ISA_ACPI_DEV    *PcatIsaAcpiDev;\r
   UINT64               Supports;\r
+  UINT64               OriginalAttributes;\r
   BOOLEAN              Enabled;\r
 \r
   Enabled = FALSE;\r
   Supports = 0;\r
   PcatIsaAcpiDev = NULL;\r
+  OriginalAttributes = 0;\r
   //\r
   // Open the PCI I/O Protocol Interface\r
   //\r
@@ -206,13 +208,22 @@ PcatIsaAcpiDriverBindingStart (
     goto Done;\r
   }\r
 \r
-  Supports &= (EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_IO_16);\r
+  Supports &= (UINT64) (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
+\r
+  Status = PciIo->Attributes (\r
+                    PciIo,\r
+                    EfiPciIoAttributeOperationGet,\r
+                    0,\r
+                    &OriginalAttributes\r
+                    );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
 \r
-  Enabled = TRUE;\r
   Status = PciIo->Attributes (\r
                     PciIo, \r
                     EfiPciIoAttributeOperationEnable, \r
@@ -222,7 +233,8 @@ PcatIsaAcpiDriverBindingStart (
   if (EFI_ERROR (Status)) {\r
     goto Done;\r
   }\r
-  \r
+\r
+  Enabled = TRUE;\r
   //\r
   // Allocate memory for the PCAT ISA ACPI Device structure\r
   //\r
@@ -239,9 +251,10 @@ PcatIsaAcpiDriverBindingStart (
   //\r
   // Initialize the PCAT ISA ACPI Device structure\r
   //\r
-  PcatIsaAcpiDev->Signature = PCAT_ISA_ACPI_DEV_SIGNATURE;\r
-  PcatIsaAcpiDev->Handle    = Controller;\r
-  PcatIsaAcpiDev->PciIo     = PciIo;\r
+  PcatIsaAcpiDev->Signature          = PCAT_ISA_ACPI_DEV_SIGNATURE;\r
+  PcatIsaAcpiDev->Handle             = Controller;\r
+  PcatIsaAcpiDev->PciIo              = PciIo;\r
+  PcatIsaAcpiDev->OriginalAttributes = OriginalAttributes;\r
 \r
   //\r
   // Initialize PcatIsaAcpiDeviceList\r
@@ -274,8 +287,8 @@ Done:
     if (PciIo != NULL && Enabled) {\r
       PciIo->Attributes (\r
                PciIo, \r
-               EfiPciIoAttributeOperationDisable, \r
-               EFI_PCI_DEVICE_ENABLE | Supports | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO,\r
+               EfiPciIoAttributeOperationSet,\r
+               OriginalAttributes,\r
                NULL \r
                );\r
     }\r
@@ -321,7 +334,6 @@ 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
@@ -344,27 +356,18 @@ PcatIsaAcpiDriverBindingStop (
   PcatIsaAcpiDev = PCAT_ISA_ACPI_DEV_FROM_THIS (IsaAcpi);\r
 \r
   //\r
-  // Get supported PCI attributes\r
+  // Restore PCI attributes\r
   //\r
   Status = PcatIsaAcpiDev->PciIo->Attributes (\r
                                     PcatIsaAcpiDev->PciIo,\r
-                                    EfiPciIoAttributeOperationSupported,\r
-                                    0,\r
-                                    &Supports\r
+                                    EfiPciIoAttributeOperationSet,\r
+                                    PcatIsaAcpiDev->OriginalAttributes,\r
+                                    NULL\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 | Supports | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO,\r
-                           NULL \r
-                           );\r
\r
   //\r
   // Uninstall protocol interface: EFI_ISA_ACPI_PROTOCOL\r
   //\r