FILE_LICENCE ( GPL2_OR_LATER );
#include <stdlib.h>
+#include <errno.h>
#include <ipxe/efi/efi.h>
/**
return efirc;
/* Call to main() */
- return RC_TO_EFIRC ( main () );
+ return EFIRC ( main () );
}
struct io_buffer *iobuf ) {
struct snpnet_device *snpnetdev = netdev->priv;
EFI_SIMPLE_NETWORK_PROTOCOL *snp = snpnetdev->snp;
- EFI_STATUS efirc;
void *txbuf=NULL;
size_t len = iob_len ( iobuf );
+ EFI_STATUS efirc;
+ int rc;
- efirc = snp->Transmit ( snp, 0, len, iobuf->data, NULL, NULL, NULL );
- if (efirc) {
- return EFIRC_TO_RC ( efirc );
+ if ( ( efirc = snp->Transmit ( snp, 0, len, iobuf->data, NULL, NULL,
+ NULL ) ) != 0 ) {
+ return -EEFI ( efirc );
}
/* since GetStatus is so inconsistent, don't try more than one outstanding transmit at a time */
while ( txbuf == NULL ) {
- efirc = snp->GetStatus ( snp, NULL, &txbuf );
- if ( efirc ) {
+ if ( ( efirc = snp->GetStatus ( snp, NULL, &txbuf ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( snp, "SNP %p could not get status %s\n", snp,
- efi_strerror ( efirc ) );
+ strerror ( rc ) );
break;
}
static void snpnet_poll ( struct net_device *netdev ) {
struct snpnet_device *snpnetdev = netdev->priv;
EFI_SIMPLE_NETWORK_PROTOCOL *snp = snpnetdev->snp;
- EFI_STATUS efirc;
struct io_buffer *iobuf = NULL;
UINTN len;
+ EFI_STATUS efirc;
+ int rc;
/* Process received packets */
while ( 1 ) {
}
/* Other error? */
- if ( efirc ) {
+ if ( efirc != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( snp, "SNP %p receive packet error: %s "
"(len was %zd, is now %zd)\n",
- snp, efi_strerror ( efirc ), iob_len(iobuf),
+ snp, strerror ( rc ), iob_len(iobuf),
(size_t)len );
- netdev_rx_err ( netdev, iobuf, efirc );
+ netdev_rx_err ( netdev, iobuf, rc );
break;
}
static int snpnet_open ( struct net_device *netdev ) {
struct snpnet_device *snpnetdev = netdev->priv;
EFI_SIMPLE_NETWORK_PROTOCOL *snp = snpnetdev->snp;
- EFI_STATUS efirc;
+ EFI_MAC_ADDRESS *mac;
UINT32 enableFlags, disableFlags;
+ EFI_STATUS efirc;
+ int rc;
snpnetdev->close_state = snp->Mode->State;
if ( snp->Mode->State != EfiSimpleNetworkInitialized ) {
- efirc = snp->Initialize ( snp, 0, 0 );
- if ( efirc ) {
+ if ( ( efirc = snp->Initialize ( snp, 0, 0 ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( snp, "SNP %p could not initialize: %s\n",
- snp, efi_strerror ( efirc ) );
- return EFIRC_TO_RC ( efirc );
+ snp, strerror ( rc ) );
+ return rc;
}
}
/* Use the default MAC address */
- efirc = snp->StationAddress ( snp, FALSE,
- (EFI_MAC_ADDRESS *)netdev->ll_addr );
- if ( efirc ) {
+ mac = ( ( void * ) netdev->ll_addr );
+ if ( ( efirc = snp->StationAddress ( snp, FALSE, mac ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( snp, "SNP %p could not reset station address: %s\n",
- snp, efi_strerror ( efirc ) );
+ snp, strerror ( rc ) );
}
/* Set up receive filters to receive unicast and broadcast packets
enableFlags |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS;
}
disableFlags &= ~enableFlags;
- efirc = snp->ReceiveFilters ( snp, enableFlags, disableFlags,
- FALSE, 0, NULL );
- if ( efirc ) {
+ if ( ( efirc = snp->ReceiveFilters ( snp, enableFlags, disableFlags,
+ FALSE, 0, NULL ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( snp, "SNP %p could not set receive filters: %s\n",
- snp, efi_strerror ( efirc ) );
+ snp, strerror ( rc ) );
}
DBGC ( snp, "SNP %p opened\n", snp );
struct snpnet_device *snpnetdev = netdev->priv;
EFI_SIMPLE_NETWORK_PROTOCOL *snp = snpnetdev->snp;
EFI_STATUS efirc;
+ int rc;
if ( snpnetdev->close_state != EfiSimpleNetworkInitialized ) {
- efirc = snp->Shutdown ( snp );
- if ( efirc ) {
+ if ( ( efirc = snp->Shutdown ( snp ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( snp, "SNP %p could not shut down: %s\n",
- snp, efi_strerror ( efirc ) );
+ snp, strerror ( rc ) );
}
}
}
/* Start the interface */
if ( snp->Mode->State == EfiSimpleNetworkStopped ) {
- efirc = snp->Start ( snp );
- if ( efirc ) {
+ if ( ( efirc = snp->Start ( snp ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( snp, "SNP %p could not start: %s\n", snp,
- efi_strerror ( efirc ) );
- rc = EFIRC_TO_RC ( efirc );
+ strerror ( rc ) );
goto err_start;
}
}
*/
void snpnet_remove ( struct snp_device *snpdev ) {
EFI_SIMPLE_NETWORK_PROTOCOL *snp = snpdev->snp;
- EFI_STATUS efirc;
struct net_device *netdev = snpdev->netdev;
+ EFI_STATUS efirc;
+ int rc;
if ( snp->Mode->State == EfiSimpleNetworkInitialized &&
snpdev->removal_state != EfiSimpleNetworkInitialized ) {
DBGC ( snp, "SNP %p shutting down\n", snp );
- efirc = snp->Shutdown ( snp );
- if ( efirc ) {
+ if ( ( efirc = snp->Shutdown ( snp ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( snp, "SNP %p could not shut down: %s\n",
- snp, efi_strerror ( efirc ) );
+ snp, strerror ( rc ) );
}
}
if ( snp->Mode->State == EfiSimpleNetworkStarted &&
snpdev->removal_state == EfiSimpleNetworkStopped ) {
DBGC ( snp, "SNP %p stopping\n", snp );
- efirc = snp->Stop ( snp );
- if ( efirc ) {
- DBGC ( snp, "SNP %p could not be stopped\n", snp );
+ if ( ( efirc = snp->Stop ( snp ) ) != 0 ) {
+ rc = -EEFI ( efirc );
+ DBGC ( snp, "SNP %p could not be stopped: %s\n",
+ snp, strerror ( rc ) );
}
}
user_to_virt ( image->data, 0 ),
image->len, &handle ) ) != 0 ) {
/* Not an EFI image */
+ rc = -EEFI ( efirc );
DBGC ( image, "EFIIMAGE %p could not load: %s\n",
- image, efi_strerror ( efirc ) );
- rc = -ENOEXEC;
+ image, strerror ( rc ) );
goto err_load_image;
}
NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL );
if ( efirc ) {
/* Should never happen */
- rc = EFIRC_TO_RC ( efirc );
+ rc = -EEFI ( efirc );
goto err_open_protocol;
}
/* Start the image */
if ( ( efirc = bs->StartImage ( handle, NULL, NULL ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( image, "EFIIMAGE %p returned with status %s\n",
- image, efi_strerror ( efirc ) );
- rc = EFIRC_TO_RC ( efirc );
+ image, strerror ( rc ) );
goto err_start_image;
}
* have no "unload" operation.
*/
if ( ( efirc = bs->UnloadImage ( handle ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( image, "EFIIMAGE %p could not unload: %s\n",
- image, efi_strerror ( efirc ) );
+ image, strerror ( rc ) );
}
err_load_image:
free ( cmdline );
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
EFI_HANDLE handle;
EFI_STATUS efirc;
+ int rc;
/* Attempt loading image */
if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, NULL,
user_to_virt ( image->data, 0 ),
image->len, &handle ) ) != 0 ) {
/* Not an EFI image */
+ rc = -EEFI ( efirc );
DBGC ( image, "EFIIMAGE %p could not load: %s\n",
- image, efi_strerror ( efirc ) );
- return -ENOEXEC;
+ image, strerror ( rc ) );
+ return rc;
}
/* Unload the image. We can't leave it loaded, because we
.required = (_required), \
}
-/** Convert a iPXE status code to an EFI status code
+/**
+ * Convert an iPXE status code to an EFI status code
*
- * FIXME: actually perform some kind of conversion. iPXE error codes
- * will be detected as EFI error codes; both have the top bit set, and
- * the success return code is zero for both. Anything that just
- * reports a numerical error will be OK, anything attempting to
- * interpret the value or to display a text equivalent will be
- * screwed.
+ * @v rc iPXE status code
+ * @ret efirc EFI status code
*/
-#define RC_TO_EFIRC( rc ) (rc)
+#define EFIRC( rc ) ERRNO_TO_PLATFORM ( -(rc) )
-/** Convert an EFI status code to a iPXE status code
+/**
+ * Convert an EFI status code to an iPXE status code
*
- * FIXME: as above
+ * @v efirc EFI status code
+ * @ret rc iPXE status code (before negation)
*/
-#define EFIRC_TO_RC( efirc ) (efirc)
+#define EEFI( efirc ) EPLATFORM ( EINFO_EPLATFORM, efirc )
extern EFI_HANDLE efi_image_handle;
extern EFI_LOADED_IMAGE_PROTOCOL *efi_loaded_image;
extern EFI_DEVICE_PATH_PROTOCOL *efi_loaded_image_path;
extern EFI_SYSTEM_TABLE *efi_systab;
-extern const char * efi_strerror ( EFI_STATUS efirc );
extern const char * efi_guid_ntoa ( EFI_GUID *guid );
extern void dbg_efi_protocols ( EFI_HANDLE handle );
extern EFI_DEVICE_PATH_PROTOCOL *
efi_devpath_end ( EFI_DEVICE_PATH_PROTOCOL *path );
-extern EFI_STATUS efi_driver_install ( struct efi_driver *efidrv );
+extern int efi_driver_install ( struct efi_driver *efidrv );
#endif /* _IPXE_EFI_DRIVER_H */
extern struct efi_pci_device * efipci_create ( struct efi_driver *efidrv,
EFI_HANDLE device );
-extern EFI_STATUS efipci_enable ( struct efi_pci_device *efipci );
+extern int efipci_enable ( struct efi_pci_device *efipci );
extern struct efi_pci_device * efipci_find_efi ( EFI_HANDLE device );
extern struct efi_pci_device * efipci_find ( struct device *dev );
-extern EFI_STATUS efipci_child_add ( struct efi_pci_device *efipci,
- EFI_HANDLE device );
+extern int efipci_child_add ( struct efi_pci_device *efipci,
+ EFI_HANDLE device );
extern void efipci_child_del ( struct efi_pci_device *efipci,
EFI_HANDLE device );
extern void efipci_destroy ( struct efi_driver *efidrv,
#define ERRFILE_nslookup ( ERRFILE_OTHER | 0x00300000 )
#define ERRFILE_efi_snp_hii ( ERRFILE_OTHER | 0x00310000 )
#define ERRFILE_readline ( ERRFILE_OTHER | 0x00320000 )
+#define ERRFILE_efi_bofm ( ERRFILE_OTHER | 0x00330000 )
+#define ERRFILE_efi_console ( ERRFILE_OTHER | 0x00340000 )
+#define ERRFILE_efi_debug ( ERRFILE_OTHER | 0x00350000 )
+#define ERRFILE_efi_download ( ERRFILE_OTHER | 0x00360000 )
+#define ERRFILE_efi_driver ( ERRFILE_OTHER | 0x00370000 )
+#define ERRFILE_efi_file ( ERRFILE_OTHER | 0x00380000 )
+#define ERRFILE_efi_init ( ERRFILE_OTHER | 0x00390000 )
+#define ERRFILE_efi_timer ( ERRFILE_OTHER | 0x003a0000 )
+#define ERRFILE_efi_umalloc ( ERRFILE_OTHER | 0x003b0000 )
/** @} */
/* Create corresponding PCI device, if any */
efipci = efipci_create ( efidrv, device );
if ( ! efipci ) {
- efirc = EFI_UNSUPPORTED;
+ rc = -ENOTSUP;
goto err_not_pci;
}
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;
}
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;
}
err_no_driver:
efipci_destroy ( efidrv, efipci );
err_not_pci:
- return efirc;
+ return EFIRC ( rc );
}
/**
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;
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;
}
}
err_enable:
efipci_destroy ( efidrv, efipci );
err_create:
- return efirc;
+ return EFIRC ( rc );
}
/**
*/
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;
}
FILE_LICENCE ( GPL2_OR_LATER );
#include <stddef.h>
+#include <string.h>
+#include <errno.h>
#include <assert.h>
#include <ipxe/efi/efi.h>
#include <ipxe/ansiesc.h>
const char *ansi_seq;
EFI_INPUT_KEY key;
EFI_STATUS efirc;
+ int rc;
/* If we are mid-sequence, pass out the next byte */
if ( *ansi_input )
/* Read key from real EFI console */
if ( ( efirc = conin->ReadKeyStroke ( conin, &key ) ) != 0 ) {
- DBG ( "EFI could not read keystroke: %s\n",
- efi_strerror ( efirc ) );
+ rc = -EEFI ( efirc );
+ DBG ( "EFI could not read keystroke: %s\n", strerror ( rc ) );
return 0;
}
DBG2 ( "EFI read key stroke with unicode %04x scancode %04x\n",
#include <stdio.h>
#include <string.h>
+#include <errno.h>
#include <ipxe/uuid.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_driver.h>
UINTN count;
unsigned int i;
EFI_STATUS efirc;
+ int rc;
/* Retrieve list of protocols */
if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
&count ) ) != 0 ) {
+ rc = -EEFI ( efirc );
printf ( "EFI could not retrieve protocols for %p: %s\n",
- handle, efi_strerror ( efirc ) );
+ handle, strerror ( rc ) );
return;
}
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include <ipxe/open.h>
#include <ipxe/process.h>
#include <ipxe/iobuf.h>
*/
static void efi_download_close ( struct efi_download_file *file, int rc ) {
- file->finish_callback ( file->context, RC_TO_EFIRC ( rc ) );
+ file->finish_callback ( file->context, EFIRC ( rc ) );
intf_shutdown ( &file->xfer, rc );
}
struct xfer_metadata *meta ) {
EFI_STATUS efirc;
size_t len = iob_len ( iobuf );
+ int rc;
/* Calculate new buffer position */
if ( meta->flags & XFER_FL_ABS_OFFSET )
file->pos += meta->offset;
/* Call out to the data handler */
- efirc = file->data_callback ( file->context, iobuf->data,
- len, file->pos );
+ if ( ( efirc = file->data_callback ( file->context, iobuf->data,
+ len, file->pos ) ) != 0 ) {
+ rc = -EEFI ( efirc );
+ goto err_callback;
+ }
/* Update current buffer position */
file->pos += len;
+ /* Success */
+ rc = 0;
+
+ err_callback:
free_iob ( iobuf );
- return EFIRC_TO_RC ( efirc );
+ return rc;
}
/** Data transfer interface operations */
rc = xfer_open ( &file->xfer, LOCATION_URI_STRING, Url );
if ( rc ) {
free ( file );
- return RC_TO_EFIRC ( rc );
+ return EFIRC ( rc );
}
file->pos = 0;
EFI_STATUS Status ) {
struct efi_download_file *file = File;
- efi_download_close ( file, EFIRC_TO_RC ( Status ) );
+ efi_download_close ( file, -EEFI ( Status ) );
return EFI_SUCCESS;
}
int efi_download_install ( EFI_HANDLE *handle ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
EFI_STATUS efirc;
+ int rc;
efirc = bs->InstallMultipleProtocolInterfaces (
handle,
&ipxe_download_protocol_interface,
NULL );
if ( efirc ) {
+ rc = -EEFI ( efirc );
DBG ( "Could not install download protocol: %s\n",
- efi_strerror ( efirc ) );
- return EFIRC_TO_RC ( efirc );
+ strerror ( rc ) );
+ return rc;
}
return 0;
#include <stddef.h>
#include <stdio.h>
+#include <string.h>
+#include <errno.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/Protocol/DriverBinding.h>
#include <ipxe/efi/Protocol/ComponentName2.h>
* @v efidrv EFI driver
* @ret efirc EFI status code
*/
-EFI_STATUS efi_driver_install ( struct efi_driver *efidrv ) {
+int efi_driver_install ( struct efi_driver *efidrv ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
EFI_DRIVER_BINDING_PROTOCOL *driver = &efidrv->driver;
EFI_COMPONENT_NAME2_PROTOCOL *wtf = &efidrv->wtf;
EFI_STATUS efirc;
+ int rc;
/* Configure driver binding protocol */
driver->ImageHandle = efi_image_handle;
&efi_driver_binding_protocol_guid, driver,
&efi_component_name2_protocol_guid, wtf,
NULL ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( efidrv, "EFIDRV %s could not install protocol: %s\n",
- efidrv->name, efi_strerror ( efirc ) );
- return efirc;
+ efidrv->name, strerror ( rc ) );
+ return rc;
}
DBGC ( efidrv, "EFIDRV %s installed\n", efidrv->name );
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <errno.h>
#include <wchar.h>
#include <ipxe/image.h>
#include <ipxe/efi/efi.h>
int efi_file_install ( EFI_HANDLE *handle ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
EFI_STATUS efirc;
+ int rc;
/* Install the simple file system protocol and the block I/O
* protocol. We don't have a block device, but large parts of
&efi_block_io_protocol,
&efi_simple_file_system_protocol_guid,
&efi_simple_file_system_protocol, NULL ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( handle, "Could not install simple file system protocol: "
- "%s\n", efi_strerror ( efirc ) );
- return EFIRC_TO_RC ( efirc );
+ "%s\n", strerror ( rc ) );
+ return rc;
}
return 0;
FILE_LICENCE ( GPL2_OR_LATER );
#include <string.h>
+#include <errno.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/Protocol/LoadedImage.h>
#include <ipxe/efi/Protocol/DevicePath.h>
void *loaded_image;
void *loaded_image_path;
EFI_STATUS efirc;
+ int rc;
/* Store image handle and system table pointer for future use */
efi_image_handle = image_handle;
&efi_loaded_image_protocol_guid,
&loaded_image, image_handle, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( systab, "EFI could not get loaded image protocol: %s",
- efi_strerror ( efirc ) );
+ strerror ( rc ) );
return efirc;
}
efi_loaded_image = loaded_image;
&efi_loaded_image_device_path_protocol_guid,
&loaded_image_path, image_handle, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( systab, "EFI could not get loaded image device path "
- "protocol: %s", efi_strerror ( efirc ) );
+ "protocol: %s", strerror ( rc ) );
return efirc;
}
efi_loaded_image_path = loaded_image_path;
if ( ( efirc = bs->CreateEvent ( EVT_SIGNAL_EXIT_BOOT_SERVICES,
TPL_CALLBACK, efi_shutdown_hook,
NULL, &efi_shutdown_event ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( systab, "EFI could not create ExitBootServices event: "
- "%s\n", efi_strerror ( efirc ) );
+ "%s\n", strerror ( rc ) );
return efirc;
}
int efipci_read ( struct pci_device *pci, unsigned long location,
void *value ) {
EFI_STATUS efirc;
+ int rc;
if ( ( efirc = efipci->Pci.Read ( efipci, EFIPCI_WIDTH ( location ),
efipci_address ( pci, location ), 1,
value ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBG ( "EFIPCI config read from " PCI_FMT " offset %02lx "
"failed: %s\n", PCI_ARGS ( pci ),
- EFIPCI_OFFSET ( location ), efi_strerror ( efirc ) );
+ EFIPCI_OFFSET ( location ), strerror ( rc ) );
return -EIO;
}
int efipci_write ( struct pci_device *pci, unsigned long location,
unsigned long value ) {
EFI_STATUS efirc;
+ int rc;
if ( ( efirc = efipci->Pci.Write ( efipci, EFIPCI_WIDTH ( location ),
efipci_address ( pci, location ), 1,
&value ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBG ( "EFIPCI config write to " PCI_FMT " offset %02lx "
"failed: %s\n", PCI_ARGS ( pci ),
- EFIPCI_OFFSET ( location ), efi_strerror ( efirc ) );
+ EFIPCI_OFFSET ( location ), strerror ( rc ) );
return -EIO;
}
efidrv->driver.DriverBindingHandle,
device,
EFI_OPEN_PROTOCOL_BY_DRIVER )) !=0 ){
+ rc = -EEFI ( efirc );
DBGCP ( efipci, "EFIPCI device %p is not a PCI device\n",
device );
goto err_open_protocol;
&pci_segment,
&pci_bus, &pci_dev,
&pci_fn ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( efipci, "EFIPCI device %p could not get PCI "
- "location: %s\n", device, efi_strerror ( efirc ) );
+ "location: %s\n", device, strerror ( rc ) );
goto err_get_location;
}
DBGC2 ( efipci, "EFIPCI device %p is PCI %04lx:%02lx:%02lx.%lx\n",
efidrv->driver.DriverBindingHandle,
device,
EFI_OPEN_PROTOCOL_BY_DRIVER )) !=0 ){
+ rc = -EEFI ( efirc );
DBGC ( efipci, "EFIPCI " PCI_FMT " has no device path\n",
PCI_ARGS ( &efipci->pci ) );
goto err_no_device_path;
* Enable EFI PCI device
*
* @v efipci EFI PCI device
- * @ret efirc EFI status code
+ * @ret rc Return status code
*/
-EFI_STATUS efipci_enable ( struct efi_pci_device *efipci ) {
+int efipci_enable ( struct efi_pci_device *efipci ) {
EFI_PCI_IO_PROTOCOL *pci_io = efipci->pci_io;
/* Try to enable I/O cycles, memory cycles, and bus mastering.
* @v device EFI child device
* @ret efirc EFI status code
*/
-EFI_STATUS efipci_child_add ( struct efi_pci_device *efipci,
- EFI_HANDLE device ) {
+int efipci_child_add ( struct efi_pci_device *efipci, EFI_HANDLE device ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
struct efi_driver *efidrv = efipci->efidrv;
union {
void *interface;
} pci_io;
EFI_STATUS efirc;
+ int rc;
/* Re-open the PCI_IO_PROTOCOL */
if ( ( efirc = bs->OpenProtocol ( efipci->device,
device,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( efipci, "EFIPCI " PCI_FMT " could not add child: %s\n",
- PCI_ARGS ( &efipci->pci ), efi_strerror ( efirc ) );
- return efirc;
+ PCI_ARGS ( &efipci->pci ), strerror ( rc ) );
+ return rc;
}
return 0;
struct efi_driver *efidrv =
container_of ( driver, struct efi_driver, driver );
struct efi_pci_device *efipci;
- EFI_STATUS efirc;
int rc;
DBGCP ( efidrv, "EFIPCI DRIVER_SUPPORTED %p (%p)\n", device, child );
efipci = efipci_create ( efidrv, device );
if ( ! efipci ) {
/* Non-PCI devices are simply unsupported */
- efirc = EFI_UNSUPPORTED;
+ rc = -ENOTSUP;
goto err_not_pci;
}
if ( ( rc = pci_find_driver ( &efipci->pci ) ) != 0 ) {
DBGCP ( efipci, "EFIPCI " PCI_FMT " has no driver\n",
PCI_ARGS ( &efipci->pci ) );
- efirc = EFI_UNSUPPORTED;
goto err_no_driver;
}
err_no_driver:
efipci_destroy ( efidrv, efipci );
err_not_pci:
- return efirc;
+ return EFIRC ( rc );
}
/**
struct efi_driver *efidrv =
container_of ( driver, struct efi_driver, driver );
struct efi_pci_device *efipci;
- EFI_STATUS efirc;
int rc;
DBGC ( efidrv, "EFIPCI 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;
}
if ( ( rc = pci_find_driver ( &efipci->pci ) ) != 0 ) {
DBGC ( efipci, "EFIPCI " PCI_FMT " has no driver\n",
PCI_ARGS ( &efipci->pci ) );
- efirc = RC_TO_EFIRC ( rc );
goto err_find_driver;
}
/* Enable PCI device */
- if ( ( efirc = efipci_enable ( efipci ) ) != 0 )
+ if ( ( rc = efipci_enable ( efipci ) ) != 0 )
goto err_enable;
/* Probe driver */
DBGC ( efipci, "EFIPCI " PCI_FMT " could not probe driver "
"\"%s\": %s\n", PCI_ARGS ( &efipci->pci ),
efipci->pci.id->name, strerror ( rc ) );
- efirc = RC_TO_EFIRC ( rc );
goto err_probe;
}
err_find_driver:
efipci_destroy ( efidrv, efipci );
err_create:
- return efirc;
+ return EFIRC ( rc );
}
/**
*/
static void efipci_driver_startup ( void ) {
struct efi_driver *efidrv = &efipci_driver;
- EFI_STATUS efirc;
+ int rc;
/* Install driver */
- if ( ( efirc = efi_driver_install ( efidrv ) ) != 0 ) {
+ if ( ( rc = efi_driver_install ( efidrv ) ) != 0 ) {
DBGC ( efidrv, "EFIPCI could not install driver: %s\n",
- efi_strerror ( efirc ) );
+ strerror ( rc ) );
return;
}
if ( ( rc = netdev_open ( snpdev->netdev ) ) != 0 ) {
DBGC ( snpdev, "SNPDEV %p could not open %s: %s\n",
snpdev, snpdev->netdev->name, strerror ( rc ) );
- return RC_TO_EFIRC ( rc );
+ return EFIRC ( rc );
}
snpdev->mode.State = EfiSimpleNetworkInitialized;
if ( ( rc = netdev_open ( snpdev->netdev ) ) != 0 ) {
DBGC ( snpdev, "SNPDEV %p could not reopen %s: %s\n",
snpdev, snpdev->netdev->name, strerror ( rc ) );
- return RC_TO_EFIRC ( rc );
+ return EFIRC ( rc );
}
snpdev->mode.State = EfiSimpleNetworkInitialized;
ip, mac ) ) != 0 ) {
DBGC ( snpdev, "SNPDEV %p could not hash %s: %s\n",
snpdev, ip_str, strerror ( rc ) );
- return RC_TO_EFIRC ( rc );
+ return EFIRC ( rc );
}
return 0;
struct io_buffer *iobuf;
size_t payload_len;
int rc;
- EFI_STATUS efirc;
DBGC2 ( snpdev, "SNPDEV %p TRANSMIT %p+%lx", snpdev, data,
( ( unsigned long ) len ) );
DBGC ( snpdev, "SNPDEV %p TX invalid header length "
"%ld\n", snpdev,
( ( unsigned long ) ll_header_len ) );
- efirc = EFI_INVALID_PARAMETER;
+ rc = -EINVAL;
goto err_sanity;
}
if ( len < ll_header_len ) {
DBGC ( snpdev, "SNPDEV %p invalid packet length %ld\n",
snpdev, ( ( unsigned long ) len ) );
- efirc = EFI_BUFFER_TOO_SMALL;
+ rc = -EINVAL;
goto err_sanity;
}
if ( ! ll_dest ) {
DBGC ( snpdev, "SNPDEV %p TX missing destination "
"address\n", snpdev );
- efirc = EFI_INVALID_PARAMETER;
+ rc = -EINVAL;
goto err_sanity;
}
if ( ! net_proto ) {
DBGC ( snpdev, "SNPDEV %p TX missing network "
"protocol\n", snpdev );
- efirc = EFI_INVALID_PARAMETER;
+ rc = -EINVAL;
goto err_sanity;
}
if ( ! ll_src )
if ( ! iobuf ) {
DBGC ( snpdev, "SNPDEV %p TX could not allocate %ld-byte "
"buffer\n", snpdev, ( ( unsigned long ) len ) );
- efirc = EFI_DEVICE_ERROR;
+ rc = -ENOMEM;
goto err_alloc_iob;
}
iob_reserve ( iobuf, ( MAX_LL_HEADER_LEN -
htons ( *net_proto ) )) != 0 ){
DBGC ( snpdev, "SNPDEV %p TX could not construct "
"header: %s\n", snpdev, strerror ( rc ) );
- efirc = RC_TO_EFIRC ( rc );
goto err_ll_push;
}
}
if ( ( rc = netdev_tx ( snpdev->netdev, iob_disown ( iobuf ) ) ) != 0){
DBGC ( snpdev, "SNPDEV %p TX could not transmit: %s\n",
snpdev, strerror ( rc ) );
- efirc = RC_TO_EFIRC ( rc );
goto err_tx;
}
free_iob ( iobuf );
err_alloc_iob:
err_sanity:
- return efirc;
+ return EFIRC ( rc );
}
/**
uint16_t iob_net_proto;
unsigned int iob_flags;
int rc;
- EFI_STATUS efirc;
DBGC2 ( snpdev, "SNPDEV %p RECEIVE %p(+%lx)", snpdev, data,
( ( unsigned long ) *len ) );
iobuf = netdev_rx_dequeue ( snpdev->netdev );
if ( ! iobuf ) {
DBGC2 ( snpdev, "\n" );
- efirc = EFI_NOT_READY;
+ rc = -EAGAIN;
goto out_no_packet;
}
DBGC2 ( snpdev, "+%zx\n", iob_len ( iobuf ) );
&iob_flags ) ) != 0 ) {
DBGC ( snpdev, "SNPDEV %p could not parse header: %s\n",
snpdev, strerror ( rc ) );
- efirc = RC_TO_EFIRC ( rc );
goto out_bad_ll_header;
}
if ( net_proto )
*net_proto = ntohs ( iob_net_proto );
- efirc = 0;
+ rc = 0;
out_bad_ll_header:
free_iob ( iobuf );
out_no_packet:
- return efirc;
+ return EFIRC ( rc );
}
/**
if ( ( efirc = bs->CreateEvent ( EVT_NOTIFY_WAIT, TPL_NOTIFY,
efi_snp_wait_for_packet, snpdev,
&snpdev->snp.WaitForPacket ) ) != 0 ){
+ rc = -EEFI ( efirc );
DBGC ( snpdev, "SNPDEV %p could not create event: %s\n",
- snpdev, efi_strerror ( efirc ) );
- rc = EFIRC_TO_RC ( efirc );
+ snpdev, strerror ( rc ) );
goto err_create_event;
}
&efi_component_name2_protocol_guid, &snpdev->name2,
&efi_load_file_protocol_guid, &snpdev->load_file,
NULL ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( snpdev, "SNPDEV %p could not install protocols: "
- "%s\n", snpdev, efi_strerror ( efirc ) );
- rc = EFIRC_TO_RC ( efirc );
+ "%s\n", snpdev, strerror ( rc ) );
goto err_install_protocol_interface;
}
/* Add as child of PCI device */
- if ( ( efirc = efipci_child_add ( efipci, snpdev->handle ) ) != 0 ) {
+ if ( ( rc = efipci_child_add ( efipci, snpdev->handle ) ) != 0 ) {
DBGC ( snpdev, "SNPDEV %p could not become child of " PCI_FMT
": %s\n", snpdev, PCI_ARGS ( &efipci->pci ),
- efi_strerror ( efirc ) );
- rc = EFIRC_TO_RC ( efirc );
+ strerror ( rc ) );
goto err_efipci_child_add;
}
if ( ( rc = efi_snp_hii_process ( snpdev, pos, progress,
results, &have_setting,
efi_snp_hii_fetch ) ) != 0 ) {
- return RC_TO_EFIRC ( rc );
+ return EFIRC ( rc );
}
}
if ( ( rc = efi_snp_hii_fetch ( snpdev, setting->name,
NULL, results,
NULL ) ) != 0 ) {
- return RC_TO_EFIRC ( rc );
+ return EFIRC ( rc );
}
}
}
if ( ( rc = efi_snp_hii_process ( snpdev, pos, progress,
NULL, NULL,
efi_snp_hii_store ) ) != 0 ) {
- return RC_TO_EFIRC ( rc );
+ return EFIRC ( rc );
}
}
if ( ( efirc = efihii->NewPackageList ( efihii, snpdev->package_list,
snpdev->handle,
&snpdev->hii_handle ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( snpdev, "SNPDEV %p could not add HII packages: %s\n",
- snpdev, efi_strerror ( efirc ) );
- rc = EFIRC_TO_RC ( efirc );
+ snpdev, strerror ( rc ) );
goto err_new_package_list;
}
&snpdev->handle,
&efi_hii_config_access_protocol_guid, &snpdev->hii,
NULL ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( snpdev, "SNPDEV %p could not install HII protocol: %s\n",
- snpdev, efi_strerror ( efirc ) );
- rc = EFIRC_TO_RC ( efirc );
+ snpdev, strerror ( rc ) );
goto err_install_protocol;
}
+++ /dev/null
-/*
- * Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-FILE_LICENCE ( GPL2_OR_LATER );
-
-#include <stdio.h>
-#include <ipxe/efi/efi.h>
-
-/** @file
- *
- * iPXE error message formatting for EFI
- *
- */
-
-/**
- * Format EFI status code
- *
- * @v efirc EFI status code
- * @v efi_strerror EFI status code string
- */
-const char * efi_strerror ( EFI_STATUS efirc ) {
- static char errbuf[32];
-
- if ( ! efirc )
- return "No error";
-
- snprintf ( errbuf, sizeof ( errbuf ), "Error %lld",
- ( unsigned long long ) ( efirc ^ MAX_BIT ) );
- return errbuf;
-}
FILE_LICENCE ( GPL2_OR_LATER );
+#include <string.h>
+#include <errno.h>
#include <limits.h>
#include <assert.h>
#include <unistd.h>
static void efi_udelay ( unsigned long usecs ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
EFI_STATUS efirc;
+ int rc;
if ( ( efirc = bs->Stall ( usecs ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBG ( "EFI could not delay for %ldus: %s\n",
- usecs, efi_strerror ( efirc ) );
+ usecs, strerror ( rc ) );
/* Probably screwed */
}
}
static unsigned long efi_currticks ( void ) {
UINT64 time;
EFI_STATUS efirc;
+ int rc;
/* Read CPU timer 0 (TSC) */
if ( ( efirc = cpu_arch->GetTimerValue ( cpu_arch, 0, &time,
NULL ) ) != 0 ) {
- DBG ( "EFI could not read CPU timer: %s\n",
- efi_strerror ( efirc ) );
+ rc = -EEFI ( efirc );
+ DBG ( "EFI could not read CPU timer: %s\n", strerror ( rc ) );
/* Probably screwed */
return -1UL;
}
FILE_LICENCE ( GPL2_OR_LATER );
+#include <string.h>
+#include <errno.h>
#include <assert.h>
#include <ipxe/umalloc.h>
#include <ipxe/efi/efi.h>
userptr_t new_ptr = UNOWHERE;
size_t old_size;
EFI_STATUS efirc;
+ int rc;
/* Allocate new memory if necessary. If allocation fails,
* return without touching the old block.
EfiBootServicesData,
new_pages,
&phys_addr ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBG ( "EFI could not allocate %d pages: %s\n",
- new_pages, efi_strerror ( efirc ) );
+ new_pages, strerror ( rc ) );
return UNULL;
}
assert ( phys_addr != 0 );
old_pages = ( EFI_SIZE_TO_PAGES ( old_size ) + 1 );
phys_addr = user_to_phys ( old_ptr, -EFI_PAGE_SIZE );
if ( ( efirc = bs->FreePages ( phys_addr, old_pages ) ) != 0 ){
+ rc = -EEFI ( efirc );
DBG ( "EFI could not free %d pages at %llx: %s\n",
- old_pages, phys_addr, efi_strerror ( efirc ) );
+ old_pages, phys_addr, strerror ( rc ) );
/* Not fatal; we have leaked memory but successfully
* allocated (if asked to do so).
*/