efi_image.c revision a734c64bff58bda2fa48c2795453e092167b0ff7
/*
* Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
*
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <errno.h>
#include <stdlib.h>
#include <ipxe/features.h>
/** EFI loaded image protocol GUID */
static EFI_GUID efi_loaded_image_protocol_guid =
/**
* Create a Unicode command line for the image
*
* @v image EFI image
* @v devpath_out Device path to pass to image (output)
* @v cmdline_out Unicode command line (output)
* @v cmdline_len_out Length of command line in bytes (output)
* @ret rc Return status code
*/
VOID **cmdline_out,
UINT32 *cmdline_len_out ) {
char *uri;
UINT32 i;
/* Get the URI string of the image */
/* Compute final command line length */
}
/* Allocate space for the uri, final command line and device path */
+ sizeof ( EFI_DEVICE_PATH ) );
if ( ! cmdline )
return -ENOMEM;
/* Build the iPXE device path */
/* Convert to Unicode */
for ( i = 0 ; i < uri_len ; i++ ) {
}
}
for ( i = 0 ; i < args_len ; i++ ) {
}
*cmdline_out = cmdline;
return 0;
}
/**
* Execute EFI image
*
* @v image EFI image
* @ret rc Return status code
*/
union {
void *interface;
} loaded;
int rc;
/* Attempt loading image */
/* Not an EFI image */
goto err_load_image;
}
/* Get the loaded image protocol for the newly loaded image */
if ( efirc ) {
/* Should never happen */
goto err_open_protocol;
}
/* Pass an iPXE download protocol to the image */
goto err_download_install;
}
goto err_make_cmdline;
/* Start the image */
&exit_data ) ) != 0 ) {
goto err_start_image;
}
/* Success */
rc = 0;
/* Unload the image. We can't leave it loaded, because we
* have no "unload" operation.
*/
return rc;
}
/**
* Probe EFI image
*
* @v image EFI file
* @ret rc Return status code
*/
/* Attempt loading image */
/* Not an EFI image */
return -ENOEXEC;
}
/* Unload the image. We can't leave it loaded, because we
* have no "unload" operation.
*/
return 0;
}
/** EFI image type */
.name = "EFI",
.probe = efi_image_probe,
.exec = efi_image_exec,
};