[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 <mcb30@ipxe.org>
This commit is contained in:
Geoff Lywood
2010-05-27 20:08:28 -07:00
committed by Michael Brown
parent 74bc1b95bb
commit 62149deb11
10 changed files with 724 additions and 4 deletions

View File

@@ -20,14 +20,22 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <string.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/Protocol/LoadedImage.h>
#include <ipxe/uuid.h>
/** 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 ) {