Skip to content

Commit

Permalink
Part two of porting Geoff Lywood's download protocol to current iPXE
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarrod Johnson authored and Jarrod Johnson committed Aug 9, 2011
1 parent d748ebf commit e7b4189
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/image/efi_image.c
Expand Up @@ -19,13 +19,19 @@
FILE_LICENCE ( GPL2_OR_LATER );

#include <errno.h>
#include <stdlib.h>
#include <ipxe/efi/efi.h>
#include <ipxe/image.h>
#include <ipxe/init.h>
#include <ipxe/features.h>
#include <ipxe/uri.h>

FEATURE ( FEATURE_IMAGE, "EFI", DHCP_EB_FEATURE_EFI, 1 );

/** EFI loaded image protocol GUID */
static EFI_GUID efi_loaded_image_protocol_guid
= EFI_LOADED_IMAGE_PROTOCOL_GUID;

/**
* Execute EFI image
*
Expand All @@ -34,7 +40,10 @@ FEATURE ( FEATURE_IMAGE, "EFI", DHCP_EB_FEATURE_EFI, 1 );
*/
static int efi_image_exec ( struct image *image ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
EFI_LOADED_IMAGE_PROTOCOL *loaded_image = NULL;
void *loaded_image_void;
EFI_HANDLE handle;
EFI_HANDLE device_handle = NULL;
UINTN exit_data_size;
CHAR16 *exit_data;
EFI_STATUS efirc;
Expand All @@ -50,13 +59,29 @@ static int efi_image_exec ( struct image *image ) {
return -ENOEXEC;
}

/* Get the loaded image protocol for the newly loaded image */
efirc = bs->OpenProtocol ( handle, &efi_loaded_image_protocol_guid,
&loaded_image_void, efi_image_handle, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL );
if ( efirc ) {
/* Should never happen */
rc = EFIRC_TO_RC ( efirc );
}
loaded_image = loaded_image_void;

/* Pass a GPXE download protocol to the image */
rc = efi_download_install ( &device_handle );

/* Start the image */
if ( ( efirc = bs->StartImage ( handle, &exit_data_size,
&exit_data ) ) != 0 ) {
DBGC ( image, "EFIIMAGE %p returned with status %s\n",
image, efi_strerror ( efirc ) );
}
rc = EFIRC_TO_RC ( efirc );
if ( device_handle ) {
efi_download_uninstall ( device_handle );
}

/* Unload the image. We can't leave it loaded, because we
* have no "unload" operation.
Expand Down
3 changes: 3 additions & 0 deletions src/include/ipxe/efi/efi.h
Expand Up @@ -142,5 +142,8 @@ extern EFI_SYSTEM_TABLE *efi_systab;
extern const char * efi_strerror ( EFI_STATUS efirc );
extern EFI_STATUS efi_init ( EFI_HANDLE image_handle,
EFI_SYSTEM_TABLE *systab );
extern int efi_download_install ( EFI_HANDLE *device_handle );
extern void efi_download_uninstall ( EFI_HANDLE device_handle );


#endif /* _IPXE_EFI_H */

0 comments on commit e7b4189

Please sign in to comment.