mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-04 02:08:53 +00:00
The mmap interface was removed when we introduced the DisplayConnector class, as it was quite unsafe to use and didn't handle switching between graphical and text modes safely. By using the SharedFramebufferVMObject, we are able to elegantly coordinate the switch by remapping the attached mmap'ed-Memory::Region(s) with different mappings, therefore, keeping WindowServer to think that the mappings it has are still valid, while they are going to a different physical range until we are back to the graphical mode (after a switch from text mode). Most drivers take advantage of the fact that we know where is the actual framebuffer in physical memory space, the SharedFramebufferVMObject is created with that information. However, the VirtIO driver is different in that aspect, because it relies on DMA transactions to show graphics on the framebuffer, so the SharedFramebufferVMObject is created with that mindset to support the arbitrary framebuffer location in physical memory space.
61 lines
2.1 KiB
C++
61 lines
2.1 KiB
C++
/*
|
|
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <Kernel/Arch/x86/IO.h>
|
|
#include <Kernel/Bus/PCI/API.h>
|
|
#include <Kernel/Graphics/Console/ContiguousFramebufferConsole.h>
|
|
#include <Kernel/Graphics/Definitions.h>
|
|
#include <Kernel/Graphics/GraphicsManagement.h>
|
|
#include <Kernel/Graphics/Intel/NativeGraphicsAdapter.h>
|
|
#include <Kernel/PhysicalAddress.h>
|
|
|
|
namespace Kernel {
|
|
|
|
static constexpr u16 supported_models[] {
|
|
0x29c2, // Intel G35 Adapter
|
|
};
|
|
|
|
static bool is_supported_model(u16 device_id)
|
|
{
|
|
for (auto& id : supported_models) {
|
|
if (id == device_id)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
RefPtr<IntelNativeGraphicsAdapter> IntelNativeGraphicsAdapter::initialize(PCI::DeviceIdentifier const& pci_device_identifier)
|
|
{
|
|
VERIFY(pci_device_identifier.hardware_id().vendor_id == 0x8086);
|
|
if (!is_supported_model(pci_device_identifier.hardware_id().device_id))
|
|
return {};
|
|
auto adapter = adopt_ref(*new IntelNativeGraphicsAdapter(pci_device_identifier.address()));
|
|
MUST(adapter->initialize_adapter());
|
|
return adapter;
|
|
}
|
|
|
|
ErrorOr<void> IntelNativeGraphicsAdapter::initialize_adapter()
|
|
{
|
|
auto address = pci_address();
|
|
dbgln_if(INTEL_GRAPHICS_DEBUG, "Intel Native Graphics Adapter @ {}", address);
|
|
auto bar0_space_size = PCI::get_BAR_space_size(address, 0);
|
|
VERIFY(bar0_space_size == 0x80000);
|
|
auto bar2_space_size = PCI::get_BAR_space_size(address, 2);
|
|
dmesgln("Intel Native Graphics Adapter @ {}, MMIO @ {}, space size is {:x} bytes", address, PhysicalAddress(PCI::get_BAR0(address)), bar0_space_size);
|
|
dmesgln("Intel Native Graphics Adapter @ {}, framebuffer @ {}", address, PhysicalAddress(PCI::get_BAR2(address)));
|
|
PCI::enable_bus_mastering(address);
|
|
|
|
m_display_connector = IntelNativeDisplayConnector::must_create(PhysicalAddress(PCI::get_BAR2(address) & 0xfffffff0), bar2_space_size, PhysicalAddress(PCI::get_BAR0(address) & 0xfffffff0), bar0_space_size);
|
|
return {};
|
|
}
|
|
|
|
IntelNativeGraphicsAdapter::IntelNativeGraphicsAdapter(PCI::Address address)
|
|
: GenericGraphicsAdapter()
|
|
, PCI::Device(address)
|
|
{
|
|
}
|
|
|
|
}
|