diff options
author | Michael Brown <mcb30@ipxe.org> | 2013-03-27 21:23:21 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2013-03-27 21:23:21 +0000 |
commit | 6979b7a2d35bdc5fa5d691a20a3620992c824985 (patch) | |
tree | 7dd2af05aff0eff7121fd9a01e53e54830b268d1 /src | |
parent | 8a49782eebc66c3529578735386f03c262e1995b (diff) | |
download | ipxe-6979b7a2d35bdc5fa5d691a20a3620992c824985.zip ipxe-6979b7a2d35bdc5fa5d691a20a3620992c824985.tar.gz ipxe-6979b7a2d35bdc5fa5d691a20a3620992c824985.tar.bz2 |
[efi] Fetch device path for loaded image during initialisation
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/include/ipxe/efi/efi.h | 1 | ||||
-rw-r--r-- | src/interface/efi/efi_init.c | 50 |
2 files changed, 38 insertions, 13 deletions
diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 46b6669..3aaac60 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -127,6 +127,7 @@ struct efi_config_table { 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 ); diff --git a/src/interface/efi/efi_init.c b/src/interface/efi/efi_init.c index 48cac53..e40de4d 100644 --- a/src/interface/efi/efi_init.c +++ b/src/interface/efi/efi_init.c @@ -22,6 +22,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include <string.h> #include <ipxe/efi/efi.h> #include <ipxe/efi/Protocol/LoadedImage.h> +#include <ipxe/efi/Protocol/DevicePath.h> #include <ipxe/uuid.h> #include <ipxe/init.h> @@ -31,6 +32,9 @@ EFI_HANDLE efi_image_handle; /** Loaded image protocol for this image */ EFI_LOADED_IMAGE_PROTOCOL *efi_loaded_image; +/** Loaded image protocol device path for this image */ +EFI_DEVICE_PATH_PROTOCOL *efi_loaded_image_path; + /** System table passed to entry point */ EFI_SYSTEM_TABLE *efi_systab; @@ -38,6 +42,10 @@ EFI_SYSTEM_TABLE *efi_systab; static EFI_GUID efi_loaded_image_protocol_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID; +/** EFI loaded image device path protocol GUID */ +static EFI_GUID efi_loaded_image_device_path_protocol_guid + = EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID; + /** Event used to signal shutdown */ static EFI_EVENT efi_shutdown_event; @@ -83,8 +91,9 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, EFI_BOOT_SERVICES *bs; struct efi_protocol *prot; struct efi_config_table *tab; - EFI_STATUS efirc; void *loaded_image; + void *loaded_image_path; + EFI_STATUS efirc; /* Store image handle and system table pointer for future use */ efi_image_handle = image_handle; @@ -105,19 +114,7 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, return EFI_NOT_AVAILABLE_YET; } DBGC ( systab, "EFI handle %p systab %p\n", image_handle, systab ); - bs = systab->BootServices; - efirc = bs->OpenProtocol ( image_handle, - &efi_loaded_image_protocol_guid, - &loaded_image, image_handle, NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ); - if ( efirc ) { - DBGC ( systab, "Could not get loaded image protocol" ); - return efirc; - } - - efi_loaded_image = loaded_image; - DBG ( "Image base address = %p\n", efi_loaded_image->ImageBase ); /* Look up used protocols */ for_each_table_entry ( prot, EFI_PROTOCOLS ) { @@ -147,6 +144,33 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, } } + /* Get loaded image protocol */ + if ( ( efirc = bs->OpenProtocol ( image_handle, + &efi_loaded_image_protocol_guid, + &loaded_image, image_handle, NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { + DBGC ( systab, "EFI could not get loaded image protocol: %s", + efi_strerror ( efirc ) ); + return efirc; + } + efi_loaded_image = loaded_image; + DBGC ( systab, "EFI image base address %p\n", + efi_loaded_image->ImageBase ); + + /* Get loaded image device path protocol */ + if ( ( efirc = bs->OpenProtocol ( image_handle, + &efi_loaded_image_device_path_protocol_guid, + &loaded_image_path, image_handle, NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { + DBGC ( systab, "EFI could not get loaded image device path " + "protocol: %s", efi_strerror ( efirc ) ); + return efirc; + } + efi_loaded_image_path = loaded_image_path; + DBGC ( systab, "EFI image device path " ); + DBGC_EFI_DEVPATH ( systab, efi_loaded_image_path ); + DBGC ( systab, "\n" ); + /* EFI is perfectly capable of gracefully shutting down any * loaded devices if it decides to fall back to a legacy boot. * For no particularly comprehensible reason, it doesn't |