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 168 of file efi_autoexec.c.

168  {
171  struct efi_autoexec_loader *loader;
172  struct image *image;
173  unsigned int i;
174  int rc;
175 
176  /* Use first applicable loader */
177  for ( i = 0 ; i < ( sizeof ( efi_autoexec_loaders ) /
178  sizeof ( efi_autoexec_loaders[0] ) ) ; i ++ ) {
179 
180  /* Locate required protocol for this loader */
181  loader = &efi_autoexec_loaders[i];
182  if ( ( rc = efi_locate_device ( device, loader->protocol,
183  &handle, 0 ) ) != 0 ) {
184  DBGC ( device, "EFI %s found no %s: %s\n",
186  efi_guid_ntoa ( loader->protocol ),
187  strerror ( rc ) );
188  continue;
189  }
190  DBGC ( device, "EFI %s found %s on ",
192  efi_guid_ntoa ( loader->protocol ) );
193  DBGC ( device, "%s\n", efi_handle_name ( handle ) );
194 
195  /* Try loading */
196  if ( ( rc = loader->load ( handle, &image ) ) != 0 )
197  return rc;
198 
199  /* Discard zero-length images */
200  if ( ! image->len ) {
201  DBGC ( device, "EFI %s discarding zero-length %s\n",
204  return -ENOENT;
205  }
206 
207  DBGC ( device, "EFI %s loaded %s (%zd bytes)\n",
209  return 0;
210  }
211 
212  return -ENOENT;
213 }
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:57
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:810
const char * efi_guid_ntoa(CONST EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:256
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:152
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:322
int(* load)(EFI_HANDLE handle, struct image **image)
Load autoexec script.
Definition: efi_autoexec.c:65
uint16_t handle
Handle.
Definition: smbios.h:16
char * name
Name.
Definition: image.h:34
An EFI autoexec script loader.
Definition: efi_autoexec.c:55
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().