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
Notes: sideshowbarker 2024-07-18 18:00:52 +09:00
7 changed files with 28 additions and 24 deletions

View File

@ -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

View File

@ -5,7 +5,7 @@
*/
#include <AK/Singleton.h>
#include <Kernel/Console.h>
#include <Kernel/ConsoleDevice.h>
#include <Kernel/IO.h>
#include <Kernel/SpinLock.h>
#include <Kernel/kstdio.h>
@ -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<Console> s_the;
static AK::Singleton<ConsoleDevice> 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<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.
// Maybe we could use a ring buffer for this device?
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)
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);
#ifdef CONSOLE_OUT_TO_E9

View File

@ -10,15 +10,17 @@
#include <AK/Vector.h>
#include <Kernel/Devices/CharacterDevice.h>
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<char, 16384> m_logbuffer;
};
}

View File

@ -12,7 +12,7 @@
#include <Kernel/Arch/x86/CPU.h>
#include <Kernel/Arch/x86/ProcessorInfo.h>
#include <Kernel/CommandLine.h>
#include <Kernel/Console.h>
#include <Kernel/ConsoleDevice.h>
#include <Kernel/DMI.h>
#include <Kernel/Debug.h>
#include <Kernel/Devices/BlockDevice.h>
@ -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;
}

View File

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

View File

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

View File

@ -6,7 +6,7 @@
#include <AK/PrintfImplementation.h>
#include <AK/Types.h>
#include <Kernel/Console.h>
#include <Kernel/ConsoleDevice.h>
#include <Kernel/IO.h>
#include <Kernel/Process.h>
#include <Kernel/SpinLock.h>
@ -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);
}