mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
ac7ce12123
This was a premature optimization from the early days of SerenityOS. The eternal heap was a simple bump pointer allocator over a static byte array. My original idea was to avoid heap fragmentation and improve data locality, but both ideas were rooted in cargo culting, not data. We would reserve 4 MiB at boot and only ended up using ~256 KiB, wasting the rest. This patch replaces all kmalloc_eternal() usage by regular kmalloc().
46 lines
1 KiB
C++
46 lines
1 KiB
C++
/*
|
|
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/NonnullRefPtr.h>
|
|
#include <AK/NonnullRefPtrVector.h>
|
|
#include <AK/Types.h>
|
|
#include <Kernel/TTY/VirtualConsole.h>
|
|
|
|
namespace Kernel {
|
|
|
|
class ConsoleManagement {
|
|
friend class VirtualConsole;
|
|
|
|
public:
|
|
ConsoleManagement();
|
|
|
|
static constexpr size_t s_max_virtual_consoles = 6;
|
|
|
|
static bool is_initialized();
|
|
static ConsoleManagement& the();
|
|
|
|
void switch_to(unsigned);
|
|
void initialize();
|
|
|
|
void resolution_was_changed();
|
|
|
|
void switch_to_debug() { switch_to(1); }
|
|
|
|
NonnullRefPtr<VirtualConsole> first_tty() const { return m_consoles[0]; }
|
|
NonnullRefPtr<VirtualConsole> debug_tty() const { return m_consoles[1]; }
|
|
|
|
RecursiveSpinlock& tty_write_lock() { return m_tty_write_lock; }
|
|
|
|
private:
|
|
NonnullRefPtrVector<VirtualConsole, s_max_virtual_consoles> m_consoles;
|
|
VirtualConsole* m_active_console { nullptr };
|
|
Spinlock m_lock;
|
|
RecursiveSpinlock m_tty_write_lock;
|
|
};
|
|
|
|
};
|