From: Fu Siyuan Date: Fri, 31 Oct 2014 00:38:39 +0000 (+0000) Subject: Fix a bug introuduced by r16104, not all NIC device implement both memory and IO... X-Git-Tag: edk2-stable201903~10732 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=3f103c08bac599bd68d28fb5dde982049469b983 Fix a bug introuduced by r16104, not all NIC device implement both memory and IO bar. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan Reviewed-By: Ye, Ting (ting.ye@intel.com) Reviewed-By: Wu, Jiaxin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16278 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c index aa5926a6a5..a63dd10b29 100644 --- a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c +++ b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c @@ -455,10 +455,14 @@ SimpleNetworkDriverStart ( Snp->Db = (VOID *) ((UINTN) Address + 2048); // - // Find the correct memory and io bar. + // Find the correct BAR to do IO. // - Snp->MemoryBarIndex = PCI_MAX_BAR; - Snp->IoBarIndex = PCI_MAX_BAR; + // Enumerate through the PCI BARs for the device to determine which one is + // the IO BAR. Save the index of the BAR into the adapter info structure. + // for regular 32bit BARs, 0 is memory mapped, 1 is io mapped + // + Snp->MemoryBarIndex = 0; + Snp->IoBarIndex = 1; for (BarIndex = 0; BarIndex < PCI_MAX_BAR; BarIndex++) { Status = PciIo->GetBarAttributes ( PciIo, @@ -480,9 +484,6 @@ SimpleNetworkDriverStart ( FreePool (BarDesc); } - if ((Snp->MemoryBarIndex == PCI_MAX_BAR) || (Snp->IoBarIndex == PCI_MAX_BAR)) { - goto Error_DeleteSNP; - } Status = PxeStart (Snp);