aboutsummaryrefslogtreecommitdiffstats
path: root/src/drivers/net/efi
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2017-07-21 14:48:27 +0100
committerMichael Brown <mcb30@ipxe.org>2017-07-21 15:00:17 +0100
commit9ccd8fe569c75265dfa834d325046696e18616de (patch)
tree33fa17f941c9568e44c82dd99b528de242a7c0d8 /src/drivers/net/efi
parent0600d3ae94f93efd10fc6b3c7420a9557a3a1670 (diff)
downloadipxe-9ccd8fe569c75265dfa834d325046696e18616de.tar.gz
[efi] Enumerate PCI BARs in same order as SnpDxe
The UEFI specification has an implicit and demonstrably incorrect requirement (in the Mem_IO() calling convention) that any UNDI network device has at most one memory BAR and one I/O BAR. Some UEFI platforms have been observed to report the existence of non-existent additional I/O BARs, causing iPXE to select the wrong BAR. This problem does not affect the SnpDxe driver, since that driver will always choose the lowest numbered existent BAR of each type. Adjust iPXE's behaviour to match that of SnpDxe, i.e. to always select the lowest numbered BAR(s). Debugged-by: Andreas Hammarskjöld <junior@2PintSoftware.com> Debugged-by: Adklei <adklei@realtek.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/net/efi')
-rw-r--r--src/drivers/net/efi/nii.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/drivers/net/efi/nii.c b/src/drivers/net/efi/nii.c
index d76bfb898..1c6980e69 100644
--- a/src/drivers/net/efi/nii.c
+++ b/src/drivers/net/efi/nii.c
@@ -202,7 +202,7 @@ static int nii_pci_open ( struct nii_nic *nii ) {
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *acpi;
void *resource;
} desc;
- unsigned int bar;
+ int bar;
EFI_STATUS efirc;
int rc;
@@ -230,7 +230,7 @@ static int nii_pci_open ( struct nii_nic *nii ) {
/* Identify memory and I/O BARs */
nii->mem_bar = PCI_MAX_BAR;
nii->io_bar = PCI_MAX_BAR;
- for ( bar = 0 ; bar < PCI_MAX_BAR ; bar++ ) {
+ for ( bar = ( PCI_MAX_BAR - 1 ) ; bar >= 0 ; bar-- ) {
efirc = nii->pci_io->GetBarAttributes ( nii->pci_io, bar, NULL,
&desc.resource );
if ( efirc == EFI_UNSUPPORTED ) {