MdeModulePkg: Fix a PCI resource dumping bug in PciBusDxe driver

The resource dumping logic contains a bug which cannot dump the
resource for hot plug controller correctly. The patch fixes this
bug.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18718 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Ruiyu Ni
2015-11-03 02:33:41 +00:00
committed by niruiyu
parent b3800cfd10
commit f67bd32dda
3 changed files with 162 additions and 79 deletions

View File

@ -324,6 +324,81 @@ PciSearchDevice (
return EFI_SUCCESS;
}
/**
Dump the PPB padding resource information.
@param PciIoDevice PCI IO instance.
@param ResourceType The desired resource type to dump.
PciBarTypeUnknown means to dump all types of resources.
**/
VOID
DumpPpbPaddingResource (
IN PCI_IO_DEVICE *PciIoDevice,
IN PCI_BAR_TYPE ResourceType
)
{
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor;
PCI_BAR_TYPE Type;
if (PciIoDevice->ResourcePaddingDescriptors == NULL) {
return;
}
if (ResourceType == PciBarTypeIo16 || ResourceType == PciBarTypeIo32) {
ResourceType = PciBarTypeIo;
}
for (Descriptor = PciIoDevice->ResourcePaddingDescriptors; Descriptor->Desc != ACPI_END_TAG_DESCRIPTOR; Descriptor++) {
Type = PciBarTypeUnknown;
if (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR && Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_IO) {
Type = PciBarTypeIo;
} else if (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR && Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {
if (Descriptor->AddrSpaceGranularity == 32) {
//
// prefechable
//
if (Descriptor->SpecificFlag == EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE) {
Type = PciBarTypePMem32;
}
//
// Non-prefechable
//
if (Descriptor->SpecificFlag == 0) {
Type = PciBarTypeMem32;
}
}
if (Descriptor->AddrSpaceGranularity == 64) {
//
// prefechable
//
if (Descriptor->SpecificFlag == EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE) {
Type = PciBarTypePMem64;
}
//
// Non-prefechable
//
if (Descriptor->SpecificFlag == 0) {
Type = PciBarTypeMem64;
}
}
}
if ((Type != PciBarTypeUnknown) && ((ResourceType == PciBarTypeUnknown) || (ResourceType == Type))) {
DEBUG ((
EFI_D_INFO,
" Padding: Type = %s; Alignment = 0x%lx;\tLength = 0x%lx\n",
mBarTypeStr[Type], Descriptor->AddrRangeMax, Descriptor->AddrLen
));
}
}
}
/**
Dump the PCI BAR information.
@ -586,7 +661,10 @@ GatherPpbInfo (
GetResourcePaddingPpb (PciIoDevice);
DEBUG_CODE (DumpPciBars (PciIoDevice););
DEBUG_CODE (
DumpPpbPaddingResource (PciIoDevice, PciBarTypeUnknown);
DumpPciBars (PciIoDevice);
);
return PciIoDevice;
}