47 #define EINFO_EEFI_LOAD \ 48 __einfo_uniqify ( EINFO_EPLATFORM, 0x01, \ 49 "Could not load image" ) 50 #define EINFO_EEFI_LOAD_PROHIBITED \ 51 __einfo_platformify ( EINFO_EEFI_LOAD, EFI_SECURITY_VIOLATION, \ 52 "Image prohibited by security policy" ) 53 #define EEFI_LOAD_PROHIBITED \ 54 __einfo_error ( EINFO_EEFI_LOAD_PROHIBITED ) 55 #define EEFI_LOAD( efirc ) EPLATFORM ( EINFO_EEFI_LOAD, efirc, \ 56 EEFI_LOAD_PROHIBITED ) 57 #define EINFO_EEFI_START \ 58 __einfo_uniqify ( EINFO_EPLATFORM, 0x02, \ 59 "Could not start image" ) 60 #define EEFI_START( efirc ) EPLATFORM ( EINFO_EEFI_START, efirc ) 85 ( name_len + 1 ) *
sizeof (
wchar_t ) );
86 len = ( prefix_len + filepath_len +
sizeof ( *end ) );
94 memcpy ( path, parent, prefix_len );
95 filepath = ( ( (
void * ) path ) + prefix_len );
102 end = ( ( (
void * ) filepath ) + filepath_len );
170 DBGC (
image,
"EFIIMAGE %s could not identify SNP device\n",
182 DBGC (
image,
"EFIIMAGE %s executing via %s\n",
190 goto err_register_image;
194 DBGC (
image,
"EFIIMAGE %s could not install file protocol: " 196 goto err_file_install;
201 DBGC (
image,
"EFIIMAGE %s could not install PXE protocol: " 203 goto err_pxe_install;
208 DBGC (
image,
"EFIIMAGE %s could not install iPXE download " 210 goto err_download_install;
215 DBGC (
image,
"EFIIMAGE %s could not install FDT: %s\n",
217 goto err_fdt_install;
223 DBGC (
image,
"EFIIMAGE %s could not create device path\n",
232 DBGC (
image,
"EFIIMAGE %s could not create command line\n",
241 DBGC (
image,
"EFIIMAGE %s could not install shim handling: " 243 goto err_shim_install;
258 DBGC (
image,
"EFIIMAGE %s could not load: %s\n",
261 goto err_load_image_security_violation;
271 goto err_open_protocol;
276 DBGC (
image,
"EFIIMAGE %s filling in missing DeviceHandle\n",
310 DBGC (
image,
"EFIIMAGE %s could not start (or returned with " 312 goto err_start_image;
342 err_load_image_security_violation:
356 err_download_install:
379 .Length[0] =
sizeof ( empty_path ),
397 DBGC (
image,
"EFIIMAGE %s could not load: %s\n",
400 goto err_load_image_security_violation;
413 err_load_image_security_violation:
440 if (
image->
len < sizeof ( *dos ) ) {
441 DBGC (
image,
"EFIIMAGE %s too short for DOS header\n",
447 DBGC (
image,
"EFIIMAGE %s missing MZ signature\n",
455 DBGC (
image,
"EFIIMAGE %s too short for PE header\n",
461 DBGC (
image,
"EFIIMAGE %s missing PE signature\n",
468 DBGC (
image,
"EFIIMAGE %s incorrect magic %04x\n",
FILE_LICENCE(GPL2_OR_LATER)
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
struct arbelprm_rc_send_wqe rc
void efi_download_uninstall(EFI_HANDLE handle)
Uninstall iPXE download protocol.
#define END_DEVICE_PATH_TYPE
EFI PXE base code protocol.
const void * data
Read-only data.
uint16_t magic
Magic signature.
#define ENOEXEC
Exec format error.
uint32_t type
Operating system type.
int efi_shim_install(struct image *shim, EFI_HANDLE handle, wchar_t **cmdline)
Install UEFI shim special handling.
#define EEFI_START(efirc)
EFI_GUID efi_loaded_image_protocol_guid
Loaded image protocol GUID.
An executable image type.
#define PROBE_NORMAL
Normal image probe priority.
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
void efi_file_uninstall(EFI_HANDLE handle)
Uninstall EFI simple file system protocol.
#define EFI_IMAGE_DOS_SIGNATURE
EFI_IMAGE_UNLOAD UnloadImage
This protocol can be used on any device handle to obtain generic path/location information concerning...
CHAR16 PathName[1]
A NULL-terminated Path string including directory and file names.
#define FEATURE_IMAGE
Image formats.
static void efi_snp_claim(void)
Claim network devices for use by iPXE.
EFI_DEVICE_PATH_PROTOCOL Header
uint16_t device
Device ID.
Uniform Resource Identifiers.
EFI_HANDLE handle
EFI device handle.
size_t wcslen(const wchar_t *string)
Calculate length of wide-character string.
EFI_MEMORY_TYPE ImageCodeType
The memory type that the code sections were loaded as.
char * name
Name of this image type.
char * cmdline
Command line to pass to image.
static void efi_path_terminate(EFI_DEVICE_PATH_PROTOCOL *end)
Terminate device path.
int efi_file_install(EFI_HANDLE handle)
Install EFI simple file system protocol.
struct image * find_image_tag(struct image_tag *tag)
Find image by tag.
struct net_device * netdev
The underlying iPXE network device.
#define EFI_IMAGE_NT_SIGNATURE
struct efi_snp_device * last_opened_snpdev(void)
Get most recently opened SNP device.
#define ENOMEM
Not enough space.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
UEFI shim special handling.
Can be used on any image handle to obtain information about the loaded image.
void efi_pxe_uninstall(EFI_HANDLE handle)
Uninstall PXE base code protocol.
void efi_driver_reconnect_all(void)
Reconnect original EFI drivers to all possible devices.
EFI_MEMORY_TYPE
Enumeration of memory types introduced in UEFI.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define __unused
Declare a variable or data structure as unused.
int efi_snprintf(wchar_t *wbuf, size_t wsize, const char *fmt,...)
Write a formatted string to a buffer.
#define SIZE_OF_FILEPATH_DEVICE_PATH
VOID * LoadOptions
A pointer to the image's binary load options.
The code portions of a loaded Boot Services Driver.
int efi_pxe_install(EFI_HANDLE handle, struct net_device *netdev)
Install PXE base code protocol.
static int efi_can_load(struct image *image)
Check if EFI image can be loaded directly.
int register_image(struct image *image)
Register executable image.
char * strerror(int errno)
Retrieve string representation of error number.
static void(* free)(struct refcnt *refcnt))
void * zalloc(size_t size)
Allocate cleared memory.
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
size_t len
Length of raw file image.
#define IMAGE_HIDDEN
Image will be hidden from enumeration.
#define ENODEV
No such device.
static void efi_snp_release(void)
Release network devices for use via SNP.
#define efi_open(handle, protocol, interface)
Open protocol for ephemeral use.
size_t strlen(const char *src)
Get length of string.
static int efi_image_exec(struct image *image)
Execute EFI image.
__weak int efi_fdt_uninstall(void)
Uninstall EFI Flattened Device Tree table (when no FDT support is present)
static void console_reset(void)
Reset console.
EFI_IMAGE_START StartImage
#define MEDIA_DEVICE_PATH
UINT64 UINTN
Unsigned value of native width.
void efi_wrap_image(EFI_HANDLE handle)
Wrap calls made by a newly loaded image.
#define EFI_SECURITY_VIOLATION
Enumeration of EFI_STATUS.
UINT32 LoadOptionsSize
The size in bytes of LoadOptions.
static wchar_t * efi_image_cmdline(struct image *image)
Create command line for image.
#define END_ENTIRE_DEVICE_PATH_SUBTYPE
void unregister_image(struct image *image)
Unregister executable image.
UINT8 Length[2]
Specific Device Path data.
static EFI_DEVICE_PATH_PROTOCOL * efi_image_path(struct image *image, EFI_DEVICE_PATH_PROTOCOL *parent)
Create device path for image.
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
UINT8 SubType
Varies by Type 0xFF End Entire Device Path, or 0x01 End This Instance of a Device Path and start a ne...
void * rwdata
Writable data.
void efi_shim_uninstall(void)
Uninstall UEFI shim special handling.
static int efi_pe_image_probe(struct image *image)
Probe EFI PE image.
uint32_t end
Ending offset.
int efi_download_install(EFI_HANDLE handle)
Install iPXE download protocol.
EFI Flattened Device Tree.
#define __weak
Declare a function as weak (use before the definition)
static int efi_image_probe(struct image *image)
Probe EFI image.
UINT8 Type
0x01 Hardware Device Path.
FEATURE(FEATURE_IMAGE, "EFI", DHCP_EB_FEATURE_EFI, 1)
EFI_SYSTEM_TABLE * efi_systab
#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
#define DHCP_EB_FEATURE_EFI
EFI format.
int efi_asprintf(wchar_t **wstrp, const char *fmt,...)
Write a formatted string to newly allocated memory.
#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
EFI_DEVICE_PATH_PROTOCOL * path
The device path.
void efi_unwrap(void)
Remove boot services table wrapper.
int shim(struct image *image, int require_loader, int allow_pxe, int allow_sbat)
Set shim image.
#define NULL
NULL pointer (VOID *)
EFI_HANDLE ParentHandle
Parent image's image handle.
__weak int efi_fdt_install(const char *cmdline __unused)
Install EFI Flattened Device Tree table (when no FDT support is present)
EFI_HANDLE DeviceHandle
The device handle that the EFI Image was loaded from.
struct image_type efi_image_type [] __image_type(PROBE_NORMAL)
EFI image types.
#define MEDIA_FILEPATH_DP
File Path Media Device Path SubType.