u-boot/include/efi_config.h
Masahisa Kojima c416f1c0bc bootmenu: add removable media entries
UEFI specification requires booting from removal media using
a architecture-specific default image name such as BOOTAA64.EFI.
This commit adds the removable media entries into bootmenu,
so that user can select the removable media and boot with
default image.

The bootmenu automatically enumerates the possible bootable
media devices supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL,
add it as new UEFI boot option(BOOT####) and update BootOrder
variable. This automatically generated UEFI boot option
has the dedicated guid in the optional_data to distinguish it from
the UEFI boot option user adds manually. This optional_data is
removed when the efi bootmgr loads the selected UEFI boot option.

This commit also provides the BOOT#### variable maintenance feature.
Depending on the system hardware setup, some devices
may not exist at a later system boot, so bootmenu checks the
available device in each bootmenu invocation and automatically
removes the BOOT#### variable corrensponding to the non-existent
media device.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2022-09-14 08:43:32 +02:00

98 lines
2.7 KiB
C

/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Menu-driven UEFI Variable maintenance
*
* Copyright (c) 2022 Masahisa Kojima, Linaro Limited
*/
#ifndef _EFI_CONFIG_H
#define _EFI_CONFIG_H
#include <efi_loader.h>
#define EFICONFIG_ENTRY_NUM_MAX 99
#define EFICONFIG_VOLUME_PATH_MAX 512
#define EFICONFIG_FILE_PATH_MAX 512
#define EFICONFIG_FILE_PATH_BUF_SIZE (EFICONFIG_FILE_PATH_MAX * sizeof(u16))
typedef efi_status_t (*eficonfig_entry_func)(void *data);
/**
* struct eficonfig_entry - menu entry structure
*
* @num: menu entry index
* @title: title of entry
* @key: unique key
* @efi_menu: pointer to the menu structure
* @func: callback function to be called when this entry is selected
* @data: data to be passed to the callback function, caller must free() this pointer
* @list: list structure
*/
struct eficonfig_entry {
u32 num;
char *title;
char key[3];
struct efimenu *efi_menu;
eficonfig_entry_func func;
void *data;
struct list_head list;
};
/**
* struct efimenu - efi menu structure
*
* @delay: delay for autoboot
* @active: active menu entry index
* @count: total count of menu entry
* @menu_header: menu header string
* @list: menu entry list structure
*/
struct efimenu {
int delay;
int active;
int count;
char *menu_header;
struct list_head list;
};
/**
* struct eficonfig_item - structure to construct eficonfig_entry
*
* @title: title of entry
* @func: callback function to be called when this entry is selected
* @data: data to be passed to the callback function
*/
struct eficonfig_item {
char *title;
eficonfig_entry_func func;
void *data;
};
/**
* struct eficonfig_select_file_info - structure to be used for file selection
*
* @current_volume: pointer to the efi_simple_file_system_protocol
* @dp_volume: pointer to device path of the selected device
* @current_path: pointer to the selected file path string
* @filepath_list: list_head structure for file path list
* @file_selectred: flag indicates file selecting status
*/
struct eficonfig_select_file_info {
struct efi_simple_file_system_protocol *current_volume;
struct efi_device_path *dp_volume;
u16 *current_path;
struct list_head filepath_list;
bool file_selected;
};
void eficonfig_print_msg(char *msg);
void eficonfig_destroy(struct efimenu *efi_menu);
efi_status_t eficonfig_process_quit(void *data);
efi_status_t eficonfig_process_common(struct efimenu *efi_menu, char *menu_header);
efi_status_t eficonfig_select_file_handler(void *data);
efi_status_t eficonfig_get_unused_bootoption(u16 *buf,
efi_uintn_t buf_size, u32 *index);
efi_status_t eficonfig_append_bootorder(u16 index);
efi_status_t eficonfig_generate_media_device_boot_option(void);
#endif