/* * Copyright (c) 2021, Liav A. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include #include #include namespace Kernel { class BochsGraphicsAdapter; class IntelNativeGraphicsAdapter; class VGACompatibleAdapter; class GraphicsManagement { friend class BochsGraphicsAdapter; friend class IntelNativeGraphicsAdapter; friend class VGACompatibleAdapter; friend class Graphics::VirtIOGraphicsAdapter; AK_MAKE_ETERNAL public: static GraphicsManagement& the(); static bool is_initialized(); bool initialize(); unsigned allocate_minor_device_number() { return m_current_minor_number++; }; GraphicsManagement(); bool framebuffer_devices_allowed() const { return m_framebuffer_devices_allowed; } bool framebuffer_devices_exist() const; SpinLock& main_vga_lock() { return m_main_vga_lock; } RefPtr console() const { return m_console; } void deactivate_graphical_mode(); void activate_graphical_mode(); private: bool determine_and_initialize_graphics_device(const PCI::Address& address, PCI::ID id); NonnullRefPtrVector m_graphics_devices; NonnullOwnPtr m_vga_font_region; RefPtr m_console; // Note: there could be multiple VGA adapters, but only one can operate in VGA mode RefPtr m_vga_adapter; unsigned m_current_minor_number { 0 }; const bool m_framebuffer_devices_allowed; SpinLock m_main_vga_lock; }; }