blob: ea5bc4e1bff3eec9b96b001e1b9edea351c10c43 [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
14#define EFICONFIG_FILE_PATH_MAX 512
15#define EFICONFIG_FILE_PATH_BUF_SIZE (EFICONFIG_FILE_PATH_MAX * sizeof(u16))
16
17typedef efi_status_t (*eficonfig_entry_func)(void *data);
18
19/**
20 * struct eficonfig_entry - menu entry structure
21 *
22 * @num: menu entry index
23 * @title: title of entry
24 * @key: unique key
25 * @efi_menu: pointer to the menu structure
26 * @func: callback function to be called when this entry is selected
27 * @data: data to be passed to the callback function, caller must free() this pointer
28 * @list: list structure
29 */
30struct eficonfig_entry {
31 u32 num;
32 char *title;
33 char key[3];
34 struct efimenu *efi_menu;
35 eficonfig_entry_func func;
36 void *data;
37 struct list_head list;
38};
39
40/**
41 * struct efimenu - efi menu structure
42 *
43 * @delay: delay for autoboot
44 * @active: active menu entry index
45 * @count: total count of menu entry
46 * @menu_header: menu header string
47 * @list: menu entry list structure
48 */
49struct efimenu {
50 int delay;
51 int active;
52 int count;
53 char *menu_header;
54 struct list_head list;
55};
56
57/**
58 * struct eficonfig_item - structure to construct eficonfig_entry
59 *
60 * @title: title of entry
61 * @func: callback function to be called when this entry is selected
62 * @data: data to be passed to the callback function
63 */
64struct eficonfig_item {
65 char *title;
66 eficonfig_entry_func func;
67 void *data;
68};
69
70/**
71 * struct eficonfig_select_file_info - structure to be used for file selection
72 *
73 * @current_volume: pointer to the efi_simple_file_system_protocol
74 * @dp_volume: pointer to device path of the selected device
75 * @current_path: pointer to the selected file path string
76 * @filepath_list: list_head structure for file path list
77 * @file_selectred: flag indicates file selecting status
78 */
79struct eficonfig_select_file_info {
80 struct efi_simple_file_system_protocol *current_volume;
81 struct efi_device_path *dp_volume;
82 u16 *current_path;
83 struct list_head filepath_list;
84 bool file_selected;
85};
86
87void eficonfig_print_msg(char *msg);
88void eficonfig_destroy(struct efimenu *efi_menu);
89efi_status_t eficonfig_process_quit(void *data);
90efi_status_t eficonfig_process_common(struct efimenu *efi_menu, char *menu_header);
91efi_status_t eficonfig_select_file_handler(void *data);
92efi_status_t eficonfig_get_unused_bootoption(u16 *buf,
93 efi_uintn_t buf_size, u32 *index);
94efi_status_t eficonfig_append_bootorder(u16 index);
95
96#endif