1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 23:15:07 +00:00

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.
This commit is contained in:
Liav A 2022-07-13 20:20:27 +03:00 committed by Linus Groh
parent f052b9574c
commit cd8bcd06c6
2 changed files with 6 additions and 4 deletions

View file

@ -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++) {

View file

@ -36,7 +36,7 @@ public:
private:
void clear_vga_row(u16 row);
VGATextModeConsole();
explicit VGATextModeConsole(NonnullOwnPtr<Memory::Region>);
mutable Spinlock m_vga_lock;