UEFI subsystem
Lauching UEFI images
Bootefi command
The bootefi command is used to start UEFI applications or to install UEFI drivers. It takes two parameters
bootefi <image address> [fdt address]
image address - the memory address of the UEFI binary
fdt address - the memory address of the flattened device tree
The environment variable ‘bootargs’ is passed as load options in the UEFI system table. The Linux kernel EFI stub uses the load options as command line arguments.
-
efi_status_tbootefi_test_prepare(structefi_loaded_image_obj**image_objp, structefi_loaded_image**loaded_image_infop, constchar*path, constchar*load_options_path)
prepare to run an EFI test
Parameters
struct efi_loaded_image_obj **image_objppointer to be set to the loaded image handle
struct efi_loaded_image **loaded_image_infoppointer to be set to the loaded image protocol
const char *pathdummy file path used to construct the device path set in the loaded image protocol
const char *load_options_pathname of a U-Boot environment variable. Its value is set as load options in the loaded image protocol.
Description
Prepare to run a test as if it were provided by a loaded image.
Return
status code
-
intdo_efi_selftest(void)
execute EFI selftest
Parameters
voidno arguments
Return
status code
-
intdo_bootefi(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
execute bootefi command
Parameters
struct cmd_tbl *cmdtptable entry describing command
int flagbitmap indicating how the command was invoked
int argcnumber of arguments
char *const argv[]command line arguments
Return
status code
Boot manager
The UEFI specification foresees to define boot entries and boot sequence via UEFI variables. Booting according to these variables is possible via
bootefi bootmgr [fdt address]
fdt address - the memory address of the flattened device tree
The relevant variables are:
Boot0000-BootFFFF define boot entries
BootNext specifies next boot option to be booted
BootOrder specifies in which sequence the boot options shall be tried if BootNext is not defined or booting via BootNext fails
-
structuridp_context
uri device path resource
Definition
struct uridp_context {
ulong image_size;
ulong image_addr;
struct efi_device_path *loaded_dp;
struct udevice *ramdisk_blk_dev;
efi_handle_t mem_handle;
};
Members
image_sizeimage size
image_addrimage address
loaded_dppointer to loaded device path
ramdisk_blk_devpointer to the ramdisk blk device
mem_handleefi_handle to the loaded PE-COFF image
-
structefi_device_path*expand_media_path(structefi_device_path*device_path)
expand a device path for default file name
Parameters
struct efi_device_path *device_pathdevice path to check against
Description
If device_path is a media or disk partition which houses a file system, this function returns a full device path which contains an architecture-specific default file name for removable media.
Return
a newly allocated device path
-
efi_status_ttry_load_from_file_path(efi_handle_t*fs_handles, efi_uintn_tnum, structefi_device_path*fp, efi_handle_t*handle, boolremovable)
try to load a file
Parameters
efi_handle_t *fs_handlesarray of handles with the simple file protocol
efi_uintn_t numnumber of handles in fs_handles
struct efi_device_path *fpfile path to open
efi_handle_t *handleon return pointer to handle for loaded image
bool removableif true only consider removable media, else only non-removable
Description
Given a file media path iterate through a list of handles and try to to load the file from each of them until the first success.
-
efi_status_ttry_load_from_short_path(structefi_device_path*fp, efi_handle_t*handle)
Parameters
struct efi_device_path *fpfile path
efi_handle_t *handlepointer to handle for newly installed image
Description
Enumerate all the devices which support file system operations, prepend its media device path to the file path, fp, and try to load the file. This function should be called when handling a short-form path which is starting with a file device path.
Return
status code
Parameters
u16 *lo_labelu16 label string of load option
ulong addrimage address
ulong sizeimage size
Return
pointer to the UCLASS_BLK udevice, NULL if failed
-
efi_status_tsearch_default_file(structudevice *dev, structefi_device_path**loaded_dp)
search default file
Parameters
struct udevice *devpointer to the UCLASS_BLK or UCLASS_PARTITION udevice
struct efi_device_path **loaded_dppointer to default file device path
Return
status code
-
efi_status_tfill_default_file_path(structudevice *blk, structefi_device_path**dp)
get fallback boot device path for block device
Parameters
struct udevice *blkpointer to the UCLASS_BLK udevice
struct efi_device_path **dppointer to store the fallback boot device path
Description
Provide the device path to the fallback UEFI boot file, e.g. EFI/BOOT/BOOTAA64.EFI if that file exists on the block device blk.
Return
status code
-
efi_status_tprepare_loaded_image(u16*label, ulongaddr, ulongsize, structefi_device_path**dp, structudevice **blk)
prepare ramdisk for downloaded image
Parameters
u16 *labellabel of load option
ulong addrimage address
ulong sizeimage size
struct efi_device_path **dppointer to default file device path
struct udevice **blkpointer to created blk udevice
Return
status code
Description
This function handles device creation internally and performs cleanup on error paths.
-
efi_status_tefi_bootmgr_release_uridp(structuridp_context *ctx)
cleanup uri device path resource
Parameters
struct uridp_context *ctxevent context
Return
status code
-
voidEFIAPIefi_bootmgr_http_return(structefi_event*event, void*context)
return to efibootmgr callback
Parameters
struct efi_event *eventthe event for which this notification function is registered
void *contextevent context
-
efi_status_ttry_load_from_uri_path(structefi_device_path_uri*uridp, u16*lo_label, efi_handle_t*handle)
Handle the URI device path
Parameters
struct efi_device_path_uri *uridpuri device path
u16 *lo_labellabel of load option
efi_handle_t *handlepointer to handle for newly installed image
Return
status code
-
efi_status_ttry_load_from_media(structefi_device_path*file_path, efi_handle_t*handle_img)
load file from media
Parameters
struct efi_device_path *file_pathfile path
efi_handle_t *handle_imgon return handle for the newly installed image
Description
If file_path contains a file name, load the file. If file_path does not have a file name, search the architecture-specific fallback boot file and load it. TODO: If the FilePathList[0] device does not support EFI_SIMPLE_FILE_SYSTEM_PROTOCOL but supports EFI_BLOCK_IO_PROTOCOL, call EFI_BOOT_SERVICES.ConnectController() TODO: FilePathList[0] device supports the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL not based on EFI_BLOCK_IO_PROTOCOL
Return
status code
-
efi_status_ttry_load_entry(u16n, efi_handle_t*handle, void**load_options)
try to load image for boot option
Parameters
u16 nnumber of the boot option, e.g. 0x0a13 for Boot0A13
efi_handle_t *handleon return handle for the newly installed image
void **load_optionsload options set on the loaded image protocol
Description
Attempt to load load-option number ‘n’, returning device_path and file_path if successful. This checks that the EFI_LOAD_OPTION is active (enabled) and that the specified file to boot exists.
Return
status code
-
efi_status_tefi_bootmgr_load(efi_handle_t*handle, void**load_options)
try to load from BootNext or BootOrder
Parameters
efi_handle_t *handleon return handle for the newly installed image
void **load_optionsload options set on the loaded image protocol
Description
Attempt to load from BootNext or in the order specified by BootOrder EFI variable, the available load-options, finding and returning the first one that can be loaded successfully.
Return
status code
-
efi_status_tefi_bootmgr_enumerate_boot_options(structeficonfig_media_boot_option*opt, efi_uintn_tindex, efi_handle_t*handles, efi_uintn_t*count, boolremovable)
enumerate the possible bootable media
Parameters
struct eficonfig_media_boot_option *optpointer to the media boot option structure
efi_uintn_t indexindex of the opt array to store the boot option
efi_handle_t *handlespointer to block device handles
efi_uintn_t *countOn entry number of handles to block devices. On exit number of boot options.
bool removableflag to parse removable only
Return
status code
-
efi_status_tefi_bootmgr_delete_invalid_boot_option(structeficonfig_media_boot_option*opt, efi_status_tcount)
delete non-existing boot option
Parameters
struct eficonfig_media_boot_option *optpointer to the media boot option structure
efi_status_t countnumber of media boot option structure
Return
status code
-
efi_status_tefi_bootmgr_get_unused_bootoption(u16*buf, efi_uintn_tbuf_size, unsignedint*index)
get unused "Boot####" index
Parameters
u16 *bufpointer to the buffer to store boot option variable name
efi_uintn_t buf_sizebuffer size
unsigned int *indexpointer to store the index in the BootOrder variable
Return
status code
-
efi_status_tefi_bootmgr_append_bootorder(u16index)
append new boot option in BootOrder variable
Parameters
u16 index"Boot####" index to append to BootOrder variable
Return
status code
-
efi_status_tefi_bootmgr_delete_boot_option(u16boot_index)
delete selected boot option
Parameters
u16 boot_indexboot option index to delete
Return
status code
-
efi_status_tefi_bootmgr_update_media_device_boot_option(void)
generate the media device boot option
Parameters
voidno arguments
Description
This function enumerates all BlockIo devices and add the boot option for it. This function also provide the BOOT#### variable maintenance for the media device entries. - Automatically create the BOOT#### variable for the newly detected device, this BOOT#### variable is distinguished by the special GUID stored in the EFI_LOAD_OPTION.optional_data - If the device is not attached to the system, the associated BOOT#### variable is automatically deleted.
Return
status code
-
efi_status_tload_fdt_from_load_option(void**fdt)
load device-tree from load option
Parameters
void **fdtpointer to loaded device-tree or NULL
Return
status code
-
efi_status_tefi_bootmgr_run(void*fdt)
execute EFI boot manager
Parameters
void *fdtFlat device tree
Description
Invoke EFI boot manager and execute a binary depending on boot options. If fdt is not NULL, it will be passed to the executed binary.
Return
status code
Efidebug command
The efidebug command is used to set and display boot options as well as to display information about internal data of the UEFI subsystem (devices, drivers, handles, loaded images, and the memory map).
-
intdo_efi_capsule_update(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
process a capsule update
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char * const argv[]Argument array
Return
CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "capsule update" sub-command. process a capsule update.
efidebug capsule update [-v] <capsule address>
-
intdo_efi_capsule_show(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
show capsule information
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char * const argv[]Argument array
Return
CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "capsule show" sub-command. show capsule information.
efidebug capsule show <capsule address>
-
intdo_efi_capsule_esrt(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
manage UEFI capsules
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char * const argv[]Argument array
Return
- CMD_RET_SUCCESS on success,
CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "capsule esrt" sub-command. The prints the current ESRT table.
efidebug capsule esrt
-
intdo_efi_capsule_res(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
show a capsule update result
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char * const argv[]Argument array
Return
CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "capsule result" sub-command. show a capsule update result. If result number is not specified, CapsuleLast will be shown.
efidebug capsule result [<capsule result number>]
-
intdo_efi_capsule(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
manage UEFI capsules
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char * const argv[]Argument array
Return
- CMD_RET_SUCCESS on success,
CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "capsule" sub-command.
-
intefi_get_driver_handle_info(efi_handle_thandle, u16**driver_name, u16**image_path)
get information of UEFI driver
Parameters
efi_handle_t handleHandle of UEFI device
u16 **driver_nameDriver name
u16 **image_pathPointer to text of device path
Return
0 on success, -1 on failure
Description
Currently return no useful information as all UEFI drivers are built-in..
-
intdo_efi_show_drivers(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
show UEFI drivers
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char *const argv[]Argument array
Return
CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "drivers" sub-command. Show all UEFI drivers and their information.
-
intdo_efi_show_handles(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
show UEFI handles
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char *const argv[]Argument array
Return
CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "dh" sub-command. Show all UEFI handles and their information, currently all protocols added to handle.
-
intdo_efi_show_images(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
show UEFI images
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char *const argv[]Argument array
Return
CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "images" sub-command. Show all UEFI loaded images and their information.
-
intdo_efi_show_defaults(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
show UEFI default filename and PXE architecture
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char *const argv[]Argument array
Return
CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "defaults" sub-command. Shows the default EFI filename and PXE architecture
-
voidprint_memory_attributes(u64attributes)
print memory map attributes
Parameters
u64 attributesAttribute value
Description
Print memory map attributes
-
intdo_efi_show_memmap(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
show UEFI memory map
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char *const argv[]Argument array
Return
CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "memmap" sub-command. Show UEFI memory map.
-
intdo_efi_show_tables(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
show UEFI configuration tables
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char *const argv[]Argument array
Return
CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "tables" sub-command. Show UEFI configuration tables.
-
enumefi_lo_dp_part
part of device path in load option
Constants
EFI_LO_DP_PART_BINARYbinary
EFI_LO_DP_PART_INITRDinitial RAM disk
EFI_LP_DP_PART_FDTdevice-tree
-
structefi_device_path*create_lo_dp_part(constchar*dev, constchar*part, constchar*file, boolshortform, enumefi_lo_dp_part type)
create a special device path for our Boot### option
Parameters
const char *devdevice
const char *partdisk partition
const char *filefilename
bool shortformcreate short form device path
enum efi_lo_dp_part typepart of device path to be created
Return
pointer to the device path or ERR_PTR
-
intefi_boot_add_uri(intargc, char*constargv[], u16*var_name16, size_tvar_name16_size, structefi_load_option*lo, structefi_device_path**file_path, efi_uintn_t*fp_size)
set URI load option
Parameters
int argcNumber of arguments
char *const argv[]Argument array
u16 *var_name16variable name buffer
size_t var_name16_sizevariable name buffer size
struct efi_load_option *lopointer to the load option
struct efi_device_path **file_pathbuffer to set the generated device path pointer
efi_uintn_t *fp_sizefile_path size
Return
- CMD_RET_SUCCESS on success,
CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure
-
intdo_efi_boot_add(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
set UEFI load option
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char *const argv[]Argument array
Return
- CMD_RET_SUCCESS on success,
CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "boot add" sub-command. Create or change UEFI load option.
- efidebug boot add -b <id> <label> <interface> <devnum>[:<part>] <file>
-i <file> <interface2> <devnum2>[:<part>] <initrd> -s ‘<options>’
-
intdo_efi_boot_rm(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
delete UEFI load options
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char *const argv[]Argument array
Return
CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "boot rm" sub-command. Delete UEFI load options.
efidebug boot rm <id> ...
-
voidshow_efi_boot_opt_data(u16*varname16, void*data, size_t*size)
dump UEFI load option
Parameters
u16 *varname16variable name
void *datavalue of UEFI load option variable
size_t *sizesize of the boot option
Description
Decode the value of UEFI load option variable and print information.
-
voidshow_efi_boot_opt(u16*varname16)
dump UEFI load option
Parameters
u16 *varname16variable name
Description
Dump information defined by UEFI load option.
-
intdo_efi_boot_dump(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
dump all UEFI load options
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char *const argv[]Argument array
Return
CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "boot dump" sub-command. Dump information of all UEFI load options defined.
efidebug boot dump
-
intshow_efi_boot_order(void)
show order of UEFI load options
Parameters
voidno arguments
Return
CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
Description
Show order of UEFI load options defined by BootOrder variable.
-
intdo_efi_boot_next(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
manage UEFI BootNext variable
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char *const argv[]Argument array
Return
- CMD_RET_SUCCESS on success,
CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "boot next" sub-command. Set BootNext variable.
efidebug boot next <id>
-
intdo_efi_boot_order(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
manage UEFI BootOrder variable
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char *const argv[]Argument array
Return
CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "boot order" sub-command. Show order of UEFI load options, or change it in BootOrder variable.
efidebug boot order [<id> ...]
-
intdo_efi_boot_opt(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
manage UEFI load options
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char *const argv[]Argument array
Return
- CMD_RET_SUCCESS on success,
CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "boot" sub-command.
-
__maybe_unusedintdo_efi_test_bootmgr(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
run simple bootmgr for test
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char * const argv[]Argument array
Return
- CMD_RET_SUCCESS on success,
CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "test bootmgr" sub-command. Run simple bootmgr for test.
efidebug test bootmgr
-
intdo_efi_test(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
manage UEFI load options
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char * const argv[]Argument array
Return
- CMD_RET_SUCCESS on success,
CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure
Description
Implement efidebug "test" sub-command.
-
intdo_efi_query_info(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
QueryVariableInfo EFI service
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char * const argv[]Argument array
Return
- CMD_RET_SUCCESS on success,
CMD_RET_USAGE or CMD_RET_FAILURE on failure
Description
Implement efidebug "test" sub-command.
-
intdo_efidebug(structcmd_tbl*cmdtp, intflag, intargc, char*constargv[])
display and configure UEFI environment
Parameters
struct cmd_tbl *cmdtpCommand table
int flagCommand flag
int argcNumber of arguments
char *const argv[]Argument array
Return
- CMD_RET_SUCCESS on success,
CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure
Description
Implement efidebug command which allows us to display and configure UEFI environment.
Initialization of the UEFI sub-system
-
efi_status_tefi_init_platform_lang(void)
define supported languages
Parameters
voidno arguments
Description
Set the PlatformLangCodes and PlatformLang variables.
Return
status code
-
efi_status_tefi_init_secure_boot(void)
initialize secure boot state
Parameters
voidno arguments
Return
status code
-
efi_status_tefi_init_capsule(void)
initialize capsule update state
Parameters
voidno arguments
Return
status code
-
efi_status_tefi_init_os_indications(void)
indicate supported features for OS requests
Parameters
voidno arguments
Description
Set the OsIndicationsSupported variable.
Return
status code
-
intefi_init_early(void)
handle initialization at early stage
Parameters
voidno arguments
Description
expected to be called in board_init_r().
Return
status code
-
efi_status_tefi_start_obj_list(void)
Start EFI object list
Parameters
voidno arguments
Return
status code
-
efi_status_tefi_init_obj_list(void)
Initialize and populate EFI object list
Parameters
voidno arguments
Return
status code
Boot services
-
voidefi_save_gd(void)
save global data register
Parameters
voidno arguments
Description
On the ARM and RISC-V architectures gd is mapped to a fixed register. As this register may be overwritten by an EFI payload we save it here and restore it on every callback entered.
This function is called after relocation from initr_reloc_global_data().
-
voidefi_restore_gd(void)
restore global data register
Parameters
voidno arguments
Description
On the ARM and RISC-V architectures gd is mapped to a fixed register. Restore it after returning from the UEFI world to the value saved via efi_save_gd().
-
constchar*indent_string(intlevel)
returns a string for indenting with two spaces per level
Parameters
int levelindent level
Description
A maximum of ten indent levels is supported. Higher indent levels will be truncated.
Return
- A string for indenting with two spaces per level is
returned.
-
boolefi_event_is_queued(structefi_event*event)
check if an event is queued
Parameters
struct efi_event *eventevent
Return
true if event is queued
-
efi_status_tefi_purge_handle(efi_handle_thandle)
Clean the deleted handle from the various lists
Parameters
efi_handle_t handlehandle to remove
Return
status code
-
voidefi_process_event_queue(void)
process event queue
Parameters
voidno arguments
-
voidefi_queue_event(structefi_event*event)
queue an EFI event
Parameters
struct efi_event *eventevent to signal
Description
This function queues the notification function of the event for future execution.
-
efi_status_tis_valid_tpl(efi_uintn_ttpl)
check if the task priority level is valid
Parameters
efi_uintn_t tplTPL level to check
Return
status code
-
voidefi_signal_event(structefi_event*event)
signal an EFI event
Parameters
struct efi_event *eventevent to signal
Description
This function signals an event. If the event belongs to an event group, all events of the group are signaled. If they are of type EVT_NOTIFY_SIGNAL, their notification function is queued.
For the SignalEvent service see efi_signal_event_ext.
-
unsignedlongEFIAPIefi_raise_tpl(efi_uintn_tnew_tpl)
raise the task priority level
Parameters
efi_uintn_t new_tplnew value of the task priority level
Description
This function implements the RaiseTpl service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
old value of the task priority level
-
voidEFIAPIefi_restore_tpl(efi_uintn_told_tpl)
lower the task priority level
Parameters
efi_uintn_t old_tplvalue of the task priority level to be restored
Description
This function implements the RestoreTpl service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
-
efi_status_tEFIAPIefi_allocate_pages_ext(inttype, intmemory_type, efi_uintn_tpages, uint64_t*memory)
allocate memory pages
Parameters
int typetype of allocation to be performed
int memory_typeusage type of the allocated memory
efi_uintn_t pagesnumber of pages to be allocated
uint64_t *memoryallocated memory
Description
This function implements the AllocatePages service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_free_pages_ext(uint64_tmemory, efi_uintn_tpages)
Free memory pages.
Parameters
uint64_t memorystart of the memory area to be freed
efi_uintn_t pagesnumber of pages to be freed
Description
This function implements the FreePages service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_get_memory_map_ext(efi_uintn_t*memory_map_size, structefi_mem_desc*memory_map, efi_uintn_t*map_key, efi_uintn_t*descriptor_size, uint32_t*descriptor_version)
get map describing memory usage
Parameters
efi_uintn_t *memory_map_sizeon entry the size, in bytes, of the memory map buffer, on exit the size of the copied memory map
struct efi_mem_desc *memory_mapbuffer to which the memory map is written
efi_uintn_t *map_keykey for the memory map
efi_uintn_t *descriptor_sizesize of an individual memory descriptor
uint32_t *descriptor_versionversion number of the memory descriptor structure
Description
This function implements the GetMemoryMap service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_allocate_pool_ext(intpool_type, efi_uintn_tsize, void**buffer)
allocate memory from pool
Parameters
int pool_typetype of the pool from which memory is to be allocated
efi_uintn_t sizenumber of bytes to be allocated
void **bufferallocated memory
Description
This function implements the AllocatePool service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_free_pool_ext(void*buffer)
free memory from pool
Parameters
void *bufferstart of memory to be freed
Description
This function implements the FreePool service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
voidefi_add_handle(efi_handle_thandle)
add a new handle to the object list
Parameters
efi_handle_t handlehandle to be added
Description
The protocols list is initialized. The handle is added to the list of known UEFI objects.
-
efi_status_tefi_create_handle(efi_handle_t*handle)
create handle
Parameters
efi_handle_t *handlenew handle
Return
status code
-
efi_status_tefi_search_protocol(constefi_handle_thandle, constefi_guid_t*protocol_guid, structefi_handler**handler)
find a protocol on a handle.
Parameters
const efi_handle_t handlehandle
const efi_guid_t *protocol_guidGUID of the protocol
struct efi_handler **handlerreference to the protocol
Return
status code
-
efi_status_tefi_remove_protocol(constefi_handle_thandle, constefi_guid_t*protocol, void*protocol_interface)
delete protocol from a handle
Parameters
const efi_handle_t handlehandle from which the protocol shall be deleted
const efi_guid_t *protocolGUID of the protocol to be deleted
void *protocol_interfaceinterface of the protocol implementation
Return
status code
-
efi_status_tefi_remove_all_protocols(constefi_handle_thandle)
delete all protocols from a handle
Parameters
const efi_handle_t handlehandle from which the protocols shall be deleted
Return
status code
-
efi_status_tefi_delete_handle(efi_handle_thandle)
delete handle
Parameters
efi_handle_t handlehandle to delete
Return
status code
-
efi_status_tefi_is_event(conststructefi_event*event)
check if a pointer is a valid event
Parameters
const struct efi_event *eventpointer to check
Return
status code
-
efi_status_tefi_create_event(uint32_ttype, efi_uintn_tnotify_tpl, void(*notify_function)(structefi_event*event,void*context), void*notify_context, constefi_guid_t*group, structefi_event**event)
create an event
Parameters
uint32_t typetype of the event to create
efi_uintn_t notify_tpltask priority level of the event
void ( *notify_function) ( struct efi_event *event, void *context)notification function of the event
void *notify_contextpointer passed to the notification function
const efi_guid_t *groupevent group
struct efi_event **eventcreated event
Description
This function is used inside U-Boot code to create an event.
For the API function implementing the CreateEvent service see efi_create_event_ext.
Return
status code
-
efi_status_tEFIAPIefi_create_event_ext(uint32_ttype, efi_uintn_tnotify_tpl, void(*notify_function)(structefi_event*event,void*context), void*notify_context, structefi_event**event)
create an event
Parameters
uint32_t typetype of the event to create
efi_uintn_t notify_tpltask priority level of the event
void ( *notify_function) ( struct efi_event *event, void *context)notification function of the event
void *notify_contextpointer passed to the notification function
struct efi_event **eventcreated event
Description
This function implements the CreateEvent service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
voidefi_timer_check(void)
check if a timer event has occurred
Parameters
voidno arguments
Description
Check if a timer event has occurred or a queued notification function should be called.
Our timers have to work without interrupts, so we check whenever keyboard input or disk accesses happen if enough time elapsed for them to fire.
-
efi_status_tefi_set_timer(structefi_event*event, enumefi_timer_delaytype, uint64_ttrigger_time)
set the trigger time for a timer event or stop the event
Parameters
struct efi_event *eventevent for which the timer is set
enum efi_timer_delay typetype of the timer
uint64_t trigger_timetrigger period in multiples of 100 ns
Description
This is the function for internal usage in U-Boot. For the API function implementing the SetTimer service see efi_set_timer_ext.
Return
status code
-
efi_status_tEFIAPIefi_set_timer_ext(structefi_event*event, enumefi_timer_delaytype, uint64_ttrigger_time)
Set the trigger time for a timer event or stop the event
Parameters
struct efi_event *eventevent for which the timer is set
enum efi_timer_delay typetype of the timer
uint64_t trigger_timetrigger period in multiples of 100 ns
Description
This function implements the SetTimer service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_wait_for_event(efi_uintn_tnum_events, structefi_event**event, efi_uintn_t*index)
wait for events to be signaled
Parameters
efi_uintn_t num_eventsnumber of events to be waited for
struct efi_event **eventevents to be waited for
efi_uintn_t *indexindex of the event that was signaled
Description
This function implements the WaitForEvent service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_signal_event_ext(structefi_event*event)
signal an EFI event
Parameters
struct efi_event *eventevent to signal
Description
This function implements the SignalEvent service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
This functions sets the signaled state of the event and queues the notification function for execution.
Return
status code
-
efi_status_tEFIAPIefi_close_event(structefi_event*event)
close an EFI event
Parameters
struct efi_event *eventevent to close
Description
This function implements the CloseEvent service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_check_event(structefi_event*event)
check if an event is signaled
Parameters
struct efi_event *eventevent to check
Description
This function implements the CheckEvent service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
If an event is not signaled yet, the notification function is queued. The signaled state is cleared.
Return
status code
-
structefi_object*efi_search_obj(constefi_handle_thandle)
find the internal EFI object for a handle
Parameters
const efi_handle_t handlehandle to find
Return
EFI object
-
structefi_open_protocol_info_entry*efi_create_open_info(structefi_handler*handler)
create open protocol info entry and add it to a protocol
Parameters
struct efi_handler *handlerhandler of a protocol
Return
open protocol info entry
-
efi_status_tefi_delete_open_info(structefi_open_protocol_info_item*item)
remove an open protocol info entry from a protocol
Parameters
struct efi_open_protocol_info_item *itemopen protocol info entry to delete
Return
status code
-
efi_status_tefi_add_protocol(constefi_handle_thandle, constefi_guid_t*protocol, void*protocol_interface)
install new protocol on a handle
Parameters
const efi_handle_t handlehandle on which the protocol shall be installed
const efi_guid_t *protocolGUID of the protocol to be installed
void *protocol_interfaceinterface of the protocol implementation
Return
status code
-
efi_status_tEFIAPIefi_install_protocol_interface(efi_handle_t*handle, constefi_guid_t*protocol, intprotocol_interface_type, void*protocol_interface)
install protocol interface
Parameters
efi_handle_t *handlehandle on which the protocol shall be installed
const efi_guid_t *protocolGUID of the protocol to be installed
int protocol_interface_typetype of the interface to be installed, always EFI_NATIVE_INTERFACE
void *protocol_interfaceinterface of the protocol implementation
Description
This function implements the InstallProtocolInterface service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tefi_get_drivers(efi_handle_thandle, constefi_guid_t*protocol, efi_uintn_t*number_of_drivers, efi_handle_t**driver_handle_buffer)
get all drivers associated to a controller
Parameters
efi_handle_t handlehandle of the controller
const efi_guid_t *protocolprotocol GUID (optional)
efi_uintn_t *number_of_driversnumber of child controllers
efi_handle_t **driver_handle_bufferhandles of the the drivers
Description
The allocated buffer has to be freed with free().
Return
status code
-
efi_status_tefi_disconnect_all_drivers(efi_handle_thandle, constefi_guid_t*protocol, efi_handle_tchild_handle)
disconnect all drivers from a controller
Parameters
efi_handle_t handlehandle of the controller
const efi_guid_t *protocolprotocol GUID (optional)
efi_handle_t child_handlehandle of the child to destroy
Description
This function implements the DisconnectController service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tefi_uninstall_protocol(efi_handle_thandle, constefi_guid_t*protocol, void*protocol_interface, boolpreserve)
uninstall protocol interface
Parameters
efi_handle_t handlehandle from which the protocol shall be removed
const efi_guid_t *protocolGUID of the protocol to be removed
void *protocol_interfaceinterface to be removed
bool preservepreserve or delete the handle and remove it from any list it participates if no protocols remain
Description
This function DOES NOT delete a handle without installed protocol.
Return
status code
-
efi_status_tEFIAPIefi_uninstall_protocol_interface(efi_handle_thandle, constefi_guid_t*protocol, void*protocol_interface)
uninstall protocol interface
Parameters
efi_handle_t handlehandle from which the protocol shall be removed
const efi_guid_t *protocolGUID of the protocol to be removed
void *protocol_interfaceinterface to be removed
Description
This function implements the UninstallProtocolInterface service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_register_protocol_notify(constefi_guid_t*protocol, structefi_event*event, void**registration)
register an event for notification when a protocol is installed.
Parameters
const efi_guid_t *protocolGUID of the protocol whose installation shall be notified
struct efi_event *eventevent to be signaled upon installation of the protocol
void **registrationkey for retrieving the registration information
Description
This function implements the RegisterProtocolNotify service. See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
intefi_search(enumefi_locate_search_typesearch_type, constefi_guid_t*protocol, efi_handle_thandle)
determine if an EFI handle implements a protocol
Parameters
enum efi_locate_search_type search_typeselection criterion
const efi_guid_t *protocolGUID of the protocol
efi_handle_t handlehandle
Description
See the documentation of the LocateHandle service in the UEFI specification.
Return
0 if the handle implements the protocol
-
structefi_register_notify_event*efi_check_register_notify_event(void*key)
check if registration key is valid
Parameters
void *keyregistration key
Description
Check that a pointer is a valid registration key as returned by RegisterProtocolNotify().
Return
valid registration key or NULL
-
efi_status_tefi_locate_handle(enumefi_locate_search_typesearch_type, constefi_guid_t*protocol, void*search_key, efi_uintn_t*buffer_size, efi_handle_t*buffer)
locate handles implementing a protocol
Parameters
enum efi_locate_search_type search_typeselection criterion
const efi_guid_t *protocolGUID of the protocol
void *search_keyregistration key
efi_uintn_t *buffer_sizesize of the buffer to receive the handles in bytes
efi_handle_t *bufferbuffer to receive the relevant handles
Description
This function is meant for U-Boot internal calls. For the API implementation of the LocateHandle service see efi_locate_handle_ext.
Return
status code
-
efi_status_tEFIAPIefi_locate_handle_ext(enumefi_locate_search_typesearch_type, constefi_guid_t*protocol, void*search_key, efi_uintn_t*buffer_size, efi_handle_t*buffer)
locate handles implementing a protocol.
Parameters
enum efi_locate_search_type search_typeselection criterion
const efi_guid_t *protocolGUID of the protocol
void *search_keyregistration key
efi_uintn_t *buffer_sizesize of the buffer to receive the handles in bytes
efi_handle_t *bufferbuffer to receive the relevant handles
Description
This function implements the LocateHandle service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
0 if the handle implements the protocol
-
voidefi_remove_configuration_table(inti)
collapses configuration table entries, removing index i
Parameters
int iindex of the table entry to be removed
-
efi_status_tefi_install_configuration_table(constefi_guid_t*guid, void*table)
adds, updates, or removes a configuration table
Parameters
const efi_guid_t *guidGUID of the installed table
void *tabletable to be installed
Description
This function is used for internal calls. For the API implementation of the InstallConfigurationTable service see efi_install_configuration_table_ext.
Return
status code
-
efi_status_tEFIAPIefi_install_configuration_table_ext(constefi_guid_t*guid, void*table)
Adds, updates, or removes a configuration table.
Parameters
const efi_guid_t *guidGUID of the installed table
void *tabletable to be installed
Description
This function implements the InstallConfigurationTable service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tefi_setup_loaded_image(structefi_device_path*device_path, structefi_device_path*file_path, structefi_loaded_image_obj**handle_ptr, structefi_loaded_image**info_ptr)
initialize a loaded image
Parameters
struct efi_device_path *device_pathdevice path of the loaded image
struct efi_device_path *file_pathfile path of the loaded image
struct efi_loaded_image_obj **handle_ptrhandle of the loaded image
struct efi_loaded_image **info_ptrloaded image protocol
Description
Initialize a loaded_image_info and loaded_image_info object with correct protocols, boot-device, etc.
In case of an error *handle_ptr and *info_ptr are set to NULL and an error code is returned.
Return
status code
-
efi_status_tEFIAPIefi_locate_device_path(constefi_guid_t*protocol, structefi_device_path**device_path, efi_handle_t*device)
Get the device path and handle of an device implementing a protocol
Parameters
const efi_guid_t *protocolGUID of the protocol
struct efi_device_path **device_pathdevice path
efi_handle_t *devicehandle of the device
Description
This function implements the LocateDevicePath service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tefi_load_image_from_file(structefi_device_path*file_path, void**buffer, efi_uintn_t*size)
load an image from file system
Parameters
struct efi_device_path *file_paththe path of the image to load
void **bufferbuffer containing the loaded image
efi_uintn_t *sizesize of the loaded image
Description
Read a file into a buffer allocated as EFI_BOOT_SERVICES_DATA. It is the callers obligation to update the memory type as needed.
Return
status code
-
efi_status_tefi_load_image_from_path(boolboot_policy, structefi_device_path*file_path, void**buffer, efi_uintn_t*size)
load an image using a file path
Parameters
bool boot_policytrue for request originating from the boot manager
struct efi_device_path *file_paththe path of the image to load
void **bufferbuffer containing the loaded image
efi_uintn_t *sizesize of the loaded image
Description
Read a file into a buffer allocated as EFI_BOOT_SERVICES_DATA. It is the callers obligation to update the memory type as needed.
Return
status code
-
efi_status_tEFIAPIefi_load_image(boolboot_policy, efi_handle_tparent_image, structefi_device_path*file_path, void*source_buffer, efi_uintn_tsource_size, efi_handle_t*image_handle)
load an EFI image into memory
Parameters
bool boot_policytrue for request originating from the boot manager
efi_handle_t parent_imagethe caller’s image handle
struct efi_device_path *file_paththe path of the image to load
void *source_buffermemory location from which the image is installed
efi_uintn_t source_sizesize of the memory area from which the image is installed
efi_handle_t *image_handlehandle for the newly installed image
Description
This function implements the LoadImage service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
voidefi_exit_caches(void)
fix up caches for EFI payloads if necessary
Parameters
voidno arguments
-
efi_status_tEFIAPIefi_exit_boot_services(efi_handle_timage_handle, efi_uintn_tmap_key)
stop all boot services
Parameters
efi_handle_t image_handlehandle of the loaded image
efi_uintn_t map_keykey of the memory map
Description
This function implements the ExitBootServices service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
All timer events are disabled. For exit boot services events the notification function is called. The boot services are disabled in the system table.
Return
status code
-
efi_status_tEFIAPIefi_get_next_monotonic_count(uint64_t*count)
get next value of the counter
Parameters
uint64_t *countreturned value of the counter
Description
This function implements the NextMonotonicCount service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_stall(unsignedlongmicroseconds)
sleep
Parameters
unsigned long microsecondsperiod to sleep in microseconds
Description
This function implements the Stall service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_set_watchdog_timer(unsignedlongtimeout, uint64_twatchdog_code, unsignedlongdata_size, uint16_t*watchdog_data)
reset the watchdog timer
Parameters
unsigned long timeoutseconds before reset by watchdog
uint64_t watchdog_codecode to be logged when resetting
unsigned long data_sizesize of buffer in bytes
uint16_t *watchdog_databuffer with data describing the reset reason
Description
This function implements the SetWatchdogTimer service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tefi_close_protocol(efi_handle_thandle, constefi_guid_t*protocol, efi_handle_tagent_handle, efi_handle_tcontroller_handle)
close a protocol
Parameters
efi_handle_t handlehandle on which the protocol shall be closed
const efi_guid_t *protocolGUID of the protocol to close
efi_handle_t agent_handlehandle of the driver
efi_handle_t controller_handlehandle of the controller
Description
This is the function implementing the CloseProtocol service is for internal usage in U-Boot. For API usage wrapper efi_close_protocol_ext() is provided.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_close_protocol_ext(efi_handle_thandle, constefi_guid_t*protocol, efi_handle_tagent_handle, efi_handle_tcontroller_handle)
close a protocol
Parameters
efi_handle_t handlehandle on which the protocol shall be closed
const efi_guid_t *protocolGUID of the protocol to close
efi_handle_t agent_handlehandle of the driver
efi_handle_t controller_handlehandle of the controller
Description
This function implements the CloseProtocol service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_open_protocol_information(efi_handle_thandle, constefi_guid_t*protocol, structefi_open_protocol_info_entry**entry_buffer, efi_uintn_t*entry_count)
provide information about then open status of a protocol on a handle
Parameters
efi_handle_t handlehandle for which the information shall be retrieved
const efi_guid_t *protocolGUID of the protocol
struct efi_open_protocol_info_entry **entry_bufferbuffer to receive the open protocol information
efi_uintn_t *entry_countnumber of entries available in the buffer
Description
This function implements the OpenProtocolInformation service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_protocols_per_handle(efi_handle_thandle, efi_guid_t***protocol_buffer, efi_uintn_t*protocol_buffer_count)
get protocols installed on a handle
Parameters
efi_handle_t handlehandle for which the information is retrieved
efi_guid_t ***protocol_bufferbuffer with protocol GUIDs
efi_uintn_t *protocol_buffer_countnumber of entries in the buffer
Description
This function implements the ProtocolsPerHandleService.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_locate_handle_buffer(enumefi_locate_search_typesearch_type, constefi_guid_t*protocol, void*search_key, efi_uintn_t*no_handles, efi_handle_t**buffer)
locate handles implementing a protocol
Parameters
enum efi_locate_search_type search_typeselection criterion
const efi_guid_t *protocolGUID of the protocol
void *search_keyregistration key
efi_uintn_t *no_handlesnumber of returned handles
efi_handle_t **bufferbuffer with the returned handles
Description
This function implements the LocateHandleBuffer service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_locate_protocol(constefi_guid_t*protocol, void*registration, void**protocol_interface)
find an interface implementing a protocol
Parameters
const efi_guid_t *protocolGUID of the protocol
void *registrationregistration key passed to the notification function
void **protocol_interfaceinterface implementing the protocol
Description
This function implements the LocateProtocol service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_install_multiple_protocol_interfaces_int(efi_handle_t*handle, efi_va_listargptr)
Install multiple protocol interfaces
Parameters
efi_handle_t *handlehandle on which the protocol interfaces shall be installed
efi_va_list argptrva_list of args
Description
Core functionality of efi_install_multiple_protocol_interfaces Must not be called directly
Return
status code
-
efi_status_tEFIAPIefi_install_multiple_protocol_interfaces(efi_handle_t*handle, ...)
Install multiple protocol interfaces
Parameters
efi_handle_t *handlehandle on which the protocol interfaces shall be installed
...NULL terminated argument list with pairs of protocol GUIDS and interfaces
Description
This is the function for internal usage in U-Boot. For the API function implementing the InstallMultipleProtocol service see efi_install_multiple_protocol_interfaces_ext()
Return
status code
-
efi_status_tEFIAPIefi_install_multiple_protocol_interfaces_ext(efi_handle_t*handle, ...)
Install multiple protocol interfaces
Parameters
efi_handle_t *handlehandle on which the protocol interfaces shall be installed
...NULL terminated argument list with pairs of protocol GUIDS and interfaces
Description
This function implements the MultipleProtocolInterfaces service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_uninstall_multiple_protocol_interfaces_int(efi_handle_thandle, efi_va_listargptr)
wrapper for uninstall multiple protocol interfaces
Parameters
efi_handle_t handlehandle from which the protocol interfaces shall be removed
efi_va_list argptrva_list of args
Description
Core functionality of efi_uninstall_multiple_protocol_interfaces Must not be called directly
Return
status code
-
efi_status_tEFIAPIefi_uninstall_multiple_protocol_interfaces(efi_handle_thandle, ...)
uninstall multiple protocol interfaces
Parameters
efi_handle_t handlehandle from which the protocol interfaces shall be removed
...NULL terminated argument list with pairs of protocol GUIDS and interfaces
Description
This function implements the UninstallMultipleProtocolInterfaces service.
This is the function for internal usage in U-Boot. For the API function implementing the UninstallMultipleProtocolInterfaces service see efi_uninstall_multiple_protocol_interfaces_ext()
Return
status code
-
efi_status_tEFIAPIefi_uninstall_multiple_protocol_interfaces_ext(efi_handle_thandle, ...)
uninstall multiple protocol interfaces
Parameters
efi_handle_t handlehandle from which the protocol interfaces shall be removed
...NULL terminated argument list with pairs of protocol GUIDS and interfaces
Description
This function implements the UninstallMultipleProtocolInterfaces service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_calculate_crc32(constvoid*data, efi_uintn_tdata_size, u32*crc32_p)
calculate cyclic redundancy code
Parameters
const void *databuffer with data
efi_uintn_t data_sizesize of buffer in bytes
u32 *crc32_pcyclic redundancy code
Description
This function implements the CalculateCrc32 service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
voidEFIAPIefi_copy_mem(void*destination, constvoid*source, size_tlength)
copy memory
Parameters
void *destinationdestination of the copy operation
const void *sourcesource of the copy operation
size_t lengthnumber of bytes to copy
Description
This function implements the CopyMem service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
-
voidEFIAPIefi_set_mem(void*buffer, size_tsize, uint8_tvalue)
Fill memory with a byte value.
Parameters
void *bufferbuffer to fill
size_t sizesize of buffer in bytes
uint8_t valuebyte to copy to the buffer
Description
This function implements the SetMem service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
-
efi_status_tefi_protocol_open(structefi_handler*handler, void**protocol_interface, void*agent_handle, void*controller_handle, uint32_tattributes)
open protocol interface on a handle
Parameters
struct efi_handler *handlerhandler of a protocol
void **protocol_interfaceinterface implementing the protocol
void *agent_handlehandle of the driver
void *controller_handlehandle of the controller
uint32_t attributesattributes indicating how to open the protocol
Return
status code
-
efi_status_tEFIAPIefi_open_protocol(efi_handle_thandle, constefi_guid_t*protocol, void**protocol_interface, efi_handle_tagent_handle, efi_handle_tcontroller_handle, uint32_tattributes)
open protocol interface on a handle
Parameters
efi_handle_t handlehandle on which the protocol shall be opened
const efi_guid_t *protocolGUID of the protocol
void **protocol_interfaceinterface implementing the protocol
efi_handle_t agent_handlehandle of the driver
efi_handle_t controller_handlehandle of the controller
uint32_t attributesattributes indicating how to open the protocol
Description
This function implements the OpenProtocol interface.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_start_image(efi_handle_timage_handle, efi_uintn_t*exit_data_size, u16**exit_data)
call the entry point of an image
Parameters
efi_handle_t image_handlehandle of the image
efi_uintn_t *exit_data_sizesize of the buffer
u16 **exit_databuffer to receive the exit data of the called image
Description
This function implements the StartImage service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tefi_delete_image(structefi_loaded_image_obj*image_obj, structefi_loaded_image*loaded_image_protocol)
delete loaded image from memory)
Parameters
struct efi_loaded_image_obj *image_objhandle of the loaded image
struct efi_loaded_image *loaded_image_protocolloaded image protocol
-
efi_status_tEFIAPIefi_unload_image(efi_handle_timage_handle)
unload an EFI image
Parameters
efi_handle_t image_handlehandle of the image to be unloaded
Description
This function implements the UnloadImage service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tefi_update_exit_data(structefi_loaded_image_obj*image_obj, efi_uintn_texit_data_size, u16*exit_data)
fill exit data parameters of StartImage()
Parameters
struct efi_loaded_image_obj *image_objimage handle
efi_uintn_t exit_data_sizesize of the exit data buffer
u16 *exit_databuffer with data returned by UEFI payload
Return
status code
-
efi_status_tEFIAPIefi_exit(efi_handle_timage_handle, efi_status_texit_status, efi_uintn_texit_data_size, u16*exit_data)
leave an EFI application or driver
Parameters
efi_handle_t image_handlehandle of the application or driver that is exiting
efi_status_t exit_statusstatus code
efi_uintn_t exit_data_sizesize of the buffer in bytes
u16 *exit_databuffer with data describing an error
Description
This function implements the Exit service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_handle_protocol(efi_handle_thandle, constefi_guid_t*protocol, void**protocol_interface)
get interface of a protocol on a handle
Parameters
efi_handle_t handlehandle on which the protocol shall be opened
const efi_guid_t *protocolGUID of the protocol
void **protocol_interfaceinterface implementing the protocol
Description
This function implements the HandleProtocol service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tefi_bind_controller(efi_handle_tcontroller_handle, efi_handle_tdriver_image_handle, structefi_device_path*remain_device_path)
bind a single driver to a controller
Parameters
efi_handle_t controller_handlecontroller handle
efi_handle_t driver_image_handledriver handle
struct efi_device_path *remain_device_pathremaining path
Return
status code
-
efi_status_tefi_connect_single_controller(efi_handle_tcontroller_handle, efi_handle_t*driver_image_handle, structefi_device_path*remain_device_path)
connect a single driver to a controller
Parameters
efi_handle_t controller_handlecontroller
efi_handle_t *driver_image_handledriver
struct efi_device_path *remain_device_pathremaining path
Return
status code
-
efi_status_tEFIAPIefi_connect_controller(efi_handle_tcontroller_handle, efi_handle_t*driver_image_handle, structefi_device_path*remain_device_path, boolrecursive)
connect a controller to a driver
Parameters
efi_handle_t controller_handlehandle of the controller
efi_handle_t *driver_image_handlehandle of the driver
struct efi_device_path *remain_device_pathdevice path of a child controller
bool recursivetrue to connect all child controllers
Description
This function implements the ConnectController service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
First all driver binding protocol handles are tried for binding drivers. Afterwards all handles that have opened a protocol of the controller with EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER are connected to drivers.
Return
status code
-
efi_status_tEFIAPIefi_reinstall_protocol_interface(efi_handle_thandle, constefi_guid_t*protocol, void*old_interface, void*new_interface)
reinstall protocol interface
Parameters
efi_handle_t handlehandle on which the protocol shall be reinstalled
const efi_guid_t *protocolGUID of the protocol to be installed
void *old_interfaceinterface to be removed
void *new_interfaceinterface to be installed
Description
This function implements the ReinstallProtocolInterface service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
The old interface is uninstalled. The new interface is installed. Drivers are connected.
Return
status code
-
efi_status_tefi_get_child_controllers(structefi_object*efiobj, efi_handle_tdriver_handle, efi_uintn_t*number_of_children, efi_handle_t**child_handle_buffer)
get all child controllers associated to a driver
Parameters
struct efi_object *efiobjhandle of the controller
efi_handle_t driver_handlehandle of the driver
efi_uintn_t *number_of_childrennumber of child controllers
efi_handle_t **child_handle_bufferhandles of the the child controllers
Description
The allocated buffer has to be freed with free().
Return
status code
-
efi_status_tEFIAPIefi_disconnect_controller(efi_handle_tcontroller_handle, efi_handle_tdriver_image_handle, efi_handle_tchild_handle)
disconnect a controller from a driver
Parameters
efi_handle_t controller_handlehandle of the controller
efi_handle_t driver_image_handlehandle of the driver
efi_handle_t child_handlehandle of the child to destroy
Description
This function implements the DisconnectController service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tefi_initialize_system_table(void)
Initialize system table
Parameters
voidno arguments
Return
status code
Image relocation
-
efi_status_tefi_print_image_info(structefi_loaded_image_obj*obj, structefi_loaded_image*image, void*pc)
print information about a loaded image
Parameters
struct efi_loaded_image_obj *objEFI object
struct efi_loaded_image *imageloaded image
void *pcprogram counter (use NULL to suppress offset output)
Description
If the program counter is located within the image the offset to the base address is shown.
Return
status code
-
voidefi_print_image_infos(void*pc)
print information about all loaded images
Parameters
void *pcprogram counter (use NULL to suppress offset output)
-
efi_status_tefi_loader_relocate(constIMAGE_BASE_RELOCATION*rel, unsignedlongrel_size, void*efi_reloc, unsignedlongpref_address)
relocate UEFI binary
Parameters
const IMAGE_BASE_RELOCATION *relpointer to the relocation table
unsigned long rel_sizesize of the relocation table in bytes
void *efi_relocactual load address of the image
unsigned long pref_addresspreferred load address of the image
Return
status code
-
voidefi_set_code_and_data_type(structefi_loaded_image*loaded_image_info, uint16_timage_type)
determine the memory types to be used for code and data.
Parameters
struct efi_loaded_image *loaded_image_infoimage descriptor
uint16_t image_typefield Subsystem of the optional header for Windows specific field
-
efi_status_tefi_image_region_add(structefi_image_regions*regs, constvoid*start, constvoid*end, intnocheck)
add an entry of region
Parameters
struct efi_image_regions *regsPointer to array of regions
const void *startStart address of region (included)
const void *endEnd address of region (excluded)
int nocheckflag against overlapped regions
Description
Take one entry of region [start, end[ and insert it into the list.
If nocheck is false, the list will be sorted ascending by address. Overlapping entries will not be allowed.
If nocheck is true, the list will be sorted ascending by sequence of adding the entries. Overlapping is allowed.
Return
status code
-
intcmp_pe_section(constvoid*arg1, constvoid*arg2)
compare virtual addresses of two PE image sections
Parameters
const void *arg1pointer to pointer to first section header
const void *arg2pointer to pointer to second section header
Description
Compare the virtual addresses of two sections of an portable executable. The arguments are defined as const void * to allow usage with qsort().
Return
- -1 if the virtual address of arg1 is less than that of arg2,
0 if the virtual addresses are equal, 1 if the virtual address of arg1 is greater than that of arg2.
-
void*efi_prepare_aligned_image(void*efi, u64*efi_size)
prepare 8-byte aligned image
Parameters
void *efipointer to the EFI binary
u64 *efi_sizesize of efi binary
Description
If efi is not 8-byte aligned, this function newly allocates the image buffer.
Return
valid pointer to a image, return NULL if allocation fails.
-
boolefi_image_parse(void*efi, size_tlen, structefi_image_regions**regp, WIN_CERTIFICATE**auth, size_t*auth_len)
parse a PE image
Parameters
void *efiPointer to image
size_t lenSize of efi
struct efi_image_regions **regpPointer to a list of regions
WIN_CERTIFICATE **authPointer to a pointer to authentication data in PE
size_t *auth_lenSize of auth
Description
Parse image binary in PE32(+) format, assuming that sanity of PE image has been checked by a caller. On success, an address of authentication data in efi and its size will be returned in auth and auth_len, respectively.
Return
true on success, false on error
-
boolefi_image_verify_digest(structefi_image_regions*regs, structpkcs7_message*msg)
verify image’s message digest
Parameters
struct efi_image_regions *regsArray of memory regions to digest
struct pkcs7_message *msgSignature in pkcs7 structure
Description
regs contains all the data in a PE image to digest. Calculate a hash value based on regs and compare it with a messaged digest in the content (SpcPeImageData) of msg’s contentInfo.
Return
true if verified, false if not
-
boolefi_image_authenticate(void*efi, size_tefi_size)
verify a signature of signed image
Parameters
void *efiPointer to image
size_t efi_sizeSize of efi
Description
A signed image should have its signature stored in a table of its PE header. So if an image is signed and only if if its signature is verified using signature databases, an image is authenticated. If an image is not signed, its validity is checked by using efi_image_unsigned_authenticated(). TODO: When AuditMode==0, if the image’s signature is not found in the authorized database, or is found in the forbidden database, the image will not be started and instead, information about it will be placed in this table. When AuditMode==1, an EFI_IMAGE_EXECUTION_INFO element is created in the EFI_IMAGE_EXECUTION_INFO_TABLE for every certificate found in the certificate table of every image that is validated.
Return
true if authenticated, false if not
-
efi_status_tefi_check_pe(void*buffer, size_tsize, void**nt_header)
check if a memory buffer contains a PE-COFF image
Parameters
void *bufferbuffer to check
size_t sizesize of buffer
void **nt_headeron return pointer to NT header of PE-COFF image
Return
EFI_SUCCESS if the buffer contains a PE-COFF image
-
u32section_size(IMAGE_SECTION_HEADER*sec)
determine size of section
Parameters
IMAGE_SECTION_HEADER *secsection header
Description
The size of a section in memory if normally given by VirtualSize. If VirtualSize is not provided, use SizeOfRawData.
Return
size of section in memory
-
efi_status_tefi_load_pe(structefi_loaded_image_obj*handle, void*efi, size_tefi_size, structefi_loaded_image*loaded_image_info)
relocate EFI binary
Parameters
struct efi_loaded_image_obj *handleloaded image handle
void *efipointer to the EFI binary
size_t efi_sizesize of efi binary
struct efi_loaded_image *loaded_image_infoloaded image protocol
Description
This function loads all sections from a PE binary into a newly reserved piece of memory. On success the entry point is returned as handle->entry.
Return
status code
Memory services
-
structefi_pool_allocation
memory block allocated from pool
Definition
struct efi_pool_allocation {
u64 num_pages;
u64 checksum;
char data[] ;
};
Members
num_pagesnumber of pages allocated
checksumchecksum
dataallocated pool memory
Description
U-Boot services each UEFI AllocatePool() request as a separate (multiple) page allocation. We have to track the number of pages to be able to free the correct amount later.
The checksum calculated in function checksum() is used in FreePool() to avoid freeing memory not allocated by AllocatePool() and duplicate freeing.
EFI requires 8 byte alignment for pool allocations, so we can prepend each allocation with these header fields.
-
u64checksum(structefi_pool_allocation *alloc)
calculate checksum for memory allocated from pool
Parameters
struct efi_pool_allocation *allocallocation header
Return
checksum, always non-zero
-
intefi_mem_cmp(void*priv, structlist_head*a, structlist_head*b)
comparator function for sorting memory map
Parameters
void *privunused
struct list_head *afirst memory area
struct list_head *bsecond memory area
Description
Sorts the memory list from highest address to lowest address
When allocating memory we should always start from the highest address chunk, so sort the memory list such that the first list iterator gets the highest address and goes lower from there.
Return
1 if a is before b, -1 if b is before a, 0 if equal
-
uint64_tdesc_get_end(structefi_mem_desc*desc)
get end address of memory area
Parameters
struct efi_mem_desc *descmemory descriptor
Return
end address + 1
-
voidefi_mem_sort(void)
sort memory map
Parameters
voidno arguments
Description
Sort the memory map and then try to merge adjacent memory areas.
-
s64efi_mem_carve_out(structefi_mem_list*map, structefi_mem_desc*carve_desc, booloverlap_conventional)
unmap memory region
Parameters
struct efi_mem_list *mapmemory map
struct efi_mem_desc *carve_descmemory region to unmap
bool overlap_conventionalthe carved out region may only overlap free, or conventional memory
Return
- the number of overlapping pages which have been
removed from the map, EFI_CARVE_NO_OVERLAP, if the regions don’t overlap, EFI_CARVE_OVERLAPS_NONRAM, if the carve and map overlap, and the map contains anything but free ram(only when overlap_conventional is true), EFI_CARVE_LOOP_AGAIN, if the mapping list should be traversed again, as it has been altered.
Description
Unmaps all memory occupied by the carve_desc region from the list entry pointed to by map.
In case of EFI_CARVE_OVERLAPS_NONRAM it is the callers responsibility to re-add the already carved out pages to the mapping.
-
efi_status_tefi_update_memory_map(u64start, u64pages, intmemory_type, booloverlap_conventional, boolremove)
update the memory map by adding/removing pages
Parameters
u64 startstart address, must be a multiple of EFI_PAGE_SIZE
u64 pagesnumber of pages to add
int memory_typetype of memory added
bool overlap_conventionalregion may only overlap free(conventional) memory
bool removeremove memory map
Return
status code
-
efi_status_tefi_add_memory_map(u64start, u64size, intmemory_type)
add memory area to the memory map
Parameters
u64 startstart address of the memory area
u64 sizelength in bytes of the memory area
int memory_typetype of memory added
Return
status code
Description
This function automatically aligns the start and size of the memory area to EFI_PAGE_SIZE.
-
efi_status_tefi_check_allocated(u64addr, boolmust_be_allocated)
validate address to be freed
Parameters
u64 addraddress of page to be freed
bool must_be_allocatedreturn success if the page is allocated
Description
Check that the address is within allocated memory:
The address must be in a range of the memory map.
The address may not point to EFI_CONVENTIONAL_MEMORY.
Page alignment is not checked as this is not a requirement of efi_free_pool().
Return
status code
-
efi_status_tefi_allocate_pages(enumefi_allocate_typetype, enumefi_memory_typememory_type, efi_uintn_tpages, uint64_t*memory)
allocate memory pages
Parameters
enum efi_allocate_type typetype of allocation to be performed
enum efi_memory_type memory_typeusage type of the allocated memory
efi_uintn_t pagesnumber of pages to be allocated
uint64_t *memoryallocated memory
Return
status code
-
efi_status_tefi_free_pages(uint64_tmemory, efi_uintn_tpages)
free memory pages
Parameters
uint64_t memorystart of the memory area to be freed
efi_uintn_t pagesnumber of pages to be freed
Return
status code
-
void*efi_alloc_aligned_pages(u64len, intmemory_type, size_talign)
allocate aligned memory pages
Parameters
u64 lenlen in bytes
int memory_typeusage type of the allocated memory
size_t alignalignment in bytes
Return
aligned memory or NULL
-
efi_status_tefi_allocate_pool(enumefi_memory_typepool_type, efi_uintn_tsize, void**buffer)
allocate memory from pool
Parameters
enum efi_memory_type pool_typetype of the pool from which memory is to be allocated
efi_uintn_t sizenumber of bytes to be allocated
void **bufferallocated memory
Return
status code
-
void*efi_alloc(size_tsize)
allocate boot services data pool memory
Parameters
size_t sizenumber of bytes to allocate
Description
Allocate memory from pool and zero it out.
Return
pointer to allocated memory or NULL
-
efi_status_tefi_realloc(void**ptr, size_tsize)
reallocate boot services data pool memory
Parameters
void **ptrpointer to old buffer
size_t sizenumber of bytes to allocate
Description
Reallocate memory from pool for a new size and copy the data from old one.
Return
EFI status to indicate success or not
-
efi_status_tefi_free_pool(void*buffer)
free memory from pool
Parameters
void *bufferstart of memory to be freed
Return
status code
-
efi_status_tefi_get_memory_map(efi_uintn_t*memory_map_size, structefi_mem_desc*memory_map, efi_uintn_t*map_key, efi_uintn_t*descriptor_size, uint32_t*descriptor_version)
get map describing memory usage.
Parameters
efi_uintn_t *memory_map_sizeon entry the size, in bytes, of the memory map buffer, on exit the size of the copied memory map
struct efi_mem_desc *memory_mapbuffer to which the memory map is written
efi_uintn_t *map_keykey for the memory map
efi_uintn_t *descriptor_sizesize of an individual memory descriptor
uint32_t *descriptor_versionversion number of the memory descriptor structure
Return
status code
-
efi_status_tefi_get_memory_map_alloc(efi_uintn_t*map_size, structefi_mem_desc**memory_map)
allocate map describing memory usage
Parameters
efi_uintn_t *map_sizesize of the memory map
struct efi_mem_desc **memory_mapbuffer to which the memory map is written
Description
The caller is responsible for calling FreePool() if the call succeeds.
Return
status code
-
voidefi_add_known_memory(void)
add memory types to the EFI memory map
Parameters
voidno arguments
Description
This function is to be used to add different memory types other than EFI_CONVENTIONAL_MEMORY to the EFI memory map. The conventional memory is handled by the LMB module and gets added to the memory map through the LMB module.
This function may be overridden for architectures specific purposes.
-
voidadd_u_boot_and_runtime(void)
add U-Boot code to memory map
Parameters
voidno arguments
Description
Add memory regions for U-Boot’s memory and for the runtime services code.
SetWatchdogTimer service
-
voidEFIAPIefi_watchdog_timer_notify(structefi_event*event, void*context)
resets system upon watchdog event
Parameters
struct efi_event *eventthe watchdog event
void *contextnot used
Description
Reset the system when the watchdog event is notified.
-
efi_status_tefi_set_watchdog(unsignedlongtimeout)
resets the watchdog timer
Parameters
unsigned long timeoutseconds before reset by watchdog
Description
This function is used by the SetWatchdogTimer service.
Return
status code
-
efi_status_tefi_watchdog_register(void)
initializes the EFI watchdog
Parameters
voidno arguments
Description
This function is called by efi_init_obj_list().
Return
status code
Runtime services
-
efi_status_tefi_init_runtime_supported(void)
create runtime properties table
Parameters
voidno arguments
Description
Create a configuration table specifying which services are available at runtime.
Return
status code
-
void__efi_runtimeefi_memcpy_runtime(void*dest, constvoid*src, size_tn)
copy memory area
Parameters
void *destdestination buffer
const void *srcsource buffer
size_t nnumber of bytes to copy
Description
At runtime memcpy() is not available.
Overlapping memory areas can be copied safely if src >= dest.
Return
pointer to destination buffer
-
void__efi_runtimeefi_update_table_header_crc32(structefi_table_hdr*table)
Update crc32 in table header
Parameters
struct efi_table_hdr *tableEFI table
-
voidEFIAPIefi_reset_system_boottime(enumefi_reset_typereset_type, efi_status_treset_status, unsignedlongdata_size, void*reset_data)
reset system at boot time
Parameters
enum efi_reset_type reset_typetype of reset to perform
efi_status_t reset_statusstatus code for the reset
unsigned long data_sizesize of reset_data
void *reset_datainformation about the reset
Description
This function implements the ResetSystem() runtime service before SetVirtualAddressMap() is called.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
-
efi_status_tEFIAPIefi_get_time_boottime(structefi_time*time, structefi_time_cap*capabilities)
get current time at boot time
Parameters
struct efi_time *timepointer to structure to receive current time
struct efi_time_cap *capabilitiespointer to structure to receive RTC properties
Description
This function implements the GetTime runtime service before SetVirtualAddressMap() is called.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
intefi_validate_time(structefi_time*time)
checks if timestamp is valid
Parameters
struct efi_time *timetimestamp to validate
Return
0 if timestamp is valid, 1 otherwise
-
efi_status_tEFIAPIefi_set_time_boottime(structefi_time*time)
set current time
Parameters
struct efi_time *timepointer to structure to with current time
Description
This function implements the SetTime() runtime service before SetVirtualAddressMap() is called.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
void__efi_runtimeEFIAPIefi_reset_system(enumefi_reset_typereset_type, efi_status_treset_status, unsignedlongdata_size, void*reset_data)
reset system
Parameters
enum efi_reset_type reset_typetype of reset to perform
efi_status_t reset_statusstatus code for the reset
unsigned long data_sizesize of reset_data
void *reset_datainformation about the reset
Description
This function implements the ResetSystem() runtime service after SetVirtualAddressMap() is called. As this placeholder cannot reset the system it simply return to the caller.
Boards may override the helpers below to implement reset functionality.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
-
efi_status_tefi_reset_system_init(void)
initialize the reset driver
Parameters
voidno arguments
Description
Boards may override this function to initialize the reset driver.
-
efi_status_t__efi_runtimeEFIAPIefi_get_time(structefi_time*time, structefi_time_cap*capabilities)
get current time
Parameters
struct efi_time *timepointer to structure to receive current time
struct efi_time_cap *capabilitiespointer to structure to receive RTC properties
Description
This function implements the GetTime runtime service after SetVirtualAddressMap() is called. As the U-Boot driver are not available anymore only an error code is returned.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_t__efi_runtimeEFIAPIefi_set_time(structefi_time*time)
set current time
Parameters
struct efi_time *timepointer to structure to with current time
Description
This function implements the SetTime runtime service after SetVirtualAddressMap() is called. As the U-Boot driver are not available anymore only an error code is returned.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_t__efi_runtimeEFIAPIefi_update_capsule_unsupported(structefi_capsule_header**capsule_header_array, efi_uintn_tcapsule_count, u64scatter_gather_list)
process information from operating system
Parameters
struct efi_capsule_header **capsule_header_arraypointer to array of virtual pointers
efi_uintn_t capsule_countnumber of pointers in capsule_header_array
u64 scatter_gather_listpointer to array of physical pointers
Description
This function implements the UpdateCapsule() runtime service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_t__efi_runtimeEFIAPIefi_query_capsule_caps_unsupported(structefi_capsule_header**capsule_header_array, efi_uintn_tcapsule_count, u64*maximum_capsule_size, u32*reset_type)
check if capsule is supported
Parameters
struct efi_capsule_header **capsule_header_arraypointer to array of virtual pointers
efi_uintn_t capsule_countnumber of pointers in capsule_header_array
u64 *maximum_capsule_sizemaximum capsule size
u32 *reset_typetype of reset needed for capsule update
Description
This function implements the QueryCapsuleCapabilities() runtime service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
boolefi_is_runtime_service_pointer(void*p)
check if pointer points to runtime table
Parameters
void *ppointer to check
Return
- true if the pointer points to a service function pointer in the
runtime table
-
voidefi_runtime_detach(void)
detach unimplemented runtime functions
Parameters
voidno arguments
-
__efi_runtimeefi_status_tEFIAPIefi_set_virtual_address_map_runtime(efi_uintn_tmemory_map_size, efi_uintn_tdescriptor_size, uint32_tdescriptor_version, structefi_mem_desc*virtmap)
change from physical to virtual mapping
Parameters
efi_uintn_t memory_map_sizesize of the virtual map
efi_uintn_t descriptor_sizesize of an entry in the map
uint32_t descriptor_versionversion of the map entries
struct efi_mem_desc *virtmapvirtual address mapping information
Description
This function implements the SetVirtualAddressMap() runtime service after it is first called.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code EFI_UNSUPPORTED
-
__efi_runtimeefi_status_tEFIAPIefi_convert_pointer_runtime(efi_uintn_tdebug_disposition, void**address)
convert from physical to virtual pointer
Parameters
efi_uintn_t debug_dispositionindicates if pointer may be converted to NULL
void **addresspointer to be converted
Description
This function implements the ConvertPointer() runtime service after the first call to SetVirtualAddressMap().
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code EFI_UNSUPPORTED
-
__efi_runtimeefi_status_tEFIAPIefi_convert_pointer(efi_uintn_tdebug_disposition, void**address)
convert from physical to virtual pointer
Parameters
efi_uintn_t debug_dispositionindicates if pointer may be converted to NULL
void **addresspointer to be converted
Description
This function implements the ConvertPointer() runtime service until the first call to SetVirtualAddressMap().
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_set_virtual_address_map(efi_uintn_tmemory_map_size, efi_uintn_tdescriptor_size, uint32_tdescriptor_version, structefi_mem_desc*virtmap)
change from physical to virtual mapping
Parameters
efi_uintn_t memory_map_sizesize of the virtual map
efi_uintn_t descriptor_sizesize of an entry in the map
uint32_t descriptor_versionversion of the map entries
struct efi_mem_desc *virtmapvirtual address mapping information
Description
This function implements the SetVirtualAddressMap() runtime service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tefi_add_runtime_mmio(void*mmio_ptr, u64len)
add memory-mapped IO region
Parameters
void *mmio_ptrpointer to a pointer to the start of the memory-mapped IO region
u64 lensize of the memory-mapped IO region
Description
This function adds a memory-mapped IO region to the memory map to make it available at runtime.
Return
status code
-
efi_status_t__efi_runtimeEFIAPIefi_unimplemented(void)
replacement function, returns EFI_UNSUPPORTED
Parameters
voidno arguments
Description
This function is used after SetVirtualAddressMap() is called as replacement for services that are not available anymore due to constraints of the U-Boot implementation.
Return
EFI_UNSUPPORTED
Variable services
-
efi_status_tefi_get_variable_int(constu16*variable_name, constefi_guid_t*vendor, u32*attributes, efi_uintn_t*data_size, void*data, u64*timep)
retrieve value of a UEFI variable
Parameters
const u16 *variable_namename of the variable
const efi_guid_t *vendorvendor GUID
u32 *attributesattributes of the variable
efi_uintn_t *data_sizesize of the buffer to which the variable value is copied
void *databuffer to which the variable value is copied
u64 *timepauthentication time (seconds since start of epoch)
Return
status code
-
efi_status_tefi_set_variable_int(constu16*variable_name, constefi_guid_t*vendor, u32attributes, efi_uintn_tdata_size, constvoid*data, boolro_check)
set value of a UEFI variable
Parameters
const u16 *variable_namename of the variable
const efi_guid_t *vendorvendor GUID
u32 attributesattributes of the variable
efi_uintn_t data_sizesize of the buffer with the variable value
const void *databuffer with the variable value
bool ro_checkcheck the read only read only bit in attributes
Return
status code
-
efi_status_tefi_get_next_variable_name_int(efi_uintn_t*variable_name_size, u16*variable_name, efi_guid_t*vendor)
enumerate the current variable names
Parameters
efi_uintn_t *variable_name_sizesize of variable_name buffer in byte
u16 *variable_namename of uefi variable’s name in u16
efi_guid_t *vendorvendor’s guid
Description
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tefi_query_variable_info_int(u32attributes, u64*maximum_variable_storage_size, u64*remaining_variable_storage_size, u64*maximum_variable_size)
get information about EFI variables
Parameters
u32 attributesbitmask to select variables to be queried
u64 *maximum_variable_storage_sizemaximum size of storage area for the selected variable types
u64 *remaining_variable_storage_sizeremaining size of storage are for the selected variable types
u64 *maximum_variable_sizemaximum size of a variable of the selected type
Description
This function implements the QueryVariableInfo() runtime service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
structefi_var_entry
UEFI variable file entry
Definition
struct efi_var_entry {
u32 length;
u32 attr;
u64 time;
efi_guid_t guid;
u16 name[];
};
Members
lengthlength of enty, multiple of 8
attrvariable attributes
timeauthentication time (seconds since start of epoch)
guidvendor GUID
nameUTF16 variable name
-
structefi_var_file
file for storing UEFI variables
Definition
struct efi_var_file {
u64 reserved;
u64 magic;
u32 length;
u32 crc32;
struct efi_var_entry var[];
};
Members
reservedunused, may be overwritten by memory probing
magicidentifies file format, takes value
EFI_VAR_FILE_MAGIClengthlength including header
crc32CRC32 without header
varvariables
-
efi_status_tefi_var_to_file(void)
save non-volatile variables as file
Parameters
voidno arguments
Description
File ubootefi.var is created on the EFI system partion.
Return
status code
-
efi_status_t__maybe_unusedefi_var_collect(structefi_var_file **bufp, loff_t*lenp, u32check_attr_mask)
collect variables in buffer
Parameters
struct efi_var_file **bufppointer to pointer of buffer with collected variables
loff_t *lenppointer to length of buffer
u32 check_attr_maskbitmask with required attributes of variables to be collected. variables are only collected if all of the required attributes are set.
Description
A buffer is allocated and filled with variables in a format ready to be written to disk.
Return
status code
-
efi_status_tefi_var_restore(structefi_var_file *buf, boolsafe)
restore EFI variables from buffer
Parameters
struct efi_var_file *bufbuffer
bool saferestoring from tamper-resistant storage
Description
Only if safe is set secure boot related variables will be restored.
Return
status code
-
efi_status_tefi_var_from_file(void)
read variables from file
Parameters
voidno arguments
Description
File ubootefi.var is read from the EFI system partitions and the variables stored in the file are created.
In case the file does not exist yet or a variable cannot be set EFI_SUCCESS is returned.
Return
status code
-
efi_status_tefi_var_mem_init(void)
set-up variable list
Parameters
voidno arguments
Return
status code
-
structefi_var_entry *efi_var_mem_find(constefi_guid_t*guid, constu16*name, structefi_var_entry **next)
find a variable in the list
Parameters
const efi_guid_t *guidGUID of the variable
const u16 *namename of the variable
struct efi_var_entry **nexton exit pointer to the next variable after the found one
Return
found variable
-
voidefi_var_mem_del(structefi_var_entry *var)
delete a variable from the list of variables
Parameters
struct efi_var_entry *varvariable to delete
-
efi_status_tefi_var_mem_ins(constu16*variable_name, constefi_guid_t*vendor, u32attributes, constefi_uintn_tsize1, constvoid*data1, constefi_uintn_tsize2, constvoid*data2, constu64time)
append a variable to the list of variables
Parameters
const u16 *variable_namevariable name
const efi_guid_t *vendorGUID
u32 attributesvariable attributes
const efi_uintn_t size1size of the first data buffer
const void *data1first data buffer
const efi_uintn_t size2size of the second data field
const void *data2second data buffer
const u64 timetime of authentication (as seconds since start of epoch) Result: status code
Description
The variable is appended without checking if a variable of the same name already exists. The two data buffers are concatenated.
-
u64efi_var_mem_free(void)
determine free memory for variables
Parameters
voidno arguments
Return
maximum data size plus variable name size
-
efi_status_tefi_init_secure_state(void)
initialize secure boot state
Parameters
voidno arguments
Return
status code
-
enumefi_auth_var_typeefi_auth_var_get_type(constu16*name, constefi_guid_t*guid)
convert variable name and guid to enum
Parameters
const u16 *namename of UEFI variable
const efi_guid_t *guidguid of UEFI variable
Return
identifier for authentication related variables
-
constefi_guid_t*efi_auth_var_get_guid(constu16*name)
get the predefined GUID for a variable name
Parameters
const u16 *namename of UEFI variable
Return
guid of UEFI variable
-
efi_status_t__efi_runtimeefi_get_next_variable_name_mem(efi_uintn_t*variable_name_size, u16*variable_name, efi_guid_t*vendor, u32mask)
Runtime common code across efi variable implementations for GetNextVariable() from the cached memory copy
Parameters
efi_uintn_t *variable_name_sizesize of variable_name buffer in bytes
u16 *variable_namename of uefi variable’s name in u16
efi_guid_t *vendorvendor’s guid
u32 maskbitmask with required attributes of variables to be collected. variables are only collected if all of the required attributes match. Use 0 to skip matching
Return
status code
-
efi_status_t__efi_runtimeefi_get_variable_mem(constu16*variable_name, constefi_guid_t*vendor, u32*attributes, efi_uintn_t*data_size, void*data, u64*timep, u32mask)
Runtime common code across efi variable implementations for GetVariable() from the cached memory copy
Parameters
const u16 *variable_namename of the variable
const efi_guid_t *vendorvendor GUID
u32 *attributesattributes of the variable
efi_uintn_t *data_sizesize of the buffer to which the variable value is copied
void *databuffer to which the variable value is copied
u64 *timepauthentication time (seconds since start of epoch)
u32 maskbitmask with required attributes of variables to be collected. variables are only collected if all of the required attributes match. Use 0 to skip matching
Return
status code
-
efi_status_t__efi_runtimeEFIAPIefi_get_variable_runtime(u16*variable_name, constefi_guid_t*guid, u32*attributes, efi_uintn_t*data_size, void*data)
runtime implementation of GetVariable()
Parameters
u16 *variable_namename of the variable
const efi_guid_t *guidvendor GUID
u32 *attributesattributes of the variable
efi_uintn_t *data_sizesize of the buffer to which the variable value is copied
void *databuffer to which the variable value is copied
Return
status code
-
efi_status_t__efi_runtimeEFIAPIefi_get_next_variable_name_runtime(efi_uintn_t*variable_name_size, u16*variable_name, efi_guid_t*guid)
runtime implementation of GetNextVariable()
Parameters
efi_uintn_t *variable_name_sizesize of variable_name buffer in byte
u16 *variable_namename of uefi variable’s name in u16
efi_guid_t *guidvendor’s guid
Return
status code
-
voidefi_var_buf_update(structefi_var_file *var_buf)
udpate memory buffer for variables
Parameters
struct efi_var_file *var_bufsource buffer
Description
This function copies to the memory buffer for UEFI variables. Call this function in ExitBootServices() if memory backed variables are only used at runtime to fill the buffer.
-
efi_status_tefi_variable_authenticate(constu16*variable, constefi_guid_t*vendor, efi_uintn_t*data_size, constvoid**data, u32given_attr, u32*env_attr, u64*time)
authenticate a variable
Parameters
const u16 *variableVariable name in u16
const efi_guid_t *vendorGuid of variable
efi_uintn_t *data_sizeSize of data
const void **dataPointer to variable’s value
u32 given_attrAttributes to be given at SetVariable()
u32 *env_attrAttributes that an existing variable holds
u64 *timesigned time that an existing variable holds
Description
Called by efi_set_variable() to verify that the input is correct. Will replace the given data pointer with another that points to the actual data to store in the internal memory. On success, data and data_size will be replaced with variable’s actual data, excluding authentication data, and its size, and variable’s attributes and signed time will also be returned in env_attr and time, respectively.
Return
status code
-
efi_status_t__efi_runtimesetvariable_allowed(constu16*variable_name, constefi_guid_t*vendor, u32attributes, efi_uintn_tdata_size, constvoid*data)
checks defined by the UEFI spec for setvariable
Parameters
const u16 *variable_namename of the variable
const efi_guid_t *vendorvendor GUID
u32 attributesattributes of the variable
efi_uintn_t data_sizesize of the buffer with the variable value
const void *databuffer with the variable value
Return
status code
-
efi_status_t__efi_runtimeEFIAPIefi_query_variable_info_runtime(u32attributes, u64*maximum_variable_storage_size, u64*remaining_variable_storage_size, u64*maximum_variable_size)
runtime implementation of QueryVariableInfo()
Parameters
u32 attributesbitmask to select variables to be queried
u64 *maximum_variable_storage_sizemaximum size of storage area for the selected variable types
u64 *remaining_variable_storage_sizeremaining size of storage are for the selected variable types
u64 *maximum_variable_sizemaximum size of a variable of the selected type
Return
status code
-
efi_status_t__efi_runtimeEFIAPIefi_set_variable_runtime(u16*variable_name, constefi_guid_t*vendor, u32attributes, efi_uintn_tdata_size, constvoid*data)
runtime implementation of SetVariable()
Parameters
u16 *variable_namename of the variable
const efi_guid_t *vendorvendor GUID
u32 attributesattributes of the variable
efi_uintn_t data_sizesize of the buffer with the variable value
const void *databuffer with the variable value
Return
status code
-
voidefi_variables_boot_exit_notify(void)
notify ExitBootServices() is called
Parameters
voidno arguments
-
efi_status_tefi_init_variables(void)
initialize variable services
Parameters
voidno arguments
Return
status code
UEFI drivers
UEFI driver uclass
-
efi_status_tcheck_node_type(efi_handle_thandle)
check node type
Parameters
efi_handle_t handlehandle to be checked
Description
We do not support partitions as controller handles.
Return
status code
-
efi_status_tEFIAPIefi_uc_supported(structefi_driver_binding_protocol*this, efi_handle_tcontroller_handle, structefi_device_path*remaining_device_path)
check if the driver supports the controller
Parameters
struct efi_driver_binding_protocol *thisdriver binding protocol
efi_handle_t controller_handlehandle of the controller
struct efi_device_path *remaining_device_pathpath specifying the child controller
Return
status code
-
efi_status_tEFIAPIefi_uc_start(structefi_driver_binding_protocol*this, efi_handle_tcontroller_handle, structefi_device_path*remaining_device_path)
create child controllers and attach driver
Parameters
struct efi_driver_binding_protocol *thisdriver binding protocol
efi_handle_t controller_handlehandle of the controller
struct efi_device_path *remaining_device_pathpath specifying the child controller
Return
status code
-
efi_status_tdisconnect_child(efi_handle_tcontroller_handle, efi_handle_tchild_handle)
remove a single child controller from the parent controller
Parameters
efi_handle_t controller_handleparent controller
efi_handle_t child_handlechild controller
Return
status code
-
efi_status_tEFIAPIefi_uc_stop(structefi_driver_binding_protocol*this, efi_handle_tcontroller_handle, size_tnumber_of_children, efi_handle_t*child_handle_buffer)
Remove child controllers and disconnect the controller
Parameters
struct efi_driver_binding_protocol *thisdriver binding protocol
efi_handle_t controller_handlehandle of the controller
size_t number_of_childrennumber of child controllers to remove
efi_handle_t *child_handle_bufferhandles of the child controllers to remove
Return
status code
Parameters
struct driver *drvdriver to add
Return
status code
-
efi_status_tefi_driver_init(void)
initialize the EFI drivers
Parameters
voidno arguments
Description
Called by efi_init_obj_list().
Return
0 = success, any other value will stop further execution
Parameters
struct uclass *classthe EFI uclass
Return
0 = success
Parameters
struct uclass *classthe EFI uclass
Return
0 = success
Block device driver
-
structefi_blk_plat
attributes of a block device
Definition
struct efi_blk_plat {
efi_handle_t handle;
struct efi_block_io *io;
};
Members
handlehandle of the controller on which this driver is installed
ioblock io protocol proxied by this driver
-
ulongefi_bl_read(structudevice *dev, lbaint_tblknr, lbaint_tblkcnt, void*buffer)
read from block device
Parameters
struct udevice *devdevice
lbaint_t blknrfirst block to be read
lbaint_t blkcntnumber of blocks to read
void *bufferoutput buffer
Return
number of blocks transferred
-
ulongefi_bl_write(structudevice *dev, lbaint_tblknr, lbaint_tblkcnt, constvoid*buffer)
write to block device
Parameters
struct udevice *devdevice
lbaint_t blknrfirst block to write
lbaint_t blkcntnumber of blocks to write
const void *bufferinput buffer
Return
number of blocks transferred
-
efi_status_tefi_bl_create_block_device(efi_handle_thandle, void*interface)
create a block device for a handle
Parameters
efi_handle_t handlehandle
void *interfaceblock io protocol
Return
status code
-
efi_status_tefi_bl_bind(structefi_driver_binding_extended_protocol *this, efi_handle_thandle, void*interface)
bind to a block io protocol
Parameters
struct efi_driver_binding_extended_protocol *thisdriver binding protocol
efi_handle_t handlehandle
void *interfaceblock io protocol
Return
status code
-
efi_status_tefi_bl_init(structefi_driver_binding_extended_protocol *this)
initialize block device driver
Parameters
struct efi_driver_binding_extended_protocol *thisextended driver binding protocol
-
intefi_block_device_create(void)
create parent for EFI block devices
Parameters
voidno arguments
Description
Create a device that serves as parent for all block devices created via ConnectController().
Return
0 for success
Protocols
Block IO protocol
-
structefi_disk_obj
EFI disk object
Definition
struct efi_disk_obj {
struct efi_object header;
struct efi_block_io ops;
struct efi_block_io_media media;
struct efi_device_path *dp;
struct efi_simple_file_system_protocol *volume;
struct efi_partition_info info;
};
Members
headerEFI object header
opsEFI disk I/O protocol interface
mediablock I/O media information
dpdevice path to the block device
volumesimple file system protocol of the partition
infoEFI partition info protocol interface
-
efi_status_tEFIAPIefi_disk_reset(structefi_block_io*this, charextended_verification)
reset block device
Parameters
struct efi_block_io *thispointer to the BLOCK_IO_PROTOCOL
char extended_verificationextended verification
Description
This function implements the Reset service of the EFI_BLOCK_IO_PROTOCOL.
As U-Boot’s block devices do not have a reset function simply return EFI_SUCCESS.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
boolefi_disk_is_removable(efi_handle_thandle)
check if the device is removable media
Parameters
efi_handle_t handleefi object handle;
Description
Examine the device and determine if the device is a local block device and removable media.
Return
true if removable, false otherwise
-
efi_status_tEFIAPIefi_disk_read_blocks(structefi_block_io*this, u32media_id, u64lba, efi_uintn_tbuffer_size, void*buffer)
reads blocks from device
Parameters
struct efi_block_io *thispointer to the BLOCK_IO_PROTOCOL
u32 media_idid of the medium to be read from
u64 lbastarting logical block for reading
efi_uintn_t buffer_sizesize of the read buffer
void *bufferpointer to the destination buffer
Description
This function implements the ReadBlocks service of the EFI_BLOCK_IO_PROTOCOL.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_disk_write_blocks(structefi_block_io*this, u32media_id, u64lba, efi_uintn_tbuffer_size, void*buffer)
writes blocks to device
Parameters
struct efi_block_io *thispointer to the BLOCK_IO_PROTOCOL
u32 media_idid of the medium to be written to
u64 lbastarting logical block for writing
efi_uintn_t buffer_sizesize of the write buffer
void *bufferpointer to the source buffer
Description
This function implements the WriteBlocks service of the EFI_BLOCK_IO_PROTOCOL.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_disk_flush_blocks(structefi_block_io*this)
flushes modified data to the device
Parameters
struct efi_block_io *thispointer to the BLOCK_IO_PROTOCOL
Description
This function implements the FlushBlocks service of the EFI_BLOCK_IO_PROTOCOL.
As we always write synchronously nothing is done here.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
structefi_simple_file_system_protocol*efi_fs_from_path(structefi_device_path*full_path)
retrieve simple file system protocol
Parameters
struct efi_device_path *full_pathdevice path including device and file
Description
Gets the simple file system protocol for a file device path.
The full path provided is split into device part and into a file part. The device part is used to find the handle on which the simple file system protocol is installed.
Return
simple file system protocol
-
intefi_fs_exists(structblk_desc*desc, intpart)
check if a partition bears a file system
Parameters
struct blk_desc *descblock device descriptor
int partpartition number
Return
- 1 if a file system exists on the partition
0 otherwise
-
efi_status_tefi_disk_add_dev(efi_handle_tparent, structefi_device_path*dp_parent, structblk_desc*desc, structdisk_partition*part_info, unsignedintpart, structefi_disk_obj **disk, efi_handle_tagent_handle)
create a handle for a partition or disk
Parameters
efi_handle_t parentparent handle
struct efi_device_path *dp_parentparent device path
struct blk_desc *descinternal block device
struct disk_partition *part_infopartition info
unsigned int partpartition
struct efi_disk_obj **diskpointer to receive the created handle
efi_handle_t agent_handlehandle of the EFI block driver
Return
disk object
-
intefi_disk_create_raw(structudevice *dev, efi_handle_tagent_handle)
create a handle for a whole raw disk
Parameters
struct udevice *devudevice (UCLASS_BLK)
efi_handle_t agent_handlehandle of the EFI block driver
Description
Create an efi_disk object which is associated with dev. The type of dev must be UCLASS_BLK.
Return
0 on success, -1 otherwise
-
intefi_disk_create_part(structudevice *dev, efi_handle_tagent_handle)
create a handle for a disk partition
Parameters
struct udevice *devudevice (UCLASS_PARTITION)
efi_handle_t agent_handlehandle of the EFI block driver
Description
Create an efi_disk object which is associated with dev. The type of dev must be UCLASS_PARTITION.
Return
0 on success, -1 otherwise
Parameters
void *ctxevent context - driver binding protocol
struct event *eventEV_PM_POST_PROBE event
Description
Create efi_disk objects for partitions as well as a raw disk which is associated with dev. The type of dev must be UCLASS_BLK. This function is expected to be called at EV_PM_POST_PROBE.
Return
0 on success, -1 otherwise
-
intefi_disk_remove(void*ctx, structevent *event)
delete an efi_disk object for a block device or partition
Parameters
void *ctxevent context: driver binding protocol
struct event *eventEV_PM_PRE_REMOVE event
Description
Delete an efi_disk object which is associated with the UCLASS_BLK or UCLASS_PARTITION device for which the EV_PM_PRE_REMOVE event is raised.
Return
0 on success, -1 otherwise
-
efi_status_tefi_disk_get_device_name(constefi_handle_thandle, char*buf, intsize)
get U-Boot device name associated with EFI handle
Parameters
const efi_handle_t handlepointer to the EFI handle
char *bufpointer to the buffer to store the string
int sizesize of buffer
Return
status code
-
efi_status_tefi_disks_register(void)
ensure all block devices are available in UEFI
Parameters
voidno arguments
Description
The function probes all block devices. As we store UEFI variables on the EFI system partition this function has to be called before enabling variable services.
File protocol
-
intis_dir(structfile_handle*fh)
check if file handle points to directory
Parameters
struct file_handle *fhfile handle
Description
We assume that set_blk_dev(fh) has been called already.
Return
true if file handle points to a directory
-
intefi_create_file(structfile_handle*fh, u64attributes)
create file or directory
Parameters
struct file_handle *fhfile handle
u64 attributesattributes for newly created file
Return
0 for success
-
structefi_file_handle*file_open(structfile_system*fs, structfile_handle*parent, u16*file_name, u64open_mode, u64attributes)
open a file handle
Parameters
struct file_system *fsfile system
struct file_handle *parentdirectory relative to which the file is to be opened
u16 *file_namepath of the file to be opened. ‘', ‘.’, or ‘..’ may be used as modifiers. A leading backslash indicates an absolute path.
u64 open_modebit mask indicating the access mode (read, write, create)
u64 attributesattributes for newly created file
Return
handle to the opened file or NULL
-
efi_status_tEFIAPIefi_file_open(structefi_file_handle*this, structefi_file_handle**new_handle, u16*file_name, u64open_mode, u64attributes)
open file synchronously
Parameters
struct efi_file_handle *thisEFI_FILE_PROTOCOL instance
struct efi_file_handle **new_handleon return pointer to file handle
u16 *file_namefile name
u64 open_modemode to open the file (read, read/write, create/read/write)
u64 attributesattributes for newly created file
Description
This function implements the Open service of the File Protocol. See the UEFI spec for details.
-
efi_status_tEFIAPIefi_file_open_ex(structefi_file_handle*this, structefi_file_handle**new_handle, u16*file_name, u64open_mode, u64attributes, structefi_file_io_token*token)
open file asynchronously
Parameters
struct efi_file_handle *thisEFI_FILE_PROTOCOL instance
struct efi_file_handle **new_handleon return pointer to file handle
u16 *file_namefile name
u64 open_modemode to open the file (read, read/write, create/read/write)
u64 attributesattributes for newly created file
struct efi_file_io_token *tokentransaction token
Description
This function implements the OpenEx service of the File Protocol. See the UEFI spec for details.
-
efi_status_tefi_get_file_size(structfile_handle*fh, loff_t*file_size)
determine the size of a file
Parameters
struct file_handle *fhfile handle
loff_t *file_sizepointer to receive file size
Return
status code
-
efi_status_tefi_file_size(structefi_file_handle*fh, efi_uintn_t*size)
Get the size of a file using an EFI file handle
Parameters
struct efi_file_handle *fhEFI file handle
efi_uintn_t *sizebuffer to fill in the discovered size
Return
size of the file
-
efi_status_tEFIAPIefi_file_read(structefi_file_handle*this, efi_uintn_t*buffer_size, void*buffer)
read file
Parameters
struct efi_file_handle *thisfile protocol instance
efi_uintn_t *buffer_sizenumber of bytes to read
void *bufferread buffer
Description
This function implements the Read() service of the EFI_FILE_PROTOCOL.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_file_read_ex(structefi_file_handle*this, structefi_file_io_token*token)
read file asynchonously
Parameters
struct efi_file_handle *thisfile protocol instance
struct efi_file_io_token *tokentransaction token
Description
This function implements the ReadEx() service of the EFI_FILE_PROTOCOL.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_file_write(structefi_file_handle*this, efi_uintn_t*buffer_size, void*buffer)
write to file
Parameters
struct efi_file_handle *thisfile protocol instance
efi_uintn_t *buffer_sizenumber of bytes to write
void *bufferbuffer with the bytes to write
Description
This function implements the Write() service of the EFI_FILE_PROTOCOL.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_file_write_ex(structefi_file_handle*this, structefi_file_io_token*token)
write to file
Parameters
struct efi_file_handle *thisfile protocol instance
struct efi_file_io_token *tokentransaction token
Description
This function implements the WriteEx() service of the EFI_FILE_PROTOCOL.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_file_getpos(structefi_file_handle*file, u64*pos)
get current position in file
Parameters
struct efi_file_handle *filefile handle
u64 *pospointer to file position
Description
This function implements the GetPosition service of the EFI file protocol. See the UEFI spec for details.
Return
status code
-
efi_status_tEFIAPIefi_file_setpos(structefi_file_handle*file, u64pos)
set current position in file
Parameters
struct efi_file_handle *filefile handle
u64 posnew file position
Description
This function implements the SetPosition service of the EFI file protocol. See the UEFI spec for details.
Return
status code
-
efi_status_tefi_file_flush_int(structefi_file_handle*this)
flush file
Parameters
struct efi_file_handle *thisfile protocol instance
Description
This is the internal implementation of the Flush() and FlushEx() services of the EFI_FILE_PROTOCOL.
Return
status code
-
efi_status_tEFIAPIefi_file_flush(structefi_file_handle*this)
flush file
Parameters
struct efi_file_handle *thisfile protocol instance
Description
This function implements the Flush() service of the EFI_FILE_PROTOCOL.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_file_flush_ex(structefi_file_handle*this, structefi_file_io_token*token)
flush file
Parameters
struct efi_file_handle *thisfile protocol instance
struct efi_file_io_token *tokentransaction token
Description
This function implements the FlushEx() service of the EFI_FILE_PROTOCOL.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
structefi_file_handle*efi_file_from_path(structefi_device_path*fp)
open file via device path
Parameters
struct efi_device_path *fpdevice path
Description
The device path fp consists of the device path of the handle with the simple file system protocol and one or more file path device path nodes. The concatenation of all file path names provides the total file path.
The code starts at the first file path node and tries to open that file or directory. If there is a succeding file path node, the code opens it relative to this directory and continues iterating until reaching the last file path node.
Return
EFI_FILE_PROTOCOL for the file or NULL
Graphical output protocol
-
structefi_gop_obj
graphical output protocol object
Definition
struct efi_gop_obj {
struct efi_object header;
struct efi_gop ops;
struct efi_gop_mode_info info;
struct efi_gop_mode mode;
struct udevice *vdev;
u32 bpix;
void *fb;
};
Members
headerEFI object header
opsgraphical output protocol interface
infographical output mode information
modegraphical output mode
vdevbacking video device
bpixbits per pixel
fbframe buffer
-
efi_status_tEFIAPIgop_set_mode(structefi_gop*this, u32mode_number)
set graphical output mode
Parameters
struct efi_gop *thisthe graphical output protocol
u32 mode_numberthe mode to be set
Description
This function implements the SetMode() service.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
Load file 2 protocol
The load file 2 protocol can be used by the Linux kernel to load the initial RAM disk. U-Boot can be configured to provide an implementation.
-
efi_status_tget_initrd_fp(structefi_device_path**initrd_fp)
Get initrd device path from a FilePathList device path
Parameters
struct efi_device_path **initrd_fpthe final initrd filepath
Return
status code. Caller must free initrd_fp
-
efi_status_tefi_initrd_from_mem(efi_uintn_t*buffer_size, void*buffer)
load initial RAM disk from memory
Parameters
efi_uintn_t *buffer_sizesize of allocated buffer
void *bufferbuffer to load the file
Description
This function copies the initrd from the memory mapped device path pointed to by efi_initrd_dp
Return
status code
-
efi_status_tEFIAPIefi_load_file2_initrd(structefi_load_file_protocol*this, structefi_device_path*file_path, boolboot_policy, efi_uintn_t*buffer_size, void*buffer)
load initial RAM disk
Parameters
struct efi_load_file_protocol *thisEFI_LOAD_FILE2_PROTOCOL instance
struct efi_device_path *file_pathmedia device path of the file, "" in this case
bool boot_policymust be false
efi_uintn_t *buffer_sizesize of allocated buffer
void *bufferbuffer to load the file
Description
This function implements the LoadFile service of the EFI_LOAD_FILE2_PROTOCOL in order to load an initial RAM disk requested by the Linux kernel stub.
See the UEFI spec for details.
Return
status code
-
efi_status_tcheck_initrd(void)
Determine if the file defined as an initrd in Boot#### load_options device path is present
Parameters
voidno arguments
Return
status code
-
efi_status_tefi_initrd_deregister(void)
delete the handle for loading initial RAM disk
Parameters
voidno arguments
Description
This will delete the handle containing the Linux specific vendor device path and EFI_LOAD_FILE2_PROTOCOL for loading an initrd
Return
status code
-
voidEFIAPIefi_initrd_return_notify(structefi_event*event, void*context)
return to efibootmgr callback
Parameters
struct efi_event *eventthe event for which this notification function is registered
void *contextevent context
-
efi_status_tefi_initrd_register(structefi_device_path*dp_initrd)
create handle for loading initial RAM disk
Parameters
struct efi_device_path *dp_initrdoptional device path containing an initrd
Description
This function creates a new handle and installs a Linux specific vendor device path and an EFI_LOAD_FILE2_PROTOCOL. Linux uses the device path to identify the handle and then calls the LoadFile service of the EFI_LOAD_FILE2_PROTOCOL to read the initial RAM disk. If dp_initrd is not provided, the initrd will be taken from the BootCurrent variable
Return
status code
Network protocols
-
structefi_net_obj
EFI object representing a network interface
Definition
struct efi_net_obj {
struct efi_object header;
struct udevice *dev;
struct efi_simple_network net;
struct efi_simple_network_mode net_mode;
struct efi_pxe_base_code_protocol pxe;
struct efi_pxe_mode pxe_mode;
#if IS_ENABLED(CONFIG_EFI_IP4_CONFIG2_PROTOCOL);
struct efi_ip4_config2_protocol ip4_config2;
#endif;
#if IS_ENABLED(CONFIG_EFI_HTTP_PROTOCOL);
struct efi_service_binding_protocol http_service_binding;
#endif;
void *new_tx_packet;
void *transmit_buffer;
uchar **receive_buffer;
size_t *receive_lengths;
int rx_packet_idx;
int rx_packet_num;
struct efi_event *wait_for_packet;
struct efi_event *network_timer_event;
int efi_seq_num;
};
Members
headerEFI object header
devnet udevice
netsimple network protocol interface
net_modestatus of the network interface
pxePXE base code protocol interface
pxe_modestatus of the PXE base code protocol
ip4_config2IP4 Config2 protocol interface
http_service_bindingHttp service binding protocol interface
new_tx_packetnew transmit packet
transmit_buffertransmit buffer
receive_bufferarray of receive buffers
receive_lengthsarray of lengths for received packets
rx_packet_idxindex of the current receive packet
rx_packet_numnumber of received packets
wait_for_packetsignaled when a packet has been received
network_timer_eventevent to check for new network packets.
efi_seq_numsequence number of the EFI net object.
-
boolefi_netobj_is_active(structefi_net_obj *netobj)
checks if a netobj is active in the efi subsystem
Parameters
struct efi_net_obj *netobjpointer to efi_net_obj
Return
true if active
-
efi_status_tEFIAPIefi_net_nvdata(structefi_simple_network*this, intread_write, ulongoffset, ulongbuffer_size, char*buffer)
read or write NVRAM
Parameters
struct efi_simple_network *thisthe instance of the Simple Network Protocol
int read_writetrue for read, false for write
ulong offsetoffset in NVRAM
ulong buffer_sizesize of buffer
char *bufferbuffer
Description
This function implements the GetStatus service of the Simple Network Protocol. See the UEFI spec for details.
Return
status code
-
efi_status_tEFIAPIefi_net_get_status(structefi_simple_network*this, u32*int_status, void**txbuf)
get interrupt status
Parameters
struct efi_simple_network *thisthe instance of the Simple Network Protocol
u32 *int_statusinterface status
void **txbuftransmission buffer
Description
This function implements the GetStatus service of the Simple Network Protocol. See the UEFI spec for details.
-
efi_status_tEFIAPIefi_net_transmit(structefi_simple_network*this, size_theader_size, size_tbuffer_size, void*buffer, structefi_mac_address*src_addr, structefi_mac_address*dest_addr, u16*protocol)
transmit a packet
Parameters
struct efi_simple_network *thisthe instance of the Simple Network Protocol
size_t header_sizesize of the media header
size_t buffer_sizesize of the buffer to receive the packet
void *bufferbuffer to receive the packet
struct efi_mac_address *src_addrsource hardware MAC address
struct efi_mac_address *dest_addrdestination hardware MAC address
u16 *protocoltype of header to build
Description
This function implements the Transmit service of the Simple Network Protocol. See the UEFI spec for details.
Return
status code
-
efi_status_tEFIAPIefi_net_receive(structefi_simple_network*this, size_t*header_size, size_t*buffer_size, void*buffer, structefi_mac_address*src_addr, structefi_mac_address*dest_addr, u16*protocol)
receive a packet from a network interface
Parameters
struct efi_simple_network *thisthe instance of the Simple Network Protocol
size_t *header_sizesize of the media header
size_t *buffer_sizesize of the buffer to receive the packet
void *bufferbuffer to receive the packet
struct efi_mac_address *src_addrsource MAC address
struct efi_mac_address *dest_addrdestination MAC address
u16 *protocolprotocol
Description
This function implements the Receive service of the Simple Network Protocol. See the UEFI spec for details.
Return
status code
-
voidefi_net_set_dhcp_ack(void*pkt, intlen)
take note of a selected DHCP IP address
Parameters
void *pktpacket received by dhcp_handler()
int lenlength of the packet received
Description
This function is called by dhcp_handler().
-
voidefi_net_push(void*pkt, intlen)
callback for received network packet
Parameters
void *pktnetwork packet
int lenlength
Description
This function is called when a network packet is received by eth_rx().
-
voidEFIAPIefi_network_timer_notify(structefi_event*event, void*context)
check if a new network packet has been received
Parameters
struct efi_event *eventthe event for which this notification function is registered
void *contextevent context - not used in this function
Description
This notification function is called in every timer cycle.
-
efi_status_tefi_netobj_set_dp(structefi_net_obj *netobj, structefi_device_path*dp)
set device path of a netobj
Parameters
struct efi_net_obj *netobjpointer to efi_net_obj
struct efi_device_path *dpdevice path to set, allocated by caller
Return
status code
-
structefi_device_path*efi_netobj_get_dp(structefi_net_obj *netobj)
get device path of a netobj
Parameters
struct efi_net_obj *netobjpointer to efi_net_obj
Return
device path, NULL on error
Parameters
struct udevice *devnet udevice
Description
This gets called from do_bootefi_exec() each time a payload gets executed.
Return
status code
Parameters
struct udevice *devnet udevice
Description
This gets called from do_bootefi_exec().
-
efi_status_tefi_net_new_dp(constchar*dev, constchar*server, structudevice *udev)
update device path associated to a net udevice
Parameters
const char *devdev to set the device path from
const char *serverremote server address
struct udevice *udevnet udevice
Description
This gets called to update the device path when a new boot file is downloaded
Return
status code
-
voidefi_net_dp_from_dev(structefi_device_path**dp, structudevice *udev, boolcache_only)
get device path associated to a net udevice
Parameters
struct efi_device_path **dpcopy of the current device path
struct udevice *udevnet udevice
bool cache_onlyget device path from cache only
Description
Produce a copy of the current device path
-
voidefi_net_get_addr(structefi_ipv4_address*ip, structefi_ipv4_address*mask, structefi_ipv4_address*gw, structudevice *dev)
get IP address information
Parameters
struct efi_ipv4_address *ippointer to an efi_ipv4_address struct to be filled with the current IP address
struct efi_ipv4_address *maskpointer to an efi_ipv4_address struct to be filled with the current network mask
struct efi_ipv4_address *gwpointer to an efi_ipv4_address struct to be filled with the current network gateway
struct udevice *devudevice
Description
Copy the current IP address, mask, and gateway into the efi_ipv4_address structs pointed to by ip, mask and gw, respectively.
-
voidefi_net_set_addr(structefi_ipv4_address*ip, structefi_ipv4_address*mask, structefi_ipv4_address*gw, structudevice *dev)
set IP address information
Parameters
struct efi_ipv4_address *ippointer to new IP address
struct efi_ipv4_address *maskpointer to new network mask to set
struct efi_ipv4_address *gwpointer to new network gateway
struct udevice *devudevice
Description
Set the current IP address, mask, and gateway to the efi_ipv4_address structs pointed to by ip, mask and gw, respectively.
-
efi_status_tefi_net_set_buffer(void**buffer, size_tsize)
allocate a buffer of min 64K
Parameters
void **bufferallocated buffer
size_t sizedesired buffer size
Return
status code
-
voidefi_net_parse_headers(ulong*num_headers, structhttp_header*headers)
parse HTTP headers
Parameters
ulong *num_headersnumber of headers
struct http_header *headerscaller provided array of struct http_headers
Description
Parses the raw buffer efi_wget_info.headers into an array headers of efi structs http_headers. The array should be at least MAX_HTTP_HEADERS long.
-
efi_status_tefi_net_do_request(u8*url, enumefi_http_methodmethod, void**buffer, u32*status_code, ulong*file_size, char*headers_buffer, structefi_service_binding_protocol*parent)
issue an HTTP request using wget
Parameters
u8 *urlurl
enum efi_http_method methodHTTP method
void **bufferdata buffer
u32 *status_codeHTTP status code
ulong *file_sizefile size in bytes
char *headers_bufferheaders buffer
struct efi_service_binding_protocol *parentservice binding protocol
Return
status code
Random number generator protocol
Parameters
struct udevice **devudevice
Description
This function retrieves the udevice implementing a hardware random number generator.
This function may be overridden if special initialization is needed.
Return
status code
-
efi_status_tEFIAPIrng_getinfo(structefi_rng_protocol*this, efi_uintn_t*rng_algorithm_list_size, efi_guid_t*rng_algorithm_list)
get information about random number generation
Parameters
struct efi_rng_protocol *thisrandom number generator protocol instance
efi_uintn_t *rng_algorithm_list_sizenumber of random number generation algorithms
efi_guid_t *rng_algorithm_listdescriptions of random number generation algorithms
Description
This function implement the GetInfo() service of the EFI random number generator protocol. See the UEFI spec for details.
Return
status code
-
efi_status_tEFIAPIgetrng(structefi_rng_protocol*this, efi_guid_t*rng_algorithm, efi_uintn_trng_value_length, uint8_t*rng_value)
get random value
Parameters
struct efi_rng_protocol *thisrandom number generator protocol instance
efi_guid_t *rng_algorithmrandom number generation algorithm
efi_uintn_t rng_value_lengthnumber of random bytes to generate, buffer length
uint8_t *rng_valuebuffer to receive random bytes
Description
This function implement the GetRng() service of the EFI random number generator protocol. See the UEFI spec for details.
Return
status code
-
efi_status_tefi_rng_register(void)
register EFI_RNG_PROTOCOL
Parameters
voidno arguments
Description
If a RNG device is available, the Random Number Generator Protocol is registered.
Return
An error status is only returned if adding the protocol fails.
Text IO protocols
-
intterm_get_char(s32*c)
read a character from the console
Parameters
s32 *cpointer to the buffer to receive the character
Description
Wait for up to 100 ms to read a character from the console.
Return
0 on success, 1 otherwise
-
intterm_read_reply(int*n, intnum, charend_char)
receive and parse a reply from the terminal
Parameters
int *narray of return values
int numnumber of return values expected
char end_charcharacter indicating end of terminal message
Return
non-zero indicates error
-
efi_status_tEFIAPIefi_cout_output_string(structefi_simple_text_output_protocol*this, constu16*string)
write Unicode string to console
Parameters
struct efi_simple_text_output_protocol *thissimple text output protocol
const u16 *stringu16 string
Description
This function implements the OutputString service of the simple text output protocol. See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_cout_test_string(structefi_simple_text_output_protocol*this, constu16*string)
test writing Unicode string to console
Parameters
struct efi_simple_text_output_protocol *thissimple text output protocol
const u16 *stringu16 string
Description
This function implements the TestString service of the simple text output protocol. See the Unified Extensible Firmware Interface (UEFI) specification for details.
As in OutputString we simply convert UTF-16 to UTF-8 there are no unsupported code points and we can always return EFI_SUCCESS.
Return
status code
-
boolcout_mode_matches(structcout_mode*mode, introws, intcols)
check if mode has given terminal size
Parameters
struct cout_mode *modetext mode
int rowsnumber of rows
int colsnumber of columns
Return
- true if number of rows and columns matches the mode and
the mode is present
-
intquery_console_serial(int*rows, int*cols)
query serial console size
Parameters
int *rowspointer to return number of rows
int *colspointer to return number of columns
Description
When using a serial console or the net console we can only devise the terminal size by querying the terminal using ECMA-48 control sequences.
Return
0 on success
-
int__maybe_unusedquery_vidconsole(int*rows, int*cols)
query video console size
Parameters
int *rowspointer to return number of rows
int *colspointer to return number of columns
Description
Return
0 on success
-
efi_status_tEFIAPIefi_cout_query_mode(structefi_simple_text_output_protocol*this, unsignedlongmode_number, unsignedlong*columns, unsignedlong*rows)
get terminal size for a text mode
Parameters
struct efi_simple_text_output_protocol *thissimple text output protocol
unsigned long mode_numbermode number to retrieve information on
unsigned long *columnsnumber of columns
unsigned long *rowsnumber of rows
Description
This function implements the QueryMode service of the simple text output protocol. See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_cout_set_attribute(structefi_simple_text_output_protocol*this, unsignedlongattribute)
set fore- and background color
Parameters
struct efi_simple_text_output_protocol *thissimple text output protocol
unsigned long attributeforeground color - bits 0-3, background color - bits 4-6
Description
This function implements the SetAttribute service of the simple text output protocol. See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
voidefi_clear_screen(void)
clear screen
Parameters
voidno arguments
-
efi_status_tEFIAPIefi_cout_clear_screen(structefi_simple_text_output_protocol*this)
clear screen
Parameters
struct efi_simple_text_output_protocol *thispointer to the protocol instance
Description
This function implements the ClearScreen service of the simple text output protocol. See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_cout_set_mode(structefi_simple_text_output_protocol*this, unsignedlongmode_number)
set text model
Parameters
struct efi_simple_text_output_protocol *thispointer to the protocol instance
unsigned long mode_numbernumber of the text mode to set
Description
This function implements the SetMode service of the simple text output protocol. See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_cout_reset(structefi_simple_text_output_protocol*this, charextended_verification)
reset the terminal
Parameters
struct efi_simple_text_output_protocol *thispointer to the protocol instance
char extended_verificationif set an extended verification may be executed
Description
This function implements the Reset service of the simple text output protocol. See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_cout_set_cursor_position(structefi_simple_text_output_protocol*this, unsignedlongcolumn, unsignedlongrow)
reset the terminal
Parameters
struct efi_simple_text_output_protocol *thispointer to the protocol instance
unsigned long columncolumn to move to
unsigned long rowrow to move to
Description
This function implements the SetCursorPosition service of the simple text output protocol. See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
efi_status_tEFIAPIefi_cout_enable_cursor(structefi_simple_text_output_protocol*this, boolenable)
enable the cursor
Parameters
struct efi_simple_text_output_protocol *thispointer to the protocol instance
bool enableif true enable, if false disable the cursor
Description
This function implements the EnableCursor service of the simple text output protocol. See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
status code
-
structefi_cin_notify_function
registered console input notify function
Definition
struct efi_cin_notify_function {
struct list_head link;
struct efi_key_data key;
efi_status_t (EFIAPI *function) (struct efi_key_data *key_data);
};
Members
linklink to list
keykey to notify
functionfunction to call
-
voidset_shift_mask(intmod, structefi_key_state*key_state)
set shift mask
Parameters
int modXterm shift mask
struct efi_key_state *key_statereceives the state of the shift, alt, control, and logo keys
-
intanalyze_modifiers(structefi_key_state*key_state)
analyze modifiers (shift, alt, ctrl) for function keys
Parameters
struct efi_key_state *key_statereceives the state of the shift, alt, control, and logo keys
Description
This gets called when we have already parsed CSI.
Return
the unmodified code
-
efi_status_tefi_cin_read_key(structefi_key_data*key)
read a key from the console input
Parameters
struct efi_key_data *keykey received
Return
status code
-
voidefi_cin_notify(void)
notify registered functions
Parameters
voidno arguments
-
voidefi_cin_check(void)
check if keyboard input is available
Parameters
voidno arguments
-
voidefi_cin_empty_buffer(void)
empty input buffer
Parameters
voidno arguments
-
efi_status_tEFIAPIefi_cin_reset_ex(structefi_simple_text_input_ex_protocol*this, boolextended_verification)
reset console input
Parameters
struct efi_simple_text_input_ex_protocol *thisthe extended simple text input protocol
bool extended_verificationextended verification
Description
This function implements the reset service of the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
old value of the task priority level
-
efi_status_tEFIAPIefi_cin_read_key_stroke_ex(structefi_simple_text_input_ex_protocol*this, structefi_key_data*key_data)
read key stroke
Parameters
struct efi_simple_text_input_ex_protocol *thisinstance of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
struct efi_key_data *key_datakey read from console
Return
status code
Description
This function implements the ReadKeyStrokeEx service of the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
-
efi_status_tEFIAPIefi_cin_set_state(structefi_simple_text_input_ex_protocol*this, u8*key_toggle_state)
set toggle key state
Parameters
struct efi_simple_text_input_ex_protocol *thisinstance of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
u8 *key_toggle_statepointer to key toggle state
Return
status code
Description
This function implements the SetState service of the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
-
efi_status_tEFIAPIefi_cin_register_key_notify(structefi_simple_text_input_ex_protocol*this, structefi_key_data*key_data, efi_status_t(*key_notify_function)(structefi_key_data*key_data), void**notify_handle)
register key notification function
Parameters
struct efi_simple_text_input_ex_protocol *thisinstance of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
struct efi_key_data *key_datakey to be notified
efi_status_t ( *key_notify_function)( struct efi_key_data *key_data)function to be called if the key is pressed
void **notify_handlehandle for unregistering the notification
Return
status code
Description
This function implements the SetState service of the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
-
efi_status_tEFIAPIefi_cin_unregister_key_notify(structefi_simple_text_input_ex_protocol*this, void*notification_handle)
unregister key notification function
Parameters
struct efi_simple_text_input_ex_protocol *thisinstance of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
void *notification_handlehandle received when registering
Return
status code
Description
This function implements the SetState service of the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
-
efi_status_tEFIAPIefi_cin_reset(structefi_simple_text_input_protocol*this, boolextended_verification)
drain the input buffer
Parameters
struct efi_simple_text_input_protocol *thisinstance of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
bool extended_verificationallow for exhaustive verification
Return
status code
Description
This function implements the Reset service of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
-
efi_status_tEFIAPIefi_cin_read_key_stroke(structefi_simple_text_input_protocol*this, structefi_input_key*key)
read key stroke
Parameters
struct efi_simple_text_input_protocol *thisinstance of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
struct efi_input_key *keykey read from console
Return
status code
Description
This function implements the ReadKeyStroke service of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
-
voidEFIAPIefi_key_notify(structefi_event*event, void*context)
notify the wait for key event
Parameters
struct efi_event *eventwait for key event
void *contextnot used
-
efi_status_tefi_console_register(void)
install the console protocols
Parameters
voidno arguments
Description
This function is called from do_bootefi_exec().
Return
status code
-
efi_status_tefi_console_get_u16_string(structefi_simple_text_input_protocol*cin, u16*buf, efi_uintn_tcount, efi_console_filter_funcfilter_func, introw, intcol)
get user input string
Parameters
struct efi_simple_text_input_protocol *cinprotocol interface to EFI_SIMPLE_TEXT_INPUT_PROTOCOL
u16 *bufbuffer to store user input string in UTF16
efi_uintn_t countnumber of u16 string including NULL terminator that buf has
efi_console_filter_func filter_funccallback to filter user input
int rowrow number to locate user input form
int colcolumn number to locate user input form
Return
status code
Unicode Collation protocol
-
efi_intn_tEFIAPIefi_stri_coll(structefi_unicode_collation_protocol*this, u16*s1, u16*s2)
compare utf-16 strings case-insenitively
Parameters
struct efi_unicode_collation_protocol *thisunicode collation protocol instance
u16 *s1first string
u16 *s2second string
Description
This function implements the StriColl() service of the EFI_UNICODE_COLLATION_PROTOCOL2.
See the Unified Extensible Firmware Interface (UEFI) specification for details.
Return
0: s1 == s2, > 0: s1 > s2, < 0: s1 < s2
-
s32next_lower(constu16**string)
get next codepoint converted to lower case
Parameters
const u16 **stringpointer to u16 string, on return advanced by one codepoint
Return
first codepoint of string converted to lower case
-
boolmetai_match(constu16*string, constu16*pattern)
compare utf-16 string with a pattern string case-insenitively
Parameters
const u16 *stringstring to compare
const u16 *patternpattern string
Description
- The pattern string may use these:
matches >= 0 characters
? matches 1 character
[<char1><char2>...<charN>] match any character in the set
[<char1>-<char2>] matches any character in the range
This function is called my efi_metai_match().
For ‘*’ pattern searches this function calls itself recursively. Performance-wise this is suboptimal, especially for multiple ‘*’ wildcards. But it results in simple code.
Return
true if the string is matched.
-
boolEFIAPIefi_metai_match(structefi_unicode_collation_protocol*this, constu16*string, constu16*pattern)
compare utf-16 string with a pattern string case-insenitively
Parameters
struct efi_unicode_collation_protocol *thisunicode collation protocol instance
const u16 *stringstring to compare
const u16 *patternpattern string
Description
- The pattern string may use these:
matches >= 0 characters
? matches 1 character
[<char1><char2>...<charN>] match any character in the set
[<char1>-<char2>] matches any character in the range
This function implements the MetaMatch() service of the EFI_UNICODE_COLLATION_PROTOCOL2.
Return
true if the string is matched.
-
voidEFIAPIefi_str_lwr(structefi_unicode_collation_protocol*this, u16*string)
convert to lower case
Parameters
struct efi_unicode_collation_protocol *thisunicode collation protocol instance
u16 *stringstring to convert
Description
The conversion is done in place. As long as upper and lower letters use the same number of words this does not pose a problem.
This function implements the StrLwr() service of the EFI_UNICODE_COLLATION_PROTOCOL2.
-
voidEFIAPIefi_str_upr(structefi_unicode_collation_protocol*this, u16*string)
convert to upper case
Parameters
struct efi_unicode_collation_protocol *thisunicode collation protocol instance
u16 *stringstring to convert
Description
The conversion is done in place. As long as upper and lower letters use the same number of words this does not pose a problem.
This function implements the StrUpr() service of the EFI_UNICODE_COLLATION_PROTOCOL2.
-
voidEFIAPIefi_fat_to_str(structefi_unicode_collation_protocol*this, efi_uintn_tfat_size, char*fat, u16*string)
convert an 8.3 file name from an OEM codepage to Unicode
Parameters
struct efi_unicode_collation_protocol *thisunicode collation protocol instance
efi_uintn_t fat_sizesize of the string to convert
char *fatstring to convert
u16 *stringconverted string
Description
This function implements the FatToStr() service of the EFI_UNICODE_COLLATION_PROTOCOL2.
-
boolEFIAPIefi_str_to_fat(structefi_unicode_collation_protocol*this, constu16*string, efi_uintn_tfat_size, char*fat)
convert a utf-16 string to legal characters for a FAT file name in an OEM code page
Parameters
struct efi_unicode_collation_protocol *thisunicode collation protocol instance
const u16 *stringUnicode string to convert
efi_uintn_t fat_sizesize of the target buffer
char *fatconverted string
Description
This function implements the StrToFat() service of the EFI_UNICODE_COLLATION_PROTOCOL2.
Return
true if an illegal character was substituted by ‘_’.
Firmware management protocol
-
structfmp_payload_header
EDK2 header for the FMP payload
Definition
struct fmp_payload_header {
u32 signature;
u32 header_size;
u32 fw_version;
u32 lowest_supported_version;
};
Members
signatureHeader signature used to identify the header
header_sizeSize of the structure
fw_versionFirmware versions used
lowest_supported_versionLowest supported version
Description
This structure describes the header which is preprended to the FMP payload by the edk2 capsule generation scripts.
-
structfmp_state
fmp firmware update state
Definition
struct fmp_state {
u32 fw_version;
u32 lowest_supported_version;
u32 last_attempt_version;
u32 last_attempt_status;
};
Members
fw_versionFirmware versions used
lowest_supported_versionLowest supported version
last_attempt_versionLast attempt version
last_attempt_statusLast attempt status
Description
This structure describes the state of the firmware update through FMP protocol.
-
efi_guid_t*efi_firmware_get_image_type_id(u8image_index)
get image_type_id
Parameters
u8 image_indeximage index
Description
Return the image_type_id identified by the image index.
Return
pointer to the image_type_id, NULL if image_index is invalid
-
voidefi_firmware_get_lsv_from_dtb(u8image_index, efi_guid_t*image_type_id, u32*lsv)
get lowest supported version from dtb
Parameters
u8 image_indexImage index
efi_guid_t *image_type_idImage type id
u32 *lsvPointer to store the lowest supported version
Description
Read the firmware version information from dtb.
-
voidefi_firmware_fill_version_info(structefi_firmware_image_descriptor*image_info, structefi_fw_image*fw_array)
fill the version information
Parameters
struct efi_firmware_image_descriptor *image_infoImage information
struct efi_fw_image *fw_arrayPointer to size of new image
Description
Fill the version information into image_info strucrure.
-
efi_status_tefi_gen_capsule_guids(void)
generate GUIDs for the images
Parameters
voidno arguments
Description
Generate the image_type_id for each image in the update_info.images array using the first compatible from the device tree and a salt UUID defined at build time.
Return
status code
-
efi_status_tefi_fill_image_desc_array(efi_uintn_t*image_info_size, structefi_firmware_image_descriptor*image_info, u32*descriptor_version, u8*descriptor_count, efi_uintn_t*descriptor_size, u32*package_version, u16**package_version_name)
populate image descriptor array
Parameters
efi_uintn_t *image_info_sizeSize of image_info
struct efi_firmware_image_descriptor *image_infoImage information
u32 *descriptor_versionPointer to version number
u8 *descriptor_countImage count
efi_uintn_t *descriptor_sizePointer to descriptor size
u32 *package_versionPackage version
u16 **package_version_namePackage version’s name
Description
Return information about the current firmware image in image_info. image_info will consist of a number of descriptors. Each descriptor will be created based on efi_fw_image array.
Return status code
-
efi_status_tefi_firmware_capsule_authenticate(constvoid**p_image, efi_uintn_t*p_image_size)
authenticate the capsule if enabled
Parameters
const void **p_imagePointer to new image
efi_uintn_t *p_image_sizePointer to size of new image
Description
Authenticate the capsule if authentication is enabled. The image pointer and the image size are updated in case of success.
Return
status code
-
efi_status_tefi_firmware_set_fmp_state_var(structfmp_state *state, u8image_index)
set FmpStateXXXX variable
Parameters
struct fmp_state *statePointer to fmp state
u8 image_indeximage index
Description
Update the FmpStateXXXX variable with the firmware update state.
Return
status code
-
voidefi_firmware_get_fw_version(constvoid**p_image, efi_uintn_t*p_image_size, structfmp_state *state)
get fw_version from FMP payload header
Parameters
const void **p_imagePointer to new image
efi_uintn_t *p_image_sizePointer to size of new image
struct fmp_state *statePointer to fmp state
Description
Parse the FMP payload header and fill the fmp_state structure. If no FMP payload header is found, fmp_state structure is not updated.
-
efi_status_tefi_firmware_verify_image(constvoid**p_image, efi_uintn_t*p_image_size, u8image_index, structfmp_state *state)
verify image
Parameters
const void **p_imagePointer to new image
efi_uintn_t *p_image_sizePointer to size of new image
u8 image_indexImage index
struct fmp_state *statePointer to fmp state
Description
Verify the capsule authentication and check if the fw_version is equal or greater than the lowest supported version.
Return
status code
-
efi_status_tEFIAPIefi_firmware_get_image_info(structefi_firmware_management_protocol*this, efi_uintn_t*image_info_size, structefi_firmware_image_descriptor*image_info, u32*descriptor_version, u8*descriptor_count, efi_uintn_t*descriptor_size, u32*package_version, u16**package_version_name)
return information about the current firmware image
Parameters
struct efi_firmware_management_protocol *thisProtocol instance
efi_uintn_t *image_info_sizeSize of image_info
struct efi_firmware_image_descriptor *image_infoImage information
u32 *descriptor_versionPointer to version number
u8 *descriptor_countPointer to number of descriptors
efi_uintn_t *descriptor_sizePointer to descriptor size
u32 *package_versionPackage version
u16 **package_version_namePackage version’s name
Description
Return information bout the current firmware image in image_info. image_info will consist of a number of descriptors. Each descriptor will be created based on "dfu_alt_info" variable.
Return status code
-
efi_status_tEFIAPIefi_firmware_fit_set_image(structefi_firmware_management_protocol*this, u8image_index, constvoid*image, efi_uintn_timage_size, constvoid*vendor_code, efi_status_t(*progress)(efi_uintn_tcompletion), u16**abort_reason)
update the firmware image
Parameters
struct efi_firmware_management_protocol *thisProtocol instance
u8 image_indexImage index number
const void *imageNew image
efi_uintn_t image_sizeSize of new image
const void *vendor_codeVendor-specific update policy
efi_status_t (*progress)(efi_uintn_t completion)Function to report the progress of update
u16 **abort_reasonPointer to string of abort reason
Description
Update the firmware to new image, using dfu. The new image should have FIT image format commonly used in U-Boot. vendor_code, progress and abort_reason are not supported.
Return
status code
-
efi_status_tEFIAPIefi_firmware_raw_set_image(structefi_firmware_management_protocol*this, u8image_index, constvoid*image, efi_uintn_timage_size, constvoid*vendor_code, efi_status_t(*progress)(efi_uintn_tcompletion), u16**abort_reason)
update the firmware image
Parameters
struct efi_firmware_management_protocol *thisProtocol instance
u8 image_indexImage index number
const void *imageNew image
efi_uintn_t image_sizeSize of new image
const void *vendor_codeVendor-specific update policy
efi_status_t (*progress)(efi_uintn_t completion)Function to report the progress of update
u16 **abort_reasonPointer to string of abort reason
Description
Update the firmware to new image, using dfu. The new image should be a single raw image. vendor_code, progress and abort_reason are not supported.
Return
status code
Driver binding protocol
-
structefi_driver_binding_extended_protocol
extended driver binding protocol
Definition
struct efi_driver_binding_extended_protocol {
struct efi_driver_binding_protocol bp;
const struct efi_driver_ops *ops;
};
Members
bpdriver binding protocol
opsoperations supported by the driver
Description
This structure adds internal fields to the driver binding protocol.
-
structefi_driver_ops
operations support by an EFI driver
Definition
struct efi_driver_ops {
const efi_guid_t *protocol;
const efi_guid_t *child_protocol;
efi_status_t (*init)(struct efi_driver_binding_extended_protocol *this);
efi_status_t (*bind)(struct efi_driver_binding_extended_protocol *this, efi_handle_t handle, void *interface);
};
Members
protocolThe GUID of the protocol which is consumed by the driver. This GUID is used by the EFI uclass in the supports() and start() methods of the EFI_DRIVER_BINDING_PROTOCOL.
child_protocolProtocol supported by the child handles generated by the EFI driver.
initFunction called by the EFI uclass after installing the driver binding protocol.
bindFunction called by the EFI uclass to attach the driver to EFI driver to a handle.
Device paths
-
structefi_device_path*efi_dp_next(conststructefi_device_path*dp)
Iterate to next block in device-path
Parameters
const struct efi_device_path *dpPointer to the current device path node.
Description
Advance to the next node in an EFI device path.
Return
Pointer to the next device path node, or NULL if at the end or if input is NULL.
-
intefi_dp_match(conststructefi_device_path*a, conststructefi_device_path*b)
Compare two device-paths
Parameters
const struct efi_device_path *aPointer to the first device path.
const struct efi_device_path *bPointer to the second device path.
Description
Compare two device paths node by node. The comparison stops when an End node is reached in the shorter of the two paths. This is useful, for example, to compare a device-path representing a device with one representing a file on that device, or a device with a parent device.
Return
An integer less than, equal to, or greater than zero if the first differing node in ‘a’ is found, respectively, to be less than, to match, or be greater than the corresponding node in ‘b’. Returns 0 if they match up to the end of the shorter path. Compares length first, then content.
-
structefi_device_path*efi_dp_shorten(structefi_device_path*dp)
shorten device-path
Parameters
struct efi_device_path *dporiginal device-path
Description
When creating a short-boot option we want to use a device-path that is independent of the location where the block device is plugged in.
UsbWwi() nodes contain a serial number, hard drive paths a partition UUID. Both should be unique.
See UEFI spec, section 3.1.2 for "short-form device path".
Return
shortened device-path or NULL
-
efi_handle_tefi_dp_find_obj(structefi_device_path*dp, constefi_guid_t*guid, structefi_device_path**rem)
find handle by device path
Parameters
struct efi_device_path *dpdevice path to search
const efi_guid_t *guidGUID of protocol that must be installed on path or NULL
struct efi_device_path **rempointer to receive remaining device path
Description
If rem is provided, the handle with the longest partial match is returned.
Return
matching handle
-
conststructefi_device_path*efi_dp_last_node(conststructefi_device_path*dp)
Determine the last device path node before the end node
Parameters
const struct efi_device_path *dpPointer to the device path.
Description
Iterate through the device path to find the very last node before the terminating EFI_DP_END node.
Return
Pointer to the last actual data node before the end node if it exists otherwise NULL (e.g., if dp is NULL or only an EFI_DP_END node).
-
efi_uintn_tefi_dp_instance_size(conststructefi_device_path*dp)
Get size of the first device path instance
Parameters
const struct efi_device_path *dpPointer to the device path.
Description
Calculate the total length of all nodes in the first instance of a (potentially multi-instance) device path. The size of the instance-specific end node (if any) or the final device path. The end node is not included.
Return
Size in bytes of the first instance, or 0 if dp is NULL or an EFI_DP_END node
-
efi_uintn_tefi_dp_size(conststructefi_device_path*dp)
Get size of multi-instance device path excluding end node
Parameters
const struct efi_device_path *dpPointer to the device path.
Description
Calculate the total size of the entire device path structure, traversing through all instances, up to but not including the final END_ENTIRE_DEVICE_PATH node.
Return
Total size in bytes of all nodes in the device path (excluding the final EFI_DP_END node), or 0 if dp is NULL.
-
structefi_device_path*efi_dp_dup(conststructefi_device_path*dp)
Copy multi-instance device path
Parameters
const struct efi_device_path *dpPointer to the device path to duplicate.
Description
Duplicate the given device path, including its end node(s). The caller is responsible for freeing the allocated memory (e.g., using efi_free()).
Return
Pointer to the newly allocated and copied device path, or NULL on allocation failure or if dp is NULL.
-
structefi_device_path*efi_dp_concat(conststructefi_device_path*dp1, conststructefi_device_path*dp2, size_tsplit_end_node)
Concatenate two device paths and terminate the result
Parameters
const struct efi_device_path *dp1First device path
const struct efi_device_path *dp2Second device path
size_t split_end_node0 to concatenate (dp1 is assumed not to have an end node or it’s ignored, dp2 is appended, then one EFI_DP_END node)
1 to concatenate with end node added as separator (dp1, END_THIS_INSTANCE, dp2, END_ENTIRE)
Description
Size of dp1 excluding last end node to concatenate with end node as separator in case dp1 contains an end node (dp1 (partial), END_THIS_INSTANCE, dp2, END_ENTIRE)
Return
concatenated device path or NULL. Caller must free the returned value.
-
structefi_device_path*efi_dp_append_node(conststructefi_device_path*dp, conststructefi_device_path*node)
Append a single node to a device path
Parameters
const struct efi_device_path *dpOriginal device path (can be NULL).
const struct efi_device_path *nodeNode to append (can be NULL).
Description
Create a new device path by appending a given node to an existing device path. If the original device path dp is NULL, a new path is created with the given node followed by an EFI_DP_END node. If the node is NULL and dp is not NULL, the original path dp is duplicated. If both dp and node are NULL, a path with only an EFI_DP_END node is returned. The caller must free the returned path (e.g., using efi_free()).
Return
New device path with the node appended, or NULL on allocation failure.
-
structefi_device_path*efi_dp_create_device_node(constu8type, constu8sub_type, constu16length)
Create a new device path node
Parameters
const u8 typeDevice path type.
const u8 sub_typeDevice path sub-type.
const u16 lengthLength of the node (must be >= sizeof(struct efi_device_path)).
Description
Allocate and initialise the header of a new EFI device path node with the given type, sub-type, and length. The content of the node beyond the basic efi_device_path header is zeroed by efi_alloc.
Return
Pointer to the new device path node, or NULL on allocation failure or if length is invalid.
-
structefi_device_path*efi_dp_append_instance(conststructefi_device_path*dp, conststructefi_device_path*dpi)
Append a device path instance to another
Parameters
const struct efi_device_path *dpThe base device path. If NULL, dpi is duplicated.
const struct efi_device_path *dpiThe device path instance to append. Must not be NULL.
Description
Concatenate two device paths, treating the second path (dpi) as a new instance appended to the first path (dp). An END_THIS_INSTANCE node is inserted between dp and dpi if dp is not NULL. If dp is NULL, dpi is duplicated (and terminated appropriately). dpi must not be NULL. The caller is responsible for freeing the returned path (e.g., using efi_free()).
Return
A new device path with dpi appended as a new instance, or NULL on error (e.g. allocation failure, dpi is NULL).
-
structefi_device_path*efi_dp_get_next_instance(structefi_device_path**dp, efi_uintn_t*size)
Extract the next dp instance
Parameters
struct efi_device_path **dpOn input, a pointer to a pointer to the multi-instance device path. On output, *dp is updated to point to the start of the next instance, or NULL if no more instances.
efi_uintn_t *sizeOptional pointer to an efi_uintn_t variable that will receive the size of the extracted instance path (including its EFI_DP_END node).
Description
Given a pointer to a pointer to a device path (dp), this function extracts the first instance from the path. It allocates a new path for this extracted instance (including its instance-specific EFI_DP_END node). The input pointer (*dp) is then updated to point to the start of the next instance in the original path, or set to NULL if no more instances remain. The caller is responsible for freeing the returned instance path (e.g., using efi_free()).
Return
Pointer to a newly allocated device path for the extracted instance, or NULL if no instance could be extracted or an error occurred (e.g., allocation failure).
-
boolefi_dp_is_multi_instance(conststructefi_device_path*dp)
Check if a device path is multi-instance
Parameters
const struct efi_device_path *dpThe device path to check.
Description
Traverse the device path to its end. It is considered multi-instance if an END_THIS_INSTANCE_DEVICE_PATH node (type DEVICE_PATH_TYPE_END, sub-type DEVICE_PATH_SUB_TYPE_INSTANCE_END) is encountered before the final END_ENTIRE_DEVICE_PATH node.
Return
True if the device path contains multiple instances, false otherwise (including if dp is NULL).
-
structefi_device_path*efi_dp_from_part(structblk_desc*desc, intpart)
Construct a dp from a partition on a block device
Parameters
struct blk_desc *descPointer to the block device descriptor.
int partPartition number (0 for the whole device, >0 for a specific partition).
Description
Create a full device path for a specified partition on a given block device. If the partition number part is 0, the path is for the block device itself. The caller is responsible for freeing the allocated memory (e.g., using efi_free()).
Return
Pointer to the newly created device path, or NULL on allocation failure or if the device/partition is not found or invalid.
-
structefi_device_path*efi_dp_part_node(structblk_desc*desc, intpart)
Create a device node for a block device partition
Parameters
struct blk_desc *descPointer to the block device descriptor.
int partPartition number (must be > 0 and correspond to a valid partition on the device).
Description
Creates a single device path node representing a specific partition (e.g., HardDrivePath or CDROMPath, depending on desc->part_type). It does not create the full path from the root, only the partition-specific node. The caller is responsible for freeing the allocated memory (e.g., using efi_free()).
Return
Pointer to the new device path node for the partition, or NULL on allocation * failure or error in getting partition information.
-
structefi_device_path*efi_dp_from_file(conststructefi_device_path*dp, constchar*path)
append file path node to device path.
Parameters
const struct efi_device_path *dpdevice path or NULL
const char *pathfile path or NULL
Return
device path or NULL in case of an error
-
structefi_device_path*efi_dp_from_uart(void)
Create a device path for a UART device.
Parameters
voidno arguments
Description
Construct a device path representing the system’s default UART, typically based on the U-Boot device model root and a UART messaging node. The caller is responsible for freeing the allocated memory (e.g., using efi_free()).
Return
Pointer to the new UART device path, or NULL on allocation failure.
-
structefi_device_path*efi_dp_from_eth(structudevice *dev)
Create a device path for an Ethernet device
Parameters
struct udevice *devUCLASS_ETH device to process
Description
Construct a device path representing the given device. The caller is responsible for freeing the allocated memory (e.g. using efi_free())
Return
Pointer to the new Ethernet device path, or NULL on allocation failure
-
structefi_device_path*efi_dp_from_mem(u32memory_type, u64start_address, size_tsize)
Construct a device-path for a memory-mapped region
Parameters
u32 memory_typeEFI memory type (e.g., EFI_RESERVED_MEMORY_TYPE).
u64 start_addressStarting address of the memory region.
size_t sizeSize of the memory region in bytes.
Description
Create an EFI device path representing a specific memory region, defined by its type, start address, and size. The caller is responsible for freeing the allocated memory (e.g., using efi_free()).
Return
Pointer to the new memory device path, or NULL on allocation failure
-
efi_status_tefi_dp_split_file_path(structefi_device_path*full_path, structefi_device_path**device_path, structefi_device_path**file_path)
split of relative file path from device path
Parameters
struct efi_device_path *full_pathdevice path including device and file path
struct efi_device_path **device_pathpath of the device
struct efi_device_path **file_pathrelative path of the file or NULL if there is none
Description
Given a device path indicating a file on a device, separate the device path in two: the device path of the actual device and the file path relative to this device.
Return
status code
-
efi_status_tefi_dp_from_name(constchar*dev, constchar*devnr, constchar*path, structefi_device_path**device, structefi_device_path**file)
convert U-Boot device and file path to device path
Parameters
const char *devU-Boot device, e.g. ‘mmc’
const char *devnrU-Boot device number, e.g. 1 for ‘mmc:1’
const char *pathfile path relative to U-Boot device, may be NULL
struct efi_device_path **devicepointer to receive device path of the device
struct efi_device_path **filepointer to receive device path for the file
Return
status code
-
ssize_tefi_dp_check_length(conststructefi_device_path*dp, constsize_tmaxlen)
check length of a device path
Parameters
const struct efi_device_path *dppointer to device path
const size_t maxlenmaximum length of the device path
Return
length of the device path if it is less or equal maxlen
-1 if the device path is longer then maxlen
-1 if a device path node has a length of less than 4
-EINVAL if maxlen exceeds SSIZE_MAX
-
structefi_device_path*efi_dp_from_lo(structefi_load_option*lo, constefi_guid_t*guid)
get device-path from load option
Parameters
struct efi_load_option *loEFI load option containing a valid device path
const efi_guid_t *guidGUID identifying device-path or NULL for the EFI binary
Description
The load options in U-Boot may contain multiple concatenated device-paths. The first device-path indicates the EFI binary to execute. Subsequent device-paths start with a VenMedia node where the GUID identifies the function (initrd or fdt).
Return
device path excluding the matched VenMedia node or NULL. Caller must free the returned value.
-
structefi_device_path*search_gpt_dp_node(structefi_device_path*device_path)
search gpt device path node
Parameters
struct efi_device_path *device_pathdevice path
Return
pointer to the gpt device path node
-
structefi_device_path*efi_dp_from_http(constchar*server, structudevice *dev)
set device path from http
Parameters
const char *serverURI of remote server
struct udevice *devnet udevice
Description
Set the device path to an IPv4 path as provided by efi_dp_from_ipv4 concatenated with a device path of subtype DEVICE_PATH_SUB_TYPE_MSG_URI, and an EFI_DP_END node.
Return
pointer to HTTP device path, NULL on error
Unit testing
The following library functions are provided to support writing UEFI unit tests. The should not be used elsewhere.
-
efi_st_printf
efi_st_printf (...)
print a message
Parameters
...format string followed by fields to print
-
efi_st_error
efi_st_error (...)
prints an error message
Parameters
...format string followed by fields to print
-
efi_st_todo
efi_st_todo (...)
prints a TODO message
Parameters
...format string followed by fields to print
-
enumefi_test_phase
phase when test will be executed
Constants
EFI_EXECUTE_BEFORE_BOOTTIME_EXITSetup, execute, and teardown are executed before ExitBootServices().
EFI_SETUP_BEFORE_BOOTTIME_EXITSetup is executed before ExitBootServices() while execute, and teardown are executed after ExitBootServices().
EFI_SETTING_VIRTUAL_ADDRESS_MAPExecute calls SetVirtualAddressMap(). Setup is executed before ExitBootServices() while execute is executed after ExitBootServices(), and after the execute of tests marked as EFI_SETUP_BEFORE_BOOTTIME_EXIT. Teardown is executed thereafter.
Description
A test may be setup and executed at boottime, it may be setup at boottime and executed at runtime, or it may be setup and executed at runtime.
-
voidefi_st_exit_boot_services(void)
exit the boot services
Parameters
voidno arguments
Description
The size of the memory map is determined.
Pool memory is allocated to copy the memory map.
The memory map is copied and the map key is obtained.
The map key is used to exit the boot services.
-
voidefi_st_printc(intcolor, constchar*fmt, ...)
print a colored message
Parameters
int colorcolor, see constants in efi_api.h, use -1 for no color
const char *fmtprintf style format string
...arguments to be printed
-
u16*efi_st_translate_char(u16code)
translate a Unicode character to a string
Parameters
u16 codeUnicode character
Return
string
-
u16*efi_st_translate_code(u16code)
translate a scan code to a human readable string
Parameters
u16 codescan code
Description
This function translates the scan code returned by the simple text input protocol to a human readable string, e.g. 0x04 is translated to u"Left".
Return
Unicode string
-
intefi_st_strcmp_16_8(constu16*buf1, constunsignedchar*buf2)
compare an u16 string to a char string
Parameters
const u16 *buf1u16 string
const unsigned char *buf2char string
Description
This function compares each u16 value to the char value at the same position. This function is only useful for ANSI strings.
Return
0 if both buffers contain equivalent strings
-
void*efi_st_get_config_table(constefi_guid_t*guid)
get configuration table
Parameters
const efi_guid_t *guidGUID of the configuration table
Return
pointer to configuration table or NULL
-
u16efi_st_get_key(void)
reads an Unicode character from the input device
Parameters
voidno arguments
Return
Unicode character
-
intefi_st_query_variable_common(structefi_runtime_services*runtime, u32attributes)
Common variable tests for boottime/runtime
Parameters
struct efi_runtime_services *runtimePointer to services table
u32 attributesAttributes used
Return
EFI_ST_SUCCESS/FAILURE
-
structefi_unit_test
EFI unit test
Definition
struct efi_unit_test {
const char *name;
const enum efi_test_phase phase;
int (*setup)(const efi_handle_t handle, const struct efi_system_table *systable);
int (*execute)(void);
int (*teardown)(void);
bool on_request;
};
Members
namename of the unit test used in the user interface
phasespecifies when setup and execute are executed
setupset up function of the unit test
executeexecute function of the unit test
teardowntear down function of the unit test
on_requestflag indicating that the test shall only be executed on request
Description
The struct efi_unit_test structure provides a interface to an EFI unit test.
-
EFI_UNIT_TEST
EFI_UNIT_TEST (__name)
macro to declare a new EFI unit test
Parameters
__namestring identifying the unit test in the linker generated list
Description
The macro EFI_UNIT_TEST() declares an EFI unit test using the struct
efi_unit_test structure. The test is added to a linker generated list which
is evaluated by the ‘bootefi selftest’ command.