This driver module produces IDE_CONTROLLER_INIT protocol for Sata Controllers.\r
\r
Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2018, ARM Ltd. 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
EFI_SATA_CONTROLLER_PRIVATE_DATA *Private;\r
UINT32 Data32;\r
UINTN TotalCount;\r
+ UINT64 Supports;\r
\r
DEBUG ((EFI_D_INFO, "SataControllerStart start\n"));\r
\r
Private->IdeInit.CalculateMode = IdeInitCalculateMode;\r
Private->IdeInit.SetTiming = IdeInitSetTiming;\r
Private->IdeInit.EnumAll = SATA_ENUMER_ALL;\r
+ Private->PciAttributesChanged = FALSE;\r
+\r
+ //\r
+ // Save original PCI attributes\r
+ //\r
+ Status = PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationGet,\r
+ 0,\r
+ &Private->OriginalPciAttributes\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+\r
+ DEBUG ((\r
+ EFI_D_INFO,\r
+ "Original PCI Attributes = 0x%llx\n",\r
+ Private->OriginalPciAttributes\r
+ ));\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
+ DEBUG ((EFI_D_INFO, "Supported PCI Attributes = 0x%llx\n", Supports));\r
+\r
+ Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
+ Status = PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationEnable,\r
+ Supports,\r
+ NULL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+\r
+ DEBUG ((EFI_D_INFO, "Enabled PCI Attributes = 0x%llx\n", Supports));\r
+ Private->PciAttributesChanged = TRUE;\r
\r
Status = PciIo->Pci.Read (\r
PciIo,\r
sizeof (PciData.Hdr.ClassCode),\r
PciData.Hdr.ClassCode\r
);\r
- ASSERT_EFI_ERROR (Status);\r
+ if (EFI_ERROR (Status)) {\r
+ ASSERT (FALSE);\r
+ goto Done;\r
+ }\r
\r
if (IS_PCI_IDE (&PciData)) {\r
Private->IdeInit.ChannelCount = IDE_MAX_CHANNEL;\r
if (Private->IdentifyValid != NULL) {\r
FreePool (Private->IdentifyValid);\r
}\r
+ if (Private->PciAttributesChanged) {\r
+ //\r
+ // Restore original PCI attributes\r
+ //\r
+ PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationSet,\r
+ Private->OriginalPciAttributes,\r
+ NULL\r
+ );\r
+ }\r
FreePool (Private);\r
}\r
}\r
if (Private->IdentifyValid != NULL) {\r
FreePool (Private->IdentifyValid);\r
}\r
+ if (Private->PciAttributesChanged) {\r
+ //\r
+ // Restore original PCI attributes\r
+ //\r
+ Private->PciIo->Attributes (\r
+ Private->PciIo,\r
+ EfiPciIoAttributeOperationSet,\r
+ Private->OriginalPciAttributes,\r
+ NULL\r
+ );\r
+ }\r
FreePool (Private);\r
}\r
\r
Header file for Sata Controller driver.\r
\r
Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2018, ARM Ltd. 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
//\r
EFI_IDENTIFY_DATA *IdentifyData;\r
BOOLEAN *IdentifyValid;\r
+\r
+ //\r
+ // Track the state so that the PCI attributes that were modified\r
+ // can be restored to the original value later.\r
+ //\r
+ BOOLEAN PciAttributesChanged;\r
+\r
+ //\r
+ // Copy of the original PCI Attributes\r
+ //\r
+ UINT64 OriginalPciAttributes;\r
} EFI_SATA_CONTROLLER_PRIVATE_DATA;\r
\r
#define SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS(a) CR(a, EFI_SATA_CONTROLLER_PRIVATE_DATA, IdeInit, SATA_CONTROLLER_SIGNATURE)\r