Skip to content

Commit e7b4189

Browse files
Jarrod JohnsonJarrod Johnson
Jarrod Johnson
authored and
Jarrod Johnson
committedAug 9, 2011
Part two of porting Geoff Lywood's download protocol to current iPXE
1 parent d748ebf commit e7b4189

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
 

‎src/image/efi_image.c

+25
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@
1919
FILE_LICENCE ( GPL2_OR_LATER );
2020

2121
#include <errno.h>
22+
#include <stdlib.h>
2223
#include <ipxe/efi/efi.h>
2324
#include <ipxe/image.h>
2425
#include <ipxe/init.h>
2526
#include <ipxe/features.h>
27+
#include <ipxe/uri.h>
2628

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

31+
/** EFI loaded image protocol GUID */
32+
static EFI_GUID efi_loaded_image_protocol_guid
33+
= EFI_LOADED_IMAGE_PROTOCOL_GUID;
34+
2935
/**
3036
* Execute EFI image
3137
*
@@ -34,7 +40,10 @@ FEATURE ( FEATURE_IMAGE, "EFI", DHCP_EB_FEATURE_EFI, 1 );
3440
*/
3541
static int efi_image_exec ( struct image *image ) {
3642
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
43+
EFI_LOADED_IMAGE_PROTOCOL *loaded_image = NULL;
44+
void *loaded_image_void;
3745
EFI_HANDLE handle;
46+
EFI_HANDLE device_handle = NULL;
3847
UINTN exit_data_size;
3948
CHAR16 *exit_data;
4049
EFI_STATUS efirc;
@@ -50,13 +59,29 @@ static int efi_image_exec ( struct image *image ) {
5059
return -ENOEXEC;
5160
}
5261

62+
/* Get the loaded image protocol for the newly loaded image */
63+
efirc = bs->OpenProtocol ( handle, &efi_loaded_image_protocol_guid,
64+
&loaded_image_void, efi_image_handle, NULL,
65+
EFI_OPEN_PROTOCOL_GET_PROTOCOL );
66+
if ( efirc ) {
67+
/* Should never happen */
68+
rc = EFIRC_TO_RC ( efirc );
69+
}
70+
loaded_image = loaded_image_void;
71+
72+
/* Pass a GPXE download protocol to the image */
73+
rc = efi_download_install ( &device_handle );
74+
5375
/* Start the image */
5476
if ( ( efirc = bs->StartImage ( handle, &exit_data_size,
5577
&exit_data ) ) != 0 ) {
5678
DBGC ( image, "EFIIMAGE %p returned with status %s\n",
5779
image, efi_strerror ( efirc ) );
5880
}
5981
rc = EFIRC_TO_RC ( efirc );
82+
if ( device_handle ) {
83+
efi_download_uninstall ( device_handle );
84+
}
6085

6186
/* Unload the image. We can't leave it loaded, because we
6287
* have no "unload" operation.

‎src/include/ipxe/efi/efi.h

+3
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,8 @@ extern EFI_SYSTEM_TABLE *efi_systab;
142142
extern const char * efi_strerror ( EFI_STATUS efirc );
143143
extern EFI_STATUS efi_init ( EFI_HANDLE image_handle,
144144
EFI_SYSTEM_TABLE *systab );
145+
extern int efi_download_install ( EFI_HANDLE *device_handle );
146+
extern void efi_download_uninstall ( EFI_HANDLE device_handle );
147+
145148

146149
#endif /* _IPXE_EFI_H */

0 commit comments

Comments
 (0)