mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00:00

This device is supposed to be used in microvm and ISA-PC machine types, and we assume that if we are able to probe for the QEMU BGA version of 0xB0C5, then we have an existing ISA Bochs VGA adapter to utilize. To ensure we don't instantiate the driver for non isa-vga devices, we try to ensure that PCI is disabled because hardware IO test probe failed so we can be sure that we use this special handling code only in the QEMU microvm and ISA-PC machine types. Unfortunately, this means that if for some reason the isa-vga device is attached for the i440FX or Q35 machine types, we simply are not able to drive the device in such setups at all. To determine the amount of VRAM being available, we read VBE register at offset 0xA. That register holds the amount of VRAM divided by 64K, so we need to multiply the value in our code to use the actual VRAM size value again. The isa-vga device requires us to hardcode the framebuffer physical address to 0xE0000000, and that address is not expected to change in the future as many other projects rely on the isa-vga framebuffer to be present at that physical memory address.
69 lines
2.2 KiB
C++
69 lines
2.2 KiB
C++
/*
|
|
* Copyright (c) 2021-2022, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/NonnullOwnPtr.h>
|
|
#include <AK/Types.h>
|
|
#include <Kernel/Bus/PCI/Definitions.h>
|
|
#include <Kernel/Graphics/Console/Console.h>
|
|
#include <Kernel/Graphics/DisplayConnector.h>
|
|
#include <Kernel/Graphics/Generic/DisplayConnector.h>
|
|
#include <Kernel/Graphics/GenericGraphicsAdapter.h>
|
|
#include <Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h>
|
|
#include <Kernel/Library/NonnullLockRefPtr.h>
|
|
#include <Kernel/Library/NonnullLockRefPtrVector.h>
|
|
#include <Kernel/Memory/Region.h>
|
|
|
|
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>, DisplayConnector&);
|
|
void detach_display_connector(Badge<DisplayConnector>, 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();
|
|
|
|
LockRefPtr<Graphics::Console> 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&);
|
|
|
|
void initialize_preset_resolution_generic_display_connector();
|
|
|
|
NonnullLockRefPtrVector<GenericGraphicsAdapter> m_graphics_devices;
|
|
LockRefPtr<Graphics::Console> m_console;
|
|
|
|
// Note: This is only used when booting with kernel commandline that includes "graphics_subsystem_mode=limited"
|
|
LockRefPtr<GenericDisplayConnector> m_preset_resolution_generic_display_connector;
|
|
|
|
LockRefPtr<DisplayConnector> m_platform_board_specific_display_connector;
|
|
|
|
unsigned m_current_minor_number { 0 };
|
|
|
|
SpinlockProtected<IntrusiveList<&DisplayConnector::m_list_node>> m_display_connector_nodes { LockRank::None };
|
|
|
|
RecursiveSpinlock m_main_vga_lock { LockRank::None };
|
|
bool m_vga_access_is_disabled { false };
|
|
};
|
|
|
|
}
|