]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Change the algorithm in SNP to use the first found BAR index.
authorFu Siyuan <siyuan.fu@intel.com>
Tue, 15 Sep 2015 03:12:15 +0000 (03:12 +0000)
committersfu5 <sfu5@Edk2>
Tue, 15 Sep 2015 03:12:15 +0000 (03:12 +0000)
The driver binding start function in SNP.c goes through all the BARs and get
the last BAR index for use. Theoretically it should work with all valid BARs,
but we got reports some device did always use the first valid BAR, so we change
the logic in SNP to use the first found BAR index instead of the last one.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18455 6f19259b-4bc3-4df7-8a09-765794883524

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