1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 02:37:42 +00:00

Kernel: Rename Console => ConsoleDevice

This change will help to distinguish between the console
device and the Console abstraction layer in the Graphics
subsystem later.
This commit is contained in:
Liav A 2021-04-24 17:50:35 +03:00 committed by Andreas Kling
parent 0669dd82e2
commit 8f2ddde4cb
7 changed files with 28 additions and 24 deletions

View file

@ -23,7 +23,7 @@ set(KERNEL_SOURCES
Arch/x86/SmapDisabler.h Arch/x86/SmapDisabler.h
CMOS.cpp CMOS.cpp
CommandLine.cpp CommandLine.cpp
Console.cpp ConsoleDevice.cpp
CoreDump.cpp CoreDump.cpp
DMI.cpp DMI.cpp
Devices/AsyncDeviceRequest.cpp Devices/AsyncDeviceRequest.cpp

View file

@ -5,7 +5,7 @@
*/ */
#include <AK/Singleton.h> #include <AK/Singleton.h>
#include <Kernel/Console.h> #include <Kernel/ConsoleDevice.h>
#include <Kernel/IO.h> #include <Kernel/IO.h>
#include <Kernel/SpinLock.h> #include <Kernel/SpinLock.h>
#include <Kernel/kstdio.h> #include <Kernel/kstdio.h>
@ -13,46 +13,46 @@
// Bytes output to 0xE9 end up on the Bochs console. It's very handy. // Bytes output to 0xE9 end up on the Bochs console. It's very handy.
#define CONSOLE_OUT_TO_E9 #define CONSOLE_OUT_TO_E9
static AK::Singleton<Console> s_the; static AK::Singleton<ConsoleDevice> s_the;
static Kernel::SpinLock g_console_lock; static Kernel::SpinLock g_console_lock;
UNMAP_AFTER_INIT void Console::initialize() UNMAP_AFTER_INIT void ConsoleDevice::initialize()
{ {
s_the.ensure_instance(); s_the.ensure_instance();
} }
Console& Console::the() ConsoleDevice& ConsoleDevice::the()
{ {
return *s_the; return *s_the;
} }
bool Console::is_initialized() bool ConsoleDevice::is_initialized()
{ {
return s_the.is_initialized(); return s_the.is_initialized();
} }
UNMAP_AFTER_INIT Console::Console() UNMAP_AFTER_INIT ConsoleDevice::ConsoleDevice()
: CharacterDevice(5, 1) : 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; return false;
} }
Kernel::KResultOr<size_t> Console::read(FileDescription&, u64, Kernel::UserOrKernelBuffer&, size_t) Kernel::KResultOr<size_t> ConsoleDevice::read(FileDescription&, u64, Kernel::UserOrKernelBuffer&, size_t)
{ {
// FIXME: Implement reading from the console. // FIXME: Implement reading from the console.
// Maybe we could use a ring buffer for this device? // Maybe we could use a ring buffer for this device?
return 0; return 0;
} }
Kernel::KResultOr<size_t> Console::write(FileDescription&, u64, const Kernel::UserOrKernelBuffer& data, size_t size) Kernel::KResultOr<size_t> ConsoleDevice::write(FileDescription&, u64, const Kernel::UserOrKernelBuffer& data, size_t size)
{ {
if (!size) if (!size)
return 0; return 0;
@ -64,7 +64,7 @@ Kernel::KResultOr<size_t> 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); Kernel::ScopedSpinLock lock(g_console_lock);
#ifdef CONSOLE_OUT_TO_E9 #ifdef CONSOLE_OUT_TO_E9

View file

@ -10,15 +10,17 @@
#include <AK/Vector.h> #include <AK/Vector.h>
#include <Kernel/Devices/CharacterDevice.h> #include <Kernel/Devices/CharacterDevice.h>
class Console final : public Kernel::CharacterDevice { namespace Kernel {
class ConsoleDevice final : public CharacterDevice {
AK_MAKE_ETERNAL AK_MAKE_ETERNAL
public: public:
static Console& the(); static ConsoleDevice& the();
static void initialize(); static void initialize();
static bool is_initialized(); static bool is_initialized();
Console(); ConsoleDevice();
virtual ~Console() override; virtual ~ConsoleDevice() override;
// ^CharacterDevice // ^CharacterDevice
virtual bool can_read(const Kernel::FileDescription&, size_t) const override; virtual bool can_read(const Kernel::FileDescription&, size_t) const override;
@ -38,3 +40,5 @@ public:
private: private:
CircularQueue<char, 16384> m_logbuffer; CircularQueue<char, 16384> m_logbuffer;
}; };
}

View file

@ -12,7 +12,7 @@
#include <Kernel/Arch/x86/CPU.h> #include <Kernel/Arch/x86/CPU.h>
#include <Kernel/Arch/x86/ProcessorInfo.h> #include <Kernel/Arch/x86/ProcessorInfo.h>
#include <Kernel/CommandLine.h> #include <Kernel/CommandLine.h>
#include <Kernel/Console.h> #include <Kernel/ConsoleDevice.h>
#include <Kernel/DMI.h> #include <Kernel/DMI.h>
#include <Kernel/Debug.h> #include <Kernel/Debug.h>
#include <Kernel/Devices/BlockDevice.h> #include <Kernel/Devices/BlockDevice.h>
@ -653,7 +653,7 @@ static bool procfs$self(InodeIdentifier, KBufferBuilder& builder)
static bool procfs$dmesg(InodeIdentifier, KBufferBuilder& builder) static bool procfs$dmesg(InodeIdentifier, KBufferBuilder& builder)
{ {
InterruptDisabler disabler; InterruptDisabler disabler;
for (char ch : Console::the().logbuffer()) for (char ch : ConsoleDevice::the().logbuffer())
builder.append(ch); builder.append(ch);
return true; return true;
} }

View file

@ -6,7 +6,7 @@
#pragma once #pragma once
#include <Kernel/Console.h> #include <Kernel/ConsoleDevice.h>
#include <Kernel/Devices/HID/HIDManagement.h> #include <Kernel/Devices/HID/HIDManagement.h>
#include <Kernel/TTY/TTY.h> #include <Kernel/TTY/TTY.h>
#include <LibVT/Terminal.h> #include <LibVT/Terminal.h>

View file

@ -143,7 +143,7 @@ extern "C" UNMAP_AFTER_INIT [[noreturn]] void init()
ACPI::initialize(); ACPI::initialize();
VFS::initialize(); VFS::initialize();
Console::initialize(); ConsoleDevice::initialize();
dmesgln("Starting SerenityOS..."); dmesgln("Starting SerenityOS...");

View file

@ -6,7 +6,7 @@
#include <AK/PrintfImplementation.h> #include <AK/PrintfImplementation.h>
#include <AK/Types.h> #include <AK/Types.h>
#include <Kernel/Console.h> #include <Kernel/ConsoleDevice.h>
#include <Kernel/IO.h> #include <Kernel/IO.h>
#include <Kernel/Process.h> #include <Kernel/Process.h>
#include <Kernel/SpinLock.h> #include <Kernel/SpinLock.h>
@ -65,10 +65,10 @@ static void console_out(char ch)
if (serial_debug) if (serial_debug)
serial_putch(ch); 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()) { if (ConsoleDevice::is_initialized()) {
Console::the().put_char(ch); ConsoleDevice::the().put_char(ch);
} else { } else {
IO::out8(0xe9, ch); IO::out8(0xe9, ch);
} }