diff options
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Kernel/Graphics/Console/VGAConsole.h | 1 | ||||
-rw-r--r-- | Kernel/Graphics/GraphicsManagement.cpp | 89 | ||||
-rw-r--r-- | Kernel/Graphics/GraphicsManagement.h | 8 | ||||
-rw-r--r-- | Kernel/Graphics/VGA/ISAAdapter.cpp | 26 | ||||
-rw-r--r-- | Kernel/Graphics/VGA/ISAAdapter.h | 28 | ||||
-rw-r--r-- | Kernel/Graphics/VGA/PCIAdapter.cpp | 33 | ||||
-rw-r--r-- | Kernel/Graphics/VGA/PCIAdapter.h | 26 | ||||
-rw-r--r-- | Kernel/Graphics/VGA/VGACompatibleAdapter.cpp | 20 | ||||
-rw-r--r-- | Kernel/Graphics/VGA/VGACompatibleAdapter.h | 29 |
10 files changed, 30 insertions, 233 deletions
diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 1ad3e1fadf..5e4aaa6dfe 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -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 diff --git a/Kernel/Graphics/Console/VGAConsole.h b/Kernel/Graphics/Console/VGAConsole.h index 0b297163e9..5a15e89626 100644 --- a/Kernel/Graphics/Console/VGAConsole.h +++ b/Kernel/Graphics/Console/VGAConsole.h @@ -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 { diff --git a/Kernel/Graphics/GraphicsManagement.cpp b/Kernel/Graphics/GraphicsManagement.cpp index e212382ca1..a1e4d230e8 100644 --- a/Kernel/Graphics/GraphicsManagement.cpp +++ b/Kernel/Graphics/GraphicsManagement.cpp @@ -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. diff --git a/Kernel/Graphics/GraphicsManagement.h b/Kernel/Graphics/GraphicsManagement.h index 70937bbc99..d45108f106 100644 --- a/Kernel/Graphics/GraphicsManagement.h +++ b/Kernel/Graphics/GraphicsManagement.h @@ -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; diff --git a/Kernel/Graphics/VGA/ISAAdapter.cpp b/Kernel/Graphics/VGA/ISAAdapter.cpp deleted file mode 100644 index a7345e7fdd..0000000000 --- a/Kernel/Graphics/VGA/ISAAdapter.cpp +++ /dev/null @@ -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); -} - -} diff --git a/Kernel/Graphics/VGA/ISAAdapter.h b/Kernel/Graphics/VGA/ISAAdapter.h deleted file mode 100644 index 45faf5c0ec..0000000000 --- a/Kernel/Graphics/VGA/ISAAdapter.h +++ /dev/null @@ -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; -}; -} diff --git a/Kernel/Graphics/VGA/PCIAdapter.cpp b/Kernel/Graphics/VGA/PCIAdapter.cpp deleted file mode 100644 index 98f53a85e9..0000000000 --- a/Kernel/Graphics/VGA/PCIAdapter.cpp +++ /dev/null @@ -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) -{ -} - -} diff --git a/Kernel/Graphics/VGA/PCIAdapter.h b/Kernel/Graphics/VGA/PCIAdapter.h deleted file mode 100644 index fe9d0485bf..0000000000 --- a/Kernel/Graphics/VGA/PCIAdapter.h +++ /dev/null @@ -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); -}; -} diff --git a/Kernel/Graphics/VGA/VGACompatibleAdapter.cpp b/Kernel/Graphics/VGA/VGACompatibleAdapter.cpp deleted file mode 100644 index 2c4e1dccae..0000000000 --- a/Kernel/Graphics/VGA/VGACompatibleAdapter.cpp +++ /dev/null @@ -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); -} - -} diff --git a/Kernel/Graphics/VGA/VGACompatibleAdapter.h b/Kernel/Graphics/VGA/VGACompatibleAdapter.h deleted file mode 100644 index 8683a32d81..0000000000 --- a/Kernel/Graphics/VGA/VGACompatibleAdapter.h +++ /dev/null @@ -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; -}; -} |