Masahisa Kojima | 87d7914 | 2022-09-12 17:33:50 +0900 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * Menu-driven UEFI Variable maintenance |
| 4 | * |
| 5 | * Copyright (c) 2022 Masahisa Kojima, Linaro Limited |
| 6 | */ |
| 7 | |
| 8 | #ifndef _EFI_CONFIG_H |
| 9 | #define _EFI_CONFIG_H |
| 10 | |
| 11 | #include <efi_loader.h> |
| 12 | |
| 13 | #define EFICONFIG_ENTRY_NUM_MAX 99 |
Masahisa Kojima | e34158b | 2022-09-12 17:33:51 +0900 | [diff] [blame] | 14 | #define EFICONFIG_VOLUME_PATH_MAX 512 |
Masahisa Kojima | 87d7914 | 2022-09-12 17:33:50 +0900 | [diff] [blame] | 15 | #define EFICONFIG_FILE_PATH_MAX 512 |
| 16 | #define EFICONFIG_FILE_PATH_BUF_SIZE (EFICONFIG_FILE_PATH_MAX * sizeof(u16)) |
| 17 | |
| 18 | typedef efi_status_t (*eficonfig_entry_func)(void *data); |
| 19 | |
| 20 | /** |
| 21 | * struct eficonfig_entry - menu entry structure |
| 22 | * |
| 23 | * @num: menu entry index |
| 24 | * @title: title of entry |
| 25 | * @key: unique key |
| 26 | * @efi_menu: pointer to the menu structure |
| 27 | * @func: callback function to be called when this entry is selected |
| 28 | * @data: data to be passed to the callback function, caller must free() this pointer |
| 29 | * @list: list structure |
| 30 | */ |
| 31 | struct eficonfig_entry { |
| 32 | u32 num; |
| 33 | char *title; |
| 34 | char key[3]; |
| 35 | struct efimenu *efi_menu; |
| 36 | eficonfig_entry_func func; |
| 37 | void *data; |
| 38 | struct list_head list; |
| 39 | }; |
| 40 | |
| 41 | /** |
| 42 | * struct efimenu - efi menu structure |
| 43 | * |
| 44 | * @delay: delay for autoboot |
| 45 | * @active: active menu entry index |
| 46 | * @count: total count of menu entry |
| 47 | * @menu_header: menu header string |
| 48 | * @list: menu entry list structure |
| 49 | */ |
| 50 | struct efimenu { |
| 51 | int delay; |
| 52 | int active; |
| 53 | int count; |
| 54 | char *menu_header; |
| 55 | struct list_head list; |
| 56 | }; |
| 57 | |
| 58 | /** |
| 59 | * struct eficonfig_item - structure to construct eficonfig_entry |
| 60 | * |
| 61 | * @title: title of entry |
| 62 | * @func: callback function to be called when this entry is selected |
| 63 | * @data: data to be passed to the callback function |
| 64 | */ |
| 65 | struct eficonfig_item { |
| 66 | char *title; |
| 67 | eficonfig_entry_func func; |
| 68 | void *data; |
| 69 | }; |
| 70 | |
| 71 | /** |
| 72 | * struct eficonfig_select_file_info - structure to be used for file selection |
| 73 | * |
| 74 | * @current_volume: pointer to the efi_simple_file_system_protocol |
| 75 | * @dp_volume: pointer to device path of the selected device |
| 76 | * @current_path: pointer to the selected file path string |
| 77 | * @filepath_list: list_head structure for file path list |
| 78 | * @file_selectred: flag indicates file selecting status |
| 79 | */ |
| 80 | struct eficonfig_select_file_info { |
| 81 | struct efi_simple_file_system_protocol *current_volume; |
| 82 | struct efi_device_path *dp_volume; |
| 83 | u16 *current_path; |
| 84 | struct list_head filepath_list; |
| 85 | bool file_selected; |
| 86 | }; |
| 87 | |
| 88 | void eficonfig_print_msg(char *msg); |
| 89 | void eficonfig_destroy(struct efimenu *efi_menu); |
| 90 | efi_status_t eficonfig_process_quit(void *data); |
| 91 | efi_status_t eficonfig_process_common(struct efimenu *efi_menu, char *menu_header); |
Masahisa Kojima | a84040a | 2022-11-20 09:21:13 +0900 | [diff] [blame] | 92 | efi_status_t eficonfig_process_select_file(void *data); |
Masahisa Kojima | 87d7914 | 2022-09-12 17:33:50 +0900 | [diff] [blame] | 93 | efi_status_t eficonfig_get_unused_bootoption(u16 *buf, |
| 94 | efi_uintn_t buf_size, u32 *index); |
| 95 | efi_status_t eficonfig_append_bootorder(u16 index); |
Masahisa Kojima | c416f1c | 2022-09-12 17:33:54 +0900 | [diff] [blame] | 96 | efi_status_t eficonfig_generate_media_device_boot_option(void); |
Masahisa Kojima | 87d7914 | 2022-09-12 17:33:50 +0900 | [diff] [blame] | 97 | |
Masahisa Kojima | 8961e93 | 2022-11-20 09:21:14 +0900 | [diff] [blame] | 98 | efi_status_t eficonfig_append_menu_entry(struct efimenu *efi_menu, |
| 99 | char *title, eficonfig_entry_func func, |
| 100 | void *data); |
| 101 | efi_status_t eficonfig_append_quit_entry(struct efimenu *efi_menu); |
Masahisa Kojima | d656611 | 2022-11-20 09:21:16 +0900 | [diff] [blame^] | 102 | struct efi_device_path *eficonfig_create_device_path(struct efi_device_path *dp_volume, |
| 103 | u16 *current_path); |
Masahisa Kojima | 8961e93 | 2022-11-20 09:21:14 +0900 | [diff] [blame] | 104 | |
Masahisa Kojima | 87d7914 | 2022-09-12 17:33:50 +0900 | [diff] [blame] | 105 | #endif |