efi_config.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. #ifndef _EFI_CONFIG_H
  8. #define _EFI_CONFIG_H
  9. #include <efi_loader.h>
  10. #include <menu.h>
  11. #define EFICONFIG_ENTRY_NUM_MAX (INT_MAX - 1)
  12. #define EFICONFIG_VOLUME_PATH_MAX 512
  13. #define EFICONFIG_FILE_PATH_MAX 512
  14. #define EFICONFIG_FILE_PATH_BUF_SIZE (EFICONFIG_FILE_PATH_MAX * sizeof(u16))
  15. extern const char *eficonfig_menu_desc;
  16. typedef efi_status_t (*eficonfig_entry_func)(void *data);
  17. /**
  18. * struct eficonfig_entry - menu entry structure
  19. *
  20. * @num: menu entry index
  21. * @title: title of entry
  22. * @key: unique key
  23. * @efi_menu: pointer to the menu structure
  24. * @func: callback function to be called when this entry is selected
  25. * @data: data to be passed to the callback function, caller must free() this pointer
  26. * @list: list structure
  27. */
  28. struct eficonfig_entry {
  29. u32 num;
  30. char *title;
  31. char key[3];
  32. struct efimenu *efi_menu;
  33. eficonfig_entry_func func;
  34. void *data;
  35. struct list_head list;
  36. };
  37. /**
  38. * struct efimenu - efi menu structure
  39. *
  40. * @delay: delay for autoboot
  41. * @active: active menu entry index
  42. * @count: total count of menu entry
  43. * @menu_header: menu header string
  44. * @menu_desc: menu description string
  45. * @list: menu entry list structure
  46. * @start: top menu index to draw
  47. * @end: bottom menu index to draw
  48. */
  49. struct efimenu {
  50. int delay;
  51. int active;
  52. int count;
  53. char *menu_header;
  54. const char *menu_desc;
  55. struct list_head list;
  56. int start;
  57. int end;
  58. };
  59. /**
  60. * struct eficonfig_item - structure to construct eficonfig_entry
  61. *
  62. * @title: title of entry
  63. * @func: callback function to be called when this entry is selected
  64. * @data: data to be passed to the callback function
  65. */
  66. struct eficonfig_item {
  67. char *title;
  68. eficonfig_entry_func func;
  69. void *data;
  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. void eficonfig_print_msg(char *msg);
  88. void eficonfig_print_entry(void *data);
  89. void eficonfig_display_statusline(struct menu *m);
  90. char *eficonfig_choice_entry(void *data);
  91. void eficonfig_destroy(struct efimenu *efi_menu);
  92. efi_status_t eficonfig_process_quit(void *data);
  93. efi_status_t eficonfig_process_common(struct efimenu *efi_menu,
  94. char *menu_header, const char *menu_desc,
  95. void (*display_statusline)(struct menu *),
  96. void (*item_data_print)(void *),
  97. char *(*item_choice)(void *));
  98. efi_status_t eficonfig_process_select_file(void *data);
  99. efi_status_t eficonfig_append_menu_entry(struct efimenu *efi_menu,
  100. char *title, eficonfig_entry_func func,
  101. void *data);
  102. efi_status_t eficonfig_append_quit_entry(struct efimenu *efi_menu);
  103. struct efi_device_path *eficonfig_create_device_path(struct efi_device_path *dp_volume,
  104. u16 *current_path);
  105. void *eficonfig_create_fixed_menu(const struct eficonfig_item *items, int count);
  106. #ifdef CONFIG_EFI_SECURE_BOOT
  107. efi_status_t eficonfig_process_secure_boot_config(void *data);
  108. #endif
  109. #endif