mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:07:34 +00:00
Kernel: Ensure there are all VirtualConsoles properly initialized
It is possible to switch to VirtualConsoles 1 to 4 via the shortcut ALT + [1-4]. Therefor the array of VirtualConsoles should be guaranteed to be initialized. Also add an constant for the maximum number of VirtualConsoles to guarantee consistency.
This commit is contained in:
parent
971a42a816
commit
d8fa8c5f82
3 changed files with 9 additions and 3 deletions
|
@ -36,7 +36,7 @@
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
static u8* s_vga_buffer;
|
static u8* s_vga_buffer;
|
||||||
static VirtualConsole* s_consoles[6];
|
static VirtualConsole* s_consoles[s_max_virtual_consoles];
|
||||||
static int s_active_console;
|
static int s_active_console;
|
||||||
static RecursiveSpinLock s_lock;
|
static RecursiveSpinLock s_lock;
|
||||||
|
|
||||||
|
@ -68,6 +68,8 @@ VirtualConsole::VirtualConsole(const unsigned index)
|
||||||
, m_index(index)
|
, m_index(index)
|
||||||
, m_terminal(*this)
|
, m_terminal(*this)
|
||||||
{
|
{
|
||||||
|
ASSERT(index < s_max_virtual_consoles);
|
||||||
|
|
||||||
m_tty_name = String::format("/dev/tty%u", m_index);
|
m_tty_name = String::format("/dev/tty%u", m_index);
|
||||||
m_terminal.set_size(80, 25);
|
m_terminal.set_size(80, 25);
|
||||||
|
|
||||||
|
@ -83,7 +85,7 @@ void VirtualConsole::switch_to(unsigned index)
|
||||||
{
|
{
|
||||||
if ((int)index == s_active_console)
|
if ((int)index == s_active_console)
|
||||||
return;
|
return;
|
||||||
ASSERT(index < 6);
|
ASSERT(index < s_max_virtual_consoles);
|
||||||
ASSERT(s_consoles[index]);
|
ASSERT(s_consoles[index]);
|
||||||
|
|
||||||
ScopedSpinLock lock(s_lock);
|
ScopedSpinLock lock(s_lock);
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
|
static constexpr unsigned s_max_virtual_consoles = 6;
|
||||||
|
|
||||||
class VirtualConsole final : public TTY
|
class VirtualConsole final : public TTY
|
||||||
, public KeyboardClient
|
, public KeyboardClient
|
||||||
, public VT::TerminalClient {
|
, public VT::TerminalClient {
|
||||||
|
|
|
@ -144,7 +144,9 @@ extern "C" [[noreturn]] void init()
|
||||||
|
|
||||||
VirtualConsole::initialize();
|
VirtualConsole::initialize();
|
||||||
tty0 = new VirtualConsole(0);
|
tty0 = new VirtualConsole(0);
|
||||||
new VirtualConsole(1);
|
for (unsigned i = 1; i < s_max_virtual_consoles; i++) {
|
||||||
|
new VirtualConsole(i);
|
||||||
|
}
|
||||||
VirtualConsole::switch_to(0);
|
VirtualConsole::switch_to(0);
|
||||||
|
|
||||||
Process::initialize();
|
Process::initialize();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue