From aee4786d8e80a2a4b2b2422afc4f8f342433c599 Mon Sep 17 00:00:00 2001 From: Liav A Date: Sat, 11 Sep 2021 09:19:20 +0300 Subject: Kernel: Introduce the DeviceManagement singleton This singleton simplifies many aspects that we struggled with before: 1. There's no need to make derived classes of Device expose the constructor as public anymore. The singleton is a friend of them, so he can call the constructor. This solves the issue with try_create_device helper neatly, hopefully for good. 2. Getting a reference of the NullDevice is now being done from this singleton, which means that NullDevice no longer needs to use its own singleton, and we can apply the try_create_device helper on it too :) 3. We can now defer registration completely after the Device constructor which means the Device constructor is merely assigning the major and minor numbers of the Device, and the try_create_device helper ensures it calls the after_inserting method immediately after construction. This creates a great opportunity to make registration more OOM-safe. --- Kernel/TTY/VirtualConsole.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Kernel/TTY/VirtualConsole.h') diff --git a/Kernel/TTY/VirtualConsole.h b/Kernel/TTY/VirtualConsole.h index d90e718cbe..fd0047cdcd 100644 --- a/Kernel/TTY/VirtualConsole.h +++ b/Kernel/TTY/VirtualConsole.h @@ -50,6 +50,7 @@ class VirtualConsole final : public TTY , public VT::TerminalClient { AK_MAKE_ETERNAL friend class ConsoleManagement; + friend class DeviceManagement; friend class ConsoleImpl; friend class VT::Terminal; @@ -84,11 +85,9 @@ public: void emit_char(char); - // FIXME: We expose these constructors to make try_create_device helper to work +private: explicit VirtualConsole(const unsigned index); VirtualConsole(const unsigned index, const CircularQueue&); - -private: // ^KeyboardClient virtual void on_key_pressed(KeyEvent) override; -- cgit v1.2.3