2021-03-05 14:23:08 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-04-16 22:58:51 +03:00
|
|
|
#include <AK/NonnullOwnPtr.h>
|
2021-03-05 14:23:08 +02:00
|
|
|
#include <AK/NonnullRefPtr.h>
|
|
|
|
|
#include <AK/NonnullRefPtrVector.h>
|
|
|
|
|
#include <AK/Types.h>
|
2021-06-25 09:46:17 +03:00
|
|
|
#include <Kernel/Bus/PCI/Definitions.h>
|
2021-04-16 22:58:51 +03:00
|
|
|
#include <Kernel/Graphics/Console/Console.h>
|
2021-03-05 14:23:08 +02:00
|
|
|
#include <Kernel/Graphics/GraphicsDevice.h>
|
2021-04-16 22:58:51 +03:00
|
|
|
#include <Kernel/Graphics/VGACompatibleAdapter.h>
|
2021-07-07 23:51:33 +10:00
|
|
|
#include <Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h>
|
2021-08-06 10:45:34 +02:00
|
|
|
#include <Kernel/Memory/Region.h>
|
2021-03-05 14:23:08 +02:00
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
2021-04-16 22:58:51 +03:00
|
|
|
class BochsGraphicsAdapter;
|
|
|
|
|
class IntelNativeGraphicsAdapter;
|
|
|
|
|
class VGACompatibleAdapter;
|
2021-03-05 14:23:08 +02:00
|
|
|
class GraphicsManagement {
|
2021-04-16 22:58:51 +03:00
|
|
|
friend class BochsGraphicsAdapter;
|
|
|
|
|
friend class IntelNativeGraphicsAdapter;
|
|
|
|
|
friend class VGACompatibleAdapter;
|
2021-07-07 23:51:33 +10:00
|
|
|
friend class Graphics::VirtIOGPU::GraphicsAdapter;
|
2021-04-16 22:58:51 +03:00
|
|
|
AK_MAKE_ETERNAL
|
2021-03-05 14:23:08 +02:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
static GraphicsManagement& the();
|
|
|
|
|
static bool is_initialized();
|
|
|
|
|
bool initialize();
|
|
|
|
|
|
2021-05-16 21:03:33 +03:00
|
|
|
unsigned allocate_minor_device_number() { return m_current_minor_number++; };
|
2021-03-05 14:23:08 +02:00
|
|
|
GraphicsManagement();
|
|
|
|
|
|
2021-04-16 22:58:51 +03:00
|
|
|
bool framebuffer_devices_allowed() const { return m_framebuffer_devices_allowed; }
|
|
|
|
|
bool framebuffer_devices_exist() const;
|
|
|
|
|
|
2021-08-22 01:37:17 +02:00
|
|
|
Spinlock<u8>& main_vga_lock() { return m_main_vga_lock; }
|
2021-04-16 22:58:51 +03:00
|
|
|
RefPtr<Graphics::Console> console() const { return m_console; }
|
|
|
|
|
|
|
|
|
|
void deactivate_graphical_mode();
|
|
|
|
|
void activate_graphical_mode();
|
2021-03-05 14:23:08 +02:00
|
|
|
|
|
|
|
|
private:
|
2021-07-03 05:04:02 +03:00
|
|
|
bool determine_and_initialize_graphics_device(const PCI::Address& address, PCI::ID id);
|
2021-03-05 14:23:08 +02:00
|
|
|
NonnullRefPtrVector<GraphicsDevice> m_graphics_devices;
|
2021-04-16 22:58:51 +03:00
|
|
|
RefPtr<Graphics::Console> m_console;
|
|
|
|
|
|
|
|
|
|
// Note: there could be multiple VGA adapters, but only one can operate in VGA mode
|
|
|
|
|
RefPtr<VGACompatibleAdapter> m_vga_adapter;
|
2021-03-05 14:23:08 +02:00
|
|
|
unsigned m_current_minor_number { 0 };
|
2021-04-16 22:58:51 +03:00
|
|
|
const bool m_framebuffer_devices_allowed;
|
|
|
|
|
|
2021-08-22 01:37:17 +02:00
|
|
|
Spinlock<u8> m_main_vga_lock;
|
2021-03-05 14:23:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|