diff options
author | Brian Gianforcaro <b.gianfo@gmail.com> | 2022-03-13 04:00:51 +0000 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2022-03-12 21:45:57 -0800 |
commit | 3b39e16e8ff392b983cee06f66837a5dcc415828 (patch) | |
tree | a86cd45ac1bf50bb7bb519ff55688c2d502c2180 /Kernel/Graphics | |
parent | 09673e7f13c5ea92a467a9e915c6d65d9894a2ca (diff) | |
download | serenity-3b39e16e8ff392b983cee06f66837a5dcc415828.zip |
Revert "Kernel: Don't override FramebufferDevice's memory regions on mmap"
This reverts commit 85ba70d86f69b2535586a2adcd873f85238b8491.
Diffstat (limited to 'Kernel/Graphics')
-rw-r--r-- | Kernel/Graphics/FramebufferDevice.cpp | 33 | ||||
-rw-r--r-- | Kernel/Graphics/FramebufferDevice.h | 1 |
2 files changed, 12 insertions, 22 deletions
diff --git a/Kernel/Graphics/FramebufferDevice.cpp b/Kernel/Graphics/FramebufferDevice.cpp index e278a3cac0..c9b16957a0 100644 --- a/Kernel/Graphics/FramebufferDevice.cpp +++ b/Kernel/Graphics/FramebufferDevice.cpp @@ -40,10 +40,11 @@ ErrorOr<Memory::Region*> FramebufferDevice::mmap(Process& process, OpenFileDescr if (range.size() != framebuffer_length) return EOVERFLOW; - TRY(try_to_initialize()); - - if (m_userspace_framebuffer_region) - return m_userspace_framebuffer_region; + m_userspace_real_framebuffer_vmobject = TRY(Memory::AnonymousVMObject::try_create_for_physical_range(m_framebuffer_address, framebuffer_length)); + m_real_framebuffer_vmobject = TRY(Memory::AnonymousVMObject::try_create_for_physical_range(m_framebuffer_address, framebuffer_length)); + m_swapped_framebuffer_vmobject = TRY(Memory::AnonymousVMObject::try_create_with_size(framebuffer_length, AllocationStrategy::AllocateNow)); + m_real_framebuffer_region = TRY(MM.allocate_kernel_region_with_vmobject(*m_real_framebuffer_vmobject, framebuffer_length, "Framebuffer", Memory::Region::Access::ReadWrite)); + m_swapped_framebuffer_region = TRY(MM.allocate_kernel_region_with_vmobject(*m_swapped_framebuffer_vmobject, framebuffer_length, "Framebuffer Swap (Blank)", Memory::Region::Access::ReadWrite)); RefPtr<Memory::VMObject> chosen_vmobject; if (m_graphical_writes_enabled) { @@ -98,26 +99,16 @@ void FramebufferDevice::activate_writes() m_graphical_writes_enabled = true; } -ErrorOr<void> FramebufferDevice::try_to_initialize() +UNMAP_AFTER_INIT ErrorOr<void> FramebufferDevice::try_to_initialize() { - if (m_initialized) - return {}; - + // FIXME: Would be nice to be able to unify this with mmap above, but this + // function is UNMAP_AFTER_INIT for the time being. auto framebuffer_length = TRY(buffer_length(0)); framebuffer_length = TRY(Memory::page_round_up(framebuffer_length)); - - auto real_framebuffer_vmobject = TRY(Memory::AnonymousVMObject::try_create_for_physical_range(m_framebuffer_address, framebuffer_length)); - auto swapped_framebuffer_vmobject = TRY(Memory::AnonymousVMObject::try_create_with_size(framebuffer_length, AllocationStrategy::AllocateNow)); - auto real_framebuffer_region = TRY(MM.allocate_kernel_region_with_vmobject(*real_framebuffer_vmobject, framebuffer_length, "Framebuffer", Memory::Region::Access::ReadWrite)); - auto swapped_framebuffer_region = TRY(MM.allocate_kernel_region_with_vmobject(*swapped_framebuffer_vmobject, framebuffer_length, "Framebuffer Swap (Blank)", Memory::Region::Access::ReadWrite)); - - m_real_framebuffer_vmobject = move(real_framebuffer_vmobject); - m_swapped_framebuffer_vmobject = move(swapped_framebuffer_vmobject); - m_real_framebuffer_region = move(real_framebuffer_region); - m_swapped_framebuffer_region = move(swapped_framebuffer_region); - - m_initialized = true; - + m_real_framebuffer_vmobject = TRY(Memory::AnonymousVMObject::try_create_for_physical_range(m_framebuffer_address, framebuffer_length)); + m_swapped_framebuffer_vmobject = TRY(Memory::AnonymousVMObject::try_create_with_size(framebuffer_length, AllocationStrategy::AllocateNow)); + m_real_framebuffer_region = TRY(MM.allocate_kernel_region_with_vmobject(*m_real_framebuffer_vmobject, framebuffer_length, "Framebuffer", Memory::Region::Access::ReadWrite)); + m_swapped_framebuffer_region = TRY(MM.allocate_kernel_region_with_vmobject(*m_swapped_framebuffer_vmobject, framebuffer_length, "Framebuffer Swap (Blank)", Memory::Region::Access::ReadWrite)); return {}; } diff --git a/Kernel/Graphics/FramebufferDevice.h b/Kernel/Graphics/FramebufferDevice.h index 7387d200bd..207155db76 100644 --- a/Kernel/Graphics/FramebufferDevice.h +++ b/Kernel/Graphics/FramebufferDevice.h @@ -67,7 +67,6 @@ private: bool m_graphical_writes_enabled { true }; bool m_write_combine { true }; - bool m_initialized { false }; RefPtr<Memory::AnonymousVMObject> m_userspace_real_framebuffer_vmobject; Memory::Region* m_userspace_framebuffer_region { nullptr }; |