blob: cec5715f844b8361339bd442bcb30d0a7deb958f [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>
Masahisa Kojimacd160b22023-01-24 15:56:13 +090012#include <menu.h>
Masahisa Kojima87d79142022-09-12 17:33:50 +090013
14#define EFICONFIG_ENTRY_NUM_MAX 99
Masahisa Kojimae34158b2022-09-12 17:33:51 +090015#define EFICONFIG_VOLUME_PATH_MAX 512
Masahisa Kojima87d79142022-09-12 17:33:50 +090016#define EFICONFIG_FILE_PATH_MAX 512
17#define EFICONFIG_FILE_PATH_BUF_SIZE (EFICONFIG_FILE_PATH_MAX * sizeof(u16))
18
Masahisa Kojimacd160b22023-01-24 15:56:13 +090019extern const char *eficonfig_menu_desc;
Masahisa Kojima87d79142022-09-12 17:33:50 +090020typedef efi_status_t (*eficonfig_entry_func)(void *data);
21
22/**
23 * struct eficonfig_entry - menu entry structure
24 *
25 * @num: menu entry index
26 * @title: title of entry
27 * @key: unique key
28 * @efi_menu: pointer to the menu structure
29 * @func: callback function to be called when this entry is selected
30 * @data: data to be passed to the callback function, caller must free() this pointer
31 * @list: list structure
32 */
33struct eficonfig_entry {
34 u32 num;
35 char *title;
36 char key[3];
37 struct efimenu *efi_menu;
38 eficonfig_entry_func func;
39 void *data;
40 struct list_head list;
41};
42
43/**
44 * struct efimenu - efi menu structure
45 *
46 * @delay: delay for autoboot
47 * @active: active menu entry index
48 * @count: total count of menu entry
49 * @menu_header: menu header string
Masahisa Kojimacd160b22023-01-24 15:56:13 +090050 * @menu_desc: menu description string
Masahisa Kojima87d79142022-09-12 17:33:50 +090051 * @list: menu entry list structure
52 */
53struct efimenu {
54 int delay;
55 int active;
56 int count;
57 char *menu_header;
Masahisa Kojimacd160b22023-01-24 15:56:13 +090058 const char *menu_desc;
Masahisa Kojima87d79142022-09-12 17:33:50 +090059 struct list_head list;
60};
61
62/**
63 * struct eficonfig_item - structure to construct eficonfig_entry
64 *
65 * @title: title of entry
66 * @func: callback function to be called when this entry is selected
67 * @data: data to be passed to the callback function
68 */
69struct eficonfig_item {
70 char *title;
71 eficonfig_entry_func func;
72 void *data;
73};
74
75/**
76 * struct eficonfig_select_file_info - structure to be used for file selection
77 *
78 * @current_volume: pointer to the efi_simple_file_system_protocol
79 * @dp_volume: pointer to device path of the selected device
80 * @current_path: pointer to the selected file path string
81 * @filepath_list: list_head structure for file path list
82 * @file_selectred: flag indicates file selecting status
83 */
84struct eficonfig_select_file_info {
85 struct efi_simple_file_system_protocol *current_volume;
86 struct efi_device_path *dp_volume;
87 u16 *current_path;
88 struct list_head filepath_list;
89 bool file_selected;
90};
91
92void eficonfig_print_msg(char *msg);
Masahisa Kojimacd160b22023-01-24 15:56:13 +090093void eficonfig_print_entry(void *data);
94void eficonfig_display_statusline(struct menu *m);
95char *eficonfig_choice_entry(void *data);
Masahisa Kojima87d79142022-09-12 17:33:50 +090096void eficonfig_destroy(struct efimenu *efi_menu);
97efi_status_t eficonfig_process_quit(void *data);
Masahisa Kojimacd160b22023-01-24 15:56:13 +090098efi_status_t eficonfig_process_common(struct efimenu *efi_menu,
99 char *menu_header, const char *menu_desc,
100 void (*display_statusline)(struct menu *),
101 void (*item_data_print)(void *),
102 char *(*item_choice)(void *));
Masahisa Kojimaa84040a2022-11-20 09:21:13 +0900103efi_status_t eficonfig_process_select_file(void *data);
Masahisa Kojima87d79142022-09-12 17:33:50 +0900104efi_status_t eficonfig_get_unused_bootoption(u16 *buf,
105 efi_uintn_t buf_size, u32 *index);
106efi_status_t eficonfig_append_bootorder(u16 index);
Masahisa Kojimac416f1c2022-09-12 17:33:54 +0900107efi_status_t eficonfig_generate_media_device_boot_option(void);
Masahisa Kojima87d79142022-09-12 17:33:50 +0900108
Masahisa Kojima8961e932022-11-20 09:21:14 +0900109efi_status_t eficonfig_append_menu_entry(struct efimenu *efi_menu,
110 char *title, eficonfig_entry_func func,
111 void *data);
112efi_status_t eficonfig_append_quit_entry(struct efimenu *efi_menu);
Masahisa Kojimad6566112022-11-20 09:21:16 +0900113struct efi_device_path *eficonfig_create_device_path(struct efi_device_path *dp_volume,
114 u16 *current_path);
Masahisa Kojimac3b5af62022-11-20 09:21:18 +0900115void *eficonfig_create_fixed_menu(const struct eficonfig_item *items, int count);
116#ifdef CONFIG_EFI_SECURE_BOOT
117efi_status_t eficonfig_process_secure_boot_config(void *data);
118#endif
Masahisa Kojima8961e932022-11-20 09:21:14 +0900119
Masahisa Kojima87d79142022-09-12 17:33:50 +0900120#endif