From: Andreas Reichel <[email protected]> Give the user a chance to override kernel arguments. EBG waits for 3 seconds and checks if user pressed the <a> key. This can help in unbricking a system.
Signed-off-by: Andreas Reichel <[email protected]> --- configure.ac | 12 ++++++++++++ main.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6c7f381..784defa 100644 --- a/configure.ac +++ b/configure.ac @@ -166,6 +166,16 @@ AC_ARG_WITH([mem-uservars], AC_DEFINE_UNQUOTED([ENV_MEM_USERVARS], [${ENV_MEM_USERVARS}], [Reserved memory for user variables]) +AC_ARG_ENABLE([boot-keys], + AS_HELP_STRING([--enable-boot-keys], [enable on-boot hot keys for debugging]), + [ + EBG_BOOT_KEYS=[enabled] + AC_DEFINE([EBG_BOOT_KEYS],[1],[Enable on-boot hot keys]) + ], + [ + EBG_BOOT_KEYS=[disabled] + ]) + dnl pkg-config AC_PATH_PROG(PKG_CONFIG, pkg-config, no) if test "x$PKG_CONFIG" = "xno"; then @@ -196,4 +206,6 @@ AC_MSG_RESULT([ environment backend: ${ENV_API_FILE}.c number of config parts: ${ENV_NUM_CONFIG_PARTS} reserved for uservars: ${ENV_MEM_USERVARS} bytes + + ebg boot keys: ${EBG_BOOT_KEYS} ]) diff --git a/main.c b/main.c index 9fe8bbe..410da4e 100644 --- a/main.c +++ b/main.c @@ -22,6 +22,8 @@ #include <configuration.h> #include "version.h" #include "utils.h" +#include "config.h" +#include "envdata.h" extern const unsigned long init_array_start[]; extern const unsigned long init_array_end[]; @@ -198,11 +200,36 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) status); } +#ifdef EBG_BOOT_KEYS + EFI_INPUT_KEY key; + CHAR16 input_buffer[ENV_STRING_LENGTH]; + + /* Give user a chance to change the boot parameters on the fly */ + Color(system_table, 15, 0); + Print(L"Press <a> to change kernel arguments\n"); + Color(system_table, 7, 0); + + /* Wait for key for 3 seconds */ + WaitForSingleEvent(system_table->ConIn->WaitForKey, 30000000); + + input_buffer[0] = L'\0'; + if (uefi_call_wrapper(system_table->ConIn->ReadKeyStroke, + 2, system_table->ConIn, &key) == EFI_SUCCESS) { + if (key.UnicodeChar == L'a') { + Input(L"\nInput kernel args (empty str to cancel): ", + input_buffer, ENV_STRING_LENGTH - 1); + } + } + if (StrLen(input_buffer) > 0) { + StrCpy(bg_loader_params.payload_options, input_buffer); + } +#endif //EBG_BOOT_KEYS + loaded_image->LoadOptions = bg_loader_params.payload_options; loaded_image->LoadOptionsSize = (StrLen(bg_loader_params.payload_options) + 1) * sizeof(CHAR16); - Print(L"Starting %s with watchdog set to %d seconds\n", + Print(L"\nStarting %s with watchdog set to %d seconds\n", bg_loader_params.payload_path, bg_loader_params.timeout); return uefi_call_wrapper(BS->StartImage, 3, payload_handle, 0, 0); -- 2.19.1 -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/20181025153853.27705-3-andreas.reichel.ext%40siemens.com. For more options, visit https://groups.google.com/d/optout.
