diff options
author | Michael Brown <mcb30@ipxe.org> | 2013-04-18 21:29:53 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2013-04-19 13:34:19 +0100 |
commit | 54409583e29c481556e94a99dc73316d18aafc74 (patch) | |
tree | 150a8ceb85c1b523dc8dd8dd36daf8f6260e6538 /src/interface/efi/efi_bofm.c | |
parent | 73480352315a12fdef467402ea41be9ac285e4e7 (diff) | |
download | ipxe-54409583e29c481556e94a99dc73316d18aafc74.tar.gz |
[efi] Perform meaningful error code conversions
Exploit the redefinition of iPXE error codes to include a "platform
error code" to allow for meaningful conversion of EFI_STATUS values to
iPXE errors and vice versa.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/efi/efi_bofm.c')
-rw-r--r-- | src/interface/efi/efi_bofm.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/interface/efi/efi_bofm.c b/src/interface/efi/efi_bofm.c index c313d2e97..8a8489bd8 100644 --- a/src/interface/efi/efi_bofm.c +++ b/src/interface/efi/efi_bofm.c @@ -181,7 +181,7 @@ efi_bofm_supported ( EFI_DRIVER_BINDING_PROTOCOL *driver, /* Create corresponding PCI device, if any */ efipci = efipci_create ( efidrv, device ); if ( ! efipci ) { - efirc = EFI_UNSUPPORTED; + rc = -ENOTSUP; goto err_not_pci; } @@ -189,16 +189,15 @@ efi_bofm_supported ( EFI_DRIVER_BINDING_PROTOCOL *driver, if ( ( rc = bofm_find_driver ( &efipci->pci ) ) != 0 ) { DBGCP ( efidrv, "EFIBOFM " PCI_FMT " has no driver\n", PCI_ARGS ( &efipci->pci ) ); - efirc = EFI_UNSUPPORTED; goto err_no_driver; } /* Locate BOFM protocol */ if ( ( efirc = bs->LocateProtocol ( &bofm1_protocol_guid, NULL, &bofm1.interface ) ) != 0 ) { + rc = -EEFI ( efirc ); DBGC ( efidrv, "EFIBOFM " PCI_FMT " cannot find BOFM " "protocol\n", PCI_ARGS ( &efipci->pci ) ); - efirc = EFI_UNSUPPORTED; goto err_not_bofm; } @@ -207,9 +206,10 @@ efi_bofm_supported ( EFI_DRIVER_BINDING_PROTOCOL *driver, 0x04 /* Can change MAC */, 0x00 /* No iSCSI */, 0x02 /* Version */ ))!=0){ + rc = -EEFI ( efirc ); DBGC ( efidrv, "EFIBOFM " PCI_FMT " could not register " "support: %s\n", PCI_ARGS ( &efipci->pci ), - efi_strerror ( efirc ) ); + strerror ( rc ) ); goto err_cannot_register; } @@ -226,7 +226,7 @@ efi_bofm_supported ( EFI_DRIVER_BINDING_PROTOCOL *driver, err_no_driver: efipci_destroy ( efidrv, efipci ); err_not_pci: - return efirc; + return EFIRC ( rc ); } /** @@ -254,25 +254,27 @@ static EFI_STATUS EFIAPI efi_bofm_start ( EFI_DRIVER_BINDING_PROTOCOL *driver, struct efi_pci_device *efipci; IBM_BOFM_TABLE *bofmtab; IBM_BOFM_TABLE *bofmtab2; - EFI_STATUS efirc; int bofmrc; + EFI_STATUS efirc; + int rc; DBGCP ( efidrv, "EFIBOFM DRIVER_START %p (%p)\n", device, child ); /* Create corresponding PCI device */ efipci = efipci_create ( efidrv, device ); if ( ! efipci ) { - efirc = EFI_OUT_OF_RESOURCES; + rc = -ENOMEM; goto err_create; } /* Enable PCI device */ - if ( ( efirc = efipci_enable ( efipci ) ) != 0 ) + if ( ( rc = efipci_enable ( efipci ) ) != 0 ) goto err_enable; /* Locate BOFM protocol */ if ( ( efirc = bs->LocateProtocol ( &bofm1_protocol_guid, NULL, &bofm1.interface ) ) != 0 ) { + rc = -EEFI ( efirc ); DBGC ( efidrv, "EFIBOFM " PCI_FMT " cannot find BOFM " "protocol\n", PCI_ARGS ( &efipci->pci ) ); goto err_locate_bofm; @@ -324,17 +326,19 @@ static EFI_STATUS EFIAPI efi_bofm_start ( EFI_DRIVER_BINDING_PROTOCOL *driver, if ( bofmtab2 ) { if ( ( efirc = bofm2.bofm2->SetStatus ( bofm2.bofm2, device, FALSE, bofmrc ) ) != 0){ + rc = -EEFI ( efirc ); DBGC ( efidrv, "EFIBOFM " PCI_FMT " could not set " "BOFM2 status: %s\n", PCI_ARGS ( &efipci->pci ), - efi_strerror ( efirc ) ); + strerror ( rc ) ); goto err_set_status; } } else { if ( ( efirc = bofm1.bofm1->SetStatus ( bofm1.bofm1, device, FALSE, bofmrc ) ) != 0){ + rc = -EEFI ( efirc ); DBGC ( efidrv, "EFIBOFM " PCI_FMT " could not set " "BOFM status: %s\n", PCI_ARGS ( &efipci->pci ), - efi_strerror ( efirc ) ); + strerror ( rc ) ); goto err_set_status; } } @@ -350,7 +354,7 @@ static EFI_STATUS EFIAPI efi_bofm_start ( EFI_DRIVER_BINDING_PROTOCOL *driver, err_enable: efipci_destroy ( efidrv, efipci ); err_create: - return efirc; + return EFIRC ( rc ); } /** @@ -385,12 +389,12 @@ static struct efi_driver efi_bofm_driver = */ static void efi_bofm_driver_init ( void ) { struct efi_driver *efidrv = &efi_bofm_driver; - EFI_STATUS efirc; + int rc; /* Install driver */ - if ( ( efirc = efi_driver_install ( efidrv ) ) != 0 ) { + if ( ( rc = efi_driver_install ( efidrv ) ) != 0 ) { DBGC ( efidrv, "EFIBOFM could not install driver: %s\n", - efi_strerror ( efirc ) ); + strerror ( rc ) ); return; } |