diff --git a/Kernel/TTY/ConsoleManagement.cpp b/Kernel/TTY/ConsoleManagement.cpp index 20dd12c234c..ea1d2c0de04 100644 --- a/Kernel/TTY/ConsoleManagement.cpp +++ b/Kernel/TTY/ConsoleManagement.cpp @@ -38,6 +38,11 @@ UNMAP_AFTER_INIT ConsoleManagement::ConsoleManagement() UNMAP_AFTER_INIT void ConsoleManagement::initialize() { for (size_t index = 0; index < 4; index++) { + // FIXME: Better determine the debug TTY we chose... + if (index == 1) { + m_consoles.append(VirtualConsole::create_with_preset_log(index, ConsoleDevice::the().logbuffer())); + continue; + } m_consoles.append(VirtualConsole::create(index)); } // Note: By default the active console is the first one. diff --git a/Kernel/TTY/VirtualConsole.cpp b/Kernel/TTY/VirtualConsole.cpp index f08284a339c..00dd68067e5 100644 --- a/Kernel/TTY/VirtualConsole.cpp +++ b/Kernel/TTY/VirtualConsole.cpp @@ -116,10 +116,12 @@ UNMAP_AFTER_INIT NonnullRefPtr VirtualConsole::create(size_t ind return adopt_ref(*new VirtualConsole(index)); } -UNMAP_AFTER_INIT VirtualConsole::VirtualConsole(const unsigned index) - : TTY(4, index) - , m_index(index) - , m_console_impl(*this) +UNMAP_AFTER_INIT NonnullRefPtr VirtualConsole::create_with_preset_log(size_t index, const CircularQueue& log) +{ + return adopt_ref(*new VirtualConsole(index, log)); +} + +UNMAP_AFTER_INIT void VirtualConsole::initialize() { m_tty_name = String::formatted("/dev/tty{}", m_index); VERIFY(GraphicsManagement::the().console()); @@ -138,6 +140,25 @@ UNMAP_AFTER_INIT VirtualConsole::VirtualConsole(const unsigned index) VERIFY(m_cells); } +UNMAP_AFTER_INIT VirtualConsole::VirtualConsole(const unsigned index) + : TTY(4, index) + , m_index(index) + , m_console_impl(*this) +{ + initialize(); +} + +UNMAP_AFTER_INIT VirtualConsole::VirtualConsole(const unsigned index, const CircularQueue& log) + : TTY(4, index) + , m_index(index) + , m_console_impl(*this) +{ + initialize(); + for (auto& ch : log) { + echo(ch); + } +} + UNMAP_AFTER_INIT VirtualConsole::~VirtualConsole() { VERIFY_NOT_REACHED(); diff --git a/Kernel/TTY/VirtualConsole.h b/Kernel/TTY/VirtualConsole.h index 3ad2c0f7030..c36bf5da177 100644 --- a/Kernel/TTY/VirtualConsole.h +++ b/Kernel/TTY/VirtualConsole.h @@ -74,6 +74,7 @@ public: public: static NonnullRefPtr create(size_t index); + static NonnullRefPtr create_with_preset_log(size_t index, const CircularQueue&); virtual ~VirtualConsole() override; @@ -85,7 +86,8 @@ public: void emit_char(char); private: - VirtualConsole(const unsigned index); + explicit VirtualConsole(const unsigned index); + VirtualConsole(const unsigned index, const CircularQueue&); // ^KeyboardClient virtual void on_key_pressed(KeyEvent) override; @@ -119,6 +121,8 @@ private: RecursiveSpinLock m_lock; private: + void initialize(); + void invalidate_cursor(size_t row); void clear();