/* * Copyright (c) 2018-2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Kernel { extern Spinlock g_console_lock; class ConsoleDevice final : public CharacterDevice { friend class DeviceManagement; public: static NonnullLockRefPtr must_create(); virtual ~ConsoleDevice() override; // ^CharacterDevice virtual bool can_read(Kernel::OpenFileDescription const&, u64) const override; virtual bool can_write(Kernel::OpenFileDescription const&, u64) const override { return true; } virtual ErrorOr read(OpenFileDescription&, u64, Kernel::UserOrKernelBuffer&, size_t) override; virtual ErrorOr write(OpenFileDescription&, u64, Kernel::UserOrKernelBuffer const&, size_t) override; virtual StringView class_name() const override { return "Console"sv; } // ^Device virtual bool is_openable_by_jailed_processes() const override { return true; } void put_char(char); CircularQueue const& logbuffer() const { return m_logbuffer; } private: ConsoleDevice(); CircularQueue m_logbuffer; }; }