diff options
-rw-r--r-- | Kernel/CommandLine.cpp | 9 | ||||
-rw-r--r-- | Kernel/CommandLine.h | 1 | ||||
-rw-r--r-- | Kernel/TTY/ConsoleManagement.cpp | 8 | ||||
-rw-r--r-- | Kernel/init.cpp | 1 |
4 files changed, 17 insertions, 2 deletions
diff --git a/Kernel/CommandLine.cpp b/Kernel/CommandLine.cpp index 6740fad3c0..37765fbe23 100644 --- a/Kernel/CommandLine.cpp +++ b/Kernel/CommandLine.cpp @@ -201,4 +201,13 @@ Vector<String> CommandLine::userspace_init_args() const return init_args; } +UNMAP_AFTER_INIT size_t CommandLine::switch_to_tty() const +{ + const auto default_tty = lookup("switch_to_tty").value_or("1"); + auto switch_tty_number = default_tty.to_uint(); + if (switch_tty_number.has_value() && switch_tty_number.value() >= 1) { + return switch_tty_number.value() - 1; + } + PANIC("Invalid default tty value: {}", default_tty); +} } diff --git a/Kernel/CommandLine.h b/Kernel/CommandLine.h index 850ab848ab..3f94304e02 100644 --- a/Kernel/CommandLine.h +++ b/Kernel/CommandLine.h @@ -72,6 +72,7 @@ public: [[nodiscard]] String userspace_init() const; [[nodiscard]] Vector<String> userspace_init_args() const; [[nodiscard]] String root_device() const; + [[nodiscard]] size_t switch_to_tty() const; private: CommandLine(const String&); diff --git a/Kernel/TTY/ConsoleManagement.cpp b/Kernel/TTY/ConsoleManagement.cpp index c9753578f7..20dd12c234 100644 --- a/Kernel/TTY/ConsoleManagement.cpp +++ b/Kernel/TTY/ConsoleManagement.cpp @@ -5,8 +5,10 @@ */ #include <AK/Singleton.h> +#include <Kernel/CommandLine.h> #include <Kernel/Debug.h> #include <Kernel/Graphics/GraphicsManagement.h> +#include <Kernel/Panic.h> #include <Kernel/TTY/ConsoleManagement.h> namespace Kernel { @@ -39,7 +41,11 @@ UNMAP_AFTER_INIT void ConsoleManagement::initialize() m_consoles.append(VirtualConsole::create(index)); } // Note: By default the active console is the first one. - m_active_console = m_consoles[0]; + auto tty_number = kernel_command_line().switch_to_tty(); + if (tty_number > m_consoles.size()) { + PANIC("Switch to tty value is invalid: {} ", tty_number); + } + m_active_console = m_consoles[tty_number]; ScopedSpinLock lock(m_lock); m_active_console->set_active(true); } diff --git a/Kernel/init.cpp b/Kernel/init.cpp index 9f0fec02a9..4c39640561 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -166,7 +166,6 @@ extern "C" UNMAP_AFTER_INIT [[noreturn]] void init() PCI::initialize(); GraphicsManagement::the().initialize(); ConsoleManagement::the().initialize(); - ConsoleManagement::the().switch_to(0); Thread::initialize(); Process::initialize(); |