2021-04-16 19:58:51 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Types.h>
|
2022-08-19 18:53:40 +00:00
|
|
|
#include <Kernel/Library/NonnullLockRefPtr.h>
|
2021-04-16 19:58:51 +00:00
|
|
|
#include <Kernel/TTY/VirtualConsole.h>
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
class ConsoleManagement {
|
|
|
|
friend class VirtualConsole;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ConsoleManagement();
|
|
|
|
|
2021-08-07 22:44:25 +00:00
|
|
|
static constexpr size_t s_max_virtual_consoles = 6;
|
2021-05-31 16:42:21 +00:00
|
|
|
|
2021-04-16 19:58:51 +00:00
|
|
|
static bool is_initialized();
|
|
|
|
static ConsoleManagement& the();
|
|
|
|
|
|
|
|
void switch_to(unsigned);
|
|
|
|
void initialize();
|
|
|
|
|
2021-05-18 18:34:22 +00:00
|
|
|
void resolution_was_changed();
|
|
|
|
|
2021-05-13 16:36:31 +00:00
|
|
|
void switch_to_debug() { switch_to(1); }
|
|
|
|
|
2022-08-19 18:53:40 +00:00
|
|
|
NonnullLockRefPtr<VirtualConsole> first_tty() const { return m_consoles[0]; }
|
|
|
|
NonnullLockRefPtr<VirtualConsole> debug_tty() const { return m_consoles[1]; }
|
2021-04-16 19:58:51 +00:00
|
|
|
|
2022-11-09 10:39:58 +00:00
|
|
|
RecursiveSpinlock<LockRank::None>& tty_write_lock() { return m_tty_write_lock; }
|
2021-04-16 19:58:51 +00:00
|
|
|
|
|
|
|
private:
|
2023-03-06 16:56:28 +00:00
|
|
|
Vector<NonnullLockRefPtr<VirtualConsole>, s_max_virtual_consoles> m_consoles;
|
2021-08-07 22:44:25 +00:00
|
|
|
VirtualConsole* m_active_console { nullptr };
|
2022-11-09 10:39:58 +00:00
|
|
|
Spinlock<LockRank::None> m_lock {};
|
|
|
|
RecursiveSpinlock<LockRank::None> m_tty_write_lock {};
|
2021-04-16 19:58:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|