diff options
author | Liav A <liavalb@gmail.com> | 2022-07-13 20:20:27 +0300 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-07-13 19:15:17 +0100 |
commit | cd8bcd06c69e51a1782c01ab367eb011253f01df (patch) | |
tree | 3438950b0a94aef18f5f493104e2ac34749334b1 /Kernel | |
parent | f052b9574c3ddba0e4db2f08e806931f4882d26a (diff) | |
download | serenity-cd8bcd06c69e51a1782c01ab367eb011253f01df.zip |
Kernel/Graphics: Allocate VGA window region according to the usual rules
We should not allocate a kernel region inside the constructor of the
VGATextModeConsole class. We do use MUST() because allocation cannot
fail at this point, but that happens in the static factory method
instead.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Graphics/Console/VGATextModeConsole.cpp | 8 | ||||
-rw-r--r-- | Kernel/Graphics/Console/VGATextModeConsole.h | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/Kernel/Graphics/Console/VGATextModeConsole.cpp b/Kernel/Graphics/Console/VGATextModeConsole.cpp index 9af77c0465..3b0fd9dee8 100644 --- a/Kernel/Graphics/Console/VGATextModeConsole.cpp +++ b/Kernel/Graphics/Console/VGATextModeConsole.cpp @@ -13,12 +13,14 @@ namespace Kernel::Graphics { UNMAP_AFTER_INIT NonnullRefPtr<VGATextModeConsole> VGATextModeConsole::initialize() { - return adopt_ref(*new VGATextModeConsole()); + auto vga_window_size = MUST(Memory::page_round_up(0xc0000 - 0xa0000)); + auto vga_window_region = MUST(MM.allocate_kernel_region(PhysicalAddress(0xa0000), vga_window_size, "VGA Display"sv, Memory::Region::Access::ReadWrite)); + return adopt_ref(*new (nothrow) VGATextModeConsole(move(vga_window_region))); } -UNMAP_AFTER_INIT VGATextModeConsole::VGATextModeConsole() +UNMAP_AFTER_INIT VGATextModeConsole::VGATextModeConsole(NonnullOwnPtr<Memory::Region> vga_window_region) : Console(80, 25) - , m_vga_window_region(MM.allocate_kernel_region(PhysicalAddress(0xa0000), Memory::page_round_up(0xc0000 - 0xa0000).release_value_but_fixme_should_propagate_errors(), "VGA Display"sv, Memory::Region::Access::ReadWrite).release_value()) + , m_vga_window_region(move(vga_window_region)) , m_current_vga_window(m_vga_window_region->vaddr().offset(0x18000).as_ptr()) { for (size_t index = 0; index < height(); index++) { diff --git a/Kernel/Graphics/Console/VGATextModeConsole.h b/Kernel/Graphics/Console/VGATextModeConsole.h index 7bc3393462..12666e309f 100644 --- a/Kernel/Graphics/Console/VGATextModeConsole.h +++ b/Kernel/Graphics/Console/VGATextModeConsole.h @@ -36,7 +36,7 @@ public: private: void clear_vga_row(u16 row); - VGATextModeConsole(); + explicit VGATextModeConsole(NonnullOwnPtr<Memory::Region>); mutable Spinlock m_vga_lock; |