1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:57:45 +00:00

Kernel/Graphics: Bring back the mmap interface for DisplayConnectors

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.
This commit is contained in:
Liav A 2022-05-13 03:23:13 +03:00 committed by Linus Groh
parent 3d22917548
commit e2ed6ef741
19 changed files with 309 additions and 341 deletions

View file

@ -23,10 +23,10 @@ class VMWareDisplayConnector : public DisplayConnector {
friend class DeviceManagement;
public:
static NonnullRefPtr<VMWareDisplayConnector> must_create(VMWareGraphicsAdapter const& parent_adapter, PhysicalAddress framebuffer_address);
static NonnullRefPtr<VMWareDisplayConnector> must_create(VMWareGraphicsAdapter const& parent_adapter, PhysicalAddress framebuffer_address, size_t framebuffer_resource_size);
private:
VMWareDisplayConnector(VMWareGraphicsAdapter const& parent_adapter, PhysicalAddress framebuffer_address);
VMWareDisplayConnector(VMWareGraphicsAdapter const& parent_adapter, PhysicalAddress framebuffer_address, size_t framebuffer_resource_size);
ErrorOr<void> create_attached_framebuffer_console();
virtual bool mutable_mode_setting_capable() const override { return true; }
@ -41,7 +41,6 @@ private:
// Note: Paravirtualized hardware doesn't require a defined refresh rate for modesetting.
virtual bool refresh_rate_support() const override { return false; }
virtual ErrorOr<size_t> write_to_first_surface(u64 offset, UserOrKernelBuffer const&, size_t length) override;
virtual ErrorOr<void> flush_first_surface() override;
virtual ErrorOr<void> flush_rectangle(size_t buffer_index, FBRect const& rect) override;
@ -49,12 +48,7 @@ private:
virtual void disable_console() override;
private:
u8* framebuffer_data() { return m_framebuffer_data; }
const PhysicalAddress m_framebuffer_address;
NonnullRefPtr<VMWareGraphicsAdapter> m_parent_adapter;
RefPtr<VMWareFramebufferConsole> m_framebuffer_console;
OwnPtr<Memory::Region> m_framebuffer_region;
u8* m_framebuffer_data {};
};
}