]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / NonDiscoverablePciDeviceDxe / NonDiscoverablePciDeviceDxe.c
index 876e99fc87f891c5ba4678e829f3c19ad19a1078..5c93e2a7663c60cbfb2c17ac6217617612d12e0f 100644 (file)
@@ -2,13 +2,7 @@
 \r
   Copyright (C) 2016, Linaro Ltd. All rights reserved.<BR>\r
 \r
-  This program and the accompanying materials are licensed and made available\r
-  under the terms and conditions of the BSD License which accompanies this\r
-  distribution. The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
-  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -16,6 +10,9 @@
 \r
 #include <Protocol/DriverBinding.h>\r
 \r
+#define MAX_NON_DISCOVERABLE_PCI_DEVICE_ID   (32 * 256)\r
+\r
+STATIC UINTN               mUniqueIdCounter = 0;\r
 EFI_CPU_ARCH_PROTOCOL      *mCpu;\r
 \r
 //\r
@@ -23,7 +20,7 @@ EFI_CPU_ARCH_PROTOCOL      *mCpu;
 //\r
 STATIC\r
 CONST EFI_GUID * CONST\r
-SupportedNonDiscoverableDevices [] = {\r
+SupportedNonDiscoverableDevices[] = {\r
   &gEdkiiNonDiscoverableAhciDeviceGuid,\r
   &gEdkiiNonDiscoverableEhciDeviceGuid,\r
   &gEdkiiNonDiscoverableNvmeDeviceGuid,\r
@@ -141,6 +138,11 @@ NonDiscoverablePciDeviceStart (
   NON_DISCOVERABLE_PCI_DEVICE   *Dev;\r
   EFI_STATUS                    Status;\r
 \r
+  ASSERT (mUniqueIdCounter < MAX_NON_DISCOVERABLE_PCI_DEVICE_ID);\r
+  if (mUniqueIdCounter >= MAX_NON_DISCOVERABLE_PCI_DEVICE_ID) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
   Dev = AllocateZeroPool (sizeof *Dev);\r
   if (Dev == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
@@ -167,6 +169,8 @@ NonDiscoverablePciDeviceStart (
     goto CloseProtocol;\r
   }\r
 \r
+  Dev->UniqueId = mUniqueIdCounter++;\r
+\r
   return EFI_SUCCESS;\r
 \r
 CloseProtocol:\r