]> git.proxmox.com Git - mirror_edk2.git/blobdiff - PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c
BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / PcAtChipsetPkg / IsaAcpiDxe / PcatIsaAcpi.c
index 32381b112d0e68f714a8944ac0ba39bd5414ce31..533e1d3901ff1cba878e125e2ac12fb12a28f8ca 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   EFI PCAT ISA ACPI Driver for a Generic PC Platform\r
 \r
 /** @file\r
   EFI PCAT ISA ACPI Driver for a Generic PC Platform\r
 \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, 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
 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
@@ -42,8 +42,8 @@ PcatIsaAcpiDriverEntryPoint (
   )\r
 {\r
   return EfiLibInstallDriverBindingComponentName2 (\r
   )\r
 {\r
   return EfiLibInstallDriverBindingComponentName2 (\r
-           ImageHandle, \r
-           SystemTable, \r
+           ImageHandle,\r
+           SystemTable,\r
            &gPcatIsaAcpiDriverBinding,\r
            ImageHandle,\r
            &gPcatIsaAcpiComponentName,\r
            &gPcatIsaAcpiDriverBinding,\r
            ImageHandle,\r
            &gPcatIsaAcpiComponentName,\r
@@ -54,7 +54,7 @@ PcatIsaAcpiDriverEntryPoint (
 /**\r
   ControllerDriver Protocol Method\r
 \r
 /**\r
   ControllerDriver Protocol Method\r
 \r
-  @param This                 Driver Binding protocol instance pointer.   \r
+  @param This                 Driver Binding protocol instance pointer.\r
   @param Controller           Handle of device to test.\r
   @param RemainingDevicePath  Optional parameter use to pick a specific child\r
                               device to start.\r
   @param Controller           Handle of device to test.\r
   @param RemainingDevicePath  Optional parameter use to pick a specific child\r
                               device to start.\r
@@ -80,10 +80,10 @@ PcatIsaAcpiDriverBindingSupported (
 \r
   //\r
   // Get PciIo protocol instance\r
 \r
   //\r
   // Get PciIo protocol instance\r
-  //              \r
+  //\r
   Status = gBS->OpenProtocol (\r
   Status = gBS->OpenProtocol (\r
-                  Controller,  \r
-                  &gEfiPciIoProtocolGuid, \r
+                  Controller,\r
+                  &gEfiPciIoProtocolGuid,\r
                   (VOID**)&PciIo,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
                   (VOID**)&PciIo,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
@@ -97,7 +97,7 @@ PcatIsaAcpiDriverBindingSupported (
                     PciIo,\r
                     EfiPciIoWidthUint32,\r
                     0,\r
                     PciIo,\r
                     EfiPciIoWidthUint32,\r
                     0,\r
-                    sizeof(Pci) / sizeof(UINT32), \r
+                    sizeof(Pci) / sizeof(UINT32),\r
                     &Pci);\r
 \r
   if (!EFI_ERROR (Status)) {\r
                     &Pci);\r
 \r
   if (!EFI_ERROR (Status)) {\r
@@ -109,23 +109,23 @@ PcatIsaAcpiDriverBindingSupported (
         //\r
         if (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA) {\r
           Status = EFI_SUCCESS;\r
         //\r
         if (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA) {\r
           Status = EFI_SUCCESS;\r
-        } \r
+        }\r
 \r
         //\r
         // See if this is an Intel PCI to ISA bridge in Positive Decode Mode\r
         //\r
 \r
         //\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
+        if (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA_PDECODE &&\r
             Pci.Hdr.VendorId     == 0x8086                          ) {\r
           //\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
+          // 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
           // PCI_CLASS_BRIDGE_ISA_PDECODE\r
           //\r
           Status = PciIo->GetLocation (\r
-                            PciIo, \r
-                            &SegmentNumber, \r
-                            &BusNumber, \r
-                            &DeviceNumber, \r
+                            PciIo,\r
+                            &SegmentNumber,\r
+                            &BusNumber,\r
+                            &DeviceNumber,\r
                             &FunctionNumber\r
                             );\r
           if (!EFI_ERROR (Status) && FunctionNumber == 0) {\r
                             &FunctionNumber\r
                             );\r
           if (!EFI_ERROR (Status) && FunctionNumber == 0) {\r
@@ -134,17 +134,17 @@ PcatIsaAcpiDriverBindingSupported (
             Status = EFI_UNSUPPORTED;\r
           }\r
         }\r
             Status = EFI_UNSUPPORTED;\r
           }\r
         }\r
-      } \r
+      }\r
     }\r
   }\r
 \r
   gBS->CloseProtocol (\r
     }\r
   }\r
 \r
   gBS->CloseProtocol (\r
-         Controller,       \r
-         &gEfiPciIoProtocolGuid, \r
-         This->DriverBindingHandle,   \r
-         Controller   \r
+         Controller,\r
+         &gEfiPciIoProtocolGuid,\r
+         This->DriverBindingHandle,\r
+         Controller\r
          );\r
          );\r
-  \r
+\r
   return Status;\r
 }\r
 \r
   return Status;\r
 }\r
 \r
@@ -172,22 +172,24 @@ PcatIsaAcpiDriverBindingStart (
   EFI_PCI_IO_PROTOCOL  *PciIo;\r
   PCAT_ISA_ACPI_DEV    *PcatIsaAcpiDev;\r
   UINT64               Supports;\r
   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
   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
   PciIo = NULL;\r
   Status = gBS->OpenProtocol (\r
   //\r
   // Open the PCI I/O Protocol Interface\r
   //\r
   PciIo = NULL;\r
   Status = gBS->OpenProtocol (\r
-                  Controller,       \r
-                  &gEfiPciIoProtocolGuid, \r
+                  Controller,\r
+                  &gEfiPciIoProtocolGuid,\r
                   (VOID**)&PciIo,\r
                   (VOID**)&PciIo,\r
-                  This->DriverBindingHandle,   \r
-                  Controller,   \r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER \r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
                   );\r
   if (EFI_ERROR (Status)) {\r
     goto Done;\r
                   );\r
   if (EFI_ERROR (Status)) {\r
     goto Done;\r
@@ -210,19 +212,29 @@ PcatIsaAcpiDriverBindingStart (
   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
   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
 \r
-  Enabled = TRUE;\r
   Status = PciIo->Attributes (\r
   Status = PciIo->Attributes (\r
-                    PciIo, \r
-                    EfiPciIoAttributeOperationEnable, \r
-                    EFI_PCI_DEVICE_ENABLE | Supports | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO, \r
-                    NULL \r
+                    PciIo,\r
+                    EfiPciIoAttributeOperationEnable,\r
+                    EFI_PCI_DEVICE_ENABLE | Supports | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO,\r
+                    NULL\r
                     );\r
   if (EFI_ERROR (Status)) {\r
     goto Done;\r
   }\r
                     );\r
   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
   //\r
   // Allocate memory for the PCAT ISA ACPI Device structure\r
   //\r
@@ -239,15 +251,16 @@ PcatIsaAcpiDriverBindingStart (
   //\r
   // Initialize the PCAT ISA ACPI Device structure\r
   //\r
   //\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
   //\r
   InitializePcatIsaAcpiDeviceList ();\r
 \r
   //\r
   // Initialize PcatIsaAcpiDeviceList\r
   //\r
   InitializePcatIsaAcpiDeviceList ();\r
-  \r
+\r
   //\r
   // IsaAcpi interface\r
   //\r
   //\r
   // IsaAcpi interface\r
   //\r
@@ -259,7 +272,7 @@ PcatIsaAcpiDriverBindingStart (
   (PcatIsaAcpiDev->IsaAcpi).EnableDevice     = IsaEnableDevice;\r
   (PcatIsaAcpiDev->IsaAcpi).InitDevice       = IsaInitDevice;\r
   (PcatIsaAcpiDev->IsaAcpi).InterfaceInit    = IsaInterfaceInit;\r
   (PcatIsaAcpiDev->IsaAcpi).EnableDevice     = IsaEnableDevice;\r
   (PcatIsaAcpiDev->IsaAcpi).InitDevice       = IsaInitDevice;\r
   (PcatIsaAcpiDev->IsaAcpi).InterfaceInit    = IsaInterfaceInit;\r
-    \r
+\r
   //\r
   // Install the ISA ACPI Protocol interface\r
   //\r
   //\r
   // Install the ISA ACPI Protocol interface\r
   //\r
@@ -273,16 +286,16 @@ Done:
   if (EFI_ERROR (Status)) {\r
     if (PciIo != NULL && Enabled) {\r
       PciIo->Attributes (\r
   if (EFI_ERROR (Status)) {\r
     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
-               NULL \r
+               PciIo,\r
+               EfiPciIoAttributeOperationSet,\r
+               OriginalAttributes,\r
+               NULL\r
                );\r
     }\r
     gBS->CloseProtocol (\r
                );\r
     }\r
     gBS->CloseProtocol (\r
-           Controller, \r
-           &gEfiPciIoProtocolGuid, \r
-           This->DriverBindingHandle, \r
+           Controller,\r
+           &gEfiPciIoProtocolGuid,\r
+           This->DriverBindingHandle,\r
            Controller\r
            );\r
     if (PcatIsaAcpiDev != NULL) {\r
            Controller\r
            );\r
     if (PcatIsaAcpiDev != NULL) {\r
@@ -290,7 +303,7 @@ Done:
     }\r
     return Status;\r
   }\r
     }\r
     return Status;\r
   }\r
-          \r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -321,17 +334,16 @@ PcatIsaAcpiDriverBindingStop (
   EFI_STATUS             Status;\r
   EFI_ISA_ACPI_PROTOCOL  *IsaAcpi;\r
   PCAT_ISA_ACPI_DEV      *PcatIsaAcpiDev;\r
   EFI_STATUS             Status;\r
   EFI_ISA_ACPI_PROTOCOL  *IsaAcpi;\r
   PCAT_ISA_ACPI_DEV      *PcatIsaAcpiDev;\r
-  UINT64                 Supports;\r
-  \r
+\r
   //\r
   // Get the ISA ACPI Protocol Interface\r
   //\r
   // Get the ISA ACPI Protocol Interface\r
-  // \r
+  //\r
   Status = gBS->OpenProtocol (\r
   Status = gBS->OpenProtocol (\r
-                  Controller, \r
-                  &gEfiIsaAcpiProtocolGuid, \r
+                  Controller,\r
+                  &gEfiIsaAcpiProtocolGuid,\r
                   (VOID**)&IsaAcpi,\r
                   (VOID**)&IsaAcpi,\r
-                  This->DriverBindingHandle,   \r
-                  Controller,   \r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                   );\r
   if (EFI_ERROR (Status)) {\r
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                   );\r
   if (EFI_ERROR (Status)) {\r
@@ -344,27 +356,18 @@ PcatIsaAcpiDriverBindingStop (
   PcatIsaAcpiDev = PCAT_ISA_ACPI_DEV_FROM_THIS (IsaAcpi);\r
 \r
   //\r
   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
   //\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
                                     );\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
 \r
-  Supports &= (UINT64) (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
   //\r
   // Uninstall protocol interface: EFI_ISA_ACPI_PROTOCOL\r
   //\r
@@ -377,13 +380,13 @@ PcatIsaAcpiDriverBindingStop (
   }\r
 \r
   gBS->CloseProtocol (\r
   }\r
 \r
   gBS->CloseProtocol (\r
-         Controller, \r
-         &gEfiPciIoProtocolGuid, \r
-         This->DriverBindingHandle, \r
+         Controller,\r
+         &gEfiPciIoProtocolGuid,\r
+         This->DriverBindingHandle,\r
          Controller\r
          );\r
          Controller\r
          );\r
-  \r
+\r
   gBS->FreePool (PcatIsaAcpiDev);\r
   gBS->FreePool (PcatIsaAcpiDev);\r
-  \r
+\r
   return EFI_SUCCESS;\r
 }\r
   return EFI_SUCCESS;\r
 }\r