/* * Copyright (c) 2021-2022, Liav A. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include #include #include #include namespace Kernel { class GraphicsManagement { public: static GraphicsManagement& the(); static bool is_initialized(); bool initialize(); unsigned allocate_minor_device_number() { return m_current_minor_number++; }; GraphicsManagement(); void attach_new_display_connector(Badge, DisplayConnector&); void detach_display_connector(Badge, DisplayConnector&); void set_vga_text_mode_cursor(size_t console_width, size_t x, size_t y); void disable_vga_text_mode_console_cursor(); void disable_vga_emulation_access_permanently(); RefPtr console() const { return m_console; } void set_console(Graphics::Console&); void deactivate_graphical_mode(); void activate_graphical_mode(); private: void enable_vga_text_mode_console_cursor(); bool determine_and_initialize_graphics_device(PCI::DeviceIdentifier const&); bool determine_and_initialize_isa_graphics_device(); NonnullRefPtrVector m_graphics_devices; RefPtr m_console; // Note: This is only used when booting with kernel commandline that includes "graphics_subsystem_mode=limited" RefPtr m_preset_resolution_generic_display_connector; // 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 }; SpinlockProtected> m_display_connector_nodes; RecursiveSpinlock m_main_vga_lock; bool m_vga_access_is_disabled { false }; }; }