From 62149deb116516bb0d70b756bfc4f5b4669034da Mon Sep 17 00:00:00 2001 From: Geoff Lywood Date: Thu, 27 May 2010 20:08:28 -0700 Subject: [efi] Add the "snpnet" driver Add a new network driver that consumes the EFI Simple Network Protocol. Also add a bus driver that can find the Simple Network Protocol that iPXE was loaded from; the resulting behavior is similar to the "undionly" driver for BIOS systems. Signed-off-by: Michael Brown --- src/interface/efi/efi_init.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/interface/efi') diff --git a/src/interface/efi/efi_init.c b/src/interface/efi/efi_init.c index ed6599327..029bc06fc 100644 --- a/src/interface/efi/efi_init.c +++ b/src/interface/efi/efi_init.c @@ -20,14 +20,22 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include +#include #include /** Image handle passed to entry point */ EFI_HANDLE efi_image_handle; +/** Loaded image protocol for this image */ +EFI_LOADED_IMAGE_PROTOCOL *efi_loaded_image; + /** System table passed to entry point */ EFI_SYSTEM_TABLE *efi_systab; +/** EFI loaded image protocol GUID */ +static EFI_GUID efi_loaded_image_protocol_guid + = EFI_LOADED_IMAGE_PROTOCOL_GUID; + /** * Look up EFI configuration table * @@ -59,6 +67,7 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, struct efi_protocol *prot; struct efi_config_table *tab; EFI_STATUS efirc; + void *loaded_image; /* Store image handle and system table pointer for future use */ efi_image_handle = image_handle; @@ -80,8 +89,20 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, } DBGC ( systab, "EFI handle %p systab %p\n", image_handle, systab ); - /* Look up used protocols */ 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 ) { if ( ( efirc = bs->LocateProtocol ( &prot->u.guid, NULL, prot->protocol ) ) == 0 ) { -- cgit v1.2.3-55-g7522