48#define EINFO_EEFI_LOAD \
49 __einfo_uniqify ( EINFO_EPLATFORM, 0x01, \
50 "Could not load image" )
51#define EINFO_EEFI_LOAD_PROHIBITED \
52 __einfo_platformify ( EINFO_EEFI_LOAD, EFI_SECURITY_VIOLATION, \
53 "Image prohibited by security policy" )
54#define EEFI_LOAD_PROHIBITED \
55 __einfo_error ( EINFO_EEFI_LOAD_PROHIBITED )
56#define EEFI_LOAD( efirc ) EPLATFORM ( EINFO_EEFI_LOAD, efirc, \
57 EEFI_LOAD_PROHIBITED )
58#define EINFO_EEFI_START \
59 __einfo_uniqify ( EINFO_EPLATFORM, 0x02, \
60 "Could not start image" )
61#define EEFI_START( efirc ) EPLATFORM ( EINFO_EEFI_START, efirc )
86 ( name_len + 1 ) *
sizeof (
wchar_t ) );
87 len = ( prefix_len + filepath_len +
sizeof ( *end ) );
95 memcpy ( path, parent, prefix_len );
96 filepath = ( ( (
void * ) path ) + prefix_len );
103 end = ( ( (
void * ) filepath ) + filepath_len );
171 DBGC (
image,
"EFIIMAGE %s could not identify SNP device\n",
183 DBGC (
image,
"EFIIMAGE %s executing via %s\n",
191 goto err_register_image;
195 DBGC (
image,
"EFIIMAGE %s could not install file protocol: "
197 goto err_file_install;
202 DBGC (
image,
"EFIIMAGE %s could not install PXE protocol: "
204 goto err_pxe_install;
209 DBGC (
image,
"EFIIMAGE %s could not install iPXE download "
211 goto err_download_install;
216 DBGC (
image,
"EFIIMAGE %s could not install FDT: %s\n",
218 goto err_fdt_install;
224 DBGC (
image,
"EFIIMAGE %s could not create device path\n",
233 DBGC (
image,
"EFIIMAGE %s could not create command line\n",
242 DBGC (
image,
"EFIIMAGE %s could not install shim handling: "
244 goto err_shim_install;
259 DBGC (
image,
"EFIIMAGE %s could not load: %s\n",
262 goto err_load_image_security_violation;
272 goto err_open_protocol;
277 DBGC (
image,
"EFIIMAGE %s filling in missing DeviceHandle\n",
311 DBGC (
image,
"EFIIMAGE %s could not start (or returned with "
313 goto err_start_image;
343 err_load_image_security_violation:
357 err_download_install:
380 .Length[0] =
sizeof ( empty_path ),
398 DBGC (
image,
"EFIIMAGE %s could not load: %s\n",
401 goto err_load_image_security_violation;
414 err_load_image_security_violation:
441 if (
image->
len < sizeof ( *dos ) ) {
442 DBGC (
image,
"EFIIMAGE %s too short for DOS header\n",
448 DBGC (
image,
"EFIIMAGE %s missing MZ signature\n",
456 DBGC (
image,
"EFIIMAGE %s too short for PE header\n",
462 DBGC (
image,
"EFIIMAGE %s missing PE signature\n",
469 DBGC (
image,
"EFIIMAGE %s incorrect magic %04x\n",
unsigned short UINT16
2-byte unsigned value.
UINT64 UINTN
Unsigned value of native width.
#define NULL
NULL pointer (VOID *)
#define MEDIA_FILEPATH_DP
File Path Media Device Path SubType.
#define SIZE_OF_FILEPATH_DEVICE_PATH
#define MEDIA_DEVICE_PATH
#define END_ENTIRE_DEVICE_PATH_SUBTYPE
#define END_DEVICE_PATH_TYPE
#define EFI_IMAGE_NT_SIGNATURE
#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
#define EFI_IMAGE_DOS_SIGNATURE
#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
#define EFI_SECURITY_VIOLATION
Enumeration of EFI_STATUS.
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
EFI_MEMORY_TYPE
Enumeration of memory types introduced in UEFI.
@ EfiBootServicesCode
The code portions of a loaded Boot Services Driver.
struct arbelprm_rc_send_wqe rc
#define assert(condition)
Assert a condition at run-time.
uint16_t magic
Magic signature.
void efi_download_uninstall(EFI_HANDLE handle)
Uninstall iPXE download protocol.
int efi_download_install(EFI_HANDLE handle)
Install iPXE download protocol.
void efi_driver_reconnect_all(void)
Reconnect original EFI drivers to all possible devices.
EFI Flattened Device Tree.
int efi_file_install(EFI_HANDLE handle)
Install EFI simple file system protocol.
void efi_file_uninstall(EFI_HANDLE handle)
Uninstall EFI simple file system protocol.
EFI_GUID efi_loaded_image_protocol_guid
Loaded image protocol GUID.
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)
__weak int efi_fdt_install(const char *cmdline __unused)
Install EFI Flattened Device Tree table (when no FDT support is present)
static wchar_t * efi_image_cmdline(struct image *image)
Create command line for image.
static int efi_image_probe(struct image *image)
Probe EFI image.
static EFI_DEVICE_PATH_PROTOCOL * efi_image_path(struct image *image, EFI_DEVICE_PATH_PROTOCOL *parent)
Create device path for image.
#define EEFI_START(efirc)
static int efi_pe_image_probe(struct image *image)
Probe EFI PE image.
static int efi_can_load(struct image *image)
Check if EFI image can be loaded directly.
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
static void efi_path_terminate(EFI_DEVICE_PATH_PROTOCOL *end)
Terminate device path.
void efi_pxe_uninstall(EFI_HANDLE handle)
Uninstall PXE base code protocol.
int efi_pxe_install(EFI_HANDLE handle, struct net_device *netdev)
Install PXE base code protocol.
EFI PXE base code protocol.
void efi_shim_uninstall(void)
Uninstall UEFI shim special handling.
int efi_shim_install(struct image *shim, EFI_HANDLE handle, wchar_t **cmdline)
Install UEFI shim special handling.
UEFI shim special handling.
struct efi_snp_device * last_opened_snpdev(void)
Get most recently opened SNP device.
static void efi_snp_claim(void)
Claim network devices for use by iPXE.
static void efi_snp_release(void)
Release network devices for use via SNP.
int efi_asprintf(wchar_t **wstrp, const char *fmt,...)
Write a formatted string to newly allocated memory.
int efi_snprintf(wchar_t *wbuf, size_t wsize, const char *fmt,...)
Write a formatted string to a buffer.
void efi_unwrap(void)
Remove boot services table wrapper.
void efi_wrap_image(EFI_HANDLE handle)
Wrap calls made by a newly loaded image.
uint32_t type
Operating system type.
#define __unused
Declare a variable or data structure as unused.
#define DHCP_EB_FEATURE_EFI
EFI format.
#define FEATURE_IMAGE
Image formats.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define ENOEXEC
Exec format error.
#define ENOMEM
Not enough space.
#define ENODEV
No such device.
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
void unregister_image(struct image *image)
Unregister executable image.
struct image * find_image_tag(struct image_tag *tag)
Find image by tag.
int register_image(struct image *image)
Register executable image.
#define PROBE_NORMAL
Normal image probe priority.
#define IMAGE_HIDDEN
Image will be hidden from enumeration.
#define __image_type(probe_order)
An executable image type.
#define __weak
Declare a function as weak (use before the definition)
static void console_reset(void)
Reset console.
#define efi_open(handle, protocol, interface)
Open protocol for ephemeral use.
EFI_SYSTEM_TABLE * efi_systab
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define FEATURE(category, text, feature_opt, version)
Declare a feature.
void * zalloc(size_t size)
Allocate cleared memory.
uint32_t end
Ending offset.
static void(* free)(struct refcnt *refcnt))
int shim(struct image *image, int require_loader, int allow_pxe, int allow_sbat)
Set shim image.
char * strerror(int errno)
Retrieve string representation of error number.
size_t strlen(const char *src)
Get length of string.
EFI_IMAGE_START StartImage
EFI_IMAGE_UNLOAD UnloadImage
This protocol can be used on any device handle to obtain generic path/location information concerning...
UINT8 Type
0x01 Hardware Device Path.
UINT8 Length[2]
Specific Device Path data.
UINT8 SubType
Varies by Type 0xFF End Entire Device Path, or 0x01 End This Instance of a Device Path and start a ne...
Can be used on any image handle to obtain information about the loaded image.
VOID * LoadOptions
A pointer to the image's binary load options.
EFI_HANDLE DeviceHandle
The device handle that the EFI Image was loaded from.
UINT32 LoadOptionsSize
The size in bytes of LoadOptions.
EFI_MEMORY_TYPE ImageCodeType
The memory type that the code sections were loaded as.
EFI_HANDLE ParentHandle
Parent image's image handle.
CHAR16 PathName[1]
A NULL-terminated Path string including directory and file names.
EFI_DEVICE_PATH_PROTOCOL Header
EFI_HANDLE handle
EFI device handle.
EFI_DEVICE_PATH_PROTOCOL * path
The device path.
struct net_device * netdev
The underlying iPXE network device.
An executable image type.
const void * data
Read-only data.
size_t len
Length of raw file image.
char * cmdline
Command line to pass to image.
void * rwdata
Writable data.
Uniform Resource Identifiers.
size_t wcslen(const wchar_t *string)
Calculate length of wide-character string.