iPXE
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)
 FILE_SECBOOT (PERMITTED)
int efi_autoexec_load (void)
 Load autoexec script.

Detailed Description

EFI autoexec script.

Definition in file efi_autoexec.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ efi_autoexec_load()

int efi_autoexec_load ( void )
extern

Load autoexec script.

Return values
rcReturn status code

Definition at line 169 of file efi_autoexec.c.

169 {
170 EFI_HANDLE device = efi_loaded_image->DeviceHandle;
172 struct efi_autoexec_loader *loader;
173 struct image *image;
174 unsigned int i;
175 int rc;
176
177 /* Use first applicable loader */
178 for ( i = 0 ; i < ( sizeof ( efi_autoexec_loaders ) /
179 sizeof ( efi_autoexec_loaders[0] ) ) ; i ++ ) {
180
181 /* Locate required protocol for this loader */
182 loader = &efi_autoexec_loaders[i];
183 if ( ( rc = efi_locate_device ( device, loader->protocol,
184 &handle, 0 ) ) != 0 ) {
185 DBGC ( device, "EFI %s found no %s: %s\n",
187 efi_guid_ntoa ( loader->protocol ),
188 strerror ( rc ) );
189 continue;
190 }
191 DBGC ( device, "EFI %s found %s on ",
193 efi_guid_ntoa ( loader->protocol ) );
194 DBGC ( device, "%s\n", efi_handle_name ( handle ) );
195
196 /* Try loading */
197 if ( ( rc = loader->load ( handle, &image ) ) != 0 )
198 return rc;
199
200 /* Discard zero-length images */
201 if ( ! image->len ) {
202 DBGC ( device, "EFI %s discarding zero-length %s\n",
205 return -ENOENT;
206 }
207
208 DBGC ( device, "EFI %s loaded %s (%zd bytes)\n",
210 return 0;
211 }
212
213 return -ENOENT;
214}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
static struct efi_autoexec_loader efi_autoexec_loaders[]
Autoexec script loaders.
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition efi_debug.c:652
const char * efi_guid_ntoa(CONST EFI_GUID *guid)
Convert GUID to a printable string.
Definition efi_guid.c:726
EFI_LOADED_IMAGE_PROTOCOL * efi_loaded_image
Loaded image protocol for this image.
Definition efi_init.c:39
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:46
#define DBGC(...)
Definition compiler.h:505
#define ENOENT
No such file or directory.
Definition errno.h:515
void unregister_image(struct image *image)
Unregister executable image.
Definition image.c:358
#define EFI_HANDLE
Definition efi.h:53
uint16_t handle
Handle.
Definition smbios.h:5
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
A hardware device.
Definition device.h:77
An EFI autoexec script loader.
EFI_GUID * protocol
Required protocol GUID.
int(* load)(EFI_HANDLE handle, struct image **image)
Load autoexec script.
An executable image.
Definition image.h:24
char * name
Name.
Definition image.h:38
size_t len
Length of raw file image.
Definition image.h:56

References DBGC, efi_autoexec_loaders, efi_guid_ntoa(), EFI_HANDLE, 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().