efi: app: Find the device-path-to-text protocol on startup

Some protocols are generally useful for the app and it makes sense to
store these in the priv struct rather than requesting them each time
they are needed.

Add a new function which locates the device-path-to-text protocol and
stores it.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-08-15 17:55:34 -06:00
parent 8eac1801d3
commit 26075373f8
2 changed files with 11 additions and 0 deletions

View File

@@ -471,6 +471,7 @@ static inline struct efi_mem_desc *efi_get_next_mem_desc(
* allocate_pages() and free_pages()
* @ram_base: Base address of RAM (size CONFIG_EFI_RAM_SIZE)
* @image_data_type: Type of the loaded image (e.g. EFI_LOADER_CODE)
* @efi_dp_to_text: Pointer to the EFI_DEVICE_PATH protocol, or NULL if none
*
* @info: Header of the info list, holding info collected by the stub and passed
* to U-Boot
@@ -496,6 +497,7 @@ struct efi_priv {
bool use_pool_for_malloc;
unsigned long ram_base;
unsigned int image_data_type;
struct efi_device_path_to_text_protocol *efi_dp_to_text;
/* stub: */
struct efi_info_hdr *info;

View File

@@ -176,6 +176,14 @@ static void scan_tables(struct efi_system_table *sys_table)
}
}
static void find_protocols(struct efi_priv *priv)
{
efi_guid_t guid = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID;
struct efi_boot_services *boot = priv->boot;
boot->locate_protocol(&guid, NULL, (void **)&priv->efi_dp_to_text);
}
/**
* efi_main() - Start an EFI image
*
@@ -211,6 +219,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image,
}
scan_tables(priv->sys_table);
find_protocols(priv);
/*
* We could store the EFI memory map here, but it changes all the time,