iPXE
efi_image.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  */
19 
20 FILE_LICENCE ( GPL2_OR_LATER );
21 FILE_SECBOOT ( PERMITTED );
22 
23 #include <errno.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <wchar.h>
27 #include <ipxe/efi/efi.h>
28 #include <ipxe/efi/efi_snp.h>
29 #include <ipxe/efi/efi_download.h>
30 #include <ipxe/efi/efi_file.h>
31 #include <ipxe/efi/efi_path.h>
32 #include <ipxe/efi/efi_strings.h>
33 #include <ipxe/efi/efi_wrap.h>
34 #include <ipxe/efi/efi_pxe.h>
35 #include <ipxe/efi/efi_driver.h>
36 #include <ipxe/efi/efi_image.h>
37 #include <ipxe/efi/efi_shim.h>
38 #include <ipxe/efi/efi_fdt.h>
39 #include <ipxe/image.h>
40 #include <ipxe/init.h>
41 #include <ipxe/features.h>
42 #include <ipxe/uri.h>
43 #include <ipxe/console.h>
44 
46 
47 /* Disambiguate the various error causes */
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 )
62 
63 /**
64  * Create device path for image
65  *
66  * @v image EFI image
67  * @v parent Parent device path
68  * @ret path Device path, or NULL on failure
69  *
70  * The caller must eventually free() the device path.
71  */
75  FILEPATH_DEVICE_PATH *filepath;
77  size_t name_len;
78  size_t prefix_len;
79  size_t filepath_len;
80  size_t len;
81 
82  /* Calculate device path lengths */
83  prefix_len = efi_path_len ( parent );
84  name_len = strlen ( image->name );
85  filepath_len = ( SIZE_OF_FILEPATH_DEVICE_PATH +
86  ( name_len + 1 /* NUL */ ) * sizeof ( wchar_t ) );
87  len = ( prefix_len + filepath_len + sizeof ( *end ) );
88 
89  /* Allocate device path */
90  path = zalloc ( len );
91  if ( ! path )
92  return NULL;
93 
94  /* Construct device path */
95  memcpy ( path, parent, prefix_len );
96  filepath = ( ( ( void * ) path ) + prefix_len );
97  filepath->Header.Type = MEDIA_DEVICE_PATH;
98  filepath->Header.SubType = MEDIA_FILEPATH_DP;
99  filepath->Header.Length[0] = ( filepath_len & 0xff );
100  filepath->Header.Length[1] = ( filepath_len >> 8 );
101  efi_snprintf ( filepath->PathName, ( name_len + 1 /* NUL */ ),
102  "%s", image->name );
103  end = ( ( ( void * ) filepath ) + filepath_len );
105 
106  return path;
107 }
108 
109 /**
110  * Create command line for image
111  *
112  * @v image EFI image
113  * @ret cmdline Command line, or NULL on failure
114  */
115 static wchar_t * efi_image_cmdline ( struct image *image ) {
116  wchar_t *cmdline;
117 
118  /* Allocate and construct command line */
119  if ( efi_asprintf ( &cmdline, "%s%s%s", image->name,
120  ( image->cmdline ? " " : "" ),
121  ( image->cmdline ? image->cmdline : "" ) ) < 0 ) {
122  return NULL;
123  }
124 
125  return cmdline;
126 }
127 
128 /**
129  * Install EFI Flattened Device Tree table (when no FDT support is present)
130  *
131  * @v cmdline Command line, or NULL
132  * @ret rc Return status code
133  */
134 __weak int efi_fdt_install ( const char *cmdline __unused ) {
135  return 0;
136 }
137 
138 /**
139  * Uninstall EFI Flattened Device Tree table (when no FDT support is present)
140  *
141  * @ret rc Return status code
142  */
143 __weak int efi_fdt_uninstall ( void ) {
144  return 0;
145 }
146 
147 /**
148  * Execute EFI image
149  *
150  * @v image EFI image
151  * @ret rc Return status code
152  */
153 static int efi_image_exec ( struct image *image ) {
155  struct efi_snp_device *snpdev;
158  struct image *shim;
159  struct image *exec;
163  wchar_t *cmdline;
164  unsigned int toggle;
165  EFI_STATUS efirc;
166  int rc;
167 
168  /* Find an appropriate device handle to use */
169  snpdev = last_opened_snpdev();
170  if ( ! snpdev ) {
171  DBGC ( image, "EFIIMAGE %s could not identify SNP device\n",
172  image->name );
173  rc = -ENODEV;
174  goto err_no_snpdev;
175  }
176  device = snpdev->handle;
177 
178  /* Use shim instead of directly executing image if applicable */
179  shim = ( efi_can_load ( image ) ?
180  NULL : find_image_tag ( &efi_shim ) );
181  exec = ( shim ? shim : image );
182  if ( shim ) {
183  DBGC ( image, "EFIIMAGE %s executing via %s\n",
184  image->name, shim->name );
185  }
186 
187  /* Re-register as a hidden image to allow for access via file I/O */
188  toggle = ( ~image->flags & IMAGE_HIDDEN );
190  if ( ( rc = register_image ( image ) ) != 0 )
191  goto err_register_image;
192 
193  /* Install file I/O protocols */
194  if ( ( rc = efi_file_install ( device ) ) != 0 ) {
195  DBGC ( image, "EFIIMAGE %s could not install file protocol: "
196  "%s\n", image->name, strerror ( rc ) );
197  goto err_file_install;
198  }
199 
200  /* Install PXE base code protocol */
201  if ( ( rc = efi_pxe_install ( device, snpdev->netdev ) ) != 0 ){
202  DBGC ( image, "EFIIMAGE %s could not install PXE protocol: "
203  "%s\n", image->name, strerror ( rc ) );
204  goto err_pxe_install;
205  }
206 
207  /* Install iPXE download protocol */
208  if ( ( rc = efi_download_install ( device ) ) != 0 ) {
209  DBGC ( image, "EFIIMAGE %s could not install iPXE download "
210  "protocol: %s\n", image->name, strerror ( rc ) );
211  goto err_download_install;
212  }
213 
214  /* Install Flattened Device Tree table */
215  if ( ( rc = efi_fdt_install ( image->cmdline ) ) != 0 ) {
216  DBGC ( image, "EFIIMAGE %s could not install FDT: %s\n",
217  image->name, strerror ( rc ) );
218  goto err_fdt_install;
219  }
220 
221  /* Create device path for image */
222  path = efi_image_path ( exec, snpdev->path );
223  if ( ! path ) {
224  DBGC ( image, "EFIIMAGE %s could not create device path\n",
225  image->name );
226  rc = -ENOMEM;
227  goto err_image_path;
228  }
229 
230  /* Create command line for image */
232  if ( ! cmdline ) {
233  DBGC ( image, "EFIIMAGE %s could not create command line\n",
234  image->name );
235  rc = -ENOMEM;
236  goto err_cmdline;
237  }
238 
239  /* Install shim special handling if applicable */
240  if ( shim &&
241  ( ( rc = efi_shim_install ( shim, device, &cmdline ) ) != 0 ) ) {
242  DBGC ( image, "EFIIMAGE %s could not install shim handling: "
243  "%s\n", image->name, strerror ( rc ) );
244  goto err_shim_install;
245  }
246 
247  /* Attempt loading image
248  *
249  * LoadImage() does not (allegedly) modify the image content,
250  * but requires a non-const pointer to SourceBuffer. We
251  * therefore use the .rwdata field rather than .data.
252  */
253  handle = NULL;
254  if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, path,
255  exec->rwdata, exec->len,
256  &handle ) ) != 0 ) {
257  /* Not an EFI image */
258  rc = -EEFI_LOAD ( efirc );
259  DBGC ( image, "EFIIMAGE %s could not load: %s\n",
260  image->name, strerror ( rc ) );
261  if ( efirc == EFI_SECURITY_VIOLATION ) {
262  goto err_load_image_security_violation;
263  } else {
264  goto err_load_image;
265  }
266  }
267 
268  /* Get the loaded image protocol for the newly loaded image */
270  &loaded ) ) != 0 ) {
271  /* Should never happen */
272  goto err_open_protocol;
273  }
274 
275  /* Some EFI 1.10 implementations seem not to fill in DeviceHandle */
276  if ( loaded->DeviceHandle == NULL ) {
277  DBGC ( image, "EFIIMAGE %s filling in missing DeviceHandle\n",
278  image->name );
279  loaded->DeviceHandle = device;
280  }
281 
282  /* Sanity checks */
283  assert ( loaded->ParentHandle == efi_image_handle );
284  assert ( loaded->DeviceHandle == device );
285  assert ( loaded->LoadOptionsSize == 0 );
286  assert ( loaded->LoadOptions == NULL );
287 
288  /* Record image code type */
289  type = loaded->ImageCodeType;
290 
291  /* Set command line */
292  loaded->LoadOptions = cmdline;
293  loaded->LoadOptionsSize =
294  ( ( wcslen ( cmdline ) + 1 /* NUL */ ) * sizeof ( wchar_t ) );
295 
296  /* Release network devices for use via SNP */
297  efi_snp_release();
298 
299  /* Wrap calls made by the loaded image (for debugging) */
301 
302  /* Reset console since image will probably use it */
303  console_reset();
304 
305  /* Assume that image may cause SNP device to be removed */
306  snpdev = NULL;
307 
308  /* Start the image */
309  if ( ( efirc = bs->StartImage ( handle, NULL, NULL ) ) != 0 ) {
310  rc = -EEFI_START ( efirc );
311  DBGC ( image, "EFIIMAGE %s could not start (or returned with "
312  "error): %s\n", image->name, strerror ( rc ) );
313  goto err_start_image;
314  }
315 
316  /* If image was a driver, connect it up to anything available */
317  if ( type == EfiBootServicesCode ) {
318  DBGC ( image, "EFIIMAGE %s connecting drivers\n", image->name );
320  }
321 
322  /* Success */
323  rc = 0;
324 
325  err_start_image:
326  efi_unwrap();
327  efi_snp_claim();
328  err_open_protocol:
329  /* If there was no error, then the image must have been
330  * started and returned successfully. It either unloaded
331  * itself, or it intended to remain loaded (e.g. it was a
332  * driver). We therefore do not unload successful images.
333  *
334  * If there was an error, attempt to unload the image. This
335  * may not work. In particular, there is no way to tell
336  * whether an error returned from StartImage() was due to
337  * being unable to start the image (in which case we probably
338  * should call UnloadImage()), or due to the image itself
339  * returning an error (in which case we probably should not
340  * call UnloadImage()). We therefore ignore any failures from
341  * the UnloadImage() call itself.
342  */
343  err_load_image_security_violation:
344  if ( rc != 0 )
345  bs->UnloadImage ( handle );
346  err_load_image:
347  if ( shim )
349  err_shim_install:
350  free ( cmdline );
351  err_cmdline:
352  free ( path );
353  err_image_path:
355  err_fdt_install:
357  err_download_install:
359  err_pxe_install:
361  err_file_install:
363  err_register_image:
364  image->flags ^= toggle;
365  err_no_snpdev:
366  return rc;
367 }
368 
369 /**
370  * Probe EFI image
371  *
372  * @v image EFI file
373  * @ret rc Return status code
374  */
375 static int efi_image_probe ( struct image *image ) {
377  static EFI_DEVICE_PATH_PROTOCOL empty_path = {
380  .Length[0] = sizeof ( empty_path ),
381  };
383  EFI_STATUS efirc;
384  int rc;
385 
386  /* Attempt loading image
387  *
388  * LoadImage() does not (allegedly) modify the image content,
389  * but requires a non-const pointer to SourceBuffer. We
390  * therefore use the .rwdata field rather than .data.
391  */
392  handle = NULL;
393  if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, &empty_path,
394  image->rwdata, image->len,
395  &handle ) ) != 0 ) {
396  /* Not an EFI image */
397  rc = -EEFI_LOAD ( efirc );
398  DBGC ( image, "EFIIMAGE %s could not load: %s\n",
399  image->name, strerror ( rc ) );
400  if ( efirc == EFI_SECURITY_VIOLATION ) {
401  goto err_load_image_security_violation;
402  } else {
403  goto err_load_image;
404  }
405  }
406 
407  /* Unload the image. We can't leave it loaded, because we
408  * have no "unload" operation.
409  */
410  bs->UnloadImage ( handle );
411 
412  return 0;
413 
414  err_load_image_security_violation:
415  bs->UnloadImage ( handle );
416  err_load_image:
417  return rc;
418 }
419 
420 /**
421  * Probe EFI PE image
422  *
423  * @v image EFI file
424  * @ret rc Return status code
425  *
426  * The extremely broken UEFI Secure Boot model provides no way for us
427  * to unambiguously determine that a valid EFI executable image was
428  * rejected by LoadImage() because it failed signature verification.
429  * We must therefore use heuristics to guess whether not an image that
430  * was rejected by LoadImage() could still be loaded via a separate PE
431  * loader such as the UEFI shim.
432  */
433 static int efi_pe_image_probe ( struct image *image ) {
434  const UINT16 magic = ( ( sizeof ( UINTN ) == sizeof ( uint32_t ) ) ?
437  const EFI_IMAGE_DOS_HEADER *dos;
439 
440  /* Check for existence of DOS header */
441  if ( image->len < sizeof ( *dos ) ) {
442  DBGC ( image, "EFIIMAGE %s too short for DOS header\n",
443  image->name );
444  return -ENOEXEC;
445  }
446  dos = image->data;
447  if ( dos->e_magic != EFI_IMAGE_DOS_SIGNATURE ) {
448  DBGC ( image, "EFIIMAGE %s missing MZ signature\n",
449  image->name );
450  return -ENOEXEC;
451  }
452 
453  /* Check for existence of PE header */
454  if ( ( image->len < dos->e_lfanew ) ||
455  ( ( image->len - dos->e_lfanew ) < sizeof ( *pe ) ) ) {
456  DBGC ( image, "EFIIMAGE %s too short for PE header\n",
457  image->name );
458  return -ENOEXEC;
459  }
460  pe = ( image->data + dos->e_lfanew );
461  if ( pe->Pe32.Signature != EFI_IMAGE_NT_SIGNATURE ) {
462  DBGC ( image, "EFIIMAGE %s missing PE signature\n",
463  image->name );
464  return -ENOEXEC;
465  }
466 
467  /* Check PE header magic */
468  if ( pe->Pe32.OptionalHeader.Magic != magic ) {
469  DBGC ( image, "EFIIMAGE %s incorrect magic %04x\n",
471  return -ENOEXEC;
472  }
473 
474  return 0;
475 }
476 
477 /** EFI image types */
478 struct image_type efi_image_type[] __image_type ( PROBE_NORMAL ) = {
479  {
480  .name = "EFI",
481  .probe = efi_image_probe,
482  .exec = efi_image_exec,
483  },
484  {
485  .name = "EFIPE",
486  .probe = efi_pe_image_probe,
487  .exec = efi_image_exec,
488  },
489 };
iPXE Download Protocol
FILE_LICENCE(GPL2_OR_LATER)
unsigned int flags
Flags.
Definition: image.h:40
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2099
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void efi_download_uninstall(EFI_HANDLE handle)
Uninstall iPXE download protocol.
Definition: efi_download.c:237
EFI file protocols.
EFI driver interface.
#define END_DEVICE_PATH_TYPE
Definition: DevicePath.h:1394
EFI PXE base code protocol.
Error codes.
const void * data
Read-only data.
Definition: image.h:51
uint16_t magic
Magic signature.
Definition: bzimage.h:6
EFI strings.
EFI_IMAGE_LOAD LoadImage
Definition: UefiSpec.h:1978
#define ENOEXEC
Exec format error.
Definition: errno.h:520
uint32_t type
Operating system type.
Definition: ena.h:12
int efi_shim_install(struct image *shim, EFI_HANDLE handle, wchar_t **cmdline)
Install UEFI shim special handling.
Definition: efi_shim.c:341
#define EEFI_START(efirc)
Definition: efi_image.c:61
#define DBGC(...)
Definition: compiler.h:505
EFI_GUID efi_loaded_image_protocol_guid
Loaded image protocol GUID.
Definition: efi_guid.c:273
An executable image type.
Definition: image.h:95
Union of PE32, PE32+, and TE headers.
Definition: PeImage.h:805
#define PROBE_NORMAL
Normal image probe priority.
Definition: image.h:156
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_path.c:174
void efi_file_uninstall(EFI_HANDLE handle)
Uninstall EFI simple file system protocol.
Definition: efi_file.c:1212
#define EFI_IMAGE_DOS_SIGNATURE
Definition: PeImage.h:50
EFI_IMAGE_UNLOAD UnloadImage
Definition: UefiSpec.h:1981
An executable image.
Definition: image.h:24
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:46
CHAR16 PathName[1]
A NULL-terminated Path string including directory and file names.
Definition: DevicePath.h:1107
#define FEATURE_IMAGE
Image formats.
Definition: features.h:23
static void efi_snp_claim(void)
Claim network devices for use by iPXE.
Definition: efi_snp.h:92
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:1103
uint16_t device
Device ID.
Definition: ena.h:24
Uniform Resource Identifiers.
EFI_IMAGE_NT_HEADERS32 Pe32
Definition: PeImage.h:806
EFI_HANDLE handle
EFI device handle.
Definition: efi_snp.h:37
size_t wcslen(const wchar_t *string)
Calculate length of wide-character string.
Definition: wchar.c:57
EFI_MEMORY_TYPE ImageCodeType
The memory type that the code sections were loaded as.
Definition: LoadedImage.h:72
char * name
Name of this image type.
Definition: image.h:97
char * cmdline
Command line to pass to image.
Definition: image.h:43
static void efi_path_terminate(EFI_DEVICE_PATH_PROTOCOL *end)
Terminate device path.
Definition: efi_path.h:31
int efi_file_install(EFI_HANDLE handle)
Install EFI simple file system protocol.
Definition: efi_file.c:1116
struct image * find_image_tag(struct image_tag *tag)
Find image by tag.
Definition: image.c:393
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:33
#define EFI_IMAGE_NT_SIGNATURE
Definition: PeImage.h:53
struct efi_snp_device * last_opened_snpdev(void)
Get most recently opened SNP device.
Definition: efi_snp.c:2119
#define ENOMEM
Not enough space.
Definition: errno.h:535
A hardware device.
Definition: device.h:77
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.
Definition: LoadedImage.h:46
void efi_pxe_uninstall(EFI_HANDLE handle)
Uninstall PXE base code protocol.
Definition: efi_pxe.c:1632
void efi_driver_reconnect_all(void)
Reconnect original EFI drivers to all possible devices.
Definition: efi_driver.c:659
EFI_MEMORY_TYPE
Enumeration of memory types introduced in UEFI.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define EEFI_LOAD(efirc)
Definition: efi_image.c:56
Executable images.
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
ring len
Length.
Definition: dwmac.h:231
int efi_snprintf(wchar_t *wbuf, size_t wsize, const char *fmt,...)
Write a formatted string to a buffer.
Definition: efi_strings.c:107
Feature list.
#define SIZE_OF_FILEPATH_DEVICE_PATH
Definition: DevicePath.h:1110
VOID * LoadOptions
A pointer to the image's binary load options.
Definition: LoadedImage.h:65
User interaction.
The code portions of a loaded Boot Services Driver.
unsigned short UINT16
int efi_pxe_install(EFI_HANDLE handle, struct net_device *netdev)
Install PXE base code protocol.
Definition: efi_pxe.c:1549
static int efi_can_load(struct image *image)
Check if EFI image can be loaded directly.
Definition: efi_image.h:23
int register_image(struct image *image)
Register executable image.
Definition: image.c:315
UINT16 Magic
Standard fields.
Definition: PeImage.h:154
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:662
EFI Boot Services Table.
Definition: UefiSpec.h:1931
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:36
size_t len
Length of raw file image.
Definition: image.h:56
#define IMAGE_HIDDEN
Image will be hidden from enumeration.
Definition: image.h:86
An SNP device.
Definition: efi_snp.h:29
#define ENODEV
No such device.
Definition: errno.h:510
static void efi_snp_release(void)
Release network devices for use via SNP.
Definition: efi_snp.h:100
#define efi_open(handle, protocol, interface)
Open protocol for ephemeral use.
Definition: efi.h:444
size_t strlen(const char *src)
Get length of string.
Definition: string.c:244
static int efi_image_exec(struct image *image)
Execute EFI image.
Definition: efi_image.c:153
__weak int efi_fdt_uninstall(void)
Uninstall EFI Flattened Device Tree table (when no FDT support is present)
Definition: efi_image.c:143
static void console_reset(void)
Reset console.
Definition: console.h:215
EFI device paths.
EFI_IMAGE_START StartImage
Definition: UefiSpec.h:1979
#define MEDIA_DEVICE_PATH
Definition: DevicePath.h:1012
UINT64 UINTN
Unsigned value of native width.
unsigned int uint32_t
Definition: stdint.h:12
void efi_wrap_image(EFI_HANDLE handle)
Wrap calls made by a newly loaded image.
Definition: efi_wrap.c:1567
EFI API.
#define EFI_SECURITY_VIOLATION
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:141
UINT32 LoadOptionsSize
The size in bytes of LoadOptions.
Definition: LoadedImage.h:64
static wchar_t * efi_image_cmdline(struct image *image)
Create command line for image.
Definition: efi_image.c:115
UINT32 e_lfanew
File address of new exe header.
Definition: PeImage.h:78
#define END_ENTIRE_DEVICE_PATH_SUBTYPE
Definition: DevicePath.h:1395
void unregister_image(struct image *image)
Unregister executable image.
Definition: image.c:358
UINT16 e_magic
Magic number.
Definition: PeImage.h:60
UINT8 Length[2]
Specific Device Path data.
Definition: DevicePath.h:59
static EFI_DEVICE_PATH_PROTOCOL * efi_image_path(struct image *image, EFI_DEVICE_PATH_PROTOCOL *parent)
Create device path for image.
Definition: efi_image.c:73
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:32
UINT8 SubType
Varies by Type 0xFF End Entire Device Path, or 0x01 End This Instance of a Device Path and start a ne...
Definition: DevicePath.h:54
void * rwdata
Writable data.
Definition: image.h:53
void efi_shim_uninstall(void)
Uninstall UEFI shim special handling.
Definition: efi_shim.c:375
EFI images.
static int efi_pe_image_probe(struct image *image)
Probe EFI PE image.
Definition: efi_image.c:433
PE images can start with an optional DOS header, so if an image is run under DOS it can print an erro...
Definition: PeImage.h:59
uint32_t end
Ending offset.
Definition: netvsc.h:18
int efi_download_install(EFI_HANDLE handle)
Install iPXE download protocol.
Definition: efi_download.c:212
EFI Flattened Device Tree.
#define __weak
Declare a function as weak (use before the definition)
Definition: compiler.h:219
FILE_SECBOOT(PERMITTED)
#define FALSE
Definition: tlan.h:45
static int efi_image_probe(struct image *image)
Probe EFI image.
Definition: efi_image.c:375
UINT8 Type
0x01 Hardware Device Path.
Definition: DevicePath.h:47
FEATURE(FEATURE_IMAGE, "EFI", DHCP_EB_FEATURE_EFI, 1)
EFI_SYSTEM_TABLE * efi_systab
iPXE EFI SNP interface
#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
Definition: PeImage.h:145
#define DHCP_EB_FEATURE_EFI
EFI format.
Definition: features.h:53
int efi_asprintf(wchar_t **wstrp, const char *fmt,...)
Write a formatted string to newly allocated memory.
Definition: efi_strings.c:189
#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
Definition: PeImage.h:196
uint32_t cmdline
Definition: multiboot.h:16
EFI_DEVICE_PATH_PROTOCOL * path
The device path.
Definition: efi_snp.h:79
void efi_unwrap(void)
Remove boot services table wrapper.
Definition: efi_wrap.c:1543
uint16_t handle
Handle.
Definition: smbios.h:17
char * name
Name.
Definition: image.h:38
int shim(struct image *image, int require_loader, int allow_pxe, int allow_sbat)
Set shim image.
Definition: shimmgmt.c:46
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
String functions.
EFI_HANDLE ParentHandle
Parent image's image handle.
Definition: LoadedImage.h:49
EFI driver interface.
__weak int efi_fdt_install(const char *cmdline __unused)
Install EFI Flattened Device Tree table (when no FDT support is present)
Definition: efi_image.c:134
Definition: efi.h:62
EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: PeImage.h:247
EFI_HANDLE DeviceHandle
The device handle that the EFI Image was loaded from.
Definition: LoadedImage.h:56
struct image_type efi_image_type [] __image_type(PROBE_NORMAL)
EFI image types.
#define MEDIA_FILEPATH_DP
File Path Media Device Path SubType.
Definition: DevicePath.h:1101