|
iPXE
|
#include <errno.h>#include <stdlib.h>#include <string.h>#include <wchar.h>#include <ipxe/efi/efi.h>#include <ipxe/efi/efi_snp.h>#include <ipxe/efi/efi_download.h>#include <ipxe/efi/efi_file.h>#include <ipxe/efi/efi_path.h>#include <ipxe/efi/efi_strings.h>#include <ipxe/efi/efi_wrap.h>#include <ipxe/efi/efi_pxe.h>#include <ipxe/efi/efi_driver.h>#include <ipxe/efi/efi_image.h>#include <ipxe/efi/efi_shim.h>#include <ipxe/efi/efi_fdt.h>#include <ipxe/image.h>#include <ipxe/init.h>#include <ipxe/features.h>#include <ipxe/uri.h>#include <ipxe/console.h>Go to the source code of this file.
Macros | |
| #define | EINFO_EEFI_LOAD |
| #define | EINFO_EEFI_LOAD_PROHIBITED |
| #define | EEFI_LOAD_PROHIBITED __einfo_error ( EINFO_EEFI_LOAD_PROHIBITED ) |
| #define | EEFI_LOAD(efirc) |
| #define | EINFO_EEFI_START |
| #define | EEFI_START(efirc) |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| FILE_SECBOOT (PERMITTED) | |
| FEATURE (FEATURE_IMAGE, "EFI", DHCP_EB_FEATURE_EFI, 1) | |
| static EFI_DEVICE_PATH_PROTOCOL * | efi_image_path (struct image *image, EFI_DEVICE_PATH_PROTOCOL *parent) |
| Create device path for image. | |
| static wchar_t * | efi_image_cmdline (struct image *image) |
| Create command line for image. | |
| __weak int | efi_fdt_install (const char *cmdline __unused) |
| Install EFI Flattened Device Tree table (when no FDT support is present) | |
| __weak int | efi_fdt_uninstall (void) |
| Uninstall EFI Flattened Device Tree table (when no FDT support is present) | |
| static int | efi_image_exec (struct image *image) |
| Execute EFI image. | |
| static int | efi_image_probe (struct image *image) |
| Probe EFI image. | |
| static int | efi_pe_image_probe (struct image *image) |
| Probe EFI PE image. | |
| struct image_type efi_image_type[] | __image_type (PROBE_NORMAL) |
| EFI image types. | |
| #define EINFO_EEFI_LOAD |
Definition at line 48 of file efi_image.c.
| #define EINFO_EEFI_LOAD_PROHIBITED |
Definition at line 51 of file efi_image.c.
| #define EEFI_LOAD_PROHIBITED __einfo_error ( EINFO_EEFI_LOAD_PROHIBITED ) |
Definition at line 54 of file efi_image.c.
| #define EEFI_LOAD | ( | efirc | ) |
Definition at line 56 of file efi_image.c.
Referenced by efi_image_exec(), and efi_image_probe().
| #define EINFO_EEFI_START |
Definition at line 58 of file efi_image.c.
| #define EEFI_START | ( | efirc | ) |
Definition at line 61 of file efi_image.c.
Referenced by efi_image_exec().
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| FILE_SECBOOT | ( | PERMITTED | ) |
| FEATURE | ( | FEATURE_IMAGE | , |
| "EFI" | , | ||
| DHCP_EB_FEATURE_EFI | , | ||
| 1 | ) |
References DHCP_EB_FEATURE_EFI, and FEATURE_IMAGE.
|
static |
Create device path for image.
| image | EFI image |
| parent | Parent device path |
| path | Device path, or NULL on failure |
The caller must eventually free() the device path.
Definition at line 73 of file efi_image.c.
References efi_path_len(), efi_path_terminate(), efi_snprintf(), end, FILEPATH_DEVICE_PATH::Header, len, EFI_DEVICE_PATH_PROTOCOL::Length, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, memcpy(), image::name, NULL, FILEPATH_DEVICE_PATH::PathName, SIZE_OF_FILEPATH_DEVICE_PATH, strlen(), EFI_DEVICE_PATH_PROTOCOL::SubType, EFI_DEVICE_PATH_PROTOCOL::Type, and zalloc().
Referenced by efi_image_exec().
Create command line for image.
| image | EFI image |
| cmdline | Command line, or NULL on failure |
Definition at line 115 of file efi_image.c.
References cmdline, image::cmdline, efi_asprintf(), image::name, and NULL.
Referenced by efi_image_exec().
Install EFI Flattened Device Tree table (when no FDT support is present)
| cmdline | Command line, or NULL |
| rc | Return status code |
Definition at line 134 of file efi_image.c.
References __unused, __weak, and cmdline.
Referenced by efi_image_exec().
| __weak int efi_fdt_uninstall | ( | void | ) |
Uninstall EFI Flattened Device Tree table (when no FDT support is present)
| rc | Return status code |
Definition at line 143 of file efi_image.c.
References __weak.
Referenced by efi_image_exec().
|
static |
Execute EFI image.
| image | EFI image |
| rc | Return status code |
Definition at line 153 of file efi_image.c.
References assert, cmdline, image::cmdline, console_reset(), DBGC, EFI_LOADED_IMAGE_PROTOCOL::DeviceHandle, EEFI_LOAD, EEFI_START, efi_can_load(), efi_download_install(), efi_download_uninstall(), efi_driver_reconnect_all(), efi_fdt_install(), efi_fdt_uninstall(), efi_file_install(), efi_file_uninstall(), EFI_HANDLE, efi_image_cmdline(), efi_image_handle, efi_image_path(), efi_loaded_image_protocol_guid, efi_open, efi_pxe_install(), efi_pxe_uninstall(), EFI_SECURITY_VIOLATION, efi_shim_install(), efi_shim_uninstall(), efi_snp_claim(), efi_snp_release(), efi_systab, efi_unwrap(), efi_wrap_image(), EfiBootServicesCode, ENODEV, ENOMEM, FALSE, find_image_tag(), image::flags, free, efi_snp_device::handle, handle, IMAGE_HIDDEN, EFI_LOADED_IMAGE_PROTOCOL::ImageCodeType, last_opened_snpdev(), image::len, EFI_BOOT_SERVICES::LoadImage, EFI_LOADED_IMAGE_PROTOCOL::LoadOptions, EFI_LOADED_IMAGE_PROTOCOL::LoadOptionsSize, image::name, efi_snp_device::netdev, NULL, EFI_LOADED_IMAGE_PROTOCOL::ParentHandle, efi_snp_device::path, rc, register_image(), image::rwdata, shim(), EFI_BOOT_SERVICES::StartImage, strerror(), type, EFI_BOOT_SERVICES::UnloadImage, unregister_image(), and wcslen().
Referenced by __image_type().
|
static |
Probe EFI image.
| image | EFI file |
| rc | Return status code |
Definition at line 375 of file efi_image.c.
References DBGC, EEFI_LOAD, EFI_HANDLE, efi_image_handle, EFI_SECURITY_VIOLATION, efi_systab, END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, FALSE, handle, image::len, EFI_BOOT_SERVICES::LoadImage, image::name, NULL, rc, image::rwdata, strerror(), and EFI_BOOT_SERVICES::UnloadImage.
Referenced by __image_type().
|
static |
Probe EFI PE image.
| image | EFI file |
| rc | Return status code |
The extremely broken UEFI Secure Boot model provides no way for us to unambiguously determine that a valid EFI executable image was rejected by LoadImage() because it failed signature verification. We must therefore use heuristics to guess whether not an image that was rejected by LoadImage() could still be loaded via a separate PE loader such as the UEFI shim.
Definition at line 433 of file efi_image.c.
References image::data, DBGC, EFI_IMAGE_DOS_HEADER::e_lfanew, EFI_IMAGE_DOS_HEADER::e_magic, EFI_IMAGE_DOS_SIGNATURE, EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC, EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC, EFI_IMAGE_NT_SIGNATURE, ENOEXEC, image::len, EFI_IMAGE_OPTIONAL_HEADER32::Magic, magic, image::name, EFI_IMAGE_NT_HEADERS32::OptionalHeader, EFI_IMAGE_OPTIONAL_HEADER_UNION::Pe32, and EFI_IMAGE_NT_HEADERS32::Signature.
Referenced by __image_type().
| struct image_type efi_image_type[] __image_type | ( | PROBE_NORMAL | ) |
EFI image types.
References __image_type, efi_image_exec(), efi_image_probe(), efi_pe_image_probe(), and PROBE_NORMAL.