REF: https://bugzilla.tianocore.org/show_bug.cgi?id=405
The original code enables some BITs in PCI attributes in Start(),
but wrongly to disable these BITs in Stop().
The correct behavior is to save the original PCI attributes before
enables some BITs in Start(), and restore to original value
in Stop().
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
/** @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 - 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
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
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
BOOLEAN Enabled;\r
\r
Enabled = FALSE;\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
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
+ Status = PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationGet,\r
+ 0,\r
+ &OriginalAttributes\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
Status = PciIo->Attributes (\r
PciIo, \r
EfiPciIoAttributeOperationEnable, \r
Status = PciIo->Attributes (\r
PciIo, \r
EfiPciIoAttributeOperationEnable, \r
if (EFI_ERROR (Status)) {\r
goto Done;\r
}\r
if (EFI_ERROR (Status)) {\r
goto Done;\r
}\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
//\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
//\r
// Initialize PcatIsaAcpiDeviceList\r
if (PciIo != NULL && Enabled) {\r
PciIo->Attributes (\r
PciIo, \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
+ EfiPciIoAttributeOperationSet,\r
+ OriginalAttributes,\r
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
\r
//\r
// Get the ISA ACPI Protocol Interface\r
\r
//\r
// Get the ISA ACPI Protocol Interface\r
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
/** @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 - 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
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
EFI_HANDLE Handle; \r
EFI_ISA_ACPI_PROTOCOL IsaAcpi;\r
EFI_PCI_IO_PROTOCOL *PciIo;\r
EFI_HANDLE Handle; \r
EFI_ISA_ACPI_PROTOCOL IsaAcpi;\r
EFI_PCI_IO_PROTOCOL *PciIo;\r
+ UINT64 OriginalAttributes;\r
} PCAT_ISA_ACPI_DEV;\r
\r
#define PCAT_ISA_ACPI_DEV_FROM_THIS(a) BASE_CR(a, PCAT_ISA_ACPI_DEV, IsaAcpi)\r
} PCAT_ISA_ACPI_DEV;\r
\r
#define PCAT_ISA_ACPI_DEV_FROM_THIS(a) BASE_CR(a, PCAT_ISA_ACPI_DEV, IsaAcpi)\r