]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/SnpDxe/Snp.c
MdeModulePkg: Change the algorithm in SNP to use the first found BAR index.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Snp.c
index a63dd10b296d8b7d7a1d0332336467868e3dc253..db5b6267a613111bae3407cfc95c20a1e20b7699 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of driver entry point and driver binding protocol.\r
 \r
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed\r
 and made available under the terms and conditions of the BSD License which\r
 accompanies this distribution. The full text of the license may be found at\r
@@ -273,6 +273,8 @@ SimpleNetworkDriverStart (
   PXE_STATFLAGS                             InitStatFlags;\r
   EFI_PCI_IO_PROTOCOL                       *PciIo;\r
   EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR         *BarDesc;\r
+  BOOLEAN                                   FoundIoBar;\r
+  BOOLEAN                                   FoundMemoryBar;\r
   \r
   DEBUG ((EFI_D_NET, "\nSnpNotifyNetworkInterfaceIdentifier()  "));\r
 \r
@@ -403,7 +405,7 @@ SimpleNetworkDriverStart (
   Snp->TxRxBuffer         = NULL;\r
  \r
   if (Nii->Revision >= EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION) {\r
-       Snp->IfNum = Nii->IfNum;\r
+    Snp->IfNum = Nii->IfNum;\r
 \r
   } else {\r
     Snp->IfNum = (UINT8) (Nii->IfNum & 0xFF);\r
@@ -463,6 +465,8 @@ SimpleNetworkDriverStart (
   //\r
   Snp->MemoryBarIndex = 0;\r
   Snp->IoBarIndex     = 1;\r
+  FoundMemoryBar      = FALSE;\r
+  FoundIoBar          = FALSE;\r
   for (BarIndex = 0; BarIndex < PCI_MAX_BAR; BarIndex++) {\r
     Status = PciIo->GetBarAttributes (\r
                       PciIo,\r
@@ -476,13 +480,19 @@ SimpleNetworkDriverStart (
       goto Error_DeleteSNP;\r
     }\r
 \r
-    if (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {\r
+    if ((!FoundMemoryBar) && (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM)) {\r
       Snp->MemoryBarIndex = BarIndex;\r
-    } else if (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_IO) {\r
+      FoundMemoryBar      = TRUE;\r
+    } else if ((!FoundIoBar) && (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_IO)) {\r
       Snp->IoBarIndex = BarIndex;\r
+      FoundIoBar      = TRUE;\r
     }\r
 \r
     FreePool (BarDesc);\r
+\r
+    if (FoundMemoryBar && FoundIoBar) {\r
+      break;\r
+    }\r
   }\r
 \r
   Status = PxeStart (Snp);\r