mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Kernel/Graphics: Remove VGA folder and its content
We never supported VGA framebuffers and that folder was a big misleading part of the graphics subsystem. We do support bare-bones VGA text console (80x25), but that only happens to be supported because we can't be 100% sure we can always initialize framebuffer so in the worst scenario we default to plain old VGA console so the user can still use its own machine. Therefore, the only remaining parts of VGA is in the GraphicsManagement code to help driving the VGA text console if needed.
This commit is contained in:
parent
e39514721e
commit
3bd0106755
Notes:
sideshowbarker
2024-07-18 03:20:18 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/3bd0106755 Pull-request: https://github.com/SerenityOS/serenity/pull/14520 Reviewed-by: https://github.com/linusg
10 changed files with 30 additions and 233 deletions
|
@ -85,9 +85,6 @@ set(KERNEL_SOURCES
|
|||
Graphics/GraphicsManagement.cpp
|
||||
Graphics/Intel/NativeDisplayConnector.cpp
|
||||
Graphics/Intel/NativeGraphicsAdapter.cpp
|
||||
Graphics/VGA/ISAAdapter.cpp
|
||||
Graphics/VGA/PCIAdapter.cpp
|
||||
Graphics/VGA/VGACompatibleAdapter.cpp
|
||||
Graphics/VMWare/Console.cpp
|
||||
Graphics/VMWare/GraphicsAdapter.cpp
|
||||
Graphics/VMWare/DisplayConnector.cpp
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <AK/RefCounted.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Graphics/Console/Console.h>
|
||||
#include <Kernel/Graphics/VGA/VGACompatibleAdapter.h>
|
||||
|
||||
namespace Kernel::Graphics {
|
||||
class VGAConsole : public Console {
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
#include <Kernel/Graphics/Console/BootFramebufferConsole.h>
|
||||
#include <Kernel/Graphics/GraphicsManagement.h>
|
||||
#include <Kernel/Graphics/Intel/NativeGraphicsAdapter.h>
|
||||
#include <Kernel/Graphics/VGA/ISAAdapter.h>
|
||||
#include <Kernel/Graphics/VGA/PCIAdapter.h>
|
||||
#include <Kernel/Graphics/VGA/VGACompatibleAdapter.h>
|
||||
#include <Kernel/Graphics/VMWare/GraphicsAdapter.h>
|
||||
#include <Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h>
|
||||
#include <Kernel/Memory/AnonymousVMObject.h>
|
||||
|
@ -126,37 +123,11 @@ static inline bool is_display_controller_pci_device(PCI::DeviceIdentifier const&
|
|||
return device_identifier.class_code().value() == 0x3;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT bool GraphicsManagement::determine_and_initialize_isa_graphics_device()
|
||||
{
|
||||
dmesgln("Graphics: Using a ISA VGA compatible generic adapter");
|
||||
auto adapter = ISAVGAAdapter::initialize();
|
||||
m_graphics_devices.append(*adapter);
|
||||
m_vga_adapter = adapter;
|
||||
return true;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT bool GraphicsManagement::determine_and_initialize_graphics_device(PCI::DeviceIdentifier const& device_identifier)
|
||||
{
|
||||
VERIFY(is_vga_compatible_pci_device(device_identifier) || is_display_controller_pci_device(device_identifier));
|
||||
RefPtr<GenericGraphicsAdapter> adapter;
|
||||
|
||||
auto create_bootloader_framebuffer_device = [&]() {
|
||||
if (multiboot_framebuffer_addr.is_null()) {
|
||||
// Prekernel sets the framebuffer address to 0 if MULTIBOOT_INFO_FRAMEBUFFER_INFO
|
||||
// is not present, as there is likely never a valid framebuffer at this physical address.
|
||||
dmesgln("Graphics: Bootloader did not set up a framebuffer");
|
||||
} else if (multiboot_framebuffer_type != MULTIBOOT_FRAMEBUFFER_TYPE_RGB) {
|
||||
dmesgln("Graphics: The framebuffer set up by the bootloader is not RGB");
|
||||
} else {
|
||||
dmesgln("Graphics: Using a preset resolution from the bootloader");
|
||||
adapter = PCIVGACompatibleAdapter::initialize_with_preset_resolution(device_identifier,
|
||||
multiboot_framebuffer_addr,
|
||||
multiboot_framebuffer_width,
|
||||
multiboot_framebuffer_height,
|
||||
multiboot_framebuffer_pitch);
|
||||
}
|
||||
};
|
||||
|
||||
if (!adapter) {
|
||||
switch (device_identifier.hardware_id().vendor_id) {
|
||||
case PCI::VendorID::QEMUOld:
|
||||
|
@ -178,26 +149,6 @@ UNMAP_AFTER_INIT bool GraphicsManagement::determine_and_initialize_graphics_devi
|
|||
adapter = VMWareGraphicsAdapter::try_initialize(device_identifier);
|
||||
break;
|
||||
default:
|
||||
if (!is_vga_compatible_pci_device(device_identifier))
|
||||
break;
|
||||
// Note: Although technically possible that a system has a
|
||||
// non-compatible VGA graphics device that was initialized by the
|
||||
// Multiboot bootloader to provide a framebuffer, in practice we
|
||||
// probably want to support these devices natively instead of
|
||||
// initializing them as some sort of a generic GenericGraphicsAdapter. For now,
|
||||
// the only known example of this sort of device is qxl in QEMU. For VGA
|
||||
// compatible devices we don't have a special driver for (e.g. ati-vga,
|
||||
// qxl-vga, cirrus-vga, vmware-svga in QEMU), it's much more likely that
|
||||
// these devices will be supported by the Multiboot loader that will
|
||||
// utilize VESA BIOS extensions (that we don't currently) of these cards
|
||||
// support, so we want to utilize the provided framebuffer of these
|
||||
// devices, if possible.
|
||||
if (!m_vga_adapter && PCI::is_io_space_enabled(device_identifier.address())) {
|
||||
create_bootloader_framebuffer_device();
|
||||
} else {
|
||||
dmesgln("Graphics: Using a PCI VGA compatible generic adapter");
|
||||
adapter = PCIVGACompatibleAdapter::initialize(device_identifier);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -205,16 +156,21 @@ UNMAP_AFTER_INIT bool GraphicsManagement::determine_and_initialize_graphics_devi
|
|||
if (!adapter)
|
||||
return false;
|
||||
m_graphics_devices.append(*adapter);
|
||||
|
||||
// Note: If IO space is enabled, this VGA adapter is operating in VGA mode.
|
||||
// Note: If no other VGA adapter is attached as m_vga_adapter, we should attach it then.
|
||||
if (!m_vga_adapter && PCI::is_io_space_enabled(device_identifier.address()) && adapter->vga_compatible()) {
|
||||
dbgln("Graphics adapter @ {} is operating in VGA mode", device_identifier.address());
|
||||
m_vga_adapter = static_ptr_cast<VGACompatibleAdapter>(adapter);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void GraphicsManagement::initialize_preset_resolution_generic_display_connector()
|
||||
{
|
||||
VERIFY(!multiboot_framebuffer_addr.is_null());
|
||||
VERIFY(multiboot_framebuffer_type == MULTIBOOT_FRAMEBUFFER_TYPE_RGB);
|
||||
dmesgln("Graphics: Using a preset resolution from the bootloader, without knowing the PCI device");
|
||||
m_preset_resolution_generic_display_connector = GenericDisplayConnector::must_create_with_preset_resolution(
|
||||
multiboot_framebuffer_addr,
|
||||
multiboot_framebuffer_width,
|
||||
multiboot_framebuffer_height,
|
||||
multiboot_framebuffer_pitch);
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT bool GraphicsManagement::initialize()
|
||||
{
|
||||
|
||||
|
@ -272,17 +228,12 @@ UNMAP_AFTER_INIT bool GraphicsManagement::initialize()
|
|||
}
|
||||
|
||||
if (graphics_subsystem_mode == CommandLine::GraphicsSubsystemMode::Limited && !multiboot_framebuffer_addr.is_null() && multiboot_framebuffer_type != MULTIBOOT_FRAMEBUFFER_TYPE_RGB) {
|
||||
dmesgln("Graphics: Using a preset resolution from the bootloader, without knowing the PCI device");
|
||||
m_preset_resolution_generic_display_connector = GenericDisplayConnector::must_create_with_preset_resolution(
|
||||
multiboot_framebuffer_addr,
|
||||
multiboot_framebuffer_width,
|
||||
multiboot_framebuffer_height,
|
||||
multiboot_framebuffer_pitch);
|
||||
initialize_preset_resolution_generic_display_connector();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PCI::Access::is_disabled()) {
|
||||
determine_and_initialize_isa_graphics_device();
|
||||
dmesgln("Graphics: Using an assumed-to-exist ISA VGA compatible generic adapter");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -295,6 +246,18 @@ UNMAP_AFTER_INIT bool GraphicsManagement::initialize()
|
|||
determine_and_initialize_graphics_device(device_identifier);
|
||||
}));
|
||||
|
||||
// Note: If we failed to find any graphics device to be used natively, but the
|
||||
// bootloader prepared a framebuffer for us to use, then just create a DisplayConnector
|
||||
// for it so the user can still use the system in graphics mode.
|
||||
// Prekernel sets the framebuffer address to 0 if MULTIBOOT_INFO_FRAMEBUFFER_INFO
|
||||
// is not present, as there is likely never a valid framebuffer at this physical address.
|
||||
// Note: We only support RGB framebuffers. Any other format besides RGBX (and RGBA) or BGRX (and BGRA) is obsolete
|
||||
// and is not useful for us.
|
||||
if (m_graphics_devices.is_empty() && !multiboot_framebuffer_addr.is_null() && multiboot_framebuffer_type == MULTIBOOT_FRAMEBUFFER_TYPE_RGB) {
|
||||
initialize_preset_resolution_generic_display_connector();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!m_console) {
|
||||
// If no graphics driver was instantiated and we had a bootloader provided
|
||||
// framebuffer console we can simply re-use it.
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#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/VGA/VGACompatibleAdapter.h>
|
||||
#include <Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h>
|
||||
#include <Kernel/Memory/Region.h>
|
||||
|
||||
|
@ -47,15 +47,15 @@ private:
|
|||
void enable_vga_text_mode_console_cursor();
|
||||
|
||||
bool determine_and_initialize_graphics_device(PCI::DeviceIdentifier const&);
|
||||
bool determine_and_initialize_isa_graphics_device();
|
||||
|
||||
void initialize_preset_resolution_generic_display_connector();
|
||||
|
||||
NonnullRefPtrVector<GenericGraphicsAdapter> m_graphics_devices;
|
||||
RefPtr<Graphics::Console> m_console;
|
||||
|
||||
// Note: This is only used when booting with kernel commandline that includes "graphics_subsystem_mode=limited"
|
||||
RefPtr<GenericDisplayConnector> m_preset_resolution_generic_display_connector;
|
||||
|
||||
// Note: there could be multiple VGA adapters, but only one can operate in VGA mode
|
||||
RefPtr<VGACompatibleAdapter> m_vga_adapter;
|
||||
unsigned m_current_minor_number { 0 };
|
||||
|
||||
SpinlockProtected<IntrusiveList<&DisplayConnector::m_list_node>> m_display_connector_nodes;
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/Graphics/Console/ContiguousFramebufferConsole.h>
|
||||
#include <Kernel/Graphics/Console/TextModeConsole.h>
|
||||
#include <Kernel/Graphics/GraphicsManagement.h>
|
||||
#include <Kernel/Graphics/VGA/ISAAdapter.h>
|
||||
#include <Kernel/Sections.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<ISAVGAAdapter> ISAVGAAdapter::initialize()
|
||||
{
|
||||
return adopt_ref(*new ISAVGAAdapter());
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT ISAVGAAdapter::ISAVGAAdapter()
|
||||
{
|
||||
m_framebuffer_console = Graphics::TextModeConsole::initialize();
|
||||
GraphicsManagement::the().set_console(*m_framebuffer_console);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Bus/PCI/Device.h>
|
||||
#include <Kernel/Graphics/Console/Console.h>
|
||||
#include <Kernel/Graphics/GenericGraphicsAdapter.h>
|
||||
#include <Kernel/Graphics/VGA/VGACompatibleAdapter.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class ISAVGAAdapter final : public VGACompatibleAdapter {
|
||||
friend class GraphicsManagement;
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<ISAVGAAdapter> initialize();
|
||||
|
||||
private:
|
||||
ISAVGAAdapter();
|
||||
RefPtr<Graphics::Console> m_framebuffer_console;
|
||||
};
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/Graphics/Console/ContiguousFramebufferConsole.h>
|
||||
#include <Kernel/Graphics/Console/TextModeConsole.h>
|
||||
#include <Kernel/Graphics/GraphicsManagement.h>
|
||||
#include <Kernel/Graphics/VGA/PCIAdapter.h>
|
||||
#include <Kernel/Sections.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<PCIVGACompatibleAdapter> PCIVGACompatibleAdapter::initialize_with_preset_resolution(PCI::DeviceIdentifier const& pci_device_identifier, PhysicalAddress framebuffer_address, size_t framebuffer_width, size_t framebuffer_height, size_t framebuffer_pitch)
|
||||
{
|
||||
auto adapter = adopt_ref(*new PCIVGACompatibleAdapter(pci_device_identifier.address()));
|
||||
adapter->initialize_display_connector_with_preset_resolution(framebuffer_address, framebuffer_width, framebuffer_height, framebuffer_pitch);
|
||||
return adapter;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<PCIVGACompatibleAdapter> PCIVGACompatibleAdapter::initialize(PCI::DeviceIdentifier const& pci_device_identifier)
|
||||
{
|
||||
auto adapter = adopt_ref(*new PCIVGACompatibleAdapter(pci_device_identifier.address()));
|
||||
return adapter;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT PCIVGACompatibleAdapter::PCIVGACompatibleAdapter(PCI::Address address)
|
||||
: PCI::Device(address)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Bus/PCI/Device.h>
|
||||
#include <Kernel/Graphics/Console/Console.h>
|
||||
#include <Kernel/Graphics/GenericGraphicsAdapter.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class PCIVGACompatibleAdapter : public VGACompatibleAdapter
|
||||
, public PCI::Device {
|
||||
public:
|
||||
static NonnullRefPtr<PCIVGACompatibleAdapter> initialize_with_preset_resolution(PCI::DeviceIdentifier const&, PhysicalAddress, size_t framebuffer_width, size_t framebuffer_height, size_t framebuffer_pitch);
|
||||
static NonnullRefPtr<PCIVGACompatibleAdapter> initialize(PCI::DeviceIdentifier const&);
|
||||
|
||||
protected:
|
||||
explicit PCIVGACompatibleAdapter(PCI::Address);
|
||||
};
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/Graphics/Console/ContiguousFramebufferConsole.h>
|
||||
#include <Kernel/Graphics/Console/TextModeConsole.h>
|
||||
#include <Kernel/Graphics/GraphicsManagement.h>
|
||||
#include <Kernel/Graphics/VGA/VGACompatibleAdapter.h>
|
||||
#include <Kernel/Sections.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
void VGACompatibleAdapter::initialize_display_connector_with_preset_resolution(PhysicalAddress framebuffer_address, size_t framebuffer_width, size_t framebuffer_height, size_t framebuffer_pitch)
|
||||
{
|
||||
m_generic_display_connector = GenericDisplayConnector::must_create_with_preset_resolution(framebuffer_address, framebuffer_width, framebuffer_height, framebuffer_pitch);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2022, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Bus/PCI/Device.h>
|
||||
#include <Kernel/Graphics/Console/Console.h>
|
||||
#include <Kernel/Graphics/Generic/DisplayConnector.h>
|
||||
#include <Kernel/Graphics/GenericGraphicsAdapter.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class VGACompatibleAdapter : public GenericGraphicsAdapter {
|
||||
public:
|
||||
virtual bool vga_compatible() const override final { return true; }
|
||||
|
||||
protected:
|
||||
void initialize_display_connector_with_preset_resolution(PhysicalAddress, size_t framebuffer_width, size_t framebuffer_height, size_t framebuffer_pitch);
|
||||
|
||||
VGACompatibleAdapter() = default;
|
||||
|
||||
RefPtr<GenericDisplayConnector> m_generic_display_connector;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue