mirror of https://github.com/acidanthera/audk.git
MdeModulePkg: Enable SATA Controller PCI mem space
The SATA controller driver crashes while accessing the PCI memory [AHCI Base Registers (ABAR)], as the PCI memory space is not enabled. Enable the PCI memory space access to prevent the SATA Controller driver from crashing. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
parent
1e0db7b119
commit
24fee0528c
|
@ -2,6 +2,7 @@
|
||||||
This driver module produces IDE_CONTROLLER_INIT protocol for Sata Controllers.
|
This driver module produces IDE_CONTROLLER_INIT protocol for Sata Controllers.
|
||||||
|
|
||||||
Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
|
Copyright (c) 2018, ARM Ltd. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -364,6 +365,7 @@ SataControllerStart (
|
||||||
EFI_SATA_CONTROLLER_PRIVATE_DATA *Private;
|
EFI_SATA_CONTROLLER_PRIVATE_DATA *Private;
|
||||||
UINT32 Data32;
|
UINT32 Data32;
|
||||||
UINTN TotalCount;
|
UINTN TotalCount;
|
||||||
|
UINT64 Supports;
|
||||||
|
|
||||||
DEBUG ((EFI_D_INFO, "SataControllerStart start\n"));
|
DEBUG ((EFI_D_INFO, "SataControllerStart start\n"));
|
||||||
|
|
||||||
|
@ -406,6 +408,52 @@ SataControllerStart (
|
||||||
Private->IdeInit.CalculateMode = IdeInitCalculateMode;
|
Private->IdeInit.CalculateMode = IdeInitCalculateMode;
|
||||||
Private->IdeInit.SetTiming = IdeInitSetTiming;
|
Private->IdeInit.SetTiming = IdeInitSetTiming;
|
||||||
Private->IdeInit.EnumAll = SATA_ENUMER_ALL;
|
Private->IdeInit.EnumAll = SATA_ENUMER_ALL;
|
||||||
|
Private->PciAttributesChanged = FALSE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Save original PCI attributes
|
||||||
|
//
|
||||||
|
Status = PciIo->Attributes (
|
||||||
|
PciIo,
|
||||||
|
EfiPciIoAttributeOperationGet,
|
||||||
|
0,
|
||||||
|
&Private->OriginalPciAttributes
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
goto Done;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG ((
|
||||||
|
EFI_D_INFO,
|
||||||
|
"Original PCI Attributes = 0x%llx\n",
|
||||||
|
Private->OriginalPciAttributes
|
||||||
|
));
|
||||||
|
|
||||||
|
Status = PciIo->Attributes (
|
||||||
|
PciIo,
|
||||||
|
EfiPciIoAttributeOperationSupported,
|
||||||
|
0,
|
||||||
|
&Supports
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
goto Done;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG ((EFI_D_INFO, "Supported PCI Attributes = 0x%llx\n", Supports));
|
||||||
|
|
||||||
|
Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;
|
||||||
|
Status = PciIo->Attributes (
|
||||||
|
PciIo,
|
||||||
|
EfiPciIoAttributeOperationEnable,
|
||||||
|
Supports,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
goto Done;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG ((EFI_D_INFO, "Enabled PCI Attributes = 0x%llx\n", Supports));
|
||||||
|
Private->PciAttributesChanged = TRUE;
|
||||||
|
|
||||||
Status = PciIo->Pci.Read (
|
Status = PciIo->Pci.Read (
|
||||||
PciIo,
|
PciIo,
|
||||||
|
@ -414,7 +462,10 @@ SataControllerStart (
|
||||||
sizeof (PciData.Hdr.ClassCode),
|
sizeof (PciData.Hdr.ClassCode),
|
||||||
PciData.Hdr.ClassCode
|
PciData.Hdr.ClassCode
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
if (EFI_ERROR (Status)) {
|
||||||
|
ASSERT (FALSE);
|
||||||
|
goto Done;
|
||||||
|
}
|
||||||
|
|
||||||
if (IS_PCI_IDE (&PciData)) {
|
if (IS_PCI_IDE (&PciData)) {
|
||||||
Private->IdeInit.ChannelCount = IDE_MAX_CHANNEL;
|
Private->IdeInit.ChannelCount = IDE_MAX_CHANNEL;
|
||||||
|
@ -481,6 +532,17 @@ Done:
|
||||||
if (Private->IdentifyValid != NULL) {
|
if (Private->IdentifyValid != NULL) {
|
||||||
FreePool (Private->IdentifyValid);
|
FreePool (Private->IdentifyValid);
|
||||||
}
|
}
|
||||||
|
if (Private->PciAttributesChanged) {
|
||||||
|
//
|
||||||
|
// Restore original PCI attributes
|
||||||
|
//
|
||||||
|
PciIo->Attributes (
|
||||||
|
PciIo,
|
||||||
|
EfiPciIoAttributeOperationSet,
|
||||||
|
Private->OriginalPciAttributes,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
}
|
||||||
FreePool (Private);
|
FreePool (Private);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -556,6 +618,17 @@ SataControllerStop (
|
||||||
if (Private->IdentifyValid != NULL) {
|
if (Private->IdentifyValid != NULL) {
|
||||||
FreePool (Private->IdentifyValid);
|
FreePool (Private->IdentifyValid);
|
||||||
}
|
}
|
||||||
|
if (Private->PciAttributesChanged) {
|
||||||
|
//
|
||||||
|
// Restore original PCI attributes
|
||||||
|
//
|
||||||
|
Private->PciIo->Attributes (
|
||||||
|
Private->PciIo,
|
||||||
|
EfiPciIoAttributeOperationSet,
|
||||||
|
Private->OriginalPciAttributes,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
}
|
||||||
FreePool (Private);
|
FreePool (Private);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
Header file for Sata Controller driver.
|
Header file for Sata Controller driver.
|
||||||
|
|
||||||
Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
|
Copyright (c) 2018, ARM Ltd. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -104,6 +105,17 @@ typedef struct _EFI_SATA_CONTROLLER_PRIVATE_DATA {
|
||||||
//
|
//
|
||||||
EFI_IDENTIFY_DATA *IdentifyData;
|
EFI_IDENTIFY_DATA *IdentifyData;
|
||||||
BOOLEAN *IdentifyValid;
|
BOOLEAN *IdentifyValid;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Track the state so that the PCI attributes that were modified
|
||||||
|
// can be restored to the original value later.
|
||||||
|
//
|
||||||
|
BOOLEAN PciAttributesChanged;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy of the original PCI Attributes
|
||||||
|
//
|
||||||
|
UINT64 OriginalPciAttributes;
|
||||||
} EFI_SATA_CONTROLLER_PRIVATE_DATA;
|
} EFI_SATA_CONTROLLER_PRIVATE_DATA;
|
||||||
|
|
||||||
#define SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS(a) CR(a, EFI_SATA_CONTROLLER_PRIVATE_DATA, IdeInit, SATA_CONTROLLER_SIGNATURE)
|
#define SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS(a) CR(a, EFI_SATA_CONTROLLER_PRIVATE_DATA, IdeInit, SATA_CONTROLLER_SIGNATURE)
|
||||||
|
|
Loading…
Reference in New Issue