summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c')
-rw-r--r--MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
index 3e9ff6620d..2483c72969 100644
--- a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
+++ b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
@@ -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: