From b510e88745609bef2ad401ee8d6f432f7221dab6 Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Fri, 31 Jul 2026 20:06:08 +0200 Subject: [PATCH] Initialize shell only once --- boot/xtldr/includes/xtldr.hh | 1 + boot/xtldr/shell.cc | 24 ++++++++++++++++++------ boot/xtldr/xtldr.cc | 3 ++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/boot/xtldr/includes/xtldr.hh b/boot/xtldr/includes/xtldr.hh index 8534bf1..8e54c8e 100644 --- a/boot/xtldr/includes/xtldr.hh +++ b/boot/xtldr/includes/xtldr.hh @@ -261,6 +261,7 @@ class Shell STATIC LIST_ENTRY ShellCommands; public: + STATIC XTCDECL VOID InitializeShell(); STATIC XTCDECL EFI_STATUS RegisterCommand(IN PCWSTR Command, IN PCWSTR Description, IN PBL_SHELL_COMMAND Handler); diff --git a/boot/xtldr/shell.cc b/boot/xtldr/shell.cc index 88d1a07..ad918ac 100644 --- a/boot/xtldr/shell.cc +++ b/boot/xtldr/shell.cc @@ -307,6 +307,24 @@ Shell::ExecuteCommand(IN ULONG Argc, Console::Print(L"ERROR: '%S' is not recognized as a valid command.\n", Argv[0]); } +/** + * Initializes the bootloader shell. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +Shell::InitializeShell() +{ + /* Initialize the shell commands list */ + RTL::LinkedList::InitializeListHead(&ShellCommands); + + /* Register all built-in commands */ + RegisterBuiltinCommands(); +} + /** * Splits the supplied raw command line string into an argument count and an argument vector suitable * for command dispatch. The input string is tokenized by whitespace. @@ -881,12 +899,6 @@ Shell::StartLoaderShell() /* Initialize console */ Console::InitializeConsole(); - /* Initialize the shell commands list */ - RTL::LinkedList::InitializeListHead(&ShellCommands); - - /* Register all built-in commands */ - RegisterBuiltinCommands(); - /* Clear the shell exit request flag */ ExitRequest = FALSE; diff --git a/boot/xtldr/xtldr.cc b/boot/xtldr/xtldr.cc index 3e0cac9..fed2f1e 100644 --- a/boot/xtldr/xtldr.cc +++ b/boot/xtldr/xtldr.cc @@ -245,8 +245,9 @@ BlStartXtLoader(IN EFI_HANDLE ImageHandle, for(;;); } - /* Initialize XTLDR and */ + /* Initialize XTLDR and shell */ XtLoader::InitializeBootLoader(ImageHandle, SystemTable); + Shell::InitializeShell(); /* Parse configuration options passed from UEFI shell */ Status = Configuration::ParseCommandLine();