MdeModulePkg/NonDiscoverablePciDeviceDxe: expose unique B/D/F identifiers
Currently, the implementation of EFI_PCI_IO_PROTOCOL::GetLocation() in NonDiscoverablePciDeviceDxe returns the same set of dummy values for each instance of the NON_DISCOVERABLE_DEVICE protocol that it attaches itself to. However, this turns out to be causing problems in cases where software (such as the ARM Compliance Test Suite [ACS]) attempts to use these values to uniquely identify controllers, since the collisions create ambiguity in this regard. So let's modify GetLocation() to return an arbitrary bus/device tuple on segment 0xff instead. This is guaranteed not to clash with other non-discoverable PCI devices, and highly unlikely to clash with real PCIe devices. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Marcin Wojtas <mw@semihalf.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
|
||||
#include <Protocol/DriverBinding.h>
|
||||
|
||||
#define MAX_NON_DISCOVERABLE_PCI_DEVICE_ID (32 * 256)
|
||||
|
||||
STATIC UINTN mUniqueIdCounter = 0;
|
||||
EFI_CPU_ARCH_PROTOCOL *mCpu;
|
||||
|
||||
//
|
||||
@@ -141,6 +144,11 @@ NonDiscoverablePciDeviceStart (
|
||||
NON_DISCOVERABLE_PCI_DEVICE *Dev;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (mUniqueIdCounter < MAX_NON_DISCOVERABLE_PCI_DEVICE_ID);
|
||||
if (mUniqueIdCounter >= MAX_NON_DISCOVERABLE_PCI_DEVICE_ID) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Dev = AllocateZeroPool (sizeof *Dev);
|
||||
if (Dev == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
@@ -167,6 +175,8 @@ NonDiscoverablePciDeviceStart (
|
||||
goto CloseProtocol;
|
||||
}
|
||||
|
||||
Dev->UniqueId = mUniqueIdCounter++;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
CloseProtocol:
|
||||
|
Reference in New Issue
Block a user