diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 9e0d5826044..c1ef3e98a92 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -23,7 +23,7 @@ set(KERNEL_SOURCES Arch/x86/SmapDisabler.h CMOS.cpp CommandLine.cpp - Console.cpp + ConsoleDevice.cpp CoreDump.cpp DMI.cpp Devices/AsyncDeviceRequest.cpp diff --git a/Kernel/Console.cpp b/Kernel/ConsoleDevice.cpp similarity index 62% rename from Kernel/Console.cpp rename to Kernel/ConsoleDevice.cpp index d91d838425e..a0f43654ea8 100644 --- a/Kernel/Console.cpp +++ b/Kernel/ConsoleDevice.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include @@ -13,46 +13,46 @@ // Bytes output to 0xE9 end up on the Bochs console. It's very handy. #define CONSOLE_OUT_TO_E9 -static AK::Singleton s_the; +static AK::Singleton s_the; static Kernel::SpinLock g_console_lock; -UNMAP_AFTER_INIT void Console::initialize() +UNMAP_AFTER_INIT void ConsoleDevice::initialize() { s_the.ensure_instance(); } -Console& Console::the() +ConsoleDevice& ConsoleDevice::the() { return *s_the; } -bool Console::is_initialized() +bool ConsoleDevice::is_initialized() { return s_the.is_initialized(); } -UNMAP_AFTER_INIT Console::Console() +UNMAP_AFTER_INIT ConsoleDevice::ConsoleDevice() : CharacterDevice(5, 1) { } -UNMAP_AFTER_INIT Console::~Console() +UNMAP_AFTER_INIT ConsoleDevice::~ConsoleDevice() { } -bool Console::can_read(const Kernel::FileDescription&, size_t) const +bool ConsoleDevice::can_read(const Kernel::FileDescription&, size_t) const { return false; } -Kernel::KResultOr Console::read(FileDescription&, u64, Kernel::UserOrKernelBuffer&, size_t) +Kernel::KResultOr ConsoleDevice::read(FileDescription&, u64, Kernel::UserOrKernelBuffer&, size_t) { // FIXME: Implement reading from the console. // Maybe we could use a ring buffer for this device? return 0; } -Kernel::KResultOr Console::write(FileDescription&, u64, const Kernel::UserOrKernelBuffer& data, size_t size) +Kernel::KResultOr ConsoleDevice::write(FileDescription&, u64, const Kernel::UserOrKernelBuffer& data, size_t size) { if (!size) return 0; @@ -64,7 +64,7 @@ Kernel::KResultOr Console::write(FileDescription&, u64, const Kernel::Us }); } -void Console::put_char(char ch) +void ConsoleDevice::put_char(char ch) { Kernel::ScopedSpinLock lock(g_console_lock); #ifdef CONSOLE_OUT_TO_E9 diff --git a/Kernel/Console.h b/Kernel/ConsoleDevice.h similarity index 87% rename from Kernel/Console.h rename to Kernel/ConsoleDevice.h index 123d21b8c62..a66435f0950 100644 --- a/Kernel/Console.h +++ b/Kernel/ConsoleDevice.h @@ -10,15 +10,17 @@ #include #include -class Console final : public Kernel::CharacterDevice { +namespace Kernel { + +class ConsoleDevice final : public CharacterDevice { AK_MAKE_ETERNAL public: - static Console& the(); + static ConsoleDevice& the(); static void initialize(); static bool is_initialized(); - Console(); - virtual ~Console() override; + ConsoleDevice(); + virtual ~ConsoleDevice() override; // ^CharacterDevice virtual bool can_read(const Kernel::FileDescription&, size_t) const override; @@ -38,3 +40,5 @@ public: private: CircularQueue m_logbuffer; }; + +} diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 805f8522938..aff36ed954c 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -653,7 +653,7 @@ static bool procfs$self(InodeIdentifier, KBufferBuilder& builder) static bool procfs$dmesg(InodeIdentifier, KBufferBuilder& builder) { InterruptDisabler disabler; - for (char ch : Console::the().logbuffer()) + for (char ch : ConsoleDevice::the().logbuffer()) builder.append(ch); return true; } diff --git a/Kernel/TTY/VirtualConsole.h b/Kernel/TTY/VirtualConsole.h index 5f946357da4..10b04771f86 100644 --- a/Kernel/TTY/VirtualConsole.h +++ b/Kernel/TTY/VirtualConsole.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include diff --git a/Kernel/init.cpp b/Kernel/init.cpp index e497688b56d..4dbe4f86a77 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -143,7 +143,7 @@ extern "C" UNMAP_AFTER_INIT [[noreturn]] void init() ACPI::initialize(); VFS::initialize(); - Console::initialize(); + ConsoleDevice::initialize(); dmesgln("Starting SerenityOS..."); diff --git a/Kernel/kprintf.cpp b/Kernel/kprintf.cpp index bb1d8998417..fb3401e0eb6 100644 --- a/Kernel/kprintf.cpp +++ b/Kernel/kprintf.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -65,10 +65,10 @@ static void console_out(char ch) if (serial_debug) serial_putch(ch); - // It would be bad to reach the assert in Console()::the() and do a stack overflow + // It would be bad to reach the assert in ConsoleDevice()::the() and do a stack overflow - if (Console::is_initialized()) { - Console::the().put_char(ch); + if (ConsoleDevice::is_initialized()) { + ConsoleDevice::the().put_char(ch); } else { IO::out8(0xe9, ch); }