diff options
author | Liav A <liavalb@gmail.com> | 2021-05-18 21:34:22 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-21 08:08:33 +0200 |
commit | 87f8f892d858a14b5c03b7bd7fdc9517a8f4cb84 (patch) | |
tree | 7076b1d1989a9c29fe3d84948faa25af09b9a088 /Kernel/Graphics/BochsGraphicsAdapter.cpp | |
parent | 5f718c6b05a638d200b9f546cc7f67cc77cf4b66 (diff) | |
download | serenity-87f8f892d858a14b5c03b7bd7fdc9517a8f4cb84.zip |
Kernel: Fix framebuffer resolution modesetting after boot
If we tried to change the resolution before of this patch, we triggered
a kernel crash due to mmaping the framebuffer device again.
Therefore, on mmaping of the framebuffer device, we create an entire new
set of VMObjects and Regions for the new settings.
Then, when we change the resolution, the framebuffersconsole needs to be
updated with the new resolution and also to be refreshed with the new
settings. To ensure we handle both shrinking of the resolution and
growth of it, we only copy the right amount of available data from the
cells Region.
Diffstat (limited to 'Kernel/Graphics/BochsGraphicsAdapter.cpp')
-rw-r--r-- | Kernel/Graphics/BochsGraphicsAdapter.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Kernel/Graphics/BochsGraphicsAdapter.cpp b/Kernel/Graphics/BochsGraphicsAdapter.cpp index b6695216e8..534a665765 100644 --- a/Kernel/Graphics/BochsGraphicsAdapter.cpp +++ b/Kernel/Graphics/BochsGraphicsAdapter.cpp @@ -53,11 +53,11 @@ UNMAP_AFTER_INIT BochsGraphicsAdapter::BochsGraphicsAdapter(PCI::Address pci_add : PCI::DeviceController(pci_address) , m_mmio_registers(PCI::get_BAR2(pci_address) & 0xfffffff0) { - set_safe_resolution(); // We assume safe resolutio is 1024x768x32 m_framebuffer_console = Graphics::FramebufferConsole::initialize(PhysicalAddress(PCI::get_BAR0(pci_address) & 0xfffffff0), 1024, 768, 1024 * sizeof(u32)); // FIXME: This is a very wrong way to do this... GraphicsManagement::the().m_console = m_framebuffer_console; + set_safe_resolution(); } UNMAP_AFTER_INIT void BochsGraphicsAdapter::initialize_framebuffer_devices() @@ -76,6 +76,7 @@ GraphicsDevice::Type BochsGraphicsAdapter::type() const void BochsGraphicsAdapter::set_safe_resolution() { + VERIFY(m_framebuffer_console); set_resolution(1024, 768); } @@ -105,6 +106,7 @@ bool BochsGraphicsAdapter::try_to_set_resolution(size_t width, size_t height) bool BochsGraphicsAdapter::set_resolution(size_t width, size_t height) { + VERIFY(m_framebuffer_console); if (Checked<size_t>::multiplication_would_overflow(width, height, sizeof(u32))) return false; @@ -112,6 +114,7 @@ bool BochsGraphicsAdapter::set_resolution(size_t width, size_t height) return false; dbgln("BochsGraphicsAdapter: resolution set to {}x{}", width, height); + m_framebuffer_console->set_resolution(width, height, width * sizeof(u32)); return true; } |