efi_image.c File Reference

#include <errno.h>
#include <gpxe/efi/efi.h>
#include <gpxe/image.h>
#include <gpxe/features.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 FEATURE (FEATURE_IMAGE,"EFI", DHCP_EB_FEATURE_EFI, 1)
struct image_type efi_image_type __image_type (PROBE_NORMAL)
 EFI image type.
static int efi_image_exec (struct image *image)
 Execute EFI image.
static int efi_image_load (struct image *image)
 Load EFI image into memory.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

FEATURE ( FEATURE_IMAGE  ,
"EFI"  ,
DHCP_EB_FEATURE_EFI  ,
 
)

struct image_type nbi_image_type __image_type ( PROBE_NORMAL   )  [read]

Initial value:

 {
        .name = "EFI",
        .load = efi_image_load,
        .exec = efi_image_exec,
}
EFI image type.

NBI image type.

El Torito image type.

ELF image type.

SYSLINUX COMBOOT (16-bit) image type.

SYSLINUX COM32 image type.

Linux bzImage image type.

Script image type.

static int efi_image_exec ( struct image image  )  [static]

Execute EFI image.

Parameters:
image EFI image
Return values:
rc Return status code

Definition at line 36 of file efi_image.c.

References _EFI_SYSTEM_TABLE::BootServices, image::data, DBGC, efi_image_handle, efi_strerror(), efi_systab, EFIRC_TO_RC, ENOEXEC, FALSE, image::len, EFI_BOOT_SERVICES::LoadImage, NULL, EFI_BOOT_SERVICES::StartImage, EFI_BOOT_SERVICES::UnloadImage, and user_to_virt().

00036                                                   {
00037         EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
00038         EFI_HANDLE handle;
00039         UINTN exit_data_size;
00040         CHAR16 *exit_data;
00041         EFI_STATUS efirc;
00042 
00043         /* Attempt loading image */
00044         if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, NULL,
00045                                        user_to_virt ( image->data, 0 ),
00046                                        image->len, &handle ) ) != 0 ) {
00047                 /* Not an EFI image */
00048                 DBGC ( image, "EFIIMAGE %p could not load: %s\n",
00049                        image, efi_strerror ( efirc ) );
00050                 return -ENOEXEC;
00051         }
00052 
00053         /* Start the image */
00054         if ( ( efirc = bs->StartImage ( handle, &exit_data_size,
00055                                         &exit_data ) ) != 0 ) {
00056                 DBGC ( image, "EFIIMAGE %p returned with status %s\n",
00057                        image, efi_strerror ( efirc ) );
00058                 goto done;
00059         }
00060 
00061  done:
00062         /* Unload the image.  We can't leave it loaded, because we
00063          * have no "unload" operation.
00064          */
00065         bs->UnloadImage ( handle );
00066 
00067         return EFIRC_TO_RC ( efirc );
00068 }

static int efi_image_load ( struct image image  )  [static]

Load EFI image into memory.

Parameters:
image EFI file
Return values:
rc Return status code

Definition at line 76 of file efi_image.c.

References _EFI_SYSTEM_TABLE::BootServices, image::data, DBGC, efi_image_handle, efi_strerror(), efi_systab, ENOEXEC, FALSE, image::len, EFI_BOOT_SERVICES::LoadImage, NULL, image::type, EFI_BOOT_SERVICES::UnloadImage, and user_to_virt().

00076                                                   {
00077         EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
00078         EFI_HANDLE handle;
00079         EFI_STATUS efirc;
00080 
00081         /* Attempt loading image */
00082         if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, NULL,
00083                                        user_to_virt ( image->data, 0 ),
00084                                        image->len, &handle ) ) != 0 ) {
00085                 /* Not an EFI image */
00086                 DBGC ( image, "EFIIMAGE %p could not load: %s\n",
00087                        image, efi_strerror ( efirc ) );
00088                 return -ENOEXEC;
00089         }
00090 
00091         /* This is an EFI image */
00092         if ( ! image->type )
00093                 image->type = &efi_image_type;
00094 
00095         /* Unload the image.  We can't leave it loaded, because we
00096          * have no "unload" operation.
00097          */
00098         bs->UnloadImage ( handle );
00099 
00100         return 0;
00101 }


Generated on Tue Apr 6 20:01:47 2010 for gPXE by  doxygen 1.5.7.1