Ver código fonte

[efi] Make EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL optional

Some UEFI systems (observed with a Hyper-V virtual machine) do not
provide EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.  Make this an optional
protocol (and fail any attempts to access PCI configuration space via
the root bridge if the protocol is missing).

Reported-by: Colin Blacker <Colin.Blacker@computerplanet.co.uk>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 anos atrás
pai
commit
3bb910caa8
1 arquivos alterados com 7 adições e 1 exclusões
  1. 7
    1
      src/interface/efi/efi_pci.c

+ 7
- 1
src/interface/efi/efi_pci.c Ver arquivo

@@ -59,7 +59,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
59 59
 
60 60
 /** PCI root bridge I/O protocol */
61 61
 static EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *efipci;
62
-EFI_REQUIRE_PROTOCOL ( EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL, &efipci );
62
+EFI_REQUEST_PROTOCOL ( EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL, &efipci );
63 63
 
64 64
 static unsigned long efipci_address ( struct pci_device *pci,
65 65
 				      unsigned long location ) {
@@ -74,6 +74,9 @@ int efipci_read ( struct pci_device *pci, unsigned long location,
74 74
 	EFI_STATUS efirc;
75 75
 	int rc;
76 76
 
77
+	if ( ! efipci )
78
+		return -ENOTSUP;
79
+
77 80
 	if ( ( efirc = efipci->Pci.Read ( efipci, EFIPCI_WIDTH ( location ),
78 81
 					  efipci_address ( pci, location ), 1,
79 82
 					  value ) ) != 0 ) {
@@ -92,6 +95,9 @@ int efipci_write ( struct pci_device *pci, unsigned long location,
92 95
 	EFI_STATUS efirc;
93 96
 	int rc;
94 97
 
98
+	if ( ! efipci )
99
+		return -ENOTSUP;
100
+
95 101
 	if ( ( efirc = efipci->Pci.Write ( efipci, EFIPCI_WIDTH ( location ),
96 102
 					   efipci_address ( pci, location ), 1,
97 103
 					   &value ) ) != 0 ) {

Carregando…
Cancelar
Salvar