blob: 098cac21153a1dfda619285c5736b579f62415bf [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);
92efi_status_t eficonfig_select_file_handler(void *data);
93efi_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
98#endif