From 6cd57633613092b55b109d68319ead589d07410a Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 14 Dec 2023 10:54:06 +0200 Subject: [PATCH] Kernel: Allow cloning of mmapped framebuffer regions --- kernel/kernel/Device/FramebufferDevice.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/kernel/Device/FramebufferDevice.cpp b/kernel/kernel/Device/FramebufferDevice.cpp index c2ae7e8803..63c4bb533a 100644 --- a/kernel/kernel/Device/FramebufferDevice.cpp +++ b/kernel/kernel/Device/FramebufferDevice.cpp @@ -233,8 +233,14 @@ namespace Kernel virtual BAN::ErrorOr> clone(PageTable& new_page_table) override { - (void)new_page_table; - return BAN::Error::from_errno(ENOTSUP); + auto* region_ptr = new FramebufferMemoryRegion(new_page_table, m_size, m_type, m_flags, m_framebuffer); + if (region_ptr == nullptr) + return BAN::Error::from_errno(ENOMEM); + auto region = BAN::UniqPtr::adopt(region_ptr); + + TRY(region->initialize({ m_vaddr, m_vaddr + BAN::Math::div_round_up(m_size, PAGE_SIZE) * PAGE_SIZE })); + + return BAN::UniqPtr(BAN::move(region)); } protected: