summaryrefslogtreecommitdiff
path: root/Kernel/Graphics/Console
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-06 01:36:14 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-06 01:55:27 +0200
commit75564b4a5f2b5452163571116ee9efaf5c3c65af (patch)
treeec672e92fcf3e7dca6ed51bce1c287319a9fc77d /Kernel/Graphics/Console
parentcb71a7370836c3b70038e2f718ee87f6fc286229 (diff)
downloadserenity-75564b4a5f2b5452163571116ee9efaf5c3c65af.zip
Kernel: Make kernel region allocators return KResultOr<NOP<Region>>
This expands the reach of error propagation greatly throughout the kernel. Sadly, it also exposes the fact that we're allocating (and doing other fallible things) in constructors all over the place. This patch doesn't attempt to address that of course. That's work for our future selves.
Diffstat (limited to 'Kernel/Graphics/Console')
-rw-r--r--Kernel/Graphics/Console/ContiguousFramebufferConsole.cpp5
-rw-r--r--Kernel/Graphics/Console/VGAConsole.cpp2
2 files changed, 4 insertions, 3 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)
{