aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-09-14 12:31:44 -0400
committerTom Rini <trini@konsulko.com>2022-09-14 12:31:44 -0400
commit1520af3f8450bb58168fe1cc827a56d435e9f74c (patch)
treec68826240a27e03c9edbbffdfc255d0ee6d51086 /include
parent6541726ee92108935b97449ed28d8dd28c0ef001 (diff)
parentda4fb707ca095c223b67637e2525df4866e51c62 (diff)
Merge tag 'efi-next-2022-09-14' of https://source.denx.de/u-boot/custodians/u-boot-efi into next
Pull request for efi next UEFI: Implement a command eficonfig to maintain Load Options and boot order via menus.
Diffstat (limited to 'include')
-rw-r--r--include/efi_config.h98
-rw-r--r--include/efi_loader.h53
-rw-r--r--include/menu.h3
3 files changed, 154 insertions, 0 deletions
diff --git a/include/efi_config.h b/include/efi_config.h
new file mode 100644
index 0000000000..098cac2115
--- /dev/null
+++ b/include/efi_config.h
@@ -0,0 +1,98 @@
+/* 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
diff --git a/include/efi_loader.h b/include/efi_loader.h
index b0d6fff67c..6b63ae8dde 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -142,6 +142,11 @@ static inline efi_status_t efi_launch_capsules(void)
EFI_GUID(0x63293792, 0xadf5, 0x9325, \
0xb9, 0x9f, 0x4e, 0x0e, 0x45, 0x5c, 0x1b, 0x1e)
+/* GUID for the auto generated boot menu entry */
+#define EFICONFIG_AUTO_GENERATED_ENTRY_GUID \
+ EFI_GUID(0x38c1acc1, 0x9fc0, 0x41f0, \
+ 0xb9, 0x01, 0xfa, 0x74, 0xd6, 0xd6, 0xe4, 0xde)
+
/* Use internal device tree when starting UEFI application */
#define EFI_FDT_USE_INTERNAL NULL
@@ -226,6 +231,9 @@ const char *__efi_nesting_dec(void);
#define EFI_CACHELINE_SIZE 128
#endif
+/* max bootmenu title size for volume selection */
+#define BOOTMENU_DEVICE_NAME_MAX 16
+
/* Key identifying current memory map */
extern efi_uintn_t efi_memory_map_key;
@@ -249,6 +257,9 @@ extern const struct efi_hii_string_protocol efi_hii_string;
uint16_t *efi_dp_str(struct efi_device_path *dp);
+/* GUID for the auto generated boot menu entry */
+extern const efi_guid_t efi_guid_bootmenu_auto_generated;
+
/* GUID of the U-Boot root node */
extern const efi_guid_t efi_u_boot_guid;
#ifdef CONFIG_SANDBOX
@@ -314,6 +325,8 @@ extern const efi_guid_t efi_guid_firmware_management_protocol;
extern const efi_guid_t efi_esrt_guid;
/* GUID of the SMBIOS table */
extern const efi_guid_t smbios_guid;
+/*GUID of console */
+extern const efi_guid_t efi_guid_text_input_protocol;
extern char __efi_runtime_start[], __efi_runtime_stop[];
extern char __efi_runtime_rel_start[], __efi_runtime_rel_stop[];
@@ -940,6 +953,22 @@ struct efi_signature_store {
struct x509_certificate;
struct pkcs7_message;
+/**
+ * struct eficonfig_media_boot_option - boot option for (removable) media device
+ *
+ * This structure is used to enumerate possible boot option
+ *
+ * @lo: Serialized load option data
+ * @size: Size of serialized load option data
+ * @exist: Flag to indicate the load option already exists
+ * in Non-volatile load option
+ */
+struct eficonfig_media_boot_option {
+ void *lo;
+ efi_uintn_t size;
+ bool exist;
+};
+
bool efi_hash_regions(struct image_region *regs, int count,
void **hash, const char *hash_algo, int *len);
bool efi_signature_lookup_digest(struct efi_image_regions *regs,
@@ -1064,4 +1093,28 @@ efi_status_t efi_esrt_populate(void);
efi_status_t efi_load_capsule_drivers(void);
efi_status_t platform_get_eventlog(struct udevice *dev, u64 *addr, u32 *sz);
+
+efi_status_t efi_locate_handle_buffer_int(enum efi_locate_search_type search_type,
+ const efi_guid_t *protocol, void *search_key,
+ efi_uintn_t *no_handles, efi_handle_t **buffer);
+
+efi_status_t efi_open_volume_int(struct efi_simple_file_system_protocol *this,
+ struct efi_file_handle **root);
+efi_status_t efi_file_open_int(struct efi_file_handle *this,
+ struct efi_file_handle **new_handle,
+ u16 *file_name, u64 open_mode,
+ u64 attributes);
+efi_status_t efi_file_close_int(struct efi_file_handle *file);
+efi_status_t efi_file_read_int(struct efi_file_handle *this,
+ efi_uintn_t *buffer_size, void *buffer);
+efi_status_t efi_file_setpos_int(struct efi_file_handle *file, u64 pos);
+
+typedef efi_status_t (*efi_console_filter_func)(struct efi_input_key *key);
+efi_status_t efi_console_get_u16_string
+ (struct efi_simple_text_input_protocol *cin,
+ u16 *buf, efi_uintn_t count, efi_console_filter_func filer_func,
+ int row, int col);
+
+efi_status_t efi_disk_get_device_name(const efi_handle_t handle, char *buf, int size);
+
#endif /* _EFI_LOADER_H */
diff --git a/include/menu.h b/include/menu.h
index e74616cae8..702aacb170 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -48,6 +48,9 @@ enum bootmenu_key {
KEY_DOWN,
KEY_SELECT,
KEY_QUIT,
+ KEY_PLUS,
+ KEY_MINUS,
+ KEY_SPACE,
};
void bootmenu_autoboot_loop(struct bootmenu_data *menu,