iPXE
Functions
efi_autoexec.h File Reference

EFI autoexec script. More...

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
int efi_autoexec_load (void)
 Load autoexec script. More...
 

Detailed Description

EFI autoexec script.

Definition in file efi_autoexec.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ efi_autoexec_load()

int efi_autoexec_load ( void  )

Load autoexec script.

Return values
rcReturn status code

Definition at line 165 of file efi_autoexec.c.

165  {
168  struct efi_autoexec_loader *loader;
169  struct image *image;
170  unsigned int i;
171  int rc;
172 
173  /* Use first applicable loader */
174  for ( i = 0 ; i < ( sizeof ( efi_autoexec_loaders ) /
175  sizeof ( efi_autoexec_loaders[0] ) ) ; i ++ ) {
176 
177  /* Locate required protocol for this loader */
178  loader = &efi_autoexec_loaders[i];
179  if ( ( rc = efi_locate_device ( device, loader->protocol,
180  &handle, 0 ) ) != 0 ) {
181  DBGC ( device, "EFI %s found no %s: %s\n",
183  efi_guid_ntoa ( loader->protocol ),
184  strerror ( rc ) );
185  continue;
186  }
187  DBGC ( device, "EFI %s found %s on ",
189  efi_guid_ntoa ( loader->protocol ) );
190  DBGC ( device, "%s\n", efi_handle_name ( handle ) );
191 
192  /* Try loading */
193  if ( ( rc = loader->load ( handle, &image ) ) != 0 )
194  return rc;
195 
196  /* Discard zero-length images */
197  if ( ! image->len ) {
198  DBGC ( device, "EFI %s discarding zero-length %s\n",
201  return -ENOENT;
202  }
203 
204  DBGC ( device, "EFI %s loaded %s (%zd bytes)\n",
206  return 0;
207  }
208 
209  return -ENOENT;
210 }
EFI_LOADED_IMAGE_PROTOCOL * efi_loaded_image
Loaded image protocol for this image.
Definition: efi_init.c:37
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
#define ENOENT
No such file or directory.
Definition: errno.h:514
An executable image.
Definition: image.h:24
EFI_GUID * protocol
Required protocol GUID.
Definition: efi_autoexec.c:54
A hardware device.
Definition: device.h:73
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:808
const char * efi_guid_ntoa(CONST EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:254
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
size_t len
Length of raw file image.
Definition: image.h:43
static struct efi_autoexec_loader efi_autoexec_loaders[]
Autoexec script loaders.
Definition: efi_autoexec.c:149
int efi_locate_device(EFI_HANDLE device, EFI_GUID *protocol, EFI_HANDLE *parent, unsigned int skip)
Locate parent device supporting a given protocol.
Definition: efi_utils.c:45
void unregister_image(struct image *image)
Unregister executable image.
Definition: image.c:303
int(* load)(EFI_HANDLE handle, struct image **image)
Load autoexec script.
Definition: efi_autoexec.c:62
uint16_t handle
Handle.
Definition: smbios.h:16
char * name
Name.
Definition: image.h:34
An EFI autoexec script loader.
Definition: efi_autoexec.c:52
Definition: efi.h:59
EFI_HANDLE DeviceHandle
The device handle that the EFI Image was loaded from.
Definition: LoadedImage.h:55

References DBGC, EFI_LOADED_IMAGE_PROTOCOL::DeviceHandle, efi_autoexec_loaders, efi_guid_ntoa(), efi_handle_name(), efi_loaded_image, efi_locate_device(), ENOENT, handle, image::len, efi_autoexec_loader::load, image::name, efi_autoexec_loader::protocol, rc, strerror(), and unregister_image().

Referenced by efi_probe().