blob: fd699263436e456d51f1cf4ec0a3eb47240937c1 [file] [log] [blame]
Masahisa Kojima87d79142022-09-12 17:33:50 +09001/* 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 Kojimae34158b2022-09-12 17:33:51 +090014#define EFICONFIG_VOLUME_PATH_MAX 512
Masahisa Kojima87d79142022-09-12 17:33:50 +090015#define EFICONFIG_FILE_PATH_MAX 512
16#define EFICONFIG_FILE_PATH_BUF_SIZE (EFICONFIG_FILE_PATH_MAX * sizeof(u16))
17
18typedef 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 */
31struct 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 */
50struct 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 */
65struct 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 */
80struct 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
88void eficonfig_print_msg(char *msg);
89void eficonfig_destroy(struct efimenu *efi_menu);
90efi_status_t eficonfig_process_quit(void *data);
91efi_status_t eficonfig_process_common(struct efimenu *efi_menu, char *menu_header);
Masahisa Kojimaa84040a2022-11-20 09:21:13 +090092efi_status_t eficonfig_process_select_file(void *data);
Masahisa Kojima87d79142022-09-12 17:33:50 +090093efi_status_t eficonfig_get_unused_bootoption(u16 *buf,
94 efi_uintn_t buf_size, u32 *index);
95efi_status_t eficonfig_append_bootorder(u16 index);
Masahisa Kojimac416f1c2022-09-12 17:33:54 +090096efi_status_t eficonfig_generate_media_device_boot_option(void);
Masahisa Kojima87d79142022-09-12 17:33:50 +090097
Masahisa Kojima8961e932022-11-20 09:21:14 +090098efi_status_t eficonfig_append_menu_entry(struct efimenu *efi_menu,
99 char *title, eficonfig_entry_func func,
100 void *data);
101efi_status_t eficonfig_append_quit_entry(struct efimenu *efi_menu);
Masahisa Kojimad6566112022-11-20 09:21:16 +0900102struct efi_device_path *eficonfig_create_device_path(struct efi_device_path *dp_volume,
103 u16 *current_path);
Masahisa Kojimac3b5af62022-11-20 09:21:18 +0900104void *eficonfig_create_fixed_menu(const struct eficonfig_item *items, int count);
105#ifdef CONFIG_EFI_SECURE_BOOT
106efi_status_t eficonfig_process_secure_boot_config(void *data);
107#endif
Masahisa Kojima8961e932022-11-20 09:21:14 +0900108
Masahisa Kojima87d79142022-09-12 17:33:50 +0900109#endif