Browse Source

[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>
tags/v1.20.1
Michael Brown 7 years ago
parent
commit
9ccd8fe569
1 changed files with 2 additions and 2 deletions
  1. 2
    2
      src/drivers/net/efi/nii.c

+ 2
- 2
src/drivers/net/efi/nii.c View File

202
 		EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *acpi;
202
 		EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *acpi;
203
 		void *resource;
203
 		void *resource;
204
 	} desc;
204
 	} desc;
205
-	unsigned int bar;
205
+	int bar;
206
 	EFI_STATUS efirc;
206
 	EFI_STATUS efirc;
207
 	int rc;
207
 	int rc;
208
 
208
 
230
 	/* Identify memory and I/O BARs */
230
 	/* Identify memory and I/O BARs */
231
 	nii->mem_bar = PCI_MAX_BAR;
231
 	nii->mem_bar = PCI_MAX_BAR;
232
 	nii->io_bar = PCI_MAX_BAR;
232
 	nii->io_bar = PCI_MAX_BAR;
233
-	for ( bar = 0 ; bar < PCI_MAX_BAR ; bar++ ) {
233
+	for ( bar = ( PCI_MAX_BAR - 1 ) ; bar >= 0 ; bar-- ) {
234
 		efirc = nii->pci_io->GetBarAttributes ( nii->pci_io, bar, NULL,
234
 		efirc = nii->pci_io->GetBarAttributes ( nii->pci_io, bar, NULL,
235
 							&desc.resource );
235
 							&desc.resource );
236
 		if ( efirc == EFI_UNSUPPORTED ) {
236
 		if ( efirc == EFI_UNSUPPORTED ) {

Loading…
Cancel
Save