Convert CONFIG_SYS_NAND_PAGE_2K et al to Kconfig
[platform/kernel/u-boot.git] / include / efi_config.h
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
14 #define EFICONFIG_VOLUME_PATH_MAX 512
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);
92 efi_status_t eficonfig_process_select_file(void *data);
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);
96 efi_status_t eficonfig_generate_media_device_boot_option(void);
97
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);
102 struct efi_device_path *eficonfig_create_device_path(struct efi_device_path *dp_volume,
103                                                      u16 *current_path);
104 void *eficonfig_create_fixed_menu(const struct eficonfig_item *items, int count);
105 #ifdef CONFIG_EFI_SECURE_BOOT
106 efi_status_t eficonfig_process_secure_boot_config(void *data);
107 #endif
108
109 #endif