mirror of https://github.com/acidanthera/audk.git
Change PciIo::GetBarAttributes() to return unsupported for a unsupported bar even it's below 6 to follow the UEFI Spec.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15538 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
36d6448c1e
commit
6b5f577faf
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2005 - 2014, Intel Corporation. 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
|
||||||
|
@ -1600,14 +1600,10 @@ Returns:
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
|
|
||||||
UINT8 *Configuration;
|
UINT8 *Configuration;
|
||||||
UINT8 NumConfig;
|
|
||||||
PCI_IO_DEVICE *PciIoDevice;
|
PCI_IO_DEVICE *PciIoDevice;
|
||||||
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Ptr;
|
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *AddressSpace;
|
||||||
EFI_ACPI_END_TAG_DESCRIPTOR *PtrEnd;
|
EFI_ACPI_END_TAG_DESCRIPTOR *End;
|
||||||
|
|
||||||
NumConfig = 0;
|
|
||||||
|
|
||||||
PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);
|
PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);
|
||||||
|
|
||||||
|
@ -1615,7 +1611,7 @@ Returns:
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BarIndex >= PCI_MAX_BAR) {
|
if ((BarIndex >= PCI_MAX_BAR) || (PciIoDevice->PciBar[BarIndex].BarType == PciBarTypeUnknown)) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1628,106 +1624,93 @@ Returns:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Resources != NULL) {
|
if (Resources != NULL) {
|
||||||
|
Configuration = AllocateZeroPool (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR));
|
||||||
if (PciIoDevice->PciBar[BarIndex].BarType != PciBarTypeUnknown) {
|
|
||||||
NumConfig = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Configuration = AllocatePool (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) * NumConfig + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR));
|
|
||||||
if (Configuration == NULL) {
|
if (Configuration == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroMem (
|
AddressSpace = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration;
|
||||||
Configuration,
|
|
||||||
sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) * NumConfig + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR)
|
|
||||||
);
|
|
||||||
|
|
||||||
Ptr = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration;
|
AddressSpace->Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR;
|
||||||
|
AddressSpace->Len = (UINT16) (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3);
|
||||||
|
|
||||||
if (NumConfig == 1) {
|
AddressSpace->AddrRangeMin = PciIoDevice->PciBar[BarIndex].BaseAddress;
|
||||||
Ptr->Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR;
|
AddressSpace->AddrLen = PciIoDevice->PciBar[BarIndex].Length;
|
||||||
Ptr->Len = sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3;
|
AddressSpace->AddrRangeMax = PciIoDevice->PciBar[BarIndex].Alignment;
|
||||||
|
|
||||||
Ptr->AddrRangeMin = PciIoDevice->PciBar[BarIndex].BaseAddress;
|
switch (PciIoDevice->PciBar[BarIndex].BarType) {
|
||||||
Ptr->AddrLen = PciIoDevice->PciBar[BarIndex].Length;
|
case PciBarTypeIo16:
|
||||||
Ptr->AddrRangeMax = PciIoDevice->PciBar[BarIndex].Alignment;
|
case PciBarTypeIo32:
|
||||||
|
//
|
||||||
|
// Io
|
||||||
|
//
|
||||||
|
AddressSpace->ResType = ACPI_ADDRESS_SPACE_TYPE_IO;
|
||||||
|
break;
|
||||||
|
|
||||||
switch (PciIoDevice->PciBar[BarIndex].BarType) {
|
case PciBarTypeMem32:
|
||||||
case PciBarTypeIo16:
|
//
|
||||||
case PciBarTypeIo32:
|
// Mem
|
||||||
//
|
//
|
||||||
// Io
|
AddressSpace->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM;
|
||||||
//
|
//
|
||||||
Ptr->ResType = ACPI_ADDRESS_SPACE_TYPE_IO;
|
// 32 bit
|
||||||
break;
|
//
|
||||||
|
AddressSpace->AddrSpaceGranularity = 32;
|
||||||
|
break;
|
||||||
|
|
||||||
case PciBarTypeMem32:
|
case PciBarTypePMem32:
|
||||||
//
|
//
|
||||||
// Mem
|
// Mem
|
||||||
//
|
//
|
||||||
Ptr->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM;
|
AddressSpace->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM;
|
||||||
//
|
//
|
||||||
// 32 bit
|
// prefechable
|
||||||
//
|
//
|
||||||
Ptr->AddrSpaceGranularity = 32;
|
AddressSpace->SpecificFlag = 0x6;
|
||||||
break;
|
//
|
||||||
|
// 32 bit
|
||||||
|
//
|
||||||
|
AddressSpace->AddrSpaceGranularity = 32;
|
||||||
|
break;
|
||||||
|
|
||||||
case PciBarTypePMem32:
|
case PciBarTypeMem64:
|
||||||
//
|
//
|
||||||
// Mem
|
// Mem
|
||||||
//
|
//
|
||||||
Ptr->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM;
|
AddressSpace->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM;
|
||||||
//
|
//
|
||||||
// prefechable
|
// 64 bit
|
||||||
//
|
//
|
||||||
Ptr->SpecificFlag = 0x6;
|
AddressSpace->AddrSpaceGranularity = 64;
|
||||||
//
|
break;
|
||||||
// 32 bit
|
|
||||||
//
|
|
||||||
Ptr->AddrSpaceGranularity = 32;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PciBarTypeMem64:
|
case PciBarTypePMem64:
|
||||||
//
|
//
|
||||||
// Mem
|
// Mem
|
||||||
//
|
//
|
||||||
Ptr->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM;
|
AddressSpace->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM;
|
||||||
//
|
//
|
||||||
// 64 bit
|
// prefechable
|
||||||
//
|
//
|
||||||
Ptr->AddrSpaceGranularity = 64;
|
AddressSpace->SpecificFlag = 0x6;
|
||||||
break;
|
//
|
||||||
|
// 64 bit
|
||||||
|
//
|
||||||
|
AddressSpace->AddrSpaceGranularity = 64;
|
||||||
|
break;
|
||||||
|
|
||||||
case PciBarTypePMem64:
|
default:
|
||||||
//
|
break;
|
||||||
// Mem
|
|
||||||
//
|
|
||||||
Ptr->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM;
|
|
||||||
//
|
|
||||||
// prefechable
|
|
||||||
//
|
|
||||||
Ptr->SpecificFlag = 0x6;
|
|
||||||
//
|
|
||||||
// 64 bit
|
|
||||||
//
|
|
||||||
Ptr->AddrSpaceGranularity = 64;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ptr = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) ((UINT8 *) Ptr + sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// put the checksum
|
// put the checksum
|
||||||
//
|
//
|
||||||
PtrEnd = (EFI_ACPI_END_TAG_DESCRIPTOR *) ((UINT8 *) Ptr);
|
End = (EFI_ACPI_END_TAG_DESCRIPTOR *) (AddressSpace + 1);
|
||||||
PtrEnd->Desc = ACPI_END_TAG_DESCRIPTOR;
|
End->Desc = ACPI_END_TAG_DESCRIPTOR;
|
||||||
PtrEnd->Checksum = 0;
|
End->Checksum = 0;
|
||||||
|
|
||||||
*Resources = Configuration;
|
*Resources = Configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
|
Loading…
Reference in New Issue