summaryrefslogtreecommitdiff
path: root/Kernel/Graphics
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Graphics')
-rw-r--r--Kernel/Graphics/Console/ContiguousFramebufferConsole.cpp5
-rw-r--r--Kernel/Graphics/Console/VGAConsole.cpp2
-rw-r--r--Kernel/Graphics/FramebufferDevice.cpp18
-rw-r--r--Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp6
-rw-r--r--Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp7
-rw-r--r--Kernel/Graphics/VirtIOGPU/GPU.cpp5
6 files changed, 19 insertions, 24 deletions
diff --git a/Kernel/Graphics/Console/ContiguousFramebufferConsole.cpp b/Kernel/Graphics/Console/ContiguousFramebufferConsole.cpp
index 21f38dda84..08989b1b55 100644
--- a/Kernel/Graphics/Console/ContiguousFramebufferConsole.cpp
+++ b/Kernel/Graphics/Console/ContiguousFramebufferConsole.cpp
@@ -28,8 +28,9 @@ void ContiguousFramebufferConsole::set_resolution(size_t width, size_t height, s
m_pitch = pitch;
dbgln("Framebuffer Console: taking {} bytes", Memory::page_round_up(pitch * height));
- m_framebuffer_region = MM.allocate_kernel_region(m_framebuffer_address, Memory::page_round_up(pitch * height), "Framebuffer Console", Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::Yes);
- VERIFY(m_framebuffer_region);
+ auto region_or_error = MM.allocate_kernel_region(m_framebuffer_address, Memory::page_round_up(pitch * height), "Framebuffer Console", Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::Yes);
+ VERIFY(!region_or_error.is_error());
+ m_framebuffer_region = region_or_error.release_value();
// Just to start cleanly, we clean the entire framebuffer
memset(m_framebuffer_region->vaddr().as_ptr(), 0, pitch * height);
diff --git a/Kernel/Graphics/Console/VGAConsole.cpp b/Kernel/Graphics/Console/VGAConsole.cpp
index d7eba0a91f..acd9049753 100644
--- a/Kernel/Graphics/Console/VGAConsole.cpp
+++ b/Kernel/Graphics/Console/VGAConsole.cpp
@@ -11,7 +11,7 @@ namespace Kernel::Graphics {
UNMAP_AFTER_INIT VGAConsole::VGAConsole(const VGACompatibleAdapter& adapter, Mode mode, size_t width, size_t height)
: Console(width, height)
- , m_vga_region(MM.allocate_kernel_region(PhysicalAddress(0xa0000), Memory::page_round_up(0xc0000 - 0xa0000), "VGA Display", Memory::Region::Access::ReadWrite).release_nonnull())
+ , m_vga_region(MM.allocate_kernel_region(PhysicalAddress(0xa0000), Memory::page_round_up(0xc0000 - 0xa0000), "VGA Display", Memory::Region::Access::ReadWrite).release_value())
, m_adapter(adapter)
, m_mode(mode)
{
diff --git a/Kernel/Graphics/FramebufferDevice.cpp b/Kernel/Graphics/FramebufferDevice.cpp
index bf46344ade..a0533d1604 100644
--- a/Kernel/Graphics/FramebufferDevice.cpp
+++ b/Kernel/Graphics/FramebufferDevice.cpp
@@ -51,13 +51,8 @@ KResultOr<Memory::Region*> FramebufferDevice::mmap(Process& process, FileDescrip
return maybe_swapped_framebuffer_vmobject.error();
m_swapped_framebuffer_vmobject = maybe_swapped_framebuffer_vmobject.release_value();
- m_real_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_real_framebuffer_vmobject, Memory::page_round_up(framebuffer_size_in_bytes()), "Framebuffer", Memory::Region::Access::ReadWrite);
- if (!m_real_framebuffer_region)
- return ENOMEM;
-
- m_swapped_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_swapped_framebuffer_vmobject, Memory::page_round_up(framebuffer_size_in_bytes()), "Framebuffer Swap (Blank)", Memory::Region::Access::ReadWrite);
- if (!m_swapped_framebuffer_region)
- return ENOMEM;
+ m_real_framebuffer_region = TRY(MM.allocate_kernel_region_with_vmobject(*m_real_framebuffer_vmobject, Memory::page_round_up(framebuffer_size_in_bytes()), "Framebuffer", Memory::Region::Access::ReadWrite));
+ m_swapped_framebuffer_region = TRY(MM.allocate_kernel_region_with_vmobject(*m_swapped_framebuffer_vmobject, Memory::page_round_up(framebuffer_size_in_bytes()), "Framebuffer Swap (Blank)", Memory::Region::Access::ReadWrite));
RefPtr<Memory::VMObject> chosen_vmobject;
if (m_graphical_writes_enabled) {
@@ -123,13 +118,8 @@ UNMAP_AFTER_INIT KResult FramebufferDevice::initialize()
return maybe_swapped_framebuffer_vmobject.error();
m_swapped_framebuffer_vmobject = maybe_swapped_framebuffer_vmobject.release_value();
- m_real_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_real_framebuffer_vmobject, Memory::page_round_up(framebuffer_size_in_bytes()), "Framebuffer", Memory::Region::Access::ReadWrite);
- if (!m_real_framebuffer_region)
- return ENOMEM;
-
- m_swapped_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_swapped_framebuffer_vmobject, Memory::page_round_up(framebuffer_size_in_bytes()), "Framebuffer Swap (Blank)", Memory::Region::Access::ReadWrite);
- if (!m_swapped_framebuffer_region)
- return ENOMEM;
+ m_real_framebuffer_region = TRY(MM.allocate_kernel_region_with_vmobject(*m_real_framebuffer_vmobject, Memory::page_round_up(framebuffer_size_in_bytes()), "Framebuffer", Memory::Region::Access::ReadWrite));
+ m_swapped_framebuffer_region = TRY(MM.allocate_kernel_region_with_vmobject(*m_swapped_framebuffer_vmobject, Memory::page_round_up(framebuffer_size_in_bytes()), "Framebuffer Swap (Blank)", Memory::Region::Access::ReadWrite));
return KSuccess;
}
diff --git a/Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp b/Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp
index 51976a05b5..6955e7e0dd 100644
--- a/Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp
+++ b/Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp
@@ -189,7 +189,11 @@ IntelNativeGraphicsAdapter::IntelNativeGraphicsAdapter(PCI::Address address)
VERIFY(bar0_space_size == 0x80000);
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)));
- m_registers_region = MM.allocate_kernel_region(PhysicalAddress(PCI::get_BAR0(address)).page_base(), bar0_space_size, "Intel Native Graphics Registers", Memory::Region::Access::ReadWrite);
+ auto region_or_error = MM.allocate_kernel_region(PhysicalAddress(PCI::get_BAR0(address)).page_base(), bar0_space_size, "Intel Native Graphics Registers", Memory::Region::Access::ReadWrite);
+ if (region_or_error.is_error()) {
+ TODO();
+ }
+ m_registers_region = region_or_error.release_value();
PCI::enable_bus_mastering(address);
{
SpinlockLocker control_lock(m_control_lock);
diff --git a/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp b/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp
index 263e842eb4..8def0b1bfe 100644
--- a/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp
+++ b/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp
@@ -35,7 +35,7 @@ KResult FrameBufferDevice::create_framebuffer()
// Allocate frame buffer for both front and back
auto& info = display_info();
m_buffer_size = calculate_framebuffer_size(info.rect.width, info.rect.height);
- m_framebuffer = MM.allocate_kernel_region(m_buffer_size * 2, String::formatted("VirtGPU FrameBuffer #{}", m_scanout.value()), Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow);
+ m_framebuffer = TRY(MM.allocate_kernel_region(m_buffer_size * 2, String::formatted("VirtGPU FrameBuffer #{}", m_scanout.value()), Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow));
auto write_sink_page = MM.allocate_user_physical_page(Memory::MemoryManager::ShouldZeroFill::No).release_nonnull();
auto num_needed_pages = m_framebuffer->vmobject().page_count();
@@ -43,10 +43,7 @@ KResult FrameBufferDevice::create_framebuffer()
for (auto i = 0u; i < num_needed_pages; ++i) {
pages.append(write_sink_page);
}
- auto maybe_framebuffer_sink_vmobject = Memory::AnonymousVMObject::try_create_with_physical_pages(pages.span());
- if (maybe_framebuffer_sink_vmobject.is_error())
- return maybe_framebuffer_sink_vmobject.error();
- m_framebuffer_sink_vmobject = maybe_framebuffer_sink_vmobject.release_value();
+ m_framebuffer_sink_vmobject = TRY(Memory::AnonymousVMObject::try_create_with_physical_pages(pages.span()));
MutexLocker locker(m_gpu.operation_lock());
m_current_buffer = &buffer_from_index(m_last_set_buffer_index.load());
diff --git a/Kernel/Graphics/VirtIOGPU/GPU.cpp b/Kernel/Graphics/VirtIOGPU/GPU.cpp
index 3513b38067..36b50f217f 100644
--- a/Kernel/Graphics/VirtIOGPU/GPU.cpp
+++ b/Kernel/Graphics/VirtIOGPU/GPU.cpp
@@ -48,8 +48,11 @@ void GPU::initialize()
GPU::GPU(PCI::Address address)
: VirtIO::Device(address)
- , m_scratch_space(MM.allocate_contiguous_kernel_region(32 * PAGE_SIZE, "VirtGPU Scratch Space", Memory::Region::Access::ReadWrite))
{
+ auto region_or_error = MM.allocate_contiguous_kernel_region(32 * PAGE_SIZE, "VirtGPU Scratch Space", Memory::Region::Access::ReadWrite);
+ if (region_or_error.is_error())
+ TODO();
+ m_scratch_space = region_or_error.release_value();
}
GPU::~GPU()